idx
int64
1
56k
question
stringlengths
15
155
answer
stringlengths
2
29.2k
question_cut
stringlengths
15
100
answer_cut
stringlengths
2
200
conversation
stringlengths
47
29.3k
conversation_cut
stringlengths
47
301
37,001
Comparing a sample distribution to an implied distribution
Look at the ks.test function for one option of comparing data to a given continuous distribution (with predefined parameters). Look at the vcd package for tools to examine discrete distributions.
Comparing a sample distribution to an implied distribution
Look at the ks.test function for one option of comparing data to a given continuous distribution (with predefined parameters). Look at the vcd package for tools to examine discrete distributions.
Comparing a sample distribution to an implied distribution Look at the ks.test function for one option of comparing data to a given continuous distribution (with predefined parameters). Look at the vcd package for tools to examine discrete distributions.
Comparing a sample distribution to an implied distribution Look at the ks.test function for one option of comparing data to a given continuous distribution (with predefined parameters). Look at the vcd package for tools to examine discrete distributions.
37,002
Log-likelihood of multivariate Poisson distribution
Well, the $\log( y_{\bf t}!)$ terms don't involve ${\boldsymbol \theta}$, so forget about them. Multivariate derivatives are just concatenations of univariate partial derivatives. By linearity, the elements of the gradient vector are $$ \frac{ \partial \ell( {\boldsymbol \theta} )}{ \partial \theta_{i}} = \sum_{ {\bf t} \in \mathcal{T} } \frac{ -\partial \lambda_{{\bf t}}({\boldsymbol \theta})}{ \partial \theta_{i}} + y_{{\bf t}} \cdot \frac{ \partial \log (\lambda_{{\bf t}}({\boldsymbol \theta})) }{ \partial \theta_{i}} $$ Given by your expression for $\lambda_{{\bf t}}({\boldsymbol \theta})$, $$\frac{ \partial \lambda_{{\bf t}}({\boldsymbol \theta})}{ \partial \theta_{i}} = f_{i}( {\bf t}), $$ since you're just differentiating a linear function of $\theta_{i}$. From basic single variable calculus we know that $$ \frac{ \partial \log(f(x)) }{\partial x} = \frac{1}{f(x)} \cdot \frac{ \partial f(x) }{\partial x}$$ So, $$ \frac{\partial \log (\lambda_{{\bf t}}({\boldsymbol \theta})) }{ \partial \theta_{i}} = \frac{ f_{i}( {\bf t}) }{\sum_{k=1}^{d}\theta_k f_k\left(\mathbf{t}\right)} $$ Plug these parts back into the first equation above to get the score function.
Log-likelihood of multivariate Poisson distribution
Well, the $\log( y_{\bf t}!)$ terms don't involve ${\boldsymbol \theta}$, so forget about them. Multivariate derivatives are just concatenations of univariate partial derivatives. By linearity, the e
Log-likelihood of multivariate Poisson distribution Well, the $\log( y_{\bf t}!)$ terms don't involve ${\boldsymbol \theta}$, so forget about them. Multivariate derivatives are just concatenations of univariate partial derivatives. By linearity, the elements of the gradient vector are $$ \frac{ \partial \ell( {\boldsymbol \theta} )}{ \partial \theta_{i}} = \sum_{ {\bf t} \in \mathcal{T} } \frac{ -\partial \lambda_{{\bf t}}({\boldsymbol \theta})}{ \partial \theta_{i}} + y_{{\bf t}} \cdot \frac{ \partial \log (\lambda_{{\bf t}}({\boldsymbol \theta})) }{ \partial \theta_{i}} $$ Given by your expression for $\lambda_{{\bf t}}({\boldsymbol \theta})$, $$\frac{ \partial \lambda_{{\bf t}}({\boldsymbol \theta})}{ \partial \theta_{i}} = f_{i}( {\bf t}), $$ since you're just differentiating a linear function of $\theta_{i}$. From basic single variable calculus we know that $$ \frac{ \partial \log(f(x)) }{\partial x} = \frac{1}{f(x)} \cdot \frac{ \partial f(x) }{\partial x}$$ So, $$ \frac{\partial \log (\lambda_{{\bf t}}({\boldsymbol \theta})) }{ \partial \theta_{i}} = \frac{ f_{i}( {\bf t}) }{\sum_{k=1}^{d}\theta_k f_k\left(\mathbf{t}\right)} $$ Plug these parts back into the first equation above to get the score function.
Log-likelihood of multivariate Poisson distribution Well, the $\log( y_{\bf t}!)$ terms don't involve ${\boldsymbol \theta}$, so forget about them. Multivariate derivatives are just concatenations of univariate partial derivatives. By linearity, the e
37,003
Poisson with an autoregressive term
I think you are looking for the model in Brandt et al. (2000) there called PEWMA, after the forecast function. R code to fit it is available here. The paper also has some general discussion of possible conditionally Poisson AR models. Fro more of that, chapter 7 of Cameron and Trivedi (1998) is useful.
Poisson with an autoregressive term
I think you are looking for the model in Brandt et al. (2000) there called PEWMA, after the forecast function. R code to fit it is available here. The paper also has some general discussion of poss
Poisson with an autoregressive term I think you are looking for the model in Brandt et al. (2000) there called PEWMA, after the forecast function. R code to fit it is available here. The paper also has some general discussion of possible conditionally Poisson AR models. Fro more of that, chapter 7 of Cameron and Trivedi (1998) is useful.
Poisson with an autoregressive term I think you are looking for the model in Brandt et al. (2000) there called PEWMA, after the forecast function. R code to fit it is available here. The paper also has some general discussion of poss
37,004
Poisson with an autoregressive term
Have you considered a Transfer Function between N and E and your other covariates which could encode changes in parameters over time , changes in error variance over time , any necessaery autoregressive structure possibly proxying unspecified seasonal drivers and other omitted structure like level shifts, seasonal pulses and local time trends. Accomplished without letting "unusual values" distort the model/parameters. I have seen approaches like this referred to in the literature as DARIMA MODELS where the D stands for discrete. Various forms of Power Transforms such as Logs might be needed to possibly decouple the expected value from the variance of the errors ( always a good idea when needed! ) These kinds of models can be useful in detecting the possible impact of changes in N as it relates to the prediction of E.
Poisson with an autoregressive term
Have you considered a Transfer Function between N and E and your other covariates which could encode changes in parameters over time , changes in error variance over time , any necessaery autoregressi
Poisson with an autoregressive term Have you considered a Transfer Function between N and E and your other covariates which could encode changes in parameters over time , changes in error variance over time , any necessaery autoregressive structure possibly proxying unspecified seasonal drivers and other omitted structure like level shifts, seasonal pulses and local time trends. Accomplished without letting "unusual values" distort the model/parameters. I have seen approaches like this referred to in the literature as DARIMA MODELS where the D stands for discrete. Various forms of Power Transforms such as Logs might be needed to possibly decouple the expected value from the variance of the errors ( always a good idea when needed! ) These kinds of models can be useful in detecting the possible impact of changes in N as it relates to the prediction of E.
Poisson with an autoregressive term Have you considered a Transfer Function between N and E and your other covariates which could encode changes in parameters over time , changes in error variance over time , any necessaery autoregressi
37,005
Advice on scientifically sound scale construction
i'm assuming that the purpose of your analysis is to obtain evidence for the validity of your scale/instrument. so, first of all, your instrument was designed based on 4 hypothesized constructs, therefore, you should approach this using confirmatory factor analysis (CFA). exploratory factor analysis (EFA) is appropriate when there is no a priori theory describing the relationship between observed variables (i.e., items) and constructs and can result in uninterpretable factors, as you see here. then examine the results of your CFA model. the various fit statistics (e.g., X^2, RMSEA, modification indices, wald test statistics) can guide you through the refinement of your model. if you prefer a more exploratory approach, also consider "backward search": Chou C-P, Bentler, P.M. (2002). Model modification in structural equation modeling by imposing constraints, Computational Statistics & Data Analysis, 41, (2), 271-287.
Advice on scientifically sound scale construction
i'm assuming that the purpose of your analysis is to obtain evidence for the validity of your scale/instrument. so, first of all, your instrument was designed based on 4 hypothesized constructs, there
Advice on scientifically sound scale construction i'm assuming that the purpose of your analysis is to obtain evidence for the validity of your scale/instrument. so, first of all, your instrument was designed based on 4 hypothesized constructs, therefore, you should approach this using confirmatory factor analysis (CFA). exploratory factor analysis (EFA) is appropriate when there is no a priori theory describing the relationship between observed variables (i.e., items) and constructs and can result in uninterpretable factors, as you see here. then examine the results of your CFA model. the various fit statistics (e.g., X^2, RMSEA, modification indices, wald test statistics) can guide you through the refinement of your model. if you prefer a more exploratory approach, also consider "backward search": Chou C-P, Bentler, P.M. (2002). Model modification in structural equation modeling by imposing constraints, Computational Statistics & Data Analysis, 41, (2), 271-287.
Advice on scientifically sound scale construction i'm assuming that the purpose of your analysis is to obtain evidence for the validity of your scale/instrument. so, first of all, your instrument was designed based on 4 hypothesized constructs, there
37,006
Advice on scientifically sound scale construction
A tough situation. Factors 6, 4, and 7 seem fairly robustly measured, but not the others, and I bet internal consistency is going to be low for factors 1, 3, and 5. Is it at all possible to assess reliability through some other method, such as interrater rel.? Or to assess validity through some other method than construct validity via factor analysis? Even if different scales (or individual items) get validated in different ways--sometimes you need to take whatever you can. At any rate, I could see using v6 and v17 individually. Why force them into some multi-item scale when the loadings and correlations look like this. And even given what I said above about coverage implying validity, I agree that you want to keep your eventual regression predictors pretty much unidimensional--especially since you have a large number of predictors, as with multidimensional variables the waters will get very, very muddy. This is particularly relevant since you seem to be adopting much more of an explanatory than a purely predictive mode (you care about causality).
Advice on scientifically sound scale construction
A tough situation. Factors 6, 4, and 7 seem fairly robustly measured, but not the others, and I bet internal consistency is going to be low for factors 1, 3, and 5. Is it at all possible to assess r
Advice on scientifically sound scale construction A tough situation. Factors 6, 4, and 7 seem fairly robustly measured, but not the others, and I bet internal consistency is going to be low for factors 1, 3, and 5. Is it at all possible to assess reliability through some other method, such as interrater rel.? Or to assess validity through some other method than construct validity via factor analysis? Even if different scales (or individual items) get validated in different ways--sometimes you need to take whatever you can. At any rate, I could see using v6 and v17 individually. Why force them into some multi-item scale when the loadings and correlations look like this. And even given what I said above about coverage implying validity, I agree that you want to keep your eventual regression predictors pretty much unidimensional--especially since you have a large number of predictors, as with multidimensional variables the waters will get very, very muddy. This is particularly relevant since you seem to be adopting much more of an explanatory than a purely predictive mode (you care about causality).
Advice on scientifically sound scale construction A tough situation. Factors 6, 4, and 7 seem fairly robustly measured, but not the others, and I bet internal consistency is going to be low for factors 1, 3, and 5. Is it at all possible to assess r
37,007
Math behind multivariate testing for website optimization
This Microsoft page has quite a few resources. I suggest you read at least this paper from the page: "Controlled Experiments on the Web: Survey and Practical Guide." It'll give you some starting point about the metrics to measure and convey, things to consider for online experiments (including designing elements of web pages), and the related statistics. Enjoy! -Al
Math behind multivariate testing for website optimization
This Microsoft page has quite a few resources. I suggest you read at least this paper from the page: "Controlled Experiments on the Web: Survey and Practical Guide." It'll give you some starting point
Math behind multivariate testing for website optimization This Microsoft page has quite a few resources. I suggest you read at least this paper from the page: "Controlled Experiments on the Web: Survey and Practical Guide." It'll give you some starting point about the metrics to measure and convey, things to consider for online experiments (including designing elements of web pages), and the related statistics. Enjoy! -Al
Math behind multivariate testing for website optimization This Microsoft page has quite a few resources. I suggest you read at least this paper from the page: "Controlled Experiments on the Web: Survey and Practical Guide." It'll give you some starting point
37,008
Math behind multivariate testing for website optimization
These lectures notes are more about optimizing online advertising than optimizing a website, but the references there (especially lecture 6) might put you in the right direction. http://www.stanford.edu/class/msande239/ I hope it helps.
Math behind multivariate testing for website optimization
These lectures notes are more about optimizing online advertising than optimizing a website, but the references there (especially lecture 6) might put you in the right direction. http://www.stanford
Math behind multivariate testing for website optimization These lectures notes are more about optimizing online advertising than optimizing a website, but the references there (especially lecture 6) might put you in the right direction. http://www.stanford.edu/class/msande239/ I hope it helps.
Math behind multivariate testing for website optimization These lectures notes are more about optimizing online advertising than optimizing a website, but the references there (especially lecture 6) might put you in the right direction. http://www.stanford
37,009
If the n(th) moment exists does it mean all smaller moments exist too?
I believe it follows from Hölder's inequality:
If the n(th) moment exists does it mean all smaller moments exist too?
I believe it follows from Hölder's inequality:
If the n(th) moment exists does it mean all smaller moments exist too? I believe it follows from Hölder's inequality:
If the n(th) moment exists does it mean all smaller moments exist too? I believe it follows from Hölder's inequality:
37,010
If the n(th) moment exists does it mean all smaller moments exist too?
My solution lacks rigor, but here's a rough sketch: Instead of using the concept of a moment centered around zero, such as $E(X)$ and $E(X^2)$, use the notion of a central moment, defined as $\mu_k=E\left[(X-\mu)^k\right]$. From your statement, we know the $r$'th moment exists, so we know $\mu_r=E(X-\mu)^r$ exists. Use the binomial formula to expand that binomial, recalling that $(x+y)^n = \sum_{k=0}^n {n \choose k}x^{n-k}y^k$. Then $\mu_r=E(X-\mu)^r = E\left[\sum_{k=0}^r {r \choose k}X^{k}\mu^{r-k}\right]$. Note now that this is a sum of all lower moments from $0, \dots r$, times some coefficient. Thus, in order for the r'th moment to exist, all lower moments must also exist. Edit: There is a flaw, however, in using the central moments instead: We cannot assume that $\mu$ exists. Is there a way around that?
If the n(th) moment exists does it mean all smaller moments exist too?
My solution lacks rigor, but here's a rough sketch: Instead of using the concept of a moment centered around zero, such as $E(X)$ and $E(X^2)$, use the notion of a central moment, defined as $\mu_k=E\
If the n(th) moment exists does it mean all smaller moments exist too? My solution lacks rigor, but here's a rough sketch: Instead of using the concept of a moment centered around zero, such as $E(X)$ and $E(X^2)$, use the notion of a central moment, defined as $\mu_k=E\left[(X-\mu)^k\right]$. From your statement, we know the $r$'th moment exists, so we know $\mu_r=E(X-\mu)^r$ exists. Use the binomial formula to expand that binomial, recalling that $(x+y)^n = \sum_{k=0}^n {n \choose k}x^{n-k}y^k$. Then $\mu_r=E(X-\mu)^r = E\left[\sum_{k=0}^r {r \choose k}X^{k}\mu^{r-k}\right]$. Note now that this is a sum of all lower moments from $0, \dots r$, times some coefficient. Thus, in order for the r'th moment to exist, all lower moments must also exist. Edit: There is a flaw, however, in using the central moments instead: We cannot assume that $\mu$ exists. Is there a way around that?
If the n(th) moment exists does it mean all smaller moments exist too? My solution lacks rigor, but here's a rough sketch: Instead of using the concept of a moment centered around zero, such as $E(X)$ and $E(X^2)$, use the notion of a central moment, defined as $\mu_k=E\
37,011
Poisson deviance - and what about zero observed values?
Based on Cardinals' comment: $\lim\limits_{x \rightarrow 0} \ x \log x = \lim\limits_{x \rightarrow 0} \frac{ \log x}{1 \over x} = \lim\limits_{x \rightarrow 0} \frac{1 \over x}{-1 \over x^2} = \lim\limits_{x \rightarrow 0} -x = 0$
Poisson deviance - and what about zero observed values?
Based on Cardinals' comment: $\lim\limits_{x \rightarrow 0} \ x \log x = \lim\limits_{x \rightarrow 0} \frac{ \log x}{1 \over x} = \lim\limits_{x \rightarrow 0} \frac{1 \over x}{-1 \over x^2} = \lim\l
Poisson deviance - and what about zero observed values? Based on Cardinals' comment: $\lim\limits_{x \rightarrow 0} \ x \log x = \lim\limits_{x \rightarrow 0} \frac{ \log x}{1 \over x} = \lim\limits_{x \rightarrow 0} \frac{1 \over x}{-1 \over x^2} = \lim\limits_{x \rightarrow 0} -x = 0$
Poisson deviance - and what about zero observed values? Based on Cardinals' comment: $\lim\limits_{x \rightarrow 0} \ x \log x = \lim\limits_{x \rightarrow 0} \frac{ \log x}{1 \over x} = \lim\limits_{x \rightarrow 0} \frac{1 \over x}{-1 \over x^2} = \lim\l
37,012
Central limit theorem for sample quantiles
As @whuber said in a comment, the formula you cite for the variance of a sample quantile is correct, as is that you give for the sample median in the normal case. The sample mean and sample median have different distributions, and in fact the median has higher variance in the normal case. In R, you could estimate the SD of the sample median for the normal case as follows: n <- 100; n.rep <- 1000 x <- matrix(rnorm(n*n.rep), ncol=n) sd(apply(x, 1, median)) # 0.126
Central limit theorem for sample quantiles
As @whuber said in a comment, the formula you cite for the variance of a sample quantile is correct, as is that you give for the sample median in the normal case. The sample mean and sample median ha
Central limit theorem for sample quantiles As @whuber said in a comment, the formula you cite for the variance of a sample quantile is correct, as is that you give for the sample median in the normal case. The sample mean and sample median have different distributions, and in fact the median has higher variance in the normal case. In R, you could estimate the SD of the sample median for the normal case as follows: n <- 100; n.rep <- 1000 x <- matrix(rnorm(n*n.rep), ncol=n) sd(apply(x, 1, median)) # 0.126
Central limit theorem for sample quantiles As @whuber said in a comment, the formula you cite for the variance of a sample quantile is correct, as is that you give for the sample median in the normal case. The sample mean and sample median ha
37,013
Central limit theorem for sample quantiles
For $n=1$ the variance is of course 1. For $n=3$ we can show $1-\sqrt{3}/\pi$. For larger $n$ your estimate $\pi/(2n)$ seems very good from my experiments:
Central limit theorem for sample quantiles
For $n=1$ the variance is of course 1. For $n=3$ we can show $1-\sqrt{3}/\pi$. For larger $n$ your estimate $\pi/(2n)$ seems very good from my experiments:
Central limit theorem for sample quantiles For $n=1$ the variance is of course 1. For $n=3$ we can show $1-\sqrt{3}/\pi$. For larger $n$ your estimate $\pi/(2n)$ seems very good from my experiments:
Central limit theorem for sample quantiles For $n=1$ the variance is of course 1. For $n=3$ we can show $1-\sqrt{3}/\pi$. For larger $n$ your estimate $\pi/(2n)$ seems very good from my experiments:
37,014
Assuming two Gaussian distributions of equal mean and variance, then how different can we expect the top X members of each group to be?
Let's look at the top 3 of 100 Gaussians vs. the top 3 of 1000. Real statisticians will give formulas for this and more; for the rest of us, here's a little Monte Carlo. The intent of the code is to give a rough idea of the distributions of $X_{(N-2)} X_{(N-1)} X_{(N)}$; running it gives # top 3 of 100 Gaussians, medians: [[ 2. 2.1 2.4]] # top 3 of 1000 Gaussians, medians: [[ 2.8 2.9 3.2]] If someone could do this in R with rug plots, that would certainly be clearer. #!/usr/bin/env python # Monte Carlo the top 3 of 100 / of 1000 Gaussians # top 3 of 100 Gaussians, medians: [[ 2. 2.1 2.4]] # top 3 of 1000 Gaussians, medians: [[ 2.8 2.9 3.2]] # http://stats.stackexchange.com/questions/12647/assuming-two-gaussian-distributions-of-equal-mean-and-variance-then-how-differen # cf. Wikipedia World_record_progression_100_metres_men / women import sys import numpy as np top = 3 Nx = 100 Ny = 1000 nmonte = 100 percentiles = [50] seed = 1 exec "\n".join( sys.argv[1:] ) # run this.py top= ... np.set_printoptions( 1) # .1f np.random.seed(seed) print "Monte Carlo the top %d of many Gaussians:" % top # sample Nx / Ny Gaussians, nmonte times -- X = np.random.normal( size=(nmonte,Nx) ) Y = np.random.normal( size=(nmonte,Ny) ) # top 3 or so -- Xtop = np.sort( X, axis=1 )[:,-top:] Ytop = np.sort( Y, axis=1 )[:,-top:] # medians (any percentiles, but how display ?) -- Xp = np.array( np.percentile( Xtop, percentiles, axis=0 )) Yp = np.array( np.percentile( Ytop, percentiles, axis=0 )) print "top %d of %4d Gaussians, medians: %s" % (top, Nx, Xp) print "top %d of %4d Gaussians, medians: %s" % (top, Ny, Yp)
Assuming two Gaussian distributions of equal mean and variance, then how different can we expect the
Let's look at the top 3 of 100 Gaussians vs. the top 3 of 1000. Real statisticians will give formulas for this and more; for the rest of us, here's a little Monte Carlo. The intent of the code is to g
Assuming two Gaussian distributions of equal mean and variance, then how different can we expect the top X members of each group to be? Let's look at the top 3 of 100 Gaussians vs. the top 3 of 1000. Real statisticians will give formulas for this and more; for the rest of us, here's a little Monte Carlo. The intent of the code is to give a rough idea of the distributions of $X_{(N-2)} X_{(N-1)} X_{(N)}$; running it gives # top 3 of 100 Gaussians, medians: [[ 2. 2.1 2.4]] # top 3 of 1000 Gaussians, medians: [[ 2.8 2.9 3.2]] If someone could do this in R with rug plots, that would certainly be clearer. #!/usr/bin/env python # Monte Carlo the top 3 of 100 / of 1000 Gaussians # top 3 of 100 Gaussians, medians: [[ 2. 2.1 2.4]] # top 3 of 1000 Gaussians, medians: [[ 2.8 2.9 3.2]] # http://stats.stackexchange.com/questions/12647/assuming-two-gaussian-distributions-of-equal-mean-and-variance-then-how-differen # cf. Wikipedia World_record_progression_100_metres_men / women import sys import numpy as np top = 3 Nx = 100 Ny = 1000 nmonte = 100 percentiles = [50] seed = 1 exec "\n".join( sys.argv[1:] ) # run this.py top= ... np.set_printoptions( 1) # .1f np.random.seed(seed) print "Monte Carlo the top %d of many Gaussians:" % top # sample Nx / Ny Gaussians, nmonte times -- X = np.random.normal( size=(nmonte,Nx) ) Y = np.random.normal( size=(nmonte,Ny) ) # top 3 or so -- Xtop = np.sort( X, axis=1 )[:,-top:] Ytop = np.sort( Y, axis=1 )[:,-top:] # medians (any percentiles, but how display ?) -- Xp = np.array( np.percentile( Xtop, percentiles, axis=0 )) Yp = np.array( np.percentile( Ytop, percentiles, axis=0 )) print "top %d of %4d Gaussians, medians: %s" % (top, Nx, Xp) print "top %d of %4d Gaussians, medians: %s" % (top, Ny, Yp)
Assuming two Gaussian distributions of equal mean and variance, then how different can we expect the Let's look at the top 3 of 100 Gaussians vs. the top 3 of 1000. Real statisticians will give formulas for this and more; for the rest of us, here's a little Monte Carlo. The intent of the code is to g
37,015
Assuming two Gaussian distributions of equal mean and variance, then how different can we expect the top X members of each group to be?
The earlier answer doesn't address the question of the gender composition of the top $5$ or top $10$ players. The analytical answer is simple, and it doesn't depend on the underlying distribution (as long as it is the same for men and for women, and continuous, and each person's ability is assumed to be independent of anyone else's). Under these assumptions, the number of women among the top $k$ follows a hypergeometric distribution very close to a binomial distribution. If there are $10$ times as many men participating as women, then each spot has a $1/11$ chance to be occupied by a woman. For that question, the techniques used to produce the results in the paper you cite are not needed. If you want to find the expected value of the $i$th highest out of a sample of size $n$, this is the expected value of an order statistic, and this does depend (slightly) on the distribution. For a uniform distribution on $[0,1]$, the expected value of the $i$th highest value out of $n$ is $\frac{n+1-i}{n+1}$. I think the expected value for an order statistic of a normal distribution doesn't have a closed form in general, but there are good approximations which tell you how to adjust the naive guess of $\Phi^{-1}(\frac{n+1-i}{n+1})$ standard deviations above the mean. While it may be worth understanding these order statistics as a null hypothesis, I doubt that the distribution of ratings for chess players is so well approximated by the normal distribution that the top ratings out of many millions of players are properly predicted by the corresponding values for a normal distribution. Typically, when you use a normal approximation, you don't count on it working several standard deviations from the mean, and it certainly doesn't work in the other direction.
Assuming two Gaussian distributions of equal mean and variance, then how different can we expect the
The earlier answer doesn't address the question of the gender composition of the top $5$ or top $10$ players. The analytical answer is simple, and it doesn't depend on the underlying distribution (as
Assuming two Gaussian distributions of equal mean and variance, then how different can we expect the top X members of each group to be? The earlier answer doesn't address the question of the gender composition of the top $5$ or top $10$ players. The analytical answer is simple, and it doesn't depend on the underlying distribution (as long as it is the same for men and for women, and continuous, and each person's ability is assumed to be independent of anyone else's). Under these assumptions, the number of women among the top $k$ follows a hypergeometric distribution very close to a binomial distribution. If there are $10$ times as many men participating as women, then each spot has a $1/11$ chance to be occupied by a woman. For that question, the techniques used to produce the results in the paper you cite are not needed. If you want to find the expected value of the $i$th highest out of a sample of size $n$, this is the expected value of an order statistic, and this does depend (slightly) on the distribution. For a uniform distribution on $[0,1]$, the expected value of the $i$th highest value out of $n$ is $\frac{n+1-i}{n+1}$. I think the expected value for an order statistic of a normal distribution doesn't have a closed form in general, but there are good approximations which tell you how to adjust the naive guess of $\Phi^{-1}(\frac{n+1-i}{n+1})$ standard deviations above the mean. While it may be worth understanding these order statistics as a null hypothesis, I doubt that the distribution of ratings for chess players is so well approximated by the normal distribution that the top ratings out of many millions of players are properly predicted by the corresponding values for a normal distribution. Typically, when you use a normal approximation, you don't count on it working several standard deviations from the mean, and it certainly doesn't work in the other direction.
Assuming two Gaussian distributions of equal mean and variance, then how different can we expect the The earlier answer doesn't address the question of the gender composition of the top $5$ or top $10$ players. The analytical answer is simple, and it doesn't depend on the underlying distribution (as
37,016
Can slopes in linear regressions be used as the independent or dependent variables in other regression models?
In effect, you are proposing to use linear regression as a mathematical procedure to condense a 10-variate observation into a single variable (the slope). As such it's just another example of similar procedures like (say) using an average of repeated measurements as a regression variable or including principal components scores in a regression. Specific comments follow. (1) Linear regression does not require the X's (independent variables) to be "independent." Indeed, in the standard formulation the concept of independence does not even apply because the X's are fixed values, not realizations of a random variable. (2) Yes, you can use the slopes as dependent variables. It would help to establish that they might behave like the dependent variable in linear regression. For ordinary least squares this means that a. Slopes may depend on some of the patient attributes. b. The dependence is approximately linear, at least for the range of observed patient attributes. c. Any variation between an observed slope and the hypothesized slope can be considered random. d. This random variation is (i) independent from patient to patient and (ii) has approximately the same distribution from patient to patient. e. As before, the independent variables are not viewed as random but as fixed and measured without appreciable error. If all these conditions approximately hold, you should be ok. Violations of (d) or (e) can be cured by using generalizations of ordinary least squares. (2'). Because the slopes will exhibit uncertainty (as measured in the regression used to estimate the slopes), they might not be good candidates for independent variables unless you are treating them as random in a mixed model or are using an errors-in-variables model. You can also cope with this situation by means of a hierarchical Bayes model.
Can slopes in linear regressions be used as the independent or dependent variables in other regressi
In effect, you are proposing to use linear regression as a mathematical procedure to condense a 10-variate observation into a single variable (the slope). As such it's just another example of similar
Can slopes in linear regressions be used as the independent or dependent variables in other regression models? In effect, you are proposing to use linear regression as a mathematical procedure to condense a 10-variate observation into a single variable (the slope). As such it's just another example of similar procedures like (say) using an average of repeated measurements as a regression variable or including principal components scores in a regression. Specific comments follow. (1) Linear regression does not require the X's (independent variables) to be "independent." Indeed, in the standard formulation the concept of independence does not even apply because the X's are fixed values, not realizations of a random variable. (2) Yes, you can use the slopes as dependent variables. It would help to establish that they might behave like the dependent variable in linear regression. For ordinary least squares this means that a. Slopes may depend on some of the patient attributes. b. The dependence is approximately linear, at least for the range of observed patient attributes. c. Any variation between an observed slope and the hypothesized slope can be considered random. d. This random variation is (i) independent from patient to patient and (ii) has approximately the same distribution from patient to patient. e. As before, the independent variables are not viewed as random but as fixed and measured without appreciable error. If all these conditions approximately hold, you should be ok. Violations of (d) or (e) can be cured by using generalizations of ordinary least squares. (2'). Because the slopes will exhibit uncertainty (as measured in the regression used to estimate the slopes), they might not be good candidates for independent variables unless you are treating them as random in a mixed model or are using an errors-in-variables model. You can also cope with this situation by means of a hierarchical Bayes model.
Can slopes in linear regressions be used as the independent or dependent variables in other regressi In effect, you are proposing to use linear regression as a mathematical procedure to condense a 10-variate observation into a single variable (the slope). As such it's just another example of similar
37,017
What is the relation between statistics theory and decision theory?
Statistical decision theory is a subset of statistical theory. Exploratory statistics is not decision theory but it is statistics. A theory about how to make (good) decisions is certainly much wider than statistical decision theory. For example, making a good decision in society may have more relation with psychology or even philosophy than with statistics, don't you think?
What is the relation between statistics theory and decision theory?
Statistical decision theory is a subset of statistical theory. Exploratory statistics is not decision theory but it is statistics. A theory about how to make (good) decisions is certainly much wider
What is the relation between statistics theory and decision theory? Statistical decision theory is a subset of statistical theory. Exploratory statistics is not decision theory but it is statistics. A theory about how to make (good) decisions is certainly much wider than statistical decision theory. For example, making a good decision in society may have more relation with psychology or even philosophy than with statistics, don't you think?
What is the relation between statistics theory and decision theory? Statistical decision theory is a subset of statistical theory. Exploratory statistics is not decision theory but it is statistics. A theory about how to make (good) decisions is certainly much wider
37,018
How to compute prediction error from Relevance Vector Machine and Gaussian Process Regression?
Ok, here's the scoop: first off, have a look at my class in Berkeley. The slides for GP regression should be up shortly at http://alex.smola.org/teaching/berkeley2012 where I discuss this in more detail. For a GP regression you can integrate out the latent GP and since the observation model and the underlying GP are both Gaussian, you get a Gaussian again. In math this means that $$y = t + \epsilon.$$ Here $t$ is drawn from a GP and $\epsilon$ are independent Gaussian random variables. Once you have the GP representation for $y$, you can simply condition on the observed terms to get the residual variance for the rest. This yields something of the form $$E[y'|y] = \mu' + K_{x'x} K_{xx}^{-1} (y - \mu)$$ and the variance is $$K_{x'x'} - K_{x'x} K_{xx}^{-1} K_{xx'}.$$ Obviously here we added the noise for $\epsilon$ to the main diagonal. For the relevance vector machine this isn't quite so trivial since it assumes a rather different noise model. So you cannot integrate out the latent variables explicitly. Have a look at my book 'Learning with Kernels' or alternatively Mike Tipping's original paper for the details.
How to compute prediction error from Relevance Vector Machine and Gaussian Process Regression?
Ok, here's the scoop: first off, have a look at my class in Berkeley. The slides for GP regression should be up shortly at http://alex.smola.org/teaching/berkeley2012 where I discuss this in more deta
How to compute prediction error from Relevance Vector Machine and Gaussian Process Regression? Ok, here's the scoop: first off, have a look at my class in Berkeley. The slides for GP regression should be up shortly at http://alex.smola.org/teaching/berkeley2012 where I discuss this in more detail. For a GP regression you can integrate out the latent GP and since the observation model and the underlying GP are both Gaussian, you get a Gaussian again. In math this means that $$y = t + \epsilon.$$ Here $t$ is drawn from a GP and $\epsilon$ are independent Gaussian random variables. Once you have the GP representation for $y$, you can simply condition on the observed terms to get the residual variance for the rest. This yields something of the form $$E[y'|y] = \mu' + K_{x'x} K_{xx}^{-1} (y - \mu)$$ and the variance is $$K_{x'x'} - K_{x'x} K_{xx}^{-1} K_{xx'}.$$ Obviously here we added the noise for $\epsilon$ to the main diagonal. For the relevance vector machine this isn't quite so trivial since it assumes a rather different noise model. So you cannot integrate out the latent variables explicitly. Have a look at my book 'Learning with Kernels' or alternatively Mike Tipping's original paper for the details.
How to compute prediction error from Relevance Vector Machine and Gaussian Process Regression? Ok, here's the scoop: first off, have a look at my class in Berkeley. The slides for GP regression should be up shortly at http://alex.smola.org/teaching/berkeley2012 where I discuss this in more deta
37,019
Bias for kernel density estimator (periodic case)
A quick google brings up this, which indicates that when working with circular data you'll need a different definition of 'bias' for a start: However, when using data on the circle, we cannot use distance in Euclidean space, so all differences θ − θi should be replaced by considering the angle between two vectors: $d_i\theta)= \| \theta -\theta_i \| = \min(|\theta-\theta_i|, 2π -|\theta-\theta_i|).$ -- Charles C Taylor. Automatic bandwidth selection for circular density estimation. Computational Statistics & Data Analysis Volume 52, Issue 7, 15 March 2008, Pages 3493-3500. doi: 10.1016/j.csda.2007.11.003 He references these books: S. Rao Jammalamadaka and A. SenGupta, Topics in Circular Statistics, World Scientific, Singapore (2001). K.V. Mardia and P.E. Jupp, Directional Statistics, John Wiley, Chichester (1999).
Bias for kernel density estimator (periodic case)
A quick google brings up this, which indicates that when working with circular data you'll need a different definition of 'bias' for a start: However, when using data on the circle, we cannot use dis
Bias for kernel density estimator (periodic case) A quick google brings up this, which indicates that when working with circular data you'll need a different definition of 'bias' for a start: However, when using data on the circle, we cannot use distance in Euclidean space, so all differences θ − θi should be replaced by considering the angle between two vectors: $d_i\theta)= \| \theta -\theta_i \| = \min(|\theta-\theta_i|, 2π -|\theta-\theta_i|).$ -- Charles C Taylor. Automatic bandwidth selection for circular density estimation. Computational Statistics & Data Analysis Volume 52, Issue 7, 15 March 2008, Pages 3493-3500. doi: 10.1016/j.csda.2007.11.003 He references these books: S. Rao Jammalamadaka and A. SenGupta, Topics in Circular Statistics, World Scientific, Singapore (2001). K.V. Mardia and P.E. Jupp, Directional Statistics, John Wiley, Chichester (1999).
Bias for kernel density estimator (periodic case) A quick google brings up this, which indicates that when working with circular data you'll need a different definition of 'bias' for a start: However, when using data on the circle, we cannot use dis
37,020
Pitman's test of equality of variance and testing for regression to the mean: am I doing the right thing?
As far as I know, the Pitman test is formulated as : $$F=\frac{SD_2}{SD_1} ~with~ SD_2 > SD_1$$ $$T=\frac{(F-1)\sqrt{n-2}}{2\sqrt{F(1-r^2)}} $$ with $r$ the correlation between the scores in sample 1 and sample 2. This is not equivalent to the formula you use and mentioned in the paper. I'm not positive about my formula either, I got it from a course somewhere (alas no reference...) Apart from that, it might be interesting to take a look at an alternative approach to dealing with regression to the mean. I found the tutorial paper of Barnett et al on regression to the mean very enlightening. Now let's get back a moment to the 2-sided versus 1-sided p-values. Regardless of the formula you use, the sign of T is only dependent on the order of the SD's. (In fact, how I know the pitman test, T is always positive.) Hence, the underlying distribution is -as far as I'm concerned- not the T distribution but half the T distribution, meaning you have to put the cutoff at $T_{0.975, df}$, but the related p-value is originating from one tail only. This is equivalent the standard F test for comparing variances.
Pitman's test of equality of variance and testing for regression to the mean: am I doing the right t
As far as I know, the Pitman test is formulated as : $$F=\frac{SD_2}{SD_1} ~with~ SD_2 > SD_1$$ $$T=\frac{(F-1)\sqrt{n-2}}{2\sqrt{F(1-r^2)}} $$ with $r$ the correlation between the scores in sample 1
Pitman's test of equality of variance and testing for regression to the mean: am I doing the right thing? As far as I know, the Pitman test is formulated as : $$F=\frac{SD_2}{SD_1} ~with~ SD_2 > SD_1$$ $$T=\frac{(F-1)\sqrt{n-2}}{2\sqrt{F(1-r^2)}} $$ with $r$ the correlation between the scores in sample 1 and sample 2. This is not equivalent to the formula you use and mentioned in the paper. I'm not positive about my formula either, I got it from a course somewhere (alas no reference...) Apart from that, it might be interesting to take a look at an alternative approach to dealing with regression to the mean. I found the tutorial paper of Barnett et al on regression to the mean very enlightening. Now let's get back a moment to the 2-sided versus 1-sided p-values. Regardless of the formula you use, the sign of T is only dependent on the order of the SD's. (In fact, how I know the pitman test, T is always positive.) Hence, the underlying distribution is -as far as I'm concerned- not the T distribution but half the T distribution, meaning you have to put the cutoff at $T_{0.975, df}$, but the related p-value is originating from one tail only. This is equivalent the standard F test for comparing variances.
Pitman's test of equality of variance and testing for regression to the mean: am I doing the right t As far as I know, the Pitman test is formulated as : $$F=\frac{SD_2}{SD_1} ~with~ SD_2 > SD_1$$ $$T=\frac{(F-1)\sqrt{n-2}}{2\sqrt{F(1-r^2)}} $$ with $r$ the correlation between the scores in sample 1
37,021
Pitman's test of equality of variance and testing for regression to the mean: am I doing the right thing?
the short answer to your question is that with a sample size of n = 1280, a formal statistical test for equal variances is not really necessary. with that sample size, the variance 'estimates' you get are certainty-equivalents [almost certainly very close to the true population variances]. so you can just look at the two values and see if they look reasonably close or not. a comment about your linear model: i assume there is a random error term in it as well. i think there should also be an intercept term, unless you are sure the regression line goes thru the origin. also, do you treat the participant effect as a random effect? it seems you should, if each contributes more than one pair of ratings to the data. but that might cause problems with the usual methods for testing for effects other than a regression effect [for which the usual models do not have such terms]. this is because the usual models assume the different before-after [ratings] pairs are independent. but the random effect creates correlations between the ratings pairs for the same individual. such a model would have to be studied further to see if the hypothesis of no differential A'-rating effect still reduces to a test of equal variances. here is a bit more about the pitman test [altho what follows is probably unnecessary for you, in view of the 'short answer' above]: like tests for equality of variances for two [or more] independent samples, the pitman test is apparently sensitive to the non-normality of the responses. you don't mention the scale on which the variable rating is measured, but especially if it is a likert-type scale, the assumption of normality for the responses may be questionable. wilcox did a study of the pitman and other tests of variance equality for paired data and wrote: But, it is concluded that, in terms of controlling both Type I and Type II errors, a satisfactory solution does not yet exist. [this was in 1990.] this doesn't necessarily mean that the pitman test would be invalid for your data, but it does suggest that some caution in using it might be appropriate. [if i remember correctly, the difficulty with homogeneity-of-variance tests arises when the data distribution [for rating in your case] has a heavy tail [or tails]. then the actual level of the test can exceed the nominal level [of .05, say], resulting in too often falsely rejecting the hypothesis of equal variances when, in fact, they are equal. [better power, but also worse false rejection rate.] it seems unlikely that responses on a likert scale would have heavy tails [or too big a 4$^{th}$ moment - as compared with its variance], but it might not hurt to see if the usual kertosis measure [4$^{th}$ central moment divided by variance$^2$ exceeds 3 [which is then an indication of heavy tails]. grambsch in 1994 compared the pitman test to alternative procedures - some of which are more complicated to carry out. some numerical results in her paper suggest that if the distributions of rating are uniform or have the shape of a half-parabola over the range of responses [i.e. have light tails], the pitman test is conservative: the actual type 1 error for a nominal value of $\alpha = .05$ can be anywhere from .005 to about .05 - depending on the actual shape of the distributions and the sample size. [her results deal with samples sizes of 50 or less. i suppose with your sample size of 1280, her conclusions would have been somewhat different.] if you are interested, she presents a modification of the pitman test that keeps the actual significance level close to the nominal value of .05, for both light- and heavy-tailed distributions.
Pitman's test of equality of variance and testing for regression to the mean: am I doing the right t
the short answer to your question is that with a sample size of n = 1280, a formal statistical test for equal variances is not really necessary. with that sample size, the variance 'estimates' you get
Pitman's test of equality of variance and testing for regression to the mean: am I doing the right thing? the short answer to your question is that with a sample size of n = 1280, a formal statistical test for equal variances is not really necessary. with that sample size, the variance 'estimates' you get are certainty-equivalents [almost certainly very close to the true population variances]. so you can just look at the two values and see if they look reasonably close or not. a comment about your linear model: i assume there is a random error term in it as well. i think there should also be an intercept term, unless you are sure the regression line goes thru the origin. also, do you treat the participant effect as a random effect? it seems you should, if each contributes more than one pair of ratings to the data. but that might cause problems with the usual methods for testing for effects other than a regression effect [for which the usual models do not have such terms]. this is because the usual models assume the different before-after [ratings] pairs are independent. but the random effect creates correlations between the ratings pairs for the same individual. such a model would have to be studied further to see if the hypothesis of no differential A'-rating effect still reduces to a test of equal variances. here is a bit more about the pitman test [altho what follows is probably unnecessary for you, in view of the 'short answer' above]: like tests for equality of variances for two [or more] independent samples, the pitman test is apparently sensitive to the non-normality of the responses. you don't mention the scale on which the variable rating is measured, but especially if it is a likert-type scale, the assumption of normality for the responses may be questionable. wilcox did a study of the pitman and other tests of variance equality for paired data and wrote: But, it is concluded that, in terms of controlling both Type I and Type II errors, a satisfactory solution does not yet exist. [this was in 1990.] this doesn't necessarily mean that the pitman test would be invalid for your data, but it does suggest that some caution in using it might be appropriate. [if i remember correctly, the difficulty with homogeneity-of-variance tests arises when the data distribution [for rating in your case] has a heavy tail [or tails]. then the actual level of the test can exceed the nominal level [of .05, say], resulting in too often falsely rejecting the hypothesis of equal variances when, in fact, they are equal. [better power, but also worse false rejection rate.] it seems unlikely that responses on a likert scale would have heavy tails [or too big a 4$^{th}$ moment - as compared with its variance], but it might not hurt to see if the usual kertosis measure [4$^{th}$ central moment divided by variance$^2$ exceeds 3 [which is then an indication of heavy tails]. grambsch in 1994 compared the pitman test to alternative procedures - some of which are more complicated to carry out. some numerical results in her paper suggest that if the distributions of rating are uniform or have the shape of a half-parabola over the range of responses [i.e. have light tails], the pitman test is conservative: the actual type 1 error for a nominal value of $\alpha = .05$ can be anywhere from .005 to about .05 - depending on the actual shape of the distributions and the sample size. [her results deal with samples sizes of 50 or less. i suppose with your sample size of 1280, her conclusions would have been somewhat different.] if you are interested, she presents a modification of the pitman test that keeps the actual significance level close to the nominal value of .05, for both light- and heavy-tailed distributions.
Pitman's test of equality of variance and testing for regression to the mean: am I doing the right t the short answer to your question is that with a sample size of n = 1280, a formal statistical test for equal variances is not really necessary. with that sample size, the variance 'estimates' you get
37,022
Is there a biglm equivalent for coxph?
Maybe take a look at the DatABEL package. I know it is used in genomic studies with large data that may be stored on the HD instead of RAM. From what I read in the help file, you can then apply different kind of model, including survival model.
Is there a biglm equivalent for coxph?
Maybe take a look at the DatABEL package. I know it is used in genomic studies with large data that may be stored on the HD instead of RAM. From what I read in the help file, you can then apply differ
Is there a biglm equivalent for coxph? Maybe take a look at the DatABEL package. I know it is used in genomic studies with large data that may be stored on the HD instead of RAM. From what I read in the help file, you can then apply different kind of model, including survival model.
Is there a biglm equivalent for coxph? Maybe take a look at the DatABEL package. I know it is used in genomic studies with large data that may be stored on the HD instead of RAM. From what I read in the help file, you can then apply differ
37,023
Fisher information and the "surface area of the typical set"
UPDATE Tough crowd. :) For a concise account of connecting the trace of the Fisher matrix to surface area, please see section 4 ("Isoperimetric Inequalities") in the paper below. The crucial part is establishing the relation between differential entropy and the trace of the Fisher matrix, which the authors prove in the appendix. On the similarity of the entropy power inequality and the Brunn-Minkowski inequality The basic intuition is through the isoperimetric inequality for the surface area of a sphere maximizing the volume. We can arrive at a similar relationship concerning the trace of the Fisher information matrix and the entropy w.r.t the Gaussian. The following may be helpful. Information Theoretic Inequalities for Contoured Probability Distributions
Fisher information and the "surface area of the typical set"
UPDATE Tough crowd. :) For a concise account of connecting the trace of the Fisher matrix to surface area, please see section 4 ("Isoperimetric Inequalities") in the paper below. The crucial part i
Fisher information and the "surface area of the typical set" UPDATE Tough crowd. :) For a concise account of connecting the trace of the Fisher matrix to surface area, please see section 4 ("Isoperimetric Inequalities") in the paper below. The crucial part is establishing the relation between differential entropy and the trace of the Fisher matrix, which the authors prove in the appendix. On the similarity of the entropy power inequality and the Brunn-Minkowski inequality The basic intuition is through the isoperimetric inequality for the surface area of a sphere maximizing the volume. We can arrive at a similar relationship concerning the trace of the Fisher information matrix and the entropy w.r.t the Gaussian. The following may be helpful. Information Theoretic Inequalities for Contoured Probability Distributions
Fisher information and the "surface area of the typical set" UPDATE Tough crowd. :) For a concise account of connecting the trace of the Fisher matrix to surface area, please see section 4 ("Isoperimetric Inequalities") in the paper below. The crucial part i
37,024
Reliability in Elicitation Exercise
Maybe I misunderstood the question, but what you are describing sounds like a test-retest reliability study on your Q scores. You have a series of experts each going to assess a number of items or questions, at two occasions (presumably fixed in time). So, basically you can assess the temporal stability of the judgments by computing an intraclass correlation coefficient (ICC), which will give you an idea of the variance attributable to subjects in the variability of observed scores (or, in other words of the closeness of the observations on the same subject relative to the closeness of observations on different subjects). The ICC may easily be obtained from a mixed-effect model describing the measurement $y_{ij}$ of subject $i$ on occasion $j$ as $$ y_{ij}=\mu+u_i+\varepsilon_{ij},\quad \varepsilon\sim\mathcal{N}(0,\sigma^2) $$ where $u_i$ is the difference between the overall mean and subject $i$'s mean measurement, and $\varepsilon_{ij}$ is the measurement error for subject $i$ on occasion $j$. Here, this is a random-effect model. Unlike a standard ANOVA with subjects as factor, we consider the $u_i$ as random (i.i.d.) effects, $u_i\sim\mathcal{N}(0,\tau^2)$, independent of the error terms. Each measurement differ from the overall mean $\mu$ by the sum of the two error terms, among which the $u_i$ is shared between occasion on the same subjects. The total variance is then $\tau^2+\sigma^2$ and the proportion of the total variance that is accounted for by the subjects is $$ \rho=\frac{\tau^2}{\tau^2+\sigma^2} $$ which is the ICC, or the reliability index from a psychometrical point of view. Note that this reliability is sample-dependent (as it depends on the between-subject variance). Instead of the mixed-effects model, we could derive the same results from a two-way ANOVA (subjects + time, as factors) and the corresponding Mean Squares. You will find additional references in those related questions: Repeatability and measurement error from and between observers, and Inter-rater reliability for ordinal or interval data. In R, you can use the icc() function from the psy package; the random intercept model described above corresponds to the "agreement" ICC, while incorporating the time effect as a fixed factor would yield the "consistency" ICC. You can also use the lmer() function from the lme4 package, or the lme() function from the nlme package. The latter has the advantage that you can easily obtain 95% CIs for the variance components (using the intervals() function). Dave Garson provided a nice overview (with SPSS illustrations) in Reliability Analysis, and Estimating Multilevel Models using SPSS, Stata, SAS, and R constitutes a useful tutorial, with applications in educational assessment. But the definitive reference is Shrout and Fleiss (1979), Intraclass Correlations: Uses in Assessing Rater Reliability, Psychological Bulletin, 86(2), 420-428. I have also added an example R script on Githhub, that includes the ANOVA and mixed-effect approaches. Also, should you add a constant value to all of the values taken at the second occasion, the Pearson correlation would remain identical (because it is based on deviations of the 1st and 2nd measurements from their respective means), whereas the reliability as computed through the random intercept model (or the agreement ICC) would decrease. BTW, Cronbach's alpha is not very helpful in this case because it is merely a measure of the internal consistency (yet, another form of "reliability") of an unidimensional scale; it would have no meaning should it be computed on items underlying different constructs. Even if your questions survey a single domain, it's hard to imagine mixing the two series of measurements, and Cronbach's alpha should be computed on each set separately. Its associated 95% confidence interval (computed by bootstrap) should give an indication about the stability of the internal structure between the two test occasions. As an example of applied work with ICC, I would suggest Johnson, SR, Tomlinson, GA, Hawker, GA, Granton, JT, Grosbein, HA, and Feldman, BM (2010). A valid and reliable belief elicitation method for Bayesian priors. Journal of Clinical Epidemiology, 63(4), 370-383.
Reliability in Elicitation Exercise
Maybe I misunderstood the question, but what you are describing sounds like a test-retest reliability study on your Q scores. You have a series of experts each going to assess a number of items or que
Reliability in Elicitation Exercise Maybe I misunderstood the question, but what you are describing sounds like a test-retest reliability study on your Q scores. You have a series of experts each going to assess a number of items or questions, at two occasions (presumably fixed in time). So, basically you can assess the temporal stability of the judgments by computing an intraclass correlation coefficient (ICC), which will give you an idea of the variance attributable to subjects in the variability of observed scores (or, in other words of the closeness of the observations on the same subject relative to the closeness of observations on different subjects). The ICC may easily be obtained from a mixed-effect model describing the measurement $y_{ij}$ of subject $i$ on occasion $j$ as $$ y_{ij}=\mu+u_i+\varepsilon_{ij},\quad \varepsilon\sim\mathcal{N}(0,\sigma^2) $$ where $u_i$ is the difference between the overall mean and subject $i$'s mean measurement, and $\varepsilon_{ij}$ is the measurement error for subject $i$ on occasion $j$. Here, this is a random-effect model. Unlike a standard ANOVA with subjects as factor, we consider the $u_i$ as random (i.i.d.) effects, $u_i\sim\mathcal{N}(0,\tau^2)$, independent of the error terms. Each measurement differ from the overall mean $\mu$ by the sum of the two error terms, among which the $u_i$ is shared between occasion on the same subjects. The total variance is then $\tau^2+\sigma^2$ and the proportion of the total variance that is accounted for by the subjects is $$ \rho=\frac{\tau^2}{\tau^2+\sigma^2} $$ which is the ICC, or the reliability index from a psychometrical point of view. Note that this reliability is sample-dependent (as it depends on the between-subject variance). Instead of the mixed-effects model, we could derive the same results from a two-way ANOVA (subjects + time, as factors) and the corresponding Mean Squares. You will find additional references in those related questions: Repeatability and measurement error from and between observers, and Inter-rater reliability for ordinal or interval data. In R, you can use the icc() function from the psy package; the random intercept model described above corresponds to the "agreement" ICC, while incorporating the time effect as a fixed factor would yield the "consistency" ICC. You can also use the lmer() function from the lme4 package, or the lme() function from the nlme package. The latter has the advantage that you can easily obtain 95% CIs for the variance components (using the intervals() function). Dave Garson provided a nice overview (with SPSS illustrations) in Reliability Analysis, and Estimating Multilevel Models using SPSS, Stata, SAS, and R constitutes a useful tutorial, with applications in educational assessment. But the definitive reference is Shrout and Fleiss (1979), Intraclass Correlations: Uses in Assessing Rater Reliability, Psychological Bulletin, 86(2), 420-428. I have also added an example R script on Githhub, that includes the ANOVA and mixed-effect approaches. Also, should you add a constant value to all of the values taken at the second occasion, the Pearson correlation would remain identical (because it is based on deviations of the 1st and 2nd measurements from their respective means), whereas the reliability as computed through the random intercept model (or the agreement ICC) would decrease. BTW, Cronbach's alpha is not very helpful in this case because it is merely a measure of the internal consistency (yet, another form of "reliability") of an unidimensional scale; it would have no meaning should it be computed on items underlying different constructs. Even if your questions survey a single domain, it's hard to imagine mixing the two series of measurements, and Cronbach's alpha should be computed on each set separately. Its associated 95% confidence interval (computed by bootstrap) should give an indication about the stability of the internal structure between the two test occasions. As an example of applied work with ICC, I would suggest Johnson, SR, Tomlinson, GA, Hawker, GA, Granton, JT, Grosbein, HA, and Feldman, BM (2010). A valid and reliable belief elicitation method for Bayesian priors. Journal of Clinical Epidemiology, 63(4), 370-383.
Reliability in Elicitation Exercise Maybe I misunderstood the question, but what you are describing sounds like a test-retest reliability study on your Q scores. You have a series of experts each going to assess a number of items or que
37,025
Reliability in Elicitation Exercise
You would use Cronbach alpha if you do not know the true value but if you do know the true value then it seems a bit pointless to use Cronbach alpha. The use of Pearson correlation also seems a bit odd as you do not actually have a paired set of values. I would suggest using something like the Mean Squared Error (MSE). Suppose that you have N experts and that the expected estimate for the expert i is given by $\hat{\theta_i}$ and your true value is $\theta$. Then, $MSE = \frac{\sum_i (\hat{\theta_i} - \theta)^2}{N}$
Reliability in Elicitation Exercise
You would use Cronbach alpha if you do not know the true value but if you do know the true value then it seems a bit pointless to use Cronbach alpha. The use of Pearson correlation also seems a bit od
Reliability in Elicitation Exercise You would use Cronbach alpha if you do not know the true value but if you do know the true value then it seems a bit pointless to use Cronbach alpha. The use of Pearson correlation also seems a bit odd as you do not actually have a paired set of values. I would suggest using something like the Mean Squared Error (MSE). Suppose that you have N experts and that the expected estimate for the expert i is given by $\hat{\theta_i}$ and your true value is $\theta$. Then, $MSE = \frac{\sum_i (\hat{\theta_i} - \theta)^2}{N}$
Reliability in Elicitation Exercise You would use Cronbach alpha if you do not know the true value but if you do know the true value then it seems a bit pointless to use Cronbach alpha. The use of Pearson correlation also seems a bit od
37,026
What do you think is the best goodness of fit test?
I have been told many times that the Anderson Darling (AD) test is much better than the Kolmogorov-Smirnov (KS) one because AD does a better job at fitting the tails of the distribution. KS is only good at fitting the mid-range of the distribution; but, is not better than AD even in this regard. I think the main advantage of the KS test is its very intuitive visual interpretation (fitting of the respective cumulative distributions). Because of the KS easy visual and intuitive interpretation it has become dominant in certain specialties such as credit scoring models within the financial service industry. But, more visually intuitive does not mean better. When using Monte Carlo simulation models that automatically fit a statistical distribution to a data set; their respective software manuals typically recommend leaning more on the AD than the KS test for the reason mentioned above (fits the tails better).
What do you think is the best goodness of fit test?
I have been told many times that the Anderson Darling (AD) test is much better than the Kolmogorov-Smirnov (KS) one because AD does a better job at fitting the tails of the distribution. KS is only g
What do you think is the best goodness of fit test? I have been told many times that the Anderson Darling (AD) test is much better than the Kolmogorov-Smirnov (KS) one because AD does a better job at fitting the tails of the distribution. KS is only good at fitting the mid-range of the distribution; but, is not better than AD even in this regard. I think the main advantage of the KS test is its very intuitive visual interpretation (fitting of the respective cumulative distributions). Because of the KS easy visual and intuitive interpretation it has become dominant in certain specialties such as credit scoring models within the financial service industry. But, more visually intuitive does not mean better. When using Monte Carlo simulation models that automatically fit a statistical distribution to a data set; their respective software manuals typically recommend leaning more on the AD than the KS test for the reason mentioned above (fits the tails better).
What do you think is the best goodness of fit test? I have been told many times that the Anderson Darling (AD) test is much better than the Kolmogorov-Smirnov (KS) one because AD does a better job at fitting the tails of the distribution. KS is only g
37,027
What do you think is the best goodness of fit test?
I'm not sure about these tests, so this answer may be off-topic. Apologies if so. But, are you sure that you want a test? It really depends on what the purpose of the exercise is. Why are you fitting the distributions to the data, and what will you do with the fitted distributions afterward? If you want to know what distribution fits best just because you're interested, then a test may help. On the other hand, if you want to actually do something with the distribution, then you'd be better off developing a loss function based on your intentions, and using the distribution that gives you the most satisfactory value for the loss function. It sounds to me from your description (particular focus on the tail) that you want to actually do something with the distribution. If so, it's hard for me to imagine a situation where an existing test will provide better guidance than comparing the effects of the fitted distributions in situ, somehow.
What do you think is the best goodness of fit test?
I'm not sure about these tests, so this answer may be off-topic. Apologies if so. But, are you sure that you want a test? It really depends on what the purpose of the exercise is. Why are you fitt
What do you think is the best goodness of fit test? I'm not sure about these tests, so this answer may be off-topic. Apologies if so. But, are you sure that you want a test? It really depends on what the purpose of the exercise is. Why are you fitting the distributions to the data, and what will you do with the fitted distributions afterward? If you want to know what distribution fits best just because you're interested, then a test may help. On the other hand, if you want to actually do something with the distribution, then you'd be better off developing a loss function based on your intentions, and using the distribution that gives you the most satisfactory value for the loss function. It sounds to me from your description (particular focus on the tail) that you want to actually do something with the distribution. If so, it's hard for me to imagine a situation where an existing test will provide better guidance than comparing the effects of the fitted distributions in situ, somehow.
What do you think is the best goodness of fit test? I'm not sure about these tests, so this answer may be off-topic. Apologies if so. But, are you sure that you want a test? It really depends on what the purpose of the exercise is. Why are you fitt
37,028
What do you think is the best goodness of fit test?
I think that my question is subsumed by this more general discussion: Motivation for Kolmogorov distance between distributions
What do you think is the best goodness of fit test?
I think that my question is subsumed by this more general discussion: Motivation for Kolmogorov distance between distributions
What do you think is the best goodness of fit test? I think that my question is subsumed by this more general discussion: Motivation for Kolmogorov distance between distributions
What do you think is the best goodness of fit test? I think that my question is subsumed by this more general discussion: Motivation for Kolmogorov distance between distributions
37,029
Why does degrees of freedom = $\frac{\operatorname{Tr}(H'H)^2}{\operatorname{Tr}(H'HH'H)}$?
There is a Wikipedia article that is more directly about the Welch-Satterthwaite approximation. The Wikipedia article makes the following citations to original sources Satterthwaite, F. E. (1946), "An Approximate Distribution of Estimates of Variance Components.", I Biometrics Bulletin, 2 (6): 110–114 Welch, B. L. (1947), "The generalization of "student's" problem when several different population variances are involved.", Biometrika, 34 (1/2): 28–35 The principle behind it is to approximate a sum of squares (as used in several hypothesis tests or estimates of variance), when it is distributed as a linear sum of chi-squared distributions, by a single chi squared distribution. The approximation applies the methods of moments. For a chi-squared distribution we have that the degrees of freedom is expressed by $k = \frac{\text{Mean}(\chi)^2}{\text{Var}(\chi)}$, and the method of moments uses sample estimates to for the mean and variance. Let $y_i=\bar{y_i}+\epsilon_i$ be observations of true labels labels $\bar{y_i}$ corrupted with IID zero-centered noise $\epsilon_i$. For a given linear estimator $\hat{y} = H y$ The sum of squares of the model and the residuals are $$\begin{array}{rcl} SS_{model} &=& \Vert H (y-\bar{y}) \Vert^2 \\ SS_{residuals} &=& \Vert y- H y \Vert^2 = \Vert (I-H) (y-\bar{y}) \Vert^2 \\ \end{array}$$ If distribution of $y-\bar{y}$ has identity covariance, we have the following expressions for covariance of $\hat{y}$ and $y-\hat{y}$ $$\Sigma_{\hat{y}} = HH^T = H^2$$ $$\Sigma_{y-\hat{y}} = (I-H)(I-H)^T = I - 2H + H^2$$ the distribution of the sum of squares of a multivariate normal distribution can be seen as a sum of the independent principle components with variance equal to the eigenvalues. The sum of these eigenvalues is alse the trace of the covariance matrix. The mean and variance will be $$\begin{array}{rcl}\text{mean}(SS_{model}) &= &tr(HH^T) \\ \text{var}(SS_{model})& = &tr((HH^T)^T(HH^T)) = tr((HH^T)(HH^T)) \end{array}$$ and for $SS_{residuals}$ you get something similar but I won't wrote it out as it becomes a bit more complex, but that is where the different expressions come from. When $H$ is a projection matrix (as in OLS) then $H^tH = H$. That is another source for getting different types of expressions.
Why does degrees of freedom = $\frac{\operatorname{Tr}(H'H)^2}{\operatorname{Tr}(H'HH'H)}$?
There is a Wikipedia article that is more directly about the Welch-Satterthwaite approximation. The Wikipedia article makes the following citations to original sources Satterthwaite, F. E. (1946), "An
Why does degrees of freedom = $\frac{\operatorname{Tr}(H'H)^2}{\operatorname{Tr}(H'HH'H)}$? There is a Wikipedia article that is more directly about the Welch-Satterthwaite approximation. The Wikipedia article makes the following citations to original sources Satterthwaite, F. E. (1946), "An Approximate Distribution of Estimates of Variance Components.", I Biometrics Bulletin, 2 (6): 110–114 Welch, B. L. (1947), "The generalization of "student's" problem when several different population variances are involved.", Biometrika, 34 (1/2): 28–35 The principle behind it is to approximate a sum of squares (as used in several hypothesis tests or estimates of variance), when it is distributed as a linear sum of chi-squared distributions, by a single chi squared distribution. The approximation applies the methods of moments. For a chi-squared distribution we have that the degrees of freedom is expressed by $k = \frac{\text{Mean}(\chi)^2}{\text{Var}(\chi)}$, and the method of moments uses sample estimates to for the mean and variance. Let $y_i=\bar{y_i}+\epsilon_i$ be observations of true labels labels $\bar{y_i}$ corrupted with IID zero-centered noise $\epsilon_i$. For a given linear estimator $\hat{y} = H y$ The sum of squares of the model and the residuals are $$\begin{array}{rcl} SS_{model} &=& \Vert H (y-\bar{y}) \Vert^2 \\ SS_{residuals} &=& \Vert y- H y \Vert^2 = \Vert (I-H) (y-\bar{y}) \Vert^2 \\ \end{array}$$ If distribution of $y-\bar{y}$ has identity covariance, we have the following expressions for covariance of $\hat{y}$ and $y-\hat{y}$ $$\Sigma_{\hat{y}} = HH^T = H^2$$ $$\Sigma_{y-\hat{y}} = (I-H)(I-H)^T = I - 2H + H^2$$ the distribution of the sum of squares of a multivariate normal distribution can be seen as a sum of the independent principle components with variance equal to the eigenvalues. The sum of these eigenvalues is alse the trace of the covariance matrix. The mean and variance will be $$\begin{array}{rcl}\text{mean}(SS_{model}) &= &tr(HH^T) \\ \text{var}(SS_{model})& = &tr((HH^T)^T(HH^T)) = tr((HH^T)(HH^T)) \end{array}$$ and for $SS_{residuals}$ you get something similar but I won't wrote it out as it becomes a bit more complex, but that is where the different expressions come from. When $H$ is a projection matrix (as in OLS) then $H^tH = H$. That is another source for getting different types of expressions.
Why does degrees of freedom = $\frac{\operatorname{Tr}(H'H)^2}{\operatorname{Tr}(H'HH'H)}$? There is a Wikipedia article that is more directly about the Welch-Satterthwaite approximation. The Wikipedia article makes the following citations to original sources Satterthwaite, F. E. (1946), "An
37,030
Why multiple testing matters?
This is an interesting question, and I've thought about this as well. My current thinking is this: Hypothesis testing has to be seen within a wider research context. Generally testing a hypothesis cannot ultimately settle a scientific problem of interest. For sure 5% type I error probability is worryingly high if decisions are made and scientific statements are taken for granted based on significances alone that can have serious consequences for society or be it individual patients. There are also many other issues with significance tests (such as that tests with sufficiently large samples easily turn out significant, and this is theoretically even "correct", if the null hypothesis is not precisely true but effects are so small that they don't matter, or are at least over-interpreted based on a small p-value). Given all this, the difference between the two situations in my view is this. One should hope (and check!) that the "independent researchers" test hypotheses that are of real substantial interest, backed op by background information and thorough subject matter considerations. A hypothesis test should never be the only "information" based on which something is claimed; even using the very same data, effect sizes and potential violations of model assumptions, problems with data quality etc. should be addressed, and even then it should be clear that, say, $p=0.035$ isn't that strong an indication that anything meaningful is going on. Ultimately one can say that these specific data don't provide evidence against the null hypothesis, or they do, weaker or stronger (indeed keeping in mind that there are thousands of scientific papers with tests published every month if not week, and that a certain number of "false significances" is to be expected), with additional careful interpretation of all further results of data analysis. In a single study in which 10,000 hypotheses are tested, chances are that other than running the tests there isn't much further background and detailed analysis for every single test. Also chances are that significant or "most significant" results will be selectively reported, which means that the probability that something is reported as meaningful that in fact isn't is far higher than the significance level. So I indeed believe that multiple testing adjustments are more appropriate in this situation than in a situation where more thorough analysis is done and more information is taken into account. Apart from this, one can of course generally discuss the pros and cons of significance testing in all of these situations.
Why multiple testing matters?
This is an interesting question, and I've thought about this as well. My current thinking is this: Hypothesis testing has to be seen within a wider research context. Generally testing a hypothesis can
Why multiple testing matters? This is an interesting question, and I've thought about this as well. My current thinking is this: Hypothesis testing has to be seen within a wider research context. Generally testing a hypothesis cannot ultimately settle a scientific problem of interest. For sure 5% type I error probability is worryingly high if decisions are made and scientific statements are taken for granted based on significances alone that can have serious consequences for society or be it individual patients. There are also many other issues with significance tests (such as that tests with sufficiently large samples easily turn out significant, and this is theoretically even "correct", if the null hypothesis is not precisely true but effects are so small that they don't matter, or are at least over-interpreted based on a small p-value). Given all this, the difference between the two situations in my view is this. One should hope (and check!) that the "independent researchers" test hypotheses that are of real substantial interest, backed op by background information and thorough subject matter considerations. A hypothesis test should never be the only "information" based on which something is claimed; even using the very same data, effect sizes and potential violations of model assumptions, problems with data quality etc. should be addressed, and even then it should be clear that, say, $p=0.035$ isn't that strong an indication that anything meaningful is going on. Ultimately one can say that these specific data don't provide evidence against the null hypothesis, or they do, weaker or stronger (indeed keeping in mind that there are thousands of scientific papers with tests published every month if not week, and that a certain number of "false significances" is to be expected), with additional careful interpretation of all further results of data analysis. In a single study in which 10,000 hypotheses are tested, chances are that other than running the tests there isn't much further background and detailed analysis for every single test. Also chances are that significant or "most significant" results will be selectively reported, which means that the probability that something is reported as meaningful that in fact isn't is far higher than the significance level. So I indeed believe that multiple testing adjustments are more appropriate in this situation than in a situation where more thorough analysis is done and more information is taken into account. Apart from this, one can of course generally discuss the pros and cons of significance testing in all of these situations.
Why multiple testing matters? This is an interesting question, and I've thought about this as well. My current thinking is this: Hypothesis testing has to be seen within a wider research context. Generally testing a hypothesis can
37,031
Median of the sum vs. sum of the median for Gaussian variables
Here is a simple proof, by comparison with appropriate symmetric variables. For a normal variable $X$, let $m$ be the median of $X^2$. The graphs show $X\sim N(4,1)$. Now we take a variable $Y$ which is a version of $X^2$ but symmetrized from right to left about $m$: In formulas: $$ f_Y(y) = \begin{cases} f_{X^2}(y)\phantom{2m-\, }\ \text{ if }\, y>m\\ f_{X^2}(2m-y)\ \text{ if }\, y<m\\ \end{cases}$$ $$F_Y(y) = \begin{cases} \phantom{1-\, }F_{X^2}(y)\phantom{2m-\, }\ \text{ if }\, y>m\\ 1-F_{X^2}(2m-y)\ \text{ if }\, y<m\\ \end{cases} $$ Since the $Y_i$'s are symmetric with median $m_i$, the values near $(y_1, \ldots y_n)$ and $(2m_1-y_1, \ldots 2m_n-y_n)$ are equally probable and on opposite sides of $m_1+\cdots+m_n$. So $m_1+\cdots+m_n$ must be the median of their sum. Also $X^2$ dominates $Y$, i.e. $F_{X^2}(y)\le F_Y(y)$, as can be seen in graphs like the above. Thus: $$ \begin{align} \text{median}\left(\sum X_i^2\right) &\ge \text{median}\left(\sum Y_i\right)\ &\text{ (by the dominance of the }X\text{'s)}\phantom{\ \square}\\ &=\sum\text{median}(Y_i)\ &\text{ (by the symmetry of the }Y\text{'s)}\phantom{\ \square}\\ &=\sum\text{median}(X_i^2)\ &\text{ (by the construction of the }Y\text{'s)}\ \square \end{align} $$
Median of the sum vs. sum of the median for Gaussian variables
Here is a simple proof, by comparison with appropriate symmetric variables. For a normal variable $X$, let $m$ be the median of $X^2$. The graphs show $X\sim N(4,1)$. Now we take a variable $Y$ which
Median of the sum vs. sum of the median for Gaussian variables Here is a simple proof, by comparison with appropriate symmetric variables. For a normal variable $X$, let $m$ be the median of $X^2$. The graphs show $X\sim N(4,1)$. Now we take a variable $Y$ which is a version of $X^2$ but symmetrized from right to left about $m$: In formulas: $$ f_Y(y) = \begin{cases} f_{X^2}(y)\phantom{2m-\, }\ \text{ if }\, y>m\\ f_{X^2}(2m-y)\ \text{ if }\, y<m\\ \end{cases}$$ $$F_Y(y) = \begin{cases} \phantom{1-\, }F_{X^2}(y)\phantom{2m-\, }\ \text{ if }\, y>m\\ 1-F_{X^2}(2m-y)\ \text{ if }\, y<m\\ \end{cases} $$ Since the $Y_i$'s are symmetric with median $m_i$, the values near $(y_1, \ldots y_n)$ and $(2m_1-y_1, \ldots 2m_n-y_n)$ are equally probable and on opposite sides of $m_1+\cdots+m_n$. So $m_1+\cdots+m_n$ must be the median of their sum. Also $X^2$ dominates $Y$, i.e. $F_{X^2}(y)\le F_Y(y)$, as can be seen in graphs like the above. Thus: $$ \begin{align} \text{median}\left(\sum X_i^2\right) &\ge \text{median}\left(\sum Y_i\right)\ &\text{ (by the dominance of the }X\text{'s)}\phantom{\ \square}\\ &=\sum\text{median}(Y_i)\ &\text{ (by the symmetry of the }Y\text{'s)}\phantom{\ \square}\\ &=\sum\text{median}(X_i^2)\ &\text{ (by the construction of the }Y\text{'s)}\ \square \end{align} $$
Median of the sum vs. sum of the median for Gaussian variables Here is a simple proof, by comparison with appropriate symmetric variables. For a normal variable $X$, let $m$ be the median of $X^2$. The graphs show $X\sim N(4,1)$. Now we take a variable $Y$ which
37,032
Generalized Linear Model: Why do we insist on modeling the mean?
Generalized linear models are generalization of linear regression model. Linear regression minimizes squared error for fitting the regression line. Minimizing squared error is equivalent to maximizing Gaussian likelihood. GLMs generalize this idea to other distributions, so we are estimating conditional means of other distributions. So it’s a little bit like asking “what’s the fuss with bikes having two wheels”, well they’re kind of vehicles that do. As others noticed in the comments, there are many other models that not necessarily focus on means. GLMs are just a family of models that do.
Generalized Linear Model: Why do we insist on modeling the mean?
Generalized linear models are generalization of linear regression model. Linear regression minimizes squared error for fitting the regression line. Minimizing squared error is equivalent to maximizing
Generalized Linear Model: Why do we insist on modeling the mean? Generalized linear models are generalization of linear regression model. Linear regression minimizes squared error for fitting the regression line. Minimizing squared error is equivalent to maximizing Gaussian likelihood. GLMs generalize this idea to other distributions, so we are estimating conditional means of other distributions. So it’s a little bit like asking “what’s the fuss with bikes having two wheels”, well they’re kind of vehicles that do. As others noticed in the comments, there are many other models that not necessarily focus on means. GLMs are just a family of models that do.
Generalized Linear Model: Why do we insist on modeling the mean? Generalized linear models are generalization of linear regression model. Linear regression minimizes squared error for fitting the regression line. Minimizing squared error is equivalent to maximizing
37,033
Definition of heavy-tailed distribution
For a fixed $\lambda>0$, we can rewrite the product as a fraction, so we can see the complementary cdf (right tail) of $Y_\lambda\sim Exp(\lambda)$: $$ P(Y_\lambda >x)=e^{-\lambda x}. $$ We have: $$\lim_{x \to \infty} e^{\lambda x} \cdot P(X > x) = \lim_{x \rightarrow \infty} \frac{P(X > x)}{ P(Y_\lambda>x)} = \infty.$$ This infinite limit at infinity means that: for every $M>0$ there is an $N_M>0$ such that $$ \frac{P(X > x)}{ P(Y_\lambda >x)} >M \; \;\left[\iff P(X>x)> M P(Y_\lambda >x) \right]$$ for all $x>N_M.$ That is for any given positive factor, for sufficiently high $x$, $X$'s right tail (starting at $x$) is bigger than $Y_\lambda$'s right tail (starting at $x$) scaled by the given factor. In particular, for, say, $M=1$ there is $N_1> 0$ such that $$ P(X>x)> P(Y_\lambda>x) $$ for all $x>N_1$. This has to hold for all $\lambda > 0$ values.
Definition of heavy-tailed distribution
For a fixed $\lambda>0$, we can rewrite the product as a fraction, so we can see the complementary cdf (right tail) of $Y_\lambda\sim Exp(\lambda)$: $$ P(Y_\lambda >x)=e^{-\lambda x}. $$ We have: $$\
Definition of heavy-tailed distribution For a fixed $\lambda>0$, we can rewrite the product as a fraction, so we can see the complementary cdf (right tail) of $Y_\lambda\sim Exp(\lambda)$: $$ P(Y_\lambda >x)=e^{-\lambda x}. $$ We have: $$\lim_{x \to \infty} e^{\lambda x} \cdot P(X > x) = \lim_{x \rightarrow \infty} \frac{P(X > x)}{ P(Y_\lambda>x)} = \infty.$$ This infinite limit at infinity means that: for every $M>0$ there is an $N_M>0$ such that $$ \frac{P(X > x)}{ P(Y_\lambda >x)} >M \; \;\left[\iff P(X>x)> M P(Y_\lambda >x) \right]$$ for all $x>N_M.$ That is for any given positive factor, for sufficiently high $x$, $X$'s right tail (starting at $x$) is bigger than $Y_\lambda$'s right tail (starting at $x$) scaled by the given factor. In particular, for, say, $M=1$ there is $N_1> 0$ such that $$ P(X>x)> P(Y_\lambda>x) $$ for all $x>N_1$. This has to hold for all $\lambda > 0$ values.
Definition of heavy-tailed distribution For a fixed $\lambda>0$, we can rewrite the product as a fraction, so we can see the complementary cdf (right tail) of $Y_\lambda\sim Exp(\lambda)$: $$ P(Y_\lambda >x)=e^{-\lambda x}. $$ We have: $$\
37,034
Mathematical notation for suppressing differentiation
I'm not aware of any standard notation for doing so on a "loss-level", in fact there's no stop_gradient function (in a mathematical sense) that would act as identity, but have a zero derivative. However, one can use standard substitution notation at the "gradient level": $$ \left(\frac{d}{dt} f(x(s), t)\right) \Bigl|_{s=t} $$ So one way to handle your extended question is to define an extended $\mathcal{K}$: $$ \begin{align*} \hat{\mathcal{K}}(\phi_1, \phi_2, \varphi_1, \varphi_2) = \mathop{\mathbb{E}}_{\substack{\theta_1 = g(\epsilon_1, \varphi_1) \\ \theta_2 = g(\theta_1, \epsilon_2, \varphi_2)}}[ \log \pi(\theta_1, \theta_2) &+ \log f(y_1 | \theta_1) + \log f(y_2 | \theta_1, \theta_2) \\ &- \log q_1(\theta_1; \phi_1) - \log q_2(\theta_2 | \theta_1; \phi_2)]. \end{align*} $$ Now, the gradient you're interested in is $(\nabla_{\phi_1} \hat{\mathcal{K}}(\phi_1, \phi_2, \varphi_1, \phi_2))|_{\varphi_1 = \phi_1}$
Mathematical notation for suppressing differentiation
I'm not aware of any standard notation for doing so on a "loss-level", in fact there's no stop_gradient function (in a mathematical sense) that would act as identity, but have a zero derivative. Howev
Mathematical notation for suppressing differentiation I'm not aware of any standard notation for doing so on a "loss-level", in fact there's no stop_gradient function (in a mathematical sense) that would act as identity, but have a zero derivative. However, one can use standard substitution notation at the "gradient level": $$ \left(\frac{d}{dt} f(x(s), t)\right) \Bigl|_{s=t} $$ So one way to handle your extended question is to define an extended $\mathcal{K}$: $$ \begin{align*} \hat{\mathcal{K}}(\phi_1, \phi_2, \varphi_1, \varphi_2) = \mathop{\mathbb{E}}_{\substack{\theta_1 = g(\epsilon_1, \varphi_1) \\ \theta_2 = g(\theta_1, \epsilon_2, \varphi_2)}}[ \log \pi(\theta_1, \theta_2) &+ \log f(y_1 | \theta_1) + \log f(y_2 | \theta_1, \theta_2) \\ &- \log q_1(\theta_1; \phi_1) - \log q_2(\theta_2 | \theta_1; \phi_2)]. \end{align*} $$ Now, the gradient you're interested in is $(\nabla_{\phi_1} \hat{\mathcal{K}}(\phi_1, \phi_2, \varphi_1, \phi_2))|_{\varphi_1 = \phi_1}$
Mathematical notation for suppressing differentiation I'm not aware of any standard notation for doing so on a "loss-level", in fact there's no stop_gradient function (in a mathematical sense) that would act as identity, but have a zero derivative. Howev
37,035
How can I model negative binomial sampling with a maximum number of attempts until success?
This can be framed as a problem with censoring if you like. Given that it is possible to take a sample without finding the disease (even if it is there) you have two aspects to your inference problem: (a) estimating the probability that a person has the disease; and (b) estimating the probability that the disease is found in a single sample (if it is there). I recommend you build up an appropriate model via basic assumptions about the relationship between your samples and the underlying disease. Here I will give an example of a simple model that could serve as a starting point for your analysis. A simple model: Suppose we assume that the results of samples are independent conditional on the presence of the disease. (For simplicity, assume that there are no false positives, so if the disease it not there then the sample is always negative.) Let $0<\theta<1$ be the probability of finding the disease (if it is present) in a single sample, and assume that this probability is fixed for all samples over all patients. Now, consider an individual patient with covariates $\mathbf{x}_i$ and let $D_i$ be the indicator that the person has the disease. Suppose, hypothetically, that we were to continue testing the patient until the disease is found, and let $y_i$ be the number of samples taken from the patient until the disease is found (with $y_i = \infty$ if the patient does not have the disease). Under these assumptions we have the conditional geometric distribution: $$Y_i|D_i=1 \sim \text{Geom}(\theta).$$ The sampling mechanism used here is that we observe a censored version of $y_i$ with censorship after three samples (i.e., we obesrve either $y_i=1$, $y_i=2$, $y_i=3$ or $y_i > 3$). These outcomes have conditional sampling density: $$\begin{align} \mathbb{P}(y_i=1|\mathbf{x}_i, D_i=0) &= 0, \\[6pt] \mathbb{P}(y_i=2|\mathbf{x}_i, D_i=0) &= 0, \\[6pt] \mathbb{P}(y_i=3|\mathbf{x}_i, D_i=0) &= 0, \\[6pt] \mathbb{P}(y_i>3|\mathbf{x}_i, D_i=0) &= 1, \\[6pt] \mathbb{P}(y_i=1|\mathbf{x}_i, D_i=1) &= \theta , \\[6pt] \mathbb{P}(y_i=2|\mathbf{x}_i, D_i=1) &= \theta(1-\theta), \\[6pt] \mathbb{P}(y_i=3|\mathbf{x}_i, D_i=1) &= \theta(1-\theta)^2, \\[6pt] \mathbb{P}(y_i>3|\mathbf{x}_i, D_i=1) &= (1-\theta)^3. \\[6pt] \end{align}$$ Suppose we denote the disease probability (given the covariates) by $r(\mathbf{x},\boldsymbol{\beta}) \equiv \mathbb{P}(D_i=1|\mathbf{x})$ where $\boldsymbol{\beta}$ is a set of model parameters. Then for a single patient we have: $$\begin{align} \mathbb{P}(y_i=1|\mathbf{x}_i) &= \theta \cdot r(\mathbf{x}_i, \boldsymbol{\beta}), \\[6pt] \mathbb{P}(y_i=2|\mathbf{x}_i) &= \theta(1-\theta) \cdot r(\mathbf{x}_i, \boldsymbol{\beta}), \\[6pt] \mathbb{P}(y_i=3|\mathbf{x}_i) &= \theta(1-\theta)^2 \cdot r(\mathbf{x}_i, \boldsymbol{\beta}), \\[6pt] \mathbb{P}(y_i>3|\mathbf{x}_i) &= (1-\theta)^3 \cdot r(\mathbf{x}_i, \boldsymbol{\beta}) + (1- r(\mathbf{x}_i, \boldsymbol{\beta})). \\[6pt] \end{align}$$ Setting a model for the disease is equivalent to setting the form of the function $r$. For this you might like to use a logistic regression, or some similar model used on binary outcome data. Once you have done this you can form the likelihood function for your model, which is the product of the above sampling densities taken over all patients. In terms of your inferences, you will be able to get estimators for the parameters $\theta$ and $\boldsymbol{\beta}$, and the latter will give an induced estimate for the probability of disease for a patient with any particular set of covariates. Both parameters are identifiable (so long as your $\boldsymbol{\beta}$ vector is identifiable within $r$) so this type of model should allow you to make simultaneous inferences about the probability of disease and the probability of detection of disease. Of course, you will notice that this model is heavily dependent on the assumption that sample outcomes are independent given the presence of the disease (i.e., the second or third sample is no more likely than the first to find the disease if it is present). Some kind of assumption here is likely to be crucial to the model, and if it is wrong then your inferences will be wrong. Conseqeuently, it is worth thinking deeply about whether this is a plausible description of your sampling method in this case.
How can I model negative binomial sampling with a maximum number of attempts until success?
This can be framed as a problem with censoring if you like. Given that it is possible to take a sample without finding the disease (even if it is there) you have two aspects to your inference problem
How can I model negative binomial sampling with a maximum number of attempts until success? This can be framed as a problem with censoring if you like. Given that it is possible to take a sample without finding the disease (even if it is there) you have two aspects to your inference problem: (a) estimating the probability that a person has the disease; and (b) estimating the probability that the disease is found in a single sample (if it is there). I recommend you build up an appropriate model via basic assumptions about the relationship between your samples and the underlying disease. Here I will give an example of a simple model that could serve as a starting point for your analysis. A simple model: Suppose we assume that the results of samples are independent conditional on the presence of the disease. (For simplicity, assume that there are no false positives, so if the disease it not there then the sample is always negative.) Let $0<\theta<1$ be the probability of finding the disease (if it is present) in a single sample, and assume that this probability is fixed for all samples over all patients. Now, consider an individual patient with covariates $\mathbf{x}_i$ and let $D_i$ be the indicator that the person has the disease. Suppose, hypothetically, that we were to continue testing the patient until the disease is found, and let $y_i$ be the number of samples taken from the patient until the disease is found (with $y_i = \infty$ if the patient does not have the disease). Under these assumptions we have the conditional geometric distribution: $$Y_i|D_i=1 \sim \text{Geom}(\theta).$$ The sampling mechanism used here is that we observe a censored version of $y_i$ with censorship after three samples (i.e., we obesrve either $y_i=1$, $y_i=2$, $y_i=3$ or $y_i > 3$). These outcomes have conditional sampling density: $$\begin{align} \mathbb{P}(y_i=1|\mathbf{x}_i, D_i=0) &= 0, \\[6pt] \mathbb{P}(y_i=2|\mathbf{x}_i, D_i=0) &= 0, \\[6pt] \mathbb{P}(y_i=3|\mathbf{x}_i, D_i=0) &= 0, \\[6pt] \mathbb{P}(y_i>3|\mathbf{x}_i, D_i=0) &= 1, \\[6pt] \mathbb{P}(y_i=1|\mathbf{x}_i, D_i=1) &= \theta , \\[6pt] \mathbb{P}(y_i=2|\mathbf{x}_i, D_i=1) &= \theta(1-\theta), \\[6pt] \mathbb{P}(y_i=3|\mathbf{x}_i, D_i=1) &= \theta(1-\theta)^2, \\[6pt] \mathbb{P}(y_i>3|\mathbf{x}_i, D_i=1) &= (1-\theta)^3. \\[6pt] \end{align}$$ Suppose we denote the disease probability (given the covariates) by $r(\mathbf{x},\boldsymbol{\beta}) \equiv \mathbb{P}(D_i=1|\mathbf{x})$ where $\boldsymbol{\beta}$ is a set of model parameters. Then for a single patient we have: $$\begin{align} \mathbb{P}(y_i=1|\mathbf{x}_i) &= \theta \cdot r(\mathbf{x}_i, \boldsymbol{\beta}), \\[6pt] \mathbb{P}(y_i=2|\mathbf{x}_i) &= \theta(1-\theta) \cdot r(\mathbf{x}_i, \boldsymbol{\beta}), \\[6pt] \mathbb{P}(y_i=3|\mathbf{x}_i) &= \theta(1-\theta)^2 \cdot r(\mathbf{x}_i, \boldsymbol{\beta}), \\[6pt] \mathbb{P}(y_i>3|\mathbf{x}_i) &= (1-\theta)^3 \cdot r(\mathbf{x}_i, \boldsymbol{\beta}) + (1- r(\mathbf{x}_i, \boldsymbol{\beta})). \\[6pt] \end{align}$$ Setting a model for the disease is equivalent to setting the form of the function $r$. For this you might like to use a logistic regression, or some similar model used on binary outcome data. Once you have done this you can form the likelihood function for your model, which is the product of the above sampling densities taken over all patients. In terms of your inferences, you will be able to get estimators for the parameters $\theta$ and $\boldsymbol{\beta}$, and the latter will give an induced estimate for the probability of disease for a patient with any particular set of covariates. Both parameters are identifiable (so long as your $\boldsymbol{\beta}$ vector is identifiable within $r$) so this type of model should allow you to make simultaneous inferences about the probability of disease and the probability of detection of disease. Of course, you will notice that this model is heavily dependent on the assumption that sample outcomes are independent given the presence of the disease (i.e., the second or third sample is no more likely than the first to find the disease if it is present). Some kind of assumption here is likely to be crucial to the model, and if it is wrong then your inferences will be wrong. Conseqeuently, it is worth thinking deeply about whether this is a plausible description of your sampling method in this case.
How can I model negative binomial sampling with a maximum number of attempts until success? This can be framed as a problem with censoring if you like. Given that it is possible to take a sample without finding the disease (even if it is there) you have two aspects to your inference problem
37,036
How support vectors is calculated on SVM example?
Let us use the figure on the wikipedia pare of SVM https://en.wikipedia.org/wiki/Support_vector_machine#/media/File:SVM_margin.png as a guide. I understand that the $f(\phi(x))$ formula is for the separating hyperplane which is the red line in the figure. The formula is really $f(\phi(x))=0$. Then $w = [4,9*4,4,0]$ and the $x$ in the formula in the figure is really $\phi(x)$ and $b = 0$. (in one point you have $9*4 \phi(x)_2$ and on your written notes you have $9*\phi(x)_2$ - I will assume that $9*4 \phi(x)_2$ is the correct one) Thus the hyper-plane equation is $[4,9*4,4,0]*\phi(x) - 0 = 0$ According to the figure, the margins are $[4,4*9,4,0]*\phi(x) - 0 = \pm 1$ Expanding the +1 version: $$ [4,4*9,4,0]*\phi(x) - 0 = 1 \\ [4,4*9,4,0]*[x_1^2,x_1^2, x_1 x_2, -x_1] = 1 \\ 10*4 x_1^2 + 4 x_1 x_2 = 1\\ 10 x_1^2 + x_1 x_2 = 1/4 $$ and similarly for the other margin $$10 x_1^2 + x_1 x_2 = - 1/4 $$ none of the points $a = [1,1]$ and $b=[1,-1]$ satisfy either equations so they are not in the margins. So they cannot be support vectors. Notice that you cannot calculate/compute what are the support vectors. The support vectors are the points on the training set that lie on the two margins - the two blue and one green points in the figure that have the black borders. You know that the support vectors lie on the margins but you need the training set to select/verify the ones that are the support vectors. UPDATE: given that the correct formula for the hyperplane is the one without $9*4\phi(x)_2$ the margins equations are $[4,9,4,0]*\phi(x) - 0 = \pm 1$ For the +1 margin $$ [4,9,4,0]*\phi(x) - 0 = 1 \\ [4,9,4,0]*[x_1^2,x_1^2, x_1 x_2, -x_1] = 1 \\ 11 x_1^2 + 4 x_1 x_2 = 1\\ 11 x_1^2 + 4 x_1 x_2 - 1 = 0\\ $$ for the -1 margin $$11 x_1^2 + 4 x_1 x_2 + 1 = 0$$ again, neither a=[1,1] or b=[1,-1] are in the margins and therefore cannot be support vectors. There seems to be a problem with your derivation. There is no need to divide $Y_i$ by $||w||$. $ 2/||w||$ is the size of the margin. But the equation of the hyperplane $f(x)$ is computer such that: $f(x) = 0 $ for X in the separating hyperplane $f(x) = 1 $ for one of the margins $f(x) = -1$ for the other margin (please see again the figure in wikipedia).
How support vectors is calculated on SVM example?
Let us use the figure on the wikipedia pare of SVM https://en.wikipedia.org/wiki/Support_vector_machine#/media/File:SVM_margin.png as a guide. I understand that the $f(\phi(x))$ formula is for the se
How support vectors is calculated on SVM example? Let us use the figure on the wikipedia pare of SVM https://en.wikipedia.org/wiki/Support_vector_machine#/media/File:SVM_margin.png as a guide. I understand that the $f(\phi(x))$ formula is for the separating hyperplane which is the red line in the figure. The formula is really $f(\phi(x))=0$. Then $w = [4,9*4,4,0]$ and the $x$ in the formula in the figure is really $\phi(x)$ and $b = 0$. (in one point you have $9*4 \phi(x)_2$ and on your written notes you have $9*\phi(x)_2$ - I will assume that $9*4 \phi(x)_2$ is the correct one) Thus the hyper-plane equation is $[4,9*4,4,0]*\phi(x) - 0 = 0$ According to the figure, the margins are $[4,4*9,4,0]*\phi(x) - 0 = \pm 1$ Expanding the +1 version: $$ [4,4*9,4,0]*\phi(x) - 0 = 1 \\ [4,4*9,4,0]*[x_1^2,x_1^2, x_1 x_2, -x_1] = 1 \\ 10*4 x_1^2 + 4 x_1 x_2 = 1\\ 10 x_1^2 + x_1 x_2 = 1/4 $$ and similarly for the other margin $$10 x_1^2 + x_1 x_2 = - 1/4 $$ none of the points $a = [1,1]$ and $b=[1,-1]$ satisfy either equations so they are not in the margins. So they cannot be support vectors. Notice that you cannot calculate/compute what are the support vectors. The support vectors are the points on the training set that lie on the two margins - the two blue and one green points in the figure that have the black borders. You know that the support vectors lie on the margins but you need the training set to select/verify the ones that are the support vectors. UPDATE: given that the correct formula for the hyperplane is the one without $9*4\phi(x)_2$ the margins equations are $[4,9,4,0]*\phi(x) - 0 = \pm 1$ For the +1 margin $$ [4,9,4,0]*\phi(x) - 0 = 1 \\ [4,9,4,0]*[x_1^2,x_1^2, x_1 x_2, -x_1] = 1 \\ 11 x_1^2 + 4 x_1 x_2 = 1\\ 11 x_1^2 + 4 x_1 x_2 - 1 = 0\\ $$ for the -1 margin $$11 x_1^2 + 4 x_1 x_2 + 1 = 0$$ again, neither a=[1,1] or b=[1,-1] are in the margins and therefore cannot be support vectors. There seems to be a problem with your derivation. There is no need to divide $Y_i$ by $||w||$. $ 2/||w||$ is the size of the margin. But the equation of the hyperplane $f(x)$ is computer such that: $f(x) = 0 $ for X in the separating hyperplane $f(x) = 1 $ for one of the margins $f(x) = -1$ for the other margin (please see again the figure in wikipedia).
How support vectors is calculated on SVM example? Let us use the figure on the wikipedia pare of SVM https://en.wikipedia.org/wiki/Support_vector_machine#/media/File:SVM_margin.png as a guide. I understand that the $f(\phi(x))$ formula is for the se
37,037
How support vectors is calculated on SVM example?
Regarding the comment in the question: The real question is that: for detecting that some vector is support vector we should use which of them? 1) check the wx+b or 2) calculate Euclidean distance to hyperplane? We can do both. This is because the support vectors, as has been already said by @Jacques Wainer, are the ones that correspond to points lying in the minimum margins (hard margin case). So if we have an expression for the hyperplane (in feature space): $$ f(\phi(x))=0$$ Then the points $\phi(x_i)$ that don't lie in this hyperplane will have a value $\hat{\gamma_i}=|f(\phi(x_i))|>0$, being greater as the distance between the hyperplane and the point $\phi(x_i)$ increases. This value $\hat{\gamma_i}$ is known as functional margin. Hence, the support vectors, $x_{SV}$, will correspond to the points $x_i$ that in feature space , $\phi(x_i)$, satisfy: $$x_{SV} = \arg \min_{x_i} |f(\phi(x_i))| = \arg \min_{x_i} \hat{\gamma_i}$$ Note that the absolute value $|f(\phi(x_i))|$ is used to take into account that the points $\phi(x_i)$ can be at both sides of the hyperplane i.e. $f(\phi(x_i))$ will be positive for the data points with an specific label, and negative for the data points with the other label. So we can see here that using $f(\phi(x))$ is sufficient to know which points in feature space ($\phi(x_i)$) correspond to support vectors. However, note that this is equivalent as finding the points $\phi(x_i)$ with the minimum Euclidean distance to the hyperplane. This distance is also known as geometric margin ($\gamma_i$) and can be calculated as $\gamma_i = \hat{\gamma_i}/\Vert w\Vert$. Where $w=(4,9,4,0)^T$ in your example. So to sum up, support vectors in your example, would correspond to the the points $\phi(x_i)$ of your dataset that minimize Euclidean distance ($\gamma_i$, geometric margin) to the hyperplane, or equivalently, the ones that minimize the value of $|f(\phi(x_i))|$ ($\hat{\gamma_i}$, functional margin). Particularizing to your data points $a$ and $b$, we have that: $$|f(\phi(a))| = \hat{\gamma_a}=17 \quad\quad\quad |f(\phi(b))| = \hat{\gamma_b}=9$$ Given this, we can conclude that only if the rest of the data points used to construct the hyperplane $f(\phi(x))=0$ have bigger or equal functional margins, then $b$ will be a support vector.
How support vectors is calculated on SVM example?
Regarding the comment in the question: The real question is that: for detecting that some vector is support vector we should use which of them? 1) check the wx+b or 2) calculate Euclidean distance to
How support vectors is calculated on SVM example? Regarding the comment in the question: The real question is that: for detecting that some vector is support vector we should use which of them? 1) check the wx+b or 2) calculate Euclidean distance to hyperplane? We can do both. This is because the support vectors, as has been already said by @Jacques Wainer, are the ones that correspond to points lying in the minimum margins (hard margin case). So if we have an expression for the hyperplane (in feature space): $$ f(\phi(x))=0$$ Then the points $\phi(x_i)$ that don't lie in this hyperplane will have a value $\hat{\gamma_i}=|f(\phi(x_i))|>0$, being greater as the distance between the hyperplane and the point $\phi(x_i)$ increases. This value $\hat{\gamma_i}$ is known as functional margin. Hence, the support vectors, $x_{SV}$, will correspond to the points $x_i$ that in feature space , $\phi(x_i)$, satisfy: $$x_{SV} = \arg \min_{x_i} |f(\phi(x_i))| = \arg \min_{x_i} \hat{\gamma_i}$$ Note that the absolute value $|f(\phi(x_i))|$ is used to take into account that the points $\phi(x_i)$ can be at both sides of the hyperplane i.e. $f(\phi(x_i))$ will be positive for the data points with an specific label, and negative for the data points with the other label. So we can see here that using $f(\phi(x))$ is sufficient to know which points in feature space ($\phi(x_i)$) correspond to support vectors. However, note that this is equivalent as finding the points $\phi(x_i)$ with the minimum Euclidean distance to the hyperplane. This distance is also known as geometric margin ($\gamma_i$) and can be calculated as $\gamma_i = \hat{\gamma_i}/\Vert w\Vert$. Where $w=(4,9,4,0)^T$ in your example. So to sum up, support vectors in your example, would correspond to the the points $\phi(x_i)$ of your dataset that minimize Euclidean distance ($\gamma_i$, geometric margin) to the hyperplane, or equivalently, the ones that minimize the value of $|f(\phi(x_i))|$ ($\hat{\gamma_i}$, functional margin). Particularizing to your data points $a$ and $b$, we have that: $$|f(\phi(a))| = \hat{\gamma_a}=17 \quad\quad\quad |f(\phi(b))| = \hat{\gamma_b}=9$$ Given this, we can conclude that only if the rest of the data points used to construct the hyperplane $f(\phi(x))=0$ have bigger or equal functional margins, then $b$ will be a support vector.
How support vectors is calculated on SVM example? Regarding the comment in the question: The real question is that: for detecting that some vector is support vector we should use which of them? 1) check the wx+b or 2) calculate Euclidean distance to
37,038
AIC model averaging when models are correlated
To the best of my knowledge, such a modification of the weights in Bayesian Model Averaging to take the similarity (or other relations) between models into account does not exist in the literature. According to me, the main reason is that the problem your are raising (and that you nicely illustrated in your example) should be corrected at the level of models selection, and not at the level of model averaging. As far as I know, a characterization of the "similarity" of the models does not exist, and would anyway be difficult to define. Even a notion as simple and widely used as "nestedness" lacks a rigorous definition in the literature (reference) (although we proposed a definition in this recent paper). Different models might have the same prediction, while being greatly different in their structure and nature. If a phenomenological, a normative, and a physical models all agree on the same prediction, then the evidence for the said prediction is very high, and these models "deserve" to have an important weight in your model averaging (even if they have the same prediction). In your example, the problem is from the choice of the models, not the averaging itself. The family of models 1, 1a, 1b, 1c, 2 is ill-defined : it is like sampling only a small part of your population (around model 1), which will lead to a biased result. However, apart from heuristically checking if your proposed family of models is sound, I don't think there exists (yet) a quantitative criterion or method to avoid this pitfall.
AIC model averaging when models are correlated
To the best of my knowledge, such a modification of the weights in Bayesian Model Averaging to take the similarity (or other relations) between models into account does not exist in the literature. Ac
AIC model averaging when models are correlated To the best of my knowledge, such a modification of the weights in Bayesian Model Averaging to take the similarity (or other relations) between models into account does not exist in the literature. According to me, the main reason is that the problem your are raising (and that you nicely illustrated in your example) should be corrected at the level of models selection, and not at the level of model averaging. As far as I know, a characterization of the "similarity" of the models does not exist, and would anyway be difficult to define. Even a notion as simple and widely used as "nestedness" lacks a rigorous definition in the literature (reference) (although we proposed a definition in this recent paper). Different models might have the same prediction, while being greatly different in their structure and nature. If a phenomenological, a normative, and a physical models all agree on the same prediction, then the evidence for the said prediction is very high, and these models "deserve" to have an important weight in your model averaging (even if they have the same prediction). In your example, the problem is from the choice of the models, not the averaging itself. The family of models 1, 1a, 1b, 1c, 2 is ill-defined : it is like sampling only a small part of your population (around model 1), which will lead to a biased result. However, apart from heuristically checking if your proposed family of models is sound, I don't think there exists (yet) a quantitative criterion or method to avoid this pitfall.
AIC model averaging when models are correlated To the best of my knowledge, such a modification of the weights in Bayesian Model Averaging to take the similarity (or other relations) between models into account does not exist in the literature. Ac
37,039
Is AIC appropriate for comparing non linear models?
Yes, AIC (or AICc) are still "generally appropriate". We make the assumption of a Gaussian error (see below). Avoid computing AIC manually if both models are of the same type, that said: Comparing across model types requires attention to detail to make sure that parameters are counted using similar rules, and that additive constants are consistently included or not. (from: https://stat.ethz.ch/pipermail/r-help/2010-August/250839.html) For more information type stats:::logLik.nls to see for how the log-likelihood is calculated for nls fitted models as a function of their residuals and their associated weights. (Effectively it is just a Gaussian log-likelihood of the weighted residuals.)
Is AIC appropriate for comparing non linear models?
Yes, AIC (or AICc) are still "generally appropriate". We make the assumption of a Gaussian error (see below). Avoid computing AIC manually if both models are of the same type, that said: Comparing acr
Is AIC appropriate for comparing non linear models? Yes, AIC (or AICc) are still "generally appropriate". We make the assumption of a Gaussian error (see below). Avoid computing AIC manually if both models are of the same type, that said: Comparing across model types requires attention to detail to make sure that parameters are counted using similar rules, and that additive constants are consistently included or not. (from: https://stat.ethz.ch/pipermail/r-help/2010-August/250839.html) For more information type stats:::logLik.nls to see for how the log-likelihood is calculated for nls fitted models as a function of their residuals and their associated weights. (Effectively it is just a Gaussian log-likelihood of the weighted residuals.)
Is AIC appropriate for comparing non linear models? Yes, AIC (or AICc) are still "generally appropriate". We make the assumption of a Gaussian error (see below). Avoid computing AIC manually if both models are of the same type, that said: Comparing acr
37,040
Understanding Bayesian Bootstrap theory
The $(K-1)$-variate Dirichlet distribution: What Rubin means here is that the Dirichlet distribution is giving a random probability vector $\boldsymbol{\pi} = (\pi_1,...,\pi_K)$ with $K$ elements, so only $K-1$ of these elements are "free variables". Since the probability values must sum to one you have the binding equation $\pi_K = 1-\sum_{k=1}^{K-1} \pi_k$ on the last element. It is therefore a matter of convention/framing whether you include this last element as part of the argument of the distribution or exclude it and treat it as a separate equation for a value outside the distribution argument. Rubin is using the convention of regarding this element to be excluded from the argument, and so he refers to this as the "$K-1$-variate" version of the distribution; that is the number of free variables in the argument of the density. It is worth noting here that there is some variation in how statisticians and other analysts refer to the Dirichlet distribution, often depending on context. Sometimes we find it easier to include the final element in the argument and think of this as the $K$-variate case; we then consider the distribution to have an equation constraint on its argument values. Alernatively, sometimes we prefer to exclude the final element from the argument and think of this as a $(K-1)$-variate case; we then consider the distribution to have an inequality constraint on its argument values. This is summarised in the two approaches below: $$\begin{matrix} \text{Approach} & & \text{Argument} & & \text{Constraints/Definitions} \\[6pt] (K-1) \text{-variate} & & \ \boldsymbol{\pi}_* \equiv (\pi_1,...,\pi_{K-1}) & & \sum_{k=1}^{K-1} \pi_k \leqslant 1, \pi_K \equiv 1-\sum_{k=1}^{K-1} \pi_k, \\[6pt] K \text{-variate} & & \boldsymbol{\pi} \equiv (\pi_1,...,\pi_K) & & \sum_{k=1}^{K} \pi_k = 1 . \\[6pt] \end{matrix}$$ The main advantage of the first approach is that the beta distribution corresponds to the univariate case, which is a fairly natural way to look at it. If we use the second approach then even modelling the distribution of a single probability must be expressed by the pair $(\pi,1-\pi)$, and this is less parsimonious than is desirable. So, Rubin is calling this the $(K-1)$-variate version of the distribution because he is looking at the number of free parameters in the argument. In any case, don't let this issue confuse you --- regardless of what he calls it, Rubin gives an explicit formula for the density kernel, which is enough to understand the problem without ambiguity. In fact, in the present context, it is simpler to frame the distribution with all $K$ probability values in the argument of the density function. This would give the explicit density kernel: $$\text{Dirichlet}(\boldsymbol{\pi}|\mathbf{n}+\mathbf{l}+1) \propto \mathbb{I}(\boldsymbol{\pi} \in \boldsymbol{\Pi}_K) \prod_{k=1}^K \pi_k^{n_k + l_k},$$ where $\boldsymbol{\Pi}_K \equiv \{ \boldsymbol{\pi} \in \mathbb{R}^K | \sum_k \pi_k = 1, \pi_k \geqslant 0 \}$ is the space of all possible probability vectors of length $K$ (i.e., the probability simplex). Generating the Dirichlet distribution using uniform random variables: To assist you to understand this part, I will set out the method Rubin is describing using some explicit formulae that he only describes in words. This is a method that is used to generate Dirichlet random vectors from an underlying set of IID uniform random variables in the special case when the parameter of the Dirichlet distribution is a vector of integers. You start by generating $u_1,...,u_{m-1} \sim \text{IID U}(0,1)$ and then you form the 'gaps' $g_1,...,g_m$ defined by: $$g_k \equiv u_k-u_{k-1} \quad \quad \quad (u_0 \equiv 0, u_m \equiv 1).$$ Before proceeding, note here that we have $K$ gap values and these must sum to one ---i.e., we have $\sum_i g_i = 1$. Rubin then describes the idea that you partition the gap values so that there are $n_k+l_k+1$ values in the $k$th partition piece. He does not mention any further restriction on the partition, so presumably any partition that meets this criterion is acceptable. (The partition you mention, grouping adjacent gaps together, would be a legitimate partition that meets the requirement, but not the only one.) Let's follow Rubin's description but put it in explicit terms. The easiest way to do this is to denote the partition of the indices $1,...,m$ by the $\mathscr{P} = \{ \mathcal{P}_1,...,\mathcal{P}_K \}$. Note that each partition set $\mathcal{P}_k$ has $n_k+l_k+1$ elements in it (and is disjoint from the other partition sets since this is a partition). We can then write the resulting sum quantities as: $$P_k \equiv \sum_{i \in \mathcal{P}_k} g_i \quad \quad \quad \text{for } k = 1,...,K.$$ Note here that these are sums of gap values (not the initial uniform random variables) taken over the partition sets. So in answer to your question on this part, yes, these are sums of the lengths of the gaps. Now, recall from our above definitions that we must have $\sum g_i = 1$. Rubin asserts that the random vector we have formed has the required Dirichlet distribution: $$(P_1,...,P_K) \sim \text{Dirichlet}(\mathbf{n}+\mathbf{l}).$$ I note your confusion that we have $n$ data points and $m$ gaps, but we get a result for $K$ elements here. Remember that we are here forming the posterior distribution, which is for a random vector with $K$ elements. The $n$ data points only come into this as part of the Dirichlet parameter, and has no further relevance. As to the $m$ gaps, these were formed initially to correspond with the sum of the elements of the Dirichlet parameter, but we then summed the gaps to get a final vector with $K$ elements. In terms of where this result comes from, I don't have a reference on hand, but it is an extension of an older method for generating uniform random vectors on a probability simplex. The present method extends that older result by allowing you to generate random vectors on the probability simplex that follow a Dirichlet distribution with integer parameters. If you look up literature on the Dirichlet distribution then I'm sure you will be able to find some references that trace this method back to its original literature. Special case: Rubin makes some observations on simulation of the "improper" Dirichlet prior. What he is saying here is that if you set $\mathbf{n} = \mathbf{l} = \mathbf{0}$ then you end up generating $m=K$ uniform values in this method. Substituting $\mathbf{n} = \mathbf{l} = \mathbf{0}$ you will see that this particular case corresponds with simulating a probability vector from the improper Dirichlet distribution: $$(P_1,...,P_K) \sim \text{Dirichlet}(\mathbf{0}) \propto \mathbb{I}(\boldsymbol{\pi} \in \boldsymbol{\Pi}_K) \prod_{k=1}^K \pi_k^{-1}.$$ This is one particular case that can be simulated with the method, but Rubin notes that you can simulate any Dirichlet distribution with integer parameters. (I am not certain what he means when he refers to the requirement to specify all possible a priori values of the data. Perhaps he means that it is desirable to generate an algorithm for this method that allows any valid data input.) Your remaining questions concern the merits of using different types of Dirichlet distributions (e.g., the improper version versus the uniform version, etc.). There is no sacrosanct answer here except to note that context and theory will determine what is the appropriate parameter to use. In Bayesian analysis it is common to use a "non-informative" prior which sets $\mathbf{l} = \mathbf{1}$ to give a uniform prior over the set of all possible probability vectors. There are other suggestions for alternative priors, such as Jeffrey's prior (but note that this does not use integer parameters so it is not amenable to the present method). You are correct that it is usually considered "more sensible" to use the flat Dirichlet prior than the improper prior. (Although I should hedge this by saying that this is judgment usually made by "objective" Bayesians; subjective Bayesians would say it is arbitrary what prior you use.) You also ask about the considerations when using a flat prior. The main advantages of this prior are that it falls within the conjugate form (i.e., it is a Dirichlet distribution) and it also has a plausible claim to being "non-informative" in a fairly intuitive sense. Remember that Bayesian analysis has well-established theorems relating to posterior consistency, and broadly speaking, these theorems say that different priors still lead to convergence of posterior beliefs (under very weak conditions) as we get more and more data. For this reason, agonising over small differences in the prior is arguably a kind of statistician navel-gazing; that effort is much better spent trying to get more data.
Understanding Bayesian Bootstrap theory
The $(K-1)$-variate Dirichlet distribution: What Rubin means here is that the Dirichlet distribution is giving a random probability vector $\boldsymbol{\pi} = (\pi_1,...,\pi_K)$ with $K$ elements, so
Understanding Bayesian Bootstrap theory The $(K-1)$-variate Dirichlet distribution: What Rubin means here is that the Dirichlet distribution is giving a random probability vector $\boldsymbol{\pi} = (\pi_1,...,\pi_K)$ with $K$ elements, so only $K-1$ of these elements are "free variables". Since the probability values must sum to one you have the binding equation $\pi_K = 1-\sum_{k=1}^{K-1} \pi_k$ on the last element. It is therefore a matter of convention/framing whether you include this last element as part of the argument of the distribution or exclude it and treat it as a separate equation for a value outside the distribution argument. Rubin is using the convention of regarding this element to be excluded from the argument, and so he refers to this as the "$K-1$-variate" version of the distribution; that is the number of free variables in the argument of the density. It is worth noting here that there is some variation in how statisticians and other analysts refer to the Dirichlet distribution, often depending on context. Sometimes we find it easier to include the final element in the argument and think of this as the $K$-variate case; we then consider the distribution to have an equation constraint on its argument values. Alernatively, sometimes we prefer to exclude the final element from the argument and think of this as a $(K-1)$-variate case; we then consider the distribution to have an inequality constraint on its argument values. This is summarised in the two approaches below: $$\begin{matrix} \text{Approach} & & \text{Argument} & & \text{Constraints/Definitions} \\[6pt] (K-1) \text{-variate} & & \ \boldsymbol{\pi}_* \equiv (\pi_1,...,\pi_{K-1}) & & \sum_{k=1}^{K-1} \pi_k \leqslant 1, \pi_K \equiv 1-\sum_{k=1}^{K-1} \pi_k, \\[6pt] K \text{-variate} & & \boldsymbol{\pi} \equiv (\pi_1,...,\pi_K) & & \sum_{k=1}^{K} \pi_k = 1 . \\[6pt] \end{matrix}$$ The main advantage of the first approach is that the beta distribution corresponds to the univariate case, which is a fairly natural way to look at it. If we use the second approach then even modelling the distribution of a single probability must be expressed by the pair $(\pi,1-\pi)$, and this is less parsimonious than is desirable. So, Rubin is calling this the $(K-1)$-variate version of the distribution because he is looking at the number of free parameters in the argument. In any case, don't let this issue confuse you --- regardless of what he calls it, Rubin gives an explicit formula for the density kernel, which is enough to understand the problem without ambiguity. In fact, in the present context, it is simpler to frame the distribution with all $K$ probability values in the argument of the density function. This would give the explicit density kernel: $$\text{Dirichlet}(\boldsymbol{\pi}|\mathbf{n}+\mathbf{l}+1) \propto \mathbb{I}(\boldsymbol{\pi} \in \boldsymbol{\Pi}_K) \prod_{k=1}^K \pi_k^{n_k + l_k},$$ where $\boldsymbol{\Pi}_K \equiv \{ \boldsymbol{\pi} \in \mathbb{R}^K | \sum_k \pi_k = 1, \pi_k \geqslant 0 \}$ is the space of all possible probability vectors of length $K$ (i.e., the probability simplex). Generating the Dirichlet distribution using uniform random variables: To assist you to understand this part, I will set out the method Rubin is describing using some explicit formulae that he only describes in words. This is a method that is used to generate Dirichlet random vectors from an underlying set of IID uniform random variables in the special case when the parameter of the Dirichlet distribution is a vector of integers. You start by generating $u_1,...,u_{m-1} \sim \text{IID U}(0,1)$ and then you form the 'gaps' $g_1,...,g_m$ defined by: $$g_k \equiv u_k-u_{k-1} \quad \quad \quad (u_0 \equiv 0, u_m \equiv 1).$$ Before proceeding, note here that we have $K$ gap values and these must sum to one ---i.e., we have $\sum_i g_i = 1$. Rubin then describes the idea that you partition the gap values so that there are $n_k+l_k+1$ values in the $k$th partition piece. He does not mention any further restriction on the partition, so presumably any partition that meets this criterion is acceptable. (The partition you mention, grouping adjacent gaps together, would be a legitimate partition that meets the requirement, but not the only one.) Let's follow Rubin's description but put it in explicit terms. The easiest way to do this is to denote the partition of the indices $1,...,m$ by the $\mathscr{P} = \{ \mathcal{P}_1,...,\mathcal{P}_K \}$. Note that each partition set $\mathcal{P}_k$ has $n_k+l_k+1$ elements in it (and is disjoint from the other partition sets since this is a partition). We can then write the resulting sum quantities as: $$P_k \equiv \sum_{i \in \mathcal{P}_k} g_i \quad \quad \quad \text{for } k = 1,...,K.$$ Note here that these are sums of gap values (not the initial uniform random variables) taken over the partition sets. So in answer to your question on this part, yes, these are sums of the lengths of the gaps. Now, recall from our above definitions that we must have $\sum g_i = 1$. Rubin asserts that the random vector we have formed has the required Dirichlet distribution: $$(P_1,...,P_K) \sim \text{Dirichlet}(\mathbf{n}+\mathbf{l}).$$ I note your confusion that we have $n$ data points and $m$ gaps, but we get a result for $K$ elements here. Remember that we are here forming the posterior distribution, which is for a random vector with $K$ elements. The $n$ data points only come into this as part of the Dirichlet parameter, and has no further relevance. As to the $m$ gaps, these were formed initially to correspond with the sum of the elements of the Dirichlet parameter, but we then summed the gaps to get a final vector with $K$ elements. In terms of where this result comes from, I don't have a reference on hand, but it is an extension of an older method for generating uniform random vectors on a probability simplex. The present method extends that older result by allowing you to generate random vectors on the probability simplex that follow a Dirichlet distribution with integer parameters. If you look up literature on the Dirichlet distribution then I'm sure you will be able to find some references that trace this method back to its original literature. Special case: Rubin makes some observations on simulation of the "improper" Dirichlet prior. What he is saying here is that if you set $\mathbf{n} = \mathbf{l} = \mathbf{0}$ then you end up generating $m=K$ uniform values in this method. Substituting $\mathbf{n} = \mathbf{l} = \mathbf{0}$ you will see that this particular case corresponds with simulating a probability vector from the improper Dirichlet distribution: $$(P_1,...,P_K) \sim \text{Dirichlet}(\mathbf{0}) \propto \mathbb{I}(\boldsymbol{\pi} \in \boldsymbol{\Pi}_K) \prod_{k=1}^K \pi_k^{-1}.$$ This is one particular case that can be simulated with the method, but Rubin notes that you can simulate any Dirichlet distribution with integer parameters. (I am not certain what he means when he refers to the requirement to specify all possible a priori values of the data. Perhaps he means that it is desirable to generate an algorithm for this method that allows any valid data input.) Your remaining questions concern the merits of using different types of Dirichlet distributions (e.g., the improper version versus the uniform version, etc.). There is no sacrosanct answer here except to note that context and theory will determine what is the appropriate parameter to use. In Bayesian analysis it is common to use a "non-informative" prior which sets $\mathbf{l} = \mathbf{1}$ to give a uniform prior over the set of all possible probability vectors. There are other suggestions for alternative priors, such as Jeffrey's prior (but note that this does not use integer parameters so it is not amenable to the present method). You are correct that it is usually considered "more sensible" to use the flat Dirichlet prior than the improper prior. (Although I should hedge this by saying that this is judgment usually made by "objective" Bayesians; subjective Bayesians would say it is arbitrary what prior you use.) You also ask about the considerations when using a flat prior. The main advantages of this prior are that it falls within the conjugate form (i.e., it is a Dirichlet distribution) and it also has a plausible claim to being "non-informative" in a fairly intuitive sense. Remember that Bayesian analysis has well-established theorems relating to posterior consistency, and broadly speaking, these theorems say that different priors still lead to convergence of posterior beliefs (under very weak conditions) as we get more and more data. For this reason, agonising over small differences in the prior is arguably a kind of statistician navel-gazing; that effort is much better spent trying to get more data.
Understanding Bayesian Bootstrap theory The $(K-1)$-variate Dirichlet distribution: What Rubin means here is that the Dirichlet distribution is giving a random probability vector $\boldsymbol{\pi} = (\pi_1,...,\pi_K)$ with $K$ elements, so
37,041
Conditional distribution of multivariate normal distribution
It looks like you're on the right track, but you're working way too hard on this one. Sooner or later algebraic and numerical mistakes will creep into even the best calculations. A good strategy is to minimize the amount calculation: the Principle of Mathematical Laziness. A key element of this principle is just-in-time computation: don't do any work until you have to. The following solution illustrates these ideas. You have seen the virtue of changing variables. Keeping $X$ (whose conditional distribution we wish to compute), let the two new variables be $$U = Y+Z,\ V = X+Z.$$ Consequently, looking ahead to the next step, note that the original variables can be expressed as $$Y = U-V+X,\ Z=V-X.$$ You also recognized the need to compute the Jacobian of this transformation. Using the method I have described at https://stats.stackexchange.com/a/154298/919 this is almost trivial: $$\left|\mathrm{d}x\,\mathrm{d}y\,\mathrm{d}z\right| = \left|\mathrm{d}x\wedge \mathrm{d}(u-v+x)\wedge \mathrm{d}(v-x)\right| = \left|\mathrm{d}x\, \mathrm{d}u\, \mathrm{d}v\right|.$$ This leaves only the argument of the exponential, into which we need to substitute $$y = u-v+x,\ z = v-x$$ and then set $u=0$ and $v=1.$ Focusing on the argument of the exponential (and ignoring the necessary division by $2$), this can be performed by visual inspection of the coefficients of $x$ and $x^2$ and then, as always with Normal distributions, completing the square: $$\begin{aligned} 4x^{2}&+3y^{2}+5z^{2}+2xy+6xz+4zy\\ &= 4x^2 + 3(u-v+x)^2 + \cdots + 4(v-x)(u-v+x)\\ &= (4+3+5+2-6-4)x^2 \\&+ (0-6-10-2+6+8)x \\&+ \text{constants}\\ &= 4x^2 - 4x + \text{constants} \\ &= \frac{(x-1/2)^2}{(1/2)^2}+\text{some constant}. \end{aligned}$$ We know the conditional distribution will be Normal with some mean $\mu$ and some standard deviation $\sigma$, which means this quadratic part will take the form $(x-\mu)^2/\sigma^2$ plus some constant. Comparing with the foregoing, you can read off the values $\mu=1/2$ and $\sigma=1/2.$ You will, of course, wish to check this work: but I hope you find this to be much less effort than checking your original calculations.
Conditional distribution of multivariate normal distribution
It looks like you're on the right track, but you're working way too hard on this one. Sooner or later algebraic and numerical mistakes will creep into even the best calculations. A good strategy is
Conditional distribution of multivariate normal distribution It looks like you're on the right track, but you're working way too hard on this one. Sooner or later algebraic and numerical mistakes will creep into even the best calculations. A good strategy is to minimize the amount calculation: the Principle of Mathematical Laziness. A key element of this principle is just-in-time computation: don't do any work until you have to. The following solution illustrates these ideas. You have seen the virtue of changing variables. Keeping $X$ (whose conditional distribution we wish to compute), let the two new variables be $$U = Y+Z,\ V = X+Z.$$ Consequently, looking ahead to the next step, note that the original variables can be expressed as $$Y = U-V+X,\ Z=V-X.$$ You also recognized the need to compute the Jacobian of this transformation. Using the method I have described at https://stats.stackexchange.com/a/154298/919 this is almost trivial: $$\left|\mathrm{d}x\,\mathrm{d}y\,\mathrm{d}z\right| = \left|\mathrm{d}x\wedge \mathrm{d}(u-v+x)\wedge \mathrm{d}(v-x)\right| = \left|\mathrm{d}x\, \mathrm{d}u\, \mathrm{d}v\right|.$$ This leaves only the argument of the exponential, into which we need to substitute $$y = u-v+x,\ z = v-x$$ and then set $u=0$ and $v=1.$ Focusing on the argument of the exponential (and ignoring the necessary division by $2$), this can be performed by visual inspection of the coefficients of $x$ and $x^2$ and then, as always with Normal distributions, completing the square: $$\begin{aligned} 4x^{2}&+3y^{2}+5z^{2}+2xy+6xz+4zy\\ &= 4x^2 + 3(u-v+x)^2 + \cdots + 4(v-x)(u-v+x)\\ &= (4+3+5+2-6-4)x^2 \\&+ (0-6-10-2+6+8)x \\&+ \text{constants}\\ &= 4x^2 - 4x + \text{constants} \\ &= \frac{(x-1/2)^2}{(1/2)^2}+\text{some constant}. \end{aligned}$$ We know the conditional distribution will be Normal with some mean $\mu$ and some standard deviation $\sigma$, which means this quadratic part will take the form $(x-\mu)^2/\sigma^2$ plus some constant. Comparing with the foregoing, you can read off the values $\mu=1/2$ and $\sigma=1/2.$ You will, of course, wish to check this work: but I hope you find this to be much less effort than checking your original calculations.
Conditional distribution of multivariate normal distribution It looks like you're on the right track, but you're working way too hard on this one. Sooner or later algebraic and numerical mistakes will creep into even the best calculations. A good strategy is
37,042
Correct way to combine 95% confidence interval bounds returned by a fitting routine with several measurements?
I imagine the 95% confidence intervals come from some assumptions on normality of data. Otherwise, please state how you got these CI. This implies you believe the mean of each slope (viewed as a RV) is $m_i$ with some variance $\sigma_i$ In this case you can average the slopes as you did and get the new variance of the averaged estimator (assuming independent errors). From said variance you can get 95% CI (using 1.96 standard deviations). So, to summarize (assuming $m_i$ are independent is crucial): Let $m := \frac{ \sum_{i=1}^N m_i \sigma_i^{-2}}{\sum_{i=1}^N \sigma_i^{-2}}$ Let $\sigma^2 := Var(m) = Var(\frac{ \sum_{i=1}^N m_i \sigma_i^{-2}}{\sum_{i=1}^N \sigma_i^{-2}}) = (\frac{1}{\sum_{i=1}^N \sigma_i^{-2}})^2 \sum_{i=1}^N \sigma^{-4}Var(m_i) = \frac{1}{\sum_{i=1}^N \sigma_i^{-2}}$. Note that this is the harmonic mean! Finally you see it in the wild after learning that inequality in your first calculus class!! A 95% CI for the true value of the slope is $[m- 1.96\sigma, m+ 1.96\sigma]$ (see 1.96)
Correct way to combine 95% confidence interval bounds returned by a fitting routine with several mea
I imagine the 95% confidence intervals come from some assumptions on normality of data. Otherwise, please state how you got these CI. This implies you believe the mean of each slope (viewed as a RV) i
Correct way to combine 95% confidence interval bounds returned by a fitting routine with several measurements? I imagine the 95% confidence intervals come from some assumptions on normality of data. Otherwise, please state how you got these CI. This implies you believe the mean of each slope (viewed as a RV) is $m_i$ with some variance $\sigma_i$ In this case you can average the slopes as you did and get the new variance of the averaged estimator (assuming independent errors). From said variance you can get 95% CI (using 1.96 standard deviations). So, to summarize (assuming $m_i$ are independent is crucial): Let $m := \frac{ \sum_{i=1}^N m_i \sigma_i^{-2}}{\sum_{i=1}^N \sigma_i^{-2}}$ Let $\sigma^2 := Var(m) = Var(\frac{ \sum_{i=1}^N m_i \sigma_i^{-2}}{\sum_{i=1}^N \sigma_i^{-2}}) = (\frac{1}{\sum_{i=1}^N \sigma_i^{-2}})^2 \sum_{i=1}^N \sigma^{-4}Var(m_i) = \frac{1}{\sum_{i=1}^N \sigma_i^{-2}}$. Note that this is the harmonic mean! Finally you see it in the wild after learning that inequality in your first calculus class!! A 95% CI for the true value of the slope is $[m- 1.96\sigma, m+ 1.96\sigma]$ (see 1.96)
Correct way to combine 95% confidence interval bounds returned by a fitting routine with several mea I imagine the 95% confidence intervals come from some assumptions on normality of data. Otherwise, please state how you got these CI. This implies you believe the mean of each slope (viewed as a RV) i
37,043
Correct way to combine 95% confidence interval bounds returned by a fitting routine with several measurements?
I don't have much to offer in terms of methods, I think the ones presented here (esp inverse variance weighted approaches) are good ones. What I can add is a small simulation study to prove that under the assumption of Gaussian errors in the regression, this process has good enough coverage set.seed(0) library(tidyverse) simulate_data<-function(n){ x = rnorm(n) y = 2*x + 1 + rnorm(n, 0, 0.5) model = lm(y~x) results = tibble(beta = coef(model)['x'], w = 1/vcov(model)['x','x']) } simulate_procedure<-function(iter){ n = rnbinom(3,200,0.9) results = map_dfr(n, simulate_data) m = sum(results$beta*results$w)/sum(results$w) sig = sqrt(1/sum(results$w)) interval = tibble(lower = m - 1.96*sig, est = m, upper = m + 1.96*sig) interval } map_dfr(1:10000, simulate_procedure, .id = 'iter') %>% mutate(contains = (2<upper)&(2>lower)) %>% summarise(mean(contains)) >>>0.922 So what does this mean? It means that were I to repeat this procedure to construct a 95% interval for the slope, the resulting interval would capture the true slope (here 2) only 92% of the time. So barring I didn't make a mistake (entirely possible) that seems to be good enough. How should the estimate of the slope be reported, including errors? Let's imagine I only have access to these values (and not the underlying data that was used for fitting to obtain these slopes). So I would compute $m$ and $\sigma^2$ as mentioned by Yair Daon. You don't need to access the data in order to do these. In your example, the $m$ would be 5.5, 5.5, 5.2. The variances are found by doing a little algebra on the confidence interval. Remember, confidence intervals look like $$m \pm 1.96 se $$ Here, $se$ is the standard error (or the standard deviation of the sampling distribution). You can find the variance by taking the difference between interval endpoints and then dividing by $3.92 = 2\times 1.96$. Your sigmas (not squared) would then be 0.306, 0.102, 0.357. So your best estimate for $m$ from the example you've provided is 5.47, with an accompanying interval of 5.29 to 5.66. These were computed using the formulae provided by Yair.
Correct way to combine 95% confidence interval bounds returned by a fitting routine with several mea
I don't have much to offer in terms of methods, I think the ones presented here (esp inverse variance weighted approaches) are good ones. What I can add is a small simulation study to prove that unde
Correct way to combine 95% confidence interval bounds returned by a fitting routine with several measurements? I don't have much to offer in terms of methods, I think the ones presented here (esp inverse variance weighted approaches) are good ones. What I can add is a small simulation study to prove that under the assumption of Gaussian errors in the regression, this process has good enough coverage set.seed(0) library(tidyverse) simulate_data<-function(n){ x = rnorm(n) y = 2*x + 1 + rnorm(n, 0, 0.5) model = lm(y~x) results = tibble(beta = coef(model)['x'], w = 1/vcov(model)['x','x']) } simulate_procedure<-function(iter){ n = rnbinom(3,200,0.9) results = map_dfr(n, simulate_data) m = sum(results$beta*results$w)/sum(results$w) sig = sqrt(1/sum(results$w)) interval = tibble(lower = m - 1.96*sig, est = m, upper = m + 1.96*sig) interval } map_dfr(1:10000, simulate_procedure, .id = 'iter') %>% mutate(contains = (2<upper)&(2>lower)) %>% summarise(mean(contains)) >>>0.922 So what does this mean? It means that were I to repeat this procedure to construct a 95% interval for the slope, the resulting interval would capture the true slope (here 2) only 92% of the time. So barring I didn't make a mistake (entirely possible) that seems to be good enough. How should the estimate of the slope be reported, including errors? Let's imagine I only have access to these values (and not the underlying data that was used for fitting to obtain these slopes). So I would compute $m$ and $\sigma^2$ as mentioned by Yair Daon. You don't need to access the data in order to do these. In your example, the $m$ would be 5.5, 5.5, 5.2. The variances are found by doing a little algebra on the confidence interval. Remember, confidence intervals look like $$m \pm 1.96 se $$ Here, $se$ is the standard error (or the standard deviation of the sampling distribution). You can find the variance by taking the difference between interval endpoints and then dividing by $3.92 = 2\times 1.96$. Your sigmas (not squared) would then be 0.306, 0.102, 0.357. So your best estimate for $m$ from the example you've provided is 5.47, with an accompanying interval of 5.29 to 5.66. These were computed using the formulae provided by Yair.
Correct way to combine 95% confidence interval bounds returned by a fitting routine with several mea I don't have much to offer in terms of methods, I think the ones presented here (esp inverse variance weighted approaches) are good ones. What I can add is a small simulation study to prove that unde
37,044
Causality: Models, Reasoning and Inference, by Judea Pearl: Causal Bayesian Networks and the Truncated Factorization
$\newcommand{\doop}{\operatorname{do}}\newcommand{\op}[1]{\operatorname{#1}}$ I think your proof of the forward implication is correct. For the backward implication I may have something. Suppose the Truncated Factorization: for all $v$ consistent with $x$, $$P(v\mid \mathrm{do}(x))=\prod_{i\mid Vi\notin X}P(v_i \mid \mathrm{pa}_i)$$ for a non cyclic oriented graph $G$. Proof that condition 3 is verified Let be $i$, $v_i$, and an intervention $X = x$ be such that $V_i \notin X$ and a realization of $\mathrm{pa}_i$ is compatible with $X = x$. We need to prove that: $$P(v_i|\mathrm{pa}_i, \mathrm{do}(x)) = P(v_i |\mathrm{pa}_i).$$ To do so, let's take an intervention $X' = x'$ such that: $X \subset X'.$ $X = x$ and $X' = x'$ are compatible. $V_i \notin X'$ and $\forall j\neq i, V_j\in X'.$ The realization of $\mathrm{pa_i}$ considered is compatible with $X'.$ Intuitively, we are fixing everything but $V_i$ by an intervention, without contradicting the intervention $X = x$ nor the considered realization of $\mathrm{pa}_i$. Then, using the factorization, $$P(v|\mathrm{do}(x')) = P(v_i| \mathrm{pa}_i)$$ since only index $i$ is left in the product, and thus $$P(v|\mathrm{do}(x'), \mathrm{do}(x)) = P(v_i|\mathrm{pa}_i, \mathrm{do}(x)).$$ But as $X = x$ is included in $X' = x'$, $P(v|\mathrm{do}(x'), \mathrm{do}(x)) = P(v|\mathrm{do}(x'))$. So we have that: $$P(v_i|\mathrm{pa}_i, \mathrm{do}(x)) = P(v_i|\mathrm{pa}_i),$$ which is what we wanted. Proof that condition 1 is verified If we use the truncated factorization on a null intervention, we obtain that $G$ and $P$ are Markov compatible: $$P(v) = \prod_i P(v_i|\mathrm{pa}_i).$$ Conditioning the last equation on an intervention $X = x$, we get that $$P(v|\mathrm{do}(x)) = \prod_i P(v_i|\mathrm{pa}_i, \mathrm{do}(x)),$$ which is that $P(v|\mathrm{do}(x))$ and $G$ are Markov compatible. Proof that condition 2 is verified Let's consider an intervention $X =x$. Using condition 1, we have: \begin{align*} P(v|\doop(x)) &=\prod_i P(v_i|\op{pa}_i, \doop(x))\\ &=\prod_{i|V_i\in X}P(v_i|\op{pa}_i,\doop(x))\cdot\prod_{i|V_i\not\in X}P(v_i|\op{pa}_i,\doop(x))\\ &=\prod_{i|V_i\in X}P(v_i|\op{pa}_i,\doop(x))\cdot\prod_{i|V_i\not\in X}P(v_i|\op{pa}_i), \end{align*} using condition 3. As $P(v|\mathrm{do}(x))$ can also be expressed with the truncated factorization, we get that: $$\prod_{i|V_i \notin X}P(v_i|\mathrm{pa}_i) = \prod_{i|V_i \in X}P(v_i|\mathrm{pa}_i, \mathrm{do}(x))\prod_{i|V_i \notin X}P(v_i| \mathrm{pa}_i)$$ and so, simplifying by dividing out $P(v_i|\mathrm{pa}_i)$: $$ \prod_{i|V_i \in X}P(v_i|\mathrm{pa}_i) = 1 .$$ (To be allowed to make this simplification, we need to suppose that $P(v_i|\mathrm{pa}_i) \neq 0$, which is necessarily the case if we suppose $P(v|\mathrm{do}(x)) \neq 0$ for instance.) In the end we have that $P(v_i|\mathrm{pa}_i, \mathrm{do}(x)) = 1$ for all $i$ such that $i \in X$ (since their product is $1$). To get to condition 2, write $$P(v_i|\mathrm{do}(x)) = \mathbb{E}_{\mathrm{pa}_i}\left[P(v_i| \mathrm{pa}_i, \mathrm{do}(x))\right] = \mathbb{E}_{\mathrm{pa}_i}\left[1\right] = 1.$$ I hope this is understandable, correct and helping..
Causality: Models, Reasoning and Inference, by Judea Pearl: Causal Bayesian Networks and the Truncat
$\newcommand{\doop}{\operatorname{do}}\newcommand{\op}[1]{\operatorname{#1}}$ I think your proof of the forward implication is correct. For the backward implication I may have something. Suppose the T
Causality: Models, Reasoning and Inference, by Judea Pearl: Causal Bayesian Networks and the Truncated Factorization $\newcommand{\doop}{\operatorname{do}}\newcommand{\op}[1]{\operatorname{#1}}$ I think your proof of the forward implication is correct. For the backward implication I may have something. Suppose the Truncated Factorization: for all $v$ consistent with $x$, $$P(v\mid \mathrm{do}(x))=\prod_{i\mid Vi\notin X}P(v_i \mid \mathrm{pa}_i)$$ for a non cyclic oriented graph $G$. Proof that condition 3 is verified Let be $i$, $v_i$, and an intervention $X = x$ be such that $V_i \notin X$ and a realization of $\mathrm{pa}_i$ is compatible with $X = x$. We need to prove that: $$P(v_i|\mathrm{pa}_i, \mathrm{do}(x)) = P(v_i |\mathrm{pa}_i).$$ To do so, let's take an intervention $X' = x'$ such that: $X \subset X'.$ $X = x$ and $X' = x'$ are compatible. $V_i \notin X'$ and $\forall j\neq i, V_j\in X'.$ The realization of $\mathrm{pa_i}$ considered is compatible with $X'.$ Intuitively, we are fixing everything but $V_i$ by an intervention, without contradicting the intervention $X = x$ nor the considered realization of $\mathrm{pa}_i$. Then, using the factorization, $$P(v|\mathrm{do}(x')) = P(v_i| \mathrm{pa}_i)$$ since only index $i$ is left in the product, and thus $$P(v|\mathrm{do}(x'), \mathrm{do}(x)) = P(v_i|\mathrm{pa}_i, \mathrm{do}(x)).$$ But as $X = x$ is included in $X' = x'$, $P(v|\mathrm{do}(x'), \mathrm{do}(x)) = P(v|\mathrm{do}(x'))$. So we have that: $$P(v_i|\mathrm{pa}_i, \mathrm{do}(x)) = P(v_i|\mathrm{pa}_i),$$ which is what we wanted. Proof that condition 1 is verified If we use the truncated factorization on a null intervention, we obtain that $G$ and $P$ are Markov compatible: $$P(v) = \prod_i P(v_i|\mathrm{pa}_i).$$ Conditioning the last equation on an intervention $X = x$, we get that $$P(v|\mathrm{do}(x)) = \prod_i P(v_i|\mathrm{pa}_i, \mathrm{do}(x)),$$ which is that $P(v|\mathrm{do}(x))$ and $G$ are Markov compatible. Proof that condition 2 is verified Let's consider an intervention $X =x$. Using condition 1, we have: \begin{align*} P(v|\doop(x)) &=\prod_i P(v_i|\op{pa}_i, \doop(x))\\ &=\prod_{i|V_i\in X}P(v_i|\op{pa}_i,\doop(x))\cdot\prod_{i|V_i\not\in X}P(v_i|\op{pa}_i,\doop(x))\\ &=\prod_{i|V_i\in X}P(v_i|\op{pa}_i,\doop(x))\cdot\prod_{i|V_i\not\in X}P(v_i|\op{pa}_i), \end{align*} using condition 3. As $P(v|\mathrm{do}(x))$ can also be expressed with the truncated factorization, we get that: $$\prod_{i|V_i \notin X}P(v_i|\mathrm{pa}_i) = \prod_{i|V_i \in X}P(v_i|\mathrm{pa}_i, \mathrm{do}(x))\prod_{i|V_i \notin X}P(v_i| \mathrm{pa}_i)$$ and so, simplifying by dividing out $P(v_i|\mathrm{pa}_i)$: $$ \prod_{i|V_i \in X}P(v_i|\mathrm{pa}_i) = 1 .$$ (To be allowed to make this simplification, we need to suppose that $P(v_i|\mathrm{pa}_i) \neq 0$, which is necessarily the case if we suppose $P(v|\mathrm{do}(x)) \neq 0$ for instance.) In the end we have that $P(v_i|\mathrm{pa}_i, \mathrm{do}(x)) = 1$ for all $i$ such that $i \in X$ (since their product is $1$). To get to condition 2, write $$P(v_i|\mathrm{do}(x)) = \mathbb{E}_{\mathrm{pa}_i}\left[P(v_i| \mathrm{pa}_i, \mathrm{do}(x))\right] = \mathbb{E}_{\mathrm{pa}_i}\left[1\right] = 1.$$ I hope this is understandable, correct and helping..
Causality: Models, Reasoning and Inference, by Judea Pearl: Causal Bayesian Networks and the Truncat $\newcommand{\doop}{\operatorname{do}}\newcommand{\op}[1]{\operatorname{#1}}$ I think your proof of the forward implication is correct. For the backward implication I may have something. Suppose the T
37,045
Structure of Generative Adversarial Networks (GAN) for mapping a simulation model
So you want to learn a dynamics model of some system, and to improve the robustness of the model, you want to sample a wide range of inputs from a GAN. While it's certainly possible to learn a dynamics model, I don't think it's a good idea to generate inputs exclusively with a GAN -- indeed, GANs are known for mode dropping and mode collapse, exactly what you don't want. I would advise using VAEs if you want to go down this path, since they're not as vulnerable to this problem. There is a large body of work which generates synthetic data (for example, computer renderings of 3D scenes), and then uses conditional GANs to improve the photorealism of the renderings. This avoids mode dropping (since you're in full control of the computer rendering). Of course the downside is that it's up to the programmer to generate varied, interesting, and challenging synthetic data. A complementary line of attack is data augmentation -- it's often possible to easily perturb a single input datapoint slightly in many interesting ways (for images: flipping, cropping, rotating, color adjustments, elastic deformation, adding rain/fog, etc) in order to synthesize new datapoints.
Structure of Generative Adversarial Networks (GAN) for mapping a simulation model
So you want to learn a dynamics model of some system, and to improve the robustness of the model, you want to sample a wide range of inputs from a GAN. While it's certainly possible to learn a dynamic
Structure of Generative Adversarial Networks (GAN) for mapping a simulation model So you want to learn a dynamics model of some system, and to improve the robustness of the model, you want to sample a wide range of inputs from a GAN. While it's certainly possible to learn a dynamics model, I don't think it's a good idea to generate inputs exclusively with a GAN -- indeed, GANs are known for mode dropping and mode collapse, exactly what you don't want. I would advise using VAEs if you want to go down this path, since they're not as vulnerable to this problem. There is a large body of work which generates synthetic data (for example, computer renderings of 3D scenes), and then uses conditional GANs to improve the photorealism of the renderings. This avoids mode dropping (since you're in full control of the computer rendering). Of course the downside is that it's up to the programmer to generate varied, interesting, and challenging synthetic data. A complementary line of attack is data augmentation -- it's often possible to easily perturb a single input datapoint slightly in many interesting ways (for images: flipping, cropping, rotating, color adjustments, elastic deformation, adding rain/fog, etc) in order to synthesize new datapoints.
Structure of Generative Adversarial Networks (GAN) for mapping a simulation model So you want to learn a dynamics model of some system, and to improve the robustness of the model, you want to sample a wide range of inputs from a GAN. While it's certainly possible to learn a dynamic
37,046
Gradient descent: Shouldn't step size be proportional to inverse of gradient of residual?
You want to head "downhill" -- in the direction in which the slope is decreasing most quickly. Considered in terms of the axes, the relative speeds of decrease will each be proportional to that derivative. Which is to say, no the book is right. How far you step in that direction is a slightly different matter. [However, if the minimum is nearly quadratic, you actually do want to have an absolute step size that is proportional to the derivative (since the steeper the slope, the further you are from the minimum, other things being equal). However, this consideration is not usually applied with gradient descent.]
Gradient descent: Shouldn't step size be proportional to inverse of gradient of residual?
You want to head "downhill" -- in the direction in which the slope is decreasing most quickly. Considered in terms of the axes, the relative speeds of decrease will each be proportional to that deriva
Gradient descent: Shouldn't step size be proportional to inverse of gradient of residual? You want to head "downhill" -- in the direction in which the slope is decreasing most quickly. Considered in terms of the axes, the relative speeds of decrease will each be proportional to that derivative. Which is to say, no the book is right. How far you step in that direction is a slightly different matter. [However, if the minimum is nearly quadratic, you actually do want to have an absolute step size that is proportional to the derivative (since the steeper the slope, the further you are from the minimum, other things being equal). However, this consideration is not usually applied with gradient descent.]
Gradient descent: Shouldn't step size be proportional to inverse of gradient of residual? You want to head "downhill" -- in the direction in which the slope is decreasing most quickly. Considered in terms of the axes, the relative speeds of decrease will each be proportional to that deriva
37,047
Mixed Model Equations
Noting that $(A + BCD)^{-1} = A^{-1} - A^{-1}B(C^{-1} + DA^{-1}B)^{-1}DA^{-1}$ we can write \begin{equation} H^{-1} = (ZGZ^\top + R) = R^{-1} - R^{-1}Z(G^{-1} + Z^\top R^{-1}Z)^{-1}Z^\top R^{-1}. \end{equation} Using $H^{-1}$ we can write \begin{equation} \begin{aligned} GZ^\top H^{-1}ZG &= GZ^\top R^{-1}ZG - GZ^\top R^{-1}Z(G^{-1} + Z^\top R^{-1}Z)^{-1} Z^\top R^{-1} ZG \\ & = \Big[ G - GZ^\top R^{-1}Z(G^{-1} + Z^\top R^{-1}Z)^{-1}\Big]Z^\top R^{-1}ZG \\ & = \Big[G(G^{-1} + Z^\top R^{-1}Z) - GZ^\top R^{-1}Z\Big](G^{-1} + Z^\top R^{-1}Z)^{-1}Z^\top R^{-1}ZG \\ & = \Big[(I + GZ^\top R^{-1}Z) - GZ^\top R^{-1}Z\Big](G^{-1} + Z^\top R^{-1}Z)^{-1}Z^\top R^{-1}ZG \\ & = (G^{-1} + Z^\top R^{-1}Z)^{-1}Z^\top R^{-1}ZG. \end{aligned} \end{equation} Thus $\text{Var}(u \mid y)$ can be written as \begin{equation} \begin{aligned} \text{Var}(u \mid y) & = \sigma^2(G - GZ^\top H^{-1}ZG) \\ &= \sigma^2(G - [G^{-1} + Z^\top R^{-1}Z]^{-1}Z^\top R^{-1}ZG) \\ &= \sigma^2(G - [G^{-1} + Z^\top R^{-1}Z]^{-1}[Z^\top R^{-1}Z + G^{-1} - G^{-1}]G) \\ & = \sigma^2(G^{-1} + Z^\top R^{-1}Z)^{-1}. \end{aligned} \end{equation} Edit: Noting that \begin{equation} (Z^\top R^{-1}Z + G^{-1})GZ^\top = Z^\top R^{-1}H. \end{equation} Multiplying on the left by $(Z^\top R^{-1}Z + G^{-1})^{-1}$ and on the right by $H^{-1}$ we obtain \begin{equation} \begin{aligned} (Z^\top R^{-1}Z + G^{-1})^{-1}(Z^\top R^{-1}Z + G^{-1})GZ^\top H^{-1} & = (Z^\top R^{-1}Z + G^{-1})^{-1}Z^\top R^{-1}HH^{-1} \\ \implies GZ^\top H^{-1} & = (Z^\top R^{-1}Z + G^{-1})^{-1}Z^\top R^{-1}. \end{aligned} \end{equation}
Mixed Model Equations
Noting that $(A + BCD)^{-1} = A^{-1} - A^{-1}B(C^{-1} + DA^{-1}B)^{-1}DA^{-1}$ we can write \begin{equation} H^{-1} = (ZGZ^\top + R) = R^{-1} - R^{-1}Z(G^{-1} + Z^\top R^{-1}Z)^{-1}Z^\top R^{-1}. \en
Mixed Model Equations Noting that $(A + BCD)^{-1} = A^{-1} - A^{-1}B(C^{-1} + DA^{-1}B)^{-1}DA^{-1}$ we can write \begin{equation} H^{-1} = (ZGZ^\top + R) = R^{-1} - R^{-1}Z(G^{-1} + Z^\top R^{-1}Z)^{-1}Z^\top R^{-1}. \end{equation} Using $H^{-1}$ we can write \begin{equation} \begin{aligned} GZ^\top H^{-1}ZG &= GZ^\top R^{-1}ZG - GZ^\top R^{-1}Z(G^{-1} + Z^\top R^{-1}Z)^{-1} Z^\top R^{-1} ZG \\ & = \Big[ G - GZ^\top R^{-1}Z(G^{-1} + Z^\top R^{-1}Z)^{-1}\Big]Z^\top R^{-1}ZG \\ & = \Big[G(G^{-1} + Z^\top R^{-1}Z) - GZ^\top R^{-1}Z\Big](G^{-1} + Z^\top R^{-1}Z)^{-1}Z^\top R^{-1}ZG \\ & = \Big[(I + GZ^\top R^{-1}Z) - GZ^\top R^{-1}Z\Big](G^{-1} + Z^\top R^{-1}Z)^{-1}Z^\top R^{-1}ZG \\ & = (G^{-1} + Z^\top R^{-1}Z)^{-1}Z^\top R^{-1}ZG. \end{aligned} \end{equation} Thus $\text{Var}(u \mid y)$ can be written as \begin{equation} \begin{aligned} \text{Var}(u \mid y) & = \sigma^2(G - GZ^\top H^{-1}ZG) \\ &= \sigma^2(G - [G^{-1} + Z^\top R^{-1}Z]^{-1}Z^\top R^{-1}ZG) \\ &= \sigma^2(G - [G^{-1} + Z^\top R^{-1}Z]^{-1}[Z^\top R^{-1}Z + G^{-1} - G^{-1}]G) \\ & = \sigma^2(G^{-1} + Z^\top R^{-1}Z)^{-1}. \end{aligned} \end{equation} Edit: Noting that \begin{equation} (Z^\top R^{-1}Z + G^{-1})GZ^\top = Z^\top R^{-1}H. \end{equation} Multiplying on the left by $(Z^\top R^{-1}Z + G^{-1})^{-1}$ and on the right by $H^{-1}$ we obtain \begin{equation} \begin{aligned} (Z^\top R^{-1}Z + G^{-1})^{-1}(Z^\top R^{-1}Z + G^{-1})GZ^\top H^{-1} & = (Z^\top R^{-1}Z + G^{-1})^{-1}Z^\top R^{-1}HH^{-1} \\ \implies GZ^\top H^{-1} & = (Z^\top R^{-1}Z + G^{-1})^{-1}Z^\top R^{-1}. \end{aligned} \end{equation}
Mixed Model Equations Noting that $(A + BCD)^{-1} = A^{-1} - A^{-1}B(C^{-1} + DA^{-1}B)^{-1}DA^{-1}$ we can write \begin{equation} H^{-1} = (ZGZ^\top + R) = R^{-1} - R^{-1}Z(G^{-1} + Z^\top R^{-1}Z)^{-1}Z^\top R^{-1}. \en
37,048
Conditioning in the definition of sufficient statistics
There is no impact on sufficiency of the fact that $\mathbb{P}_\theta(T=t)$ is not always positive. As indicated in my example, the statistic $$T=X_{(n)}=\max_{1\le i\le n} X_i$$ is sufficient when the $X_i$'s are uniform on $\{1,\ldots,\theta\}$. And $$\mathbb{P}_\theta(T=t)=0$$ when $\theta<t$. The joint probability mass function of $(X_1,\ldots,X_n,X_{(n)})$ at $(x_1,\ldots,x_n,x_{(n)})$ is also zero when $x_{(n)}>\theta$, hence the conditional probability of $(X_1,\ldots,X_n)$ given $X_{(n)}=t$ and $t>\theta$ is not defined. But since the conditional distribution of $(x_1,\ldots,x_n)$ given $X_{(n)}=t$ is uniform over $$\{(x_1,\ldots,);\ x_{(n)}=t\}$$ independently of $\theta\ge t$ (and not defined otherwise), this does not impact sufficiency. I presume that the undefined nature of the conditional in the impossible situation that $X_{(n)}=t$ and $t>\theta$ appears to bring some dependence on $\theta$ but this is not a correct impression: the conditional is not defined because the conditioning event is impossible. The part that brings information on $\theta$ is $X_{(n)}$, which is fine since it is sufficient. Here is a quote from one of the earlier papers on the topic, by Koopman (1935): where he similarly sees no impact on sufficiency in the fact that the density may be null for the actual observations and some values of the parameter.
Conditioning in the definition of sufficient statistics
There is no impact on sufficiency of the fact that $\mathbb{P}_\theta(T=t)$ is not always positive. As indicated in my example, the statistic $$T=X_{(n)}=\max_{1\le i\le n} X_i$$ is sufficient when th
Conditioning in the definition of sufficient statistics There is no impact on sufficiency of the fact that $\mathbb{P}_\theta(T=t)$ is not always positive. As indicated in my example, the statistic $$T=X_{(n)}=\max_{1\le i\le n} X_i$$ is sufficient when the $X_i$'s are uniform on $\{1,\ldots,\theta\}$. And $$\mathbb{P}_\theta(T=t)=0$$ when $\theta<t$. The joint probability mass function of $(X_1,\ldots,X_n,X_{(n)})$ at $(x_1,\ldots,x_n,x_{(n)})$ is also zero when $x_{(n)}>\theta$, hence the conditional probability of $(X_1,\ldots,X_n)$ given $X_{(n)}=t$ and $t>\theta$ is not defined. But since the conditional distribution of $(x_1,\ldots,x_n)$ given $X_{(n)}=t$ is uniform over $$\{(x_1,\ldots,);\ x_{(n)}=t\}$$ independently of $\theta\ge t$ (and not defined otherwise), this does not impact sufficiency. I presume that the undefined nature of the conditional in the impossible situation that $X_{(n)}=t$ and $t>\theta$ appears to bring some dependence on $\theta$ but this is not a correct impression: the conditional is not defined because the conditioning event is impossible. The part that brings information on $\theta$ is $X_{(n)}$, which is fine since it is sufficient. Here is a quote from one of the earlier papers on the topic, by Koopman (1935): where he similarly sees no impact on sufficiency in the fact that the density may be null for the actual observations and some values of the parameter.
Conditioning in the definition of sufficient statistics There is no impact on sufficiency of the fact that $\mathbb{P}_\theta(T=t)$ is not always positive. As indicated in my example, the statistic $$T=X_{(n)}=\max_{1\le i\le n} X_i$$ is sufficient when th
37,049
Conditioning in the definition of sufficient statistics
In advanced probability texts, sufficiency is usually defined formally in terms of partitions on the sample space, and then we build up the standard definition as an implication of this for a parametric model. In any case, once you translate to the common definition, the requirement for sufficiency is that this condition should hold for all $t$. So a statistic $T: \mathbb{R} \rightarrow \Lambda$ will be sufficient for $\theta$ if and only if it has a conditional probability function $P_{\theta}(\mathbf{X}|T =t)$ satisfying: $$P_{\theta}(\mathbf{X}|T=t) = P_{\theta'}(\mathbf{X}|T=t) \quad \quad \quad \text{for all } \theta, \theta' \in \Theta \text{ and } t \in \Lambda.$$ Note that in cases where $\mathbb{P}_\theta(T=t)=0$ for some $t$, the conditional probability is defined through the law of total probability --- i.e., it is any measureable non-negative function satisfying: $$\int \limits_\Lambda P_{\theta}(\mathbf{X} \in \mathcal{S}|T=t) dF_T(t) = \mathbb{P}_{\theta}(\mathbf{X} \in \mathcal{S}) \quad \quad \quad \text{for all } \theta \text{ and measureable } \mathcal{S}.$$ This latter part gives you some "wiggle room" for sufficiency in regard to sets with probability measure zero. If there is any conditional probability function satisfying the above then we would say that the statistic $T$ is sufficient. If you would like to know more about the underlying definition, I recommend you have a look at the definition of a sufficient partition first. Most textbooks on intermediate or advanced probability will have an explanation of sufficiency that is couched in an initial definition in terms of a partition on the sample space.
Conditioning in the definition of sufficient statistics
In advanced probability texts, sufficiency is usually defined formally in terms of partitions on the sample space, and then we build up the standard definition as an implication of this for a parametr
Conditioning in the definition of sufficient statistics In advanced probability texts, sufficiency is usually defined formally in terms of partitions on the sample space, and then we build up the standard definition as an implication of this for a parametric model. In any case, once you translate to the common definition, the requirement for sufficiency is that this condition should hold for all $t$. So a statistic $T: \mathbb{R} \rightarrow \Lambda$ will be sufficient for $\theta$ if and only if it has a conditional probability function $P_{\theta}(\mathbf{X}|T =t)$ satisfying: $$P_{\theta}(\mathbf{X}|T=t) = P_{\theta'}(\mathbf{X}|T=t) \quad \quad \quad \text{for all } \theta, \theta' \in \Theta \text{ and } t \in \Lambda.$$ Note that in cases where $\mathbb{P}_\theta(T=t)=0$ for some $t$, the conditional probability is defined through the law of total probability --- i.e., it is any measureable non-negative function satisfying: $$\int \limits_\Lambda P_{\theta}(\mathbf{X} \in \mathcal{S}|T=t) dF_T(t) = \mathbb{P}_{\theta}(\mathbf{X} \in \mathcal{S}) \quad \quad \quad \text{for all } \theta \text{ and measureable } \mathcal{S}.$$ This latter part gives you some "wiggle room" for sufficiency in regard to sets with probability measure zero. If there is any conditional probability function satisfying the above then we would say that the statistic $T$ is sufficient. If you would like to know more about the underlying definition, I recommend you have a look at the definition of a sufficient partition first. Most textbooks on intermediate or advanced probability will have an explanation of sufficiency that is couched in an initial definition in terms of a partition on the sample space.
Conditioning in the definition of sufficient statistics In advanced probability texts, sufficiency is usually defined formally in terms of partitions on the sample space, and then we build up the standard definition as an implication of this for a parametr
37,050
How does random variable nesting in GAMs work (mgcv)?
There are several ways to specify this with mgcv, each yielding a different way to estimate the smoothing parameter and variance component. For the predicted random intercepts: these will not be identical between different specifications, but I do not expect substantial differences. If you are interested in interpretation of the variance components, the difference between specifications may be quite important. With s(SURV.GR, bs="re") + s(SURV.GR, YEAR, bs="re") + s(SURV.GR, YEAR, PlotID, bs="re"), three separate smoothing parameters and variance components will be estimated, one for each smooth term specified. But perhaps you want to allow the amount of smoothing to vary between different levels of YEAR. Or you might be interested in differences of the variance explained by SURV.GR, for each of the different levels of YEAR. Then you could replace s(SURV.GR, YEAR, bs="re") with s(SURV.GR, by=YEAR, bs="re"); this would yield a separate smoothing parameter and variance component being estimated for the random intercept w.r.t. SURV.GR, for each level of YEAR. I would recommend after fitting your model(s), to inspect gamfit$sp and varcomp.gam(gamfit) to see whether the smoothing parameters and variance components are estimated as you expected. Also, you may want to compare against VarCorr(glmerfit). (where gamfit refers to the object returned by gam() and glmerfit refers to the object returned by glmer())
How does random variable nesting in GAMs work (mgcv)?
There are several ways to specify this with mgcv, each yielding a different way to estimate the smoothing parameter and variance component. For the predicted random intercepts: these will not be ident
How does random variable nesting in GAMs work (mgcv)? There are several ways to specify this with mgcv, each yielding a different way to estimate the smoothing parameter and variance component. For the predicted random intercepts: these will not be identical between different specifications, but I do not expect substantial differences. If you are interested in interpretation of the variance components, the difference between specifications may be quite important. With s(SURV.GR, bs="re") + s(SURV.GR, YEAR, bs="re") + s(SURV.GR, YEAR, PlotID, bs="re"), three separate smoothing parameters and variance components will be estimated, one for each smooth term specified. But perhaps you want to allow the amount of smoothing to vary between different levels of YEAR. Or you might be interested in differences of the variance explained by SURV.GR, for each of the different levels of YEAR. Then you could replace s(SURV.GR, YEAR, bs="re") with s(SURV.GR, by=YEAR, bs="re"); this would yield a separate smoothing parameter and variance component being estimated for the random intercept w.r.t. SURV.GR, for each level of YEAR. I would recommend after fitting your model(s), to inspect gamfit$sp and varcomp.gam(gamfit) to see whether the smoothing parameters and variance components are estimated as you expected. Also, you may want to compare against VarCorr(glmerfit). (where gamfit refers to the object returned by gam() and glmerfit refers to the object returned by glmer())
How does random variable nesting in GAMs work (mgcv)? There are several ways to specify this with mgcv, each yielding a different way to estimate the smoothing parameter and variance component. For the predicted random intercepts: these will not be ident
37,051
Reconciling Langevin MC methods as one-step HMC versus as diffusion or brownian motion
The easiest way to understand why Langevin dynamics targets the "correct distribution" is to look at the corresponding Fokker-Planck equation. Let me be more precise. Let us assume that our target distribution has the following density: $\pi(x) = \frac1{Z} \exp(-U(x))$, where $x \in \mathbb{R}^d$, $U$ is often called the potential energy, and $Z$ is the normalizing constant. The Langevin algorithm, either the Metropolis-adjusted version (MALA) or the unadjusted version (ULA), is based on the Langevin diffusion, that is described by the following stochastic differential equation (SDE): $dX_t = -\nabla U(X_t)dt + \sqrt{2}dB_t$, where $B_t$ denotes the standard Brownian motion. To understand how the probability density function of $X_t$ evolves in time, we can use a very useful tool, which is called the Fokker-Planck equation (FPE). For notational simplicity let us assume we are in the scalar case, i.e. $d=1$ (for $d>1$ the idea is the same). In this case the FPE reads: $\partial_t p(x,t) = \partial_x (\partial_x U(x) p(x,t)) + \partial_x^2 p(x,t)$, where $p(x,t)$ is the probability density function of $X_t$ at time $t$. Now the main trick is this: Let us assume the process $(X_t)_{t \geq 0}$ (which is a Markov process) is ergodic with its invariant measure. Then, when $p(x,t)$ reaches to this invariant measure, it cannot deviate from it anymore (since it's the invariant measure). Hence, when $p(x,t)$ converges to the invariant measure, then $\partial_t p(x,t)$ must be equal to zero (since it won't change over the time $t$). Given this observation, in order to verify that the invariant measure of the Langevin equation is indeed $\pi$, we only need to check if $\partial_t p(x,t)$ becomes $0$ or not, when we replace $p(x,t)$ by $\pi(x)$. Now, let's see if this really happens: \begin{align} \partial_t p(x,t) &= \partial_x (\partial_x U(x) \pi(x)) + \partial_x^2 \pi(x) \\ &= \partial_x (\partial_x U(x) \pi(x) + \partial_x \pi(x)) \end{align} By using the fact that $\partial_x U(x) = -\partial_x \log \pi(x)= - \frac1{\pi(x)} \partial_x \pi(x)$, we obtain: \begin{align} \partial_t p(x,t) &= \partial_x (- \frac1{\pi(x)} \pi(x) \partial_x \pi(x) + \partial_x \pi(x)) \\ &= \partial_x (- \partial_x \pi(x) + \partial_x \pi(x)) \\ &= 0. \end{align} Then, this shows that $\pi$ is an invariant distribution of the process $(X_t)_t$, and if $(X_t)_t$ has a unique invariant distribution (for instance if $\nabla U$ is Lipschitz), then $\pi$ is the unique invariant distribution. Now, if we go back to ULA (unadjusted Langevin algorithm) or MALA (Metropolis adjusted Langevin algorithm), they are both based on the Euler discretization of the Langevin SDE: $Y_{n+1} = Y_{n} - \eta \nabla U(Y_n) + \sqrt{2\eta} Z_{n+1}$, where $Z_n$ is a standard Gaussian random variable. This scheme is called ULA. The process $(Y_n)_n$ is still a Markov process, but it doesn't target $\pi$ anymore due to the discretization error. Hence, one can couple it with a Metropolis acceptance step to get rid of this error. The resulting algorithm is called MALA. I hope it's more clear now.
Reconciling Langevin MC methods as one-step HMC versus as diffusion or brownian motion
The easiest way to understand why Langevin dynamics targets the "correct distribution" is to look at the corresponding Fokker-Planck equation. Let me be more precise. Let us assume that our target dis
Reconciling Langevin MC methods as one-step HMC versus as diffusion or brownian motion The easiest way to understand why Langevin dynamics targets the "correct distribution" is to look at the corresponding Fokker-Planck equation. Let me be more precise. Let us assume that our target distribution has the following density: $\pi(x) = \frac1{Z} \exp(-U(x))$, where $x \in \mathbb{R}^d$, $U$ is often called the potential energy, and $Z$ is the normalizing constant. The Langevin algorithm, either the Metropolis-adjusted version (MALA) or the unadjusted version (ULA), is based on the Langevin diffusion, that is described by the following stochastic differential equation (SDE): $dX_t = -\nabla U(X_t)dt + \sqrt{2}dB_t$, where $B_t$ denotes the standard Brownian motion. To understand how the probability density function of $X_t$ evolves in time, we can use a very useful tool, which is called the Fokker-Planck equation (FPE). For notational simplicity let us assume we are in the scalar case, i.e. $d=1$ (for $d>1$ the idea is the same). In this case the FPE reads: $\partial_t p(x,t) = \partial_x (\partial_x U(x) p(x,t)) + \partial_x^2 p(x,t)$, where $p(x,t)$ is the probability density function of $X_t$ at time $t$. Now the main trick is this: Let us assume the process $(X_t)_{t \geq 0}$ (which is a Markov process) is ergodic with its invariant measure. Then, when $p(x,t)$ reaches to this invariant measure, it cannot deviate from it anymore (since it's the invariant measure). Hence, when $p(x,t)$ converges to the invariant measure, then $\partial_t p(x,t)$ must be equal to zero (since it won't change over the time $t$). Given this observation, in order to verify that the invariant measure of the Langevin equation is indeed $\pi$, we only need to check if $\partial_t p(x,t)$ becomes $0$ or not, when we replace $p(x,t)$ by $\pi(x)$. Now, let's see if this really happens: \begin{align} \partial_t p(x,t) &= \partial_x (\partial_x U(x) \pi(x)) + \partial_x^2 \pi(x) \\ &= \partial_x (\partial_x U(x) \pi(x) + \partial_x \pi(x)) \end{align} By using the fact that $\partial_x U(x) = -\partial_x \log \pi(x)= - \frac1{\pi(x)} \partial_x \pi(x)$, we obtain: \begin{align} \partial_t p(x,t) &= \partial_x (- \frac1{\pi(x)} \pi(x) \partial_x \pi(x) + \partial_x \pi(x)) \\ &= \partial_x (- \partial_x \pi(x) + \partial_x \pi(x)) \\ &= 0. \end{align} Then, this shows that $\pi$ is an invariant distribution of the process $(X_t)_t$, and if $(X_t)_t$ has a unique invariant distribution (for instance if $\nabla U$ is Lipschitz), then $\pi$ is the unique invariant distribution. Now, if we go back to ULA (unadjusted Langevin algorithm) or MALA (Metropolis adjusted Langevin algorithm), they are both based on the Euler discretization of the Langevin SDE: $Y_{n+1} = Y_{n} - \eta \nabla U(Y_n) + \sqrt{2\eta} Z_{n+1}$, where $Z_n$ is a standard Gaussian random variable. This scheme is called ULA. The process $(Y_n)_n$ is still a Markov process, but it doesn't target $\pi$ anymore due to the discretization error. Hence, one can couple it with a Metropolis acceptance step to get rid of this error. The resulting algorithm is called MALA. I hope it's more clear now.
Reconciling Langevin MC methods as one-step HMC versus as diffusion or brownian motion The easiest way to understand why Langevin dynamics targets the "correct distribution" is to look at the corresponding Fokker-Planck equation. Let me be more precise. Let us assume that our target dis
37,052
Reconciling Langevin MC methods as one-step HMC versus as diffusion or brownian motion
Here is an elementary and not entirely rigorous "proof" that Langevin dynamics satisfies detailed balance. I only bothered considering the univariate case. Let $\pi$ denote the distribution we are concerned with (and the distribution for which we'll prove detailed balance). A single step of LMC is: \begin{align} x \leftarrow x + \epsilon \eta - \frac{\epsilon^2}{2} \nabla \log \pi(x) \quad \text{where $\eta \sim \mathcal{N}(0, 1)$} \end{align} Consider any two points $x$ and $x'$, with $\delta x = (x'-x)/\epsilon$. If we assume $\log \pi(x)$ is locally linear, then \begin{align} \nabla \log \pi(x) = \nabla \log \pi(x') = \frac{\log \pi(x') - \log \pi(x)}{\epsilon \delta x} \end{align} With that in mind, we can write: \begin{align} P(x \rightarrow x') &= P(x' -x = \epsilon \eta - \frac{\epsilon^2}{2} \nabla \log \pi(x)) \\ &= P(\epsilon \delta x = \epsilon \eta - \frac{\epsilon}{2 \delta x} (\log \pi(x') - \log \pi(x))) \\ &= P(\eta = \delta x + \frac{1}{2 \delta x} (\log \pi(x') - \log \pi(x))) \end{align} For conciseness, write $\phi = \frac{1}{2} (\log \pi(x') - \log \pi(x))$ \begin{align} \log P(x \rightarrow x') &= -\frac{1}{2} (\delta x + \frac{\phi}{\delta x})^2 \\ &= -\frac{1}{2} ((\delta x)^2 + 2 \phi + (\frac{\phi}{\delta x})^2) \end{align} And analogously (although I don't bother to write out the steps): \begin{align} \log P(x' \rightarrow x) &= -\frac{1}{2} ((\delta x)^2 - 2 \phi + (\frac{\phi}{\delta x})^2) \end{align} Thus the difference is \begin{align} \log P(x' \rightarrow x) - \log P(x \rightarrow x') &= -2 \phi \end{align} Therefore we can complete the proof with: \begin{align} \log \pi(x) - \log \pi(x') &= \log P(x' \rightarrow x) - \log P(x \rightarrow x') \\ \log \pi(x) + \log P(x \rightarrow x') &= \log \pi(x') + \log P(x' \rightarrow x) \end{align} Edit: Actually my assumption about $\log \pi$ being roughly linear doesn't seem to be reasonable, unless I can guarantee that $x$ and $x'$ are close enough to each other. I'm sure there's a way to patch the proof, but I'm not quite sure how exactly.
Reconciling Langevin MC methods as one-step HMC versus as diffusion or brownian motion
Here is an elementary and not entirely rigorous "proof" that Langevin dynamics satisfies detailed balance. I only bothered considering the univariate case. Let $\pi$ denote the distribution we are co
Reconciling Langevin MC methods as one-step HMC versus as diffusion or brownian motion Here is an elementary and not entirely rigorous "proof" that Langevin dynamics satisfies detailed balance. I only bothered considering the univariate case. Let $\pi$ denote the distribution we are concerned with (and the distribution for which we'll prove detailed balance). A single step of LMC is: \begin{align} x \leftarrow x + \epsilon \eta - \frac{\epsilon^2}{2} \nabla \log \pi(x) \quad \text{where $\eta \sim \mathcal{N}(0, 1)$} \end{align} Consider any two points $x$ and $x'$, with $\delta x = (x'-x)/\epsilon$. If we assume $\log \pi(x)$ is locally linear, then \begin{align} \nabla \log \pi(x) = \nabla \log \pi(x') = \frac{\log \pi(x') - \log \pi(x)}{\epsilon \delta x} \end{align} With that in mind, we can write: \begin{align} P(x \rightarrow x') &= P(x' -x = \epsilon \eta - \frac{\epsilon^2}{2} \nabla \log \pi(x)) \\ &= P(\epsilon \delta x = \epsilon \eta - \frac{\epsilon}{2 \delta x} (\log \pi(x') - \log \pi(x))) \\ &= P(\eta = \delta x + \frac{1}{2 \delta x} (\log \pi(x') - \log \pi(x))) \end{align} For conciseness, write $\phi = \frac{1}{2} (\log \pi(x') - \log \pi(x))$ \begin{align} \log P(x \rightarrow x') &= -\frac{1}{2} (\delta x + \frac{\phi}{\delta x})^2 \\ &= -\frac{1}{2} ((\delta x)^2 + 2 \phi + (\frac{\phi}{\delta x})^2) \end{align} And analogously (although I don't bother to write out the steps): \begin{align} \log P(x' \rightarrow x) &= -\frac{1}{2} ((\delta x)^2 - 2 \phi + (\frac{\phi}{\delta x})^2) \end{align} Thus the difference is \begin{align} \log P(x' \rightarrow x) - \log P(x \rightarrow x') &= -2 \phi \end{align} Therefore we can complete the proof with: \begin{align} \log \pi(x) - \log \pi(x') &= \log P(x' \rightarrow x) - \log P(x \rightarrow x') \\ \log \pi(x) + \log P(x \rightarrow x') &= \log \pi(x') + \log P(x' \rightarrow x) \end{align} Edit: Actually my assumption about $\log \pi$ being roughly linear doesn't seem to be reasonable, unless I can guarantee that $x$ and $x'$ are close enough to each other. I'm sure there's a way to patch the proof, but I'm not quite sure how exactly.
Reconciling Langevin MC methods as one-step HMC versus as diffusion or brownian motion Here is an elementary and not entirely rigorous "proof" that Langevin dynamics satisfies detailed balance. I only bothered considering the univariate case. Let $\pi$ denote the distribution we are co
37,053
Get estimates about 'variable importance' across a large number of variables and their permutations
In my field (political science) conjoint experiments are very common. Typically the data come in the form of a forced-choice comparison — i.e., survey respondents are shown a series of comparisons between product profiles in which features of the products are randomized, and then respondents choose which product they prefer. In terms of analysis, a paper by Hainmueller, Hopkins, and Yamamoto shows that you can estimate a quantity called the average marginal component effect (AMCE) by a linear regression (using OLS) of the form $$Y_{ij} = a + \beta_1 X_{1ij} + \beta_2 X_{2ij} + \cdots + \epsilon_{ij},$$ where $Y_{ij}$ is an indicator for whether respondent $i$ chose profile $j$ when they had the option, and the $X$'s are vectors of indicator variables for the features. The AMCE is the average change in probability of choosing a product that has that specific feature, relative to the baseline, marginalizing over the distribution of other features. In other words, it averages over all possible interactions effects. This is a very simple estimator to implement since it's just OLS. If you want to know how the importance of specific factors varies as a function of other factors, you could subset based on the other factor (e.g. whether the product was made in China) and re-estimate the regression above, or you could simply include interaction indicators. As you note, though, you can't estimate all possible interactions using OLS, since the number of combinations very quickly exceeds the number of respondents. Your idea to use LASSO makes sense to me. To see another estimator for this problem that has some nice properties, you could take a look at this paper by Egami and Imai.
Get estimates about 'variable importance' across a large number of variables and their permutations
In my field (political science) conjoint experiments are very common. Typically the data come in the form of a forced-choice comparison — i.e., survey respondents are shown a series of comparisons bet
Get estimates about 'variable importance' across a large number of variables and their permutations In my field (political science) conjoint experiments are very common. Typically the data come in the form of a forced-choice comparison — i.e., survey respondents are shown a series of comparisons between product profiles in which features of the products are randomized, and then respondents choose which product they prefer. In terms of analysis, a paper by Hainmueller, Hopkins, and Yamamoto shows that you can estimate a quantity called the average marginal component effect (AMCE) by a linear regression (using OLS) of the form $$Y_{ij} = a + \beta_1 X_{1ij} + \beta_2 X_{2ij} + \cdots + \epsilon_{ij},$$ where $Y_{ij}$ is an indicator for whether respondent $i$ chose profile $j$ when they had the option, and the $X$'s are vectors of indicator variables for the features. The AMCE is the average change in probability of choosing a product that has that specific feature, relative to the baseline, marginalizing over the distribution of other features. In other words, it averages over all possible interactions effects. This is a very simple estimator to implement since it's just OLS. If you want to know how the importance of specific factors varies as a function of other factors, you could subset based on the other factor (e.g. whether the product was made in China) and re-estimate the regression above, or you could simply include interaction indicators. As you note, though, you can't estimate all possible interactions using OLS, since the number of combinations very quickly exceeds the number of respondents. Your idea to use LASSO makes sense to me. To see another estimator for this problem that has some nice properties, you could take a look at this paper by Egami and Imai.
Get estimates about 'variable importance' across a large number of variables and their permutations In my field (political science) conjoint experiments are very common. Typically the data come in the form of a forced-choice comparison — i.e., survey respondents are shown a series of comparisons bet
37,054
Get estimates about 'variable importance' across a large number of variables and their permutations
Be cautious - most analysts do not use the bootstrap to get confidence intervals for variable importance measures, but when they do they are usually disappointed. The data, unless massive, do not contain sufficient information to tell you reliably which elements of the data are predictive, and do not have sufficient information for telling you how important each potential predictor is. I expand on this in Chapter 20 of BBR. See also this for a discussion of measures of added information.
Get estimates about 'variable importance' across a large number of variables and their permutations
Be cautious - most analysts do not use the bootstrap to get confidence intervals for variable importance measures, but when they do they are usually disappointed. The data, unless massive, do not con
Get estimates about 'variable importance' across a large number of variables and their permutations Be cautious - most analysts do not use the bootstrap to get confidence intervals for variable importance measures, but when they do they are usually disappointed. The data, unless massive, do not contain sufficient information to tell you reliably which elements of the data are predictive, and do not have sufficient information for telling you how important each potential predictor is. I expand on this in Chapter 20 of BBR. See also this for a discussion of measures of added information.
Get estimates about 'variable importance' across a large number of variables and their permutations Be cautious - most analysts do not use the bootstrap to get confidence intervals for variable importance measures, but when they do they are usually disappointed. The data, unless massive, do not con
37,055
Get estimates about 'variable importance' across a large number of variables and their permutations
There are a whole host of options to determine variable importance. As you mentioned random forest has a variable importance metric built in. R package DALEX also has a model agnostic approach similar to the random forest importance but is model agnostic. When you say these don’t have effect sizes I would disagree and say they are quite interpretable. I would also suggest information theoretic methods such as information gain, though this assumes conditional independence between variables. Lastly you could look at the relief algorithm which to some extent considers dependence between predictors and works with all variable types
Get estimates about 'variable importance' across a large number of variables and their permutations
There are a whole host of options to determine variable importance. As you mentioned random forest has a variable importance metric built in. R package DALEX also has a model agnostic approach similar
Get estimates about 'variable importance' across a large number of variables and their permutations There are a whole host of options to determine variable importance. As you mentioned random forest has a variable importance metric built in. R package DALEX also has a model agnostic approach similar to the random forest importance but is model agnostic. When you say these don’t have effect sizes I would disagree and say they are quite interpretable. I would also suggest information theoretic methods such as information gain, though this assumes conditional independence between variables. Lastly you could look at the relief algorithm which to some extent considers dependence between predictors and works with all variable types
Get estimates about 'variable importance' across a large number of variables and their permutations There are a whole host of options to determine variable importance. As you mentioned random forest has a variable importance metric built in. R package DALEX also has a model agnostic approach similar
37,056
Get estimates about 'variable importance' across a large number of variables and their permutations
Have you tried to look at Pareto-smoothed importance sampling (PSIS) by Vehtari, Gelman and Gabry? Here's a fast recap: "Pareto-smoothed importance sampling (PSIS), a new procedure for regularizing importance weights". Look at the examples in the paper. It should be a good starting point. If it seems sounding to you there's an R package called ```loo`` to work on these concepts.
Get estimates about 'variable importance' across a large number of variables and their permutations
Have you tried to look at Pareto-smoothed importance sampling (PSIS) by Vehtari, Gelman and Gabry? Here's a fast recap: "Pareto-smoothed importance sampling (PSIS), a new procedure for regularizing im
Get estimates about 'variable importance' across a large number of variables and their permutations Have you tried to look at Pareto-smoothed importance sampling (PSIS) by Vehtari, Gelman and Gabry? Here's a fast recap: "Pareto-smoothed importance sampling (PSIS), a new procedure for regularizing importance weights". Look at the examples in the paper. It should be a good starting point. If it seems sounding to you there's an R package called ```loo`` to work on these concepts.
Get estimates about 'variable importance' across a large number of variables and their permutations Have you tried to look at Pareto-smoothed importance sampling (PSIS) by Vehtari, Gelman and Gabry? Here's a fast recap: "Pareto-smoothed importance sampling (PSIS), a new procedure for regularizing im
37,057
How to verify if a prediction performance improvement is significant better?
A few possibilities come to mind. If you have multiple datasets, you could use a Diebold-Mariano test. The tag wiki contains information, as well as pointers to the original and a follow-up publication. The DM test is very commonly applied in the time series forecasting community, but there is nothing specifically "time-seriesey" about it. If you have only a single dataset, then you could in principle bootstrap your model fits for both models and assess whether one improves on the other in (say) 95% of cases. If you do this on the same test set in each replicate (only bootstrapping the training data), then all you can conclude is whether one model is better on this particular test set, so the bare minimum I would do would be to wrap the exercise in a cross-validation step. And even so, applying this machinery on a single dataset would be very prone to just making you very confident that an overfitting model is better than it actually is.
How to verify if a prediction performance improvement is significant better?
A few possibilities come to mind. If you have multiple datasets, you could use a Diebold-Mariano test. The tag wiki contains information, as well as pointers to the original and a follow-up publicatio
How to verify if a prediction performance improvement is significant better? A few possibilities come to mind. If you have multiple datasets, you could use a Diebold-Mariano test. The tag wiki contains information, as well as pointers to the original and a follow-up publication. The DM test is very commonly applied in the time series forecasting community, but there is nothing specifically "time-seriesey" about it. If you have only a single dataset, then you could in principle bootstrap your model fits for both models and assess whether one improves on the other in (say) 95% of cases. If you do this on the same test set in each replicate (only bootstrapping the training data), then all you can conclude is whether one model is better on this particular test set, so the bare minimum I would do would be to wrap the exercise in a cross-validation step. And even so, applying this machinery on a single dataset would be very prone to just making you very confident that an overfitting model is better than it actually is.
How to verify if a prediction performance improvement is significant better? A few possibilities come to mind. If you have multiple datasets, you could use a Diebold-Mariano test. The tag wiki contains information, as well as pointers to the original and a follow-up publicatio
37,058
How to verify if a prediction performance improvement is significant better?
Dietterich (1998) proposes a 5x2 cross validation followed by a t-test to identify better models. When comparing models across multiple datasets, Demsar (2006) suggests the use of Wilcoxon Signed Rank test for comparing two models and Friedman test when comparing more than two models.
How to verify if a prediction performance improvement is significant better?
Dietterich (1998) proposes a 5x2 cross validation followed by a t-test to identify better models. When comparing models across multiple datasets, Demsar (2006) suggests the use of Wilcoxon Signed Rank
How to verify if a prediction performance improvement is significant better? Dietterich (1998) proposes a 5x2 cross validation followed by a t-test to identify better models. When comparing models across multiple datasets, Demsar (2006) suggests the use of Wilcoxon Signed Rank test for comparing two models and Friedman test when comparing more than two models.
How to verify if a prediction performance improvement is significant better? Dietterich (1998) proposes a 5x2 cross validation followed by a t-test to identify better models. When comparing models across multiple datasets, Demsar (2006) suggests the use of Wilcoxon Signed Rank
37,059
Can MCMC algorithm estimate partition function (normalizing constant)?
While I produced a detailed answer to an earlier X validated question, let me recall here that there are many ways of approximating the normalising constant, besides importance sampling: Chib's (1994) (or the candidate's) formula Gelfand and Dey's (1995) representation, which includes the infamous harmonic mean estimator particle filters and sequential Monte Carlo nested sampling reversible jump MCMC path sampling or thermodynamic integration bridge sampling Geyer's (1994) logistic regression the Savage-Dickey representation some of which are unbiased and most of which are described in Chen, Shao and Ibrahim (2001).
Can MCMC algorithm estimate partition function (normalizing constant)?
While I produced a detailed answer to an earlier X validated question, let me recall here that there are many ways of approximating the normalising constant, besides importance sampling: Chib's (1994
Can MCMC algorithm estimate partition function (normalizing constant)? While I produced a detailed answer to an earlier X validated question, let me recall here that there are many ways of approximating the normalising constant, besides importance sampling: Chib's (1994) (or the candidate's) formula Gelfand and Dey's (1995) representation, which includes the infamous harmonic mean estimator particle filters and sequential Monte Carlo nested sampling reversible jump MCMC path sampling or thermodynamic integration bridge sampling Geyer's (1994) logistic regression the Savage-Dickey representation some of which are unbiased and most of which are described in Chen, Shao and Ibrahim (2001).
Can MCMC algorithm estimate partition function (normalizing constant)? While I produced a detailed answer to an earlier X validated question, let me recall here that there are many ways of approximating the normalising constant, besides importance sampling: Chib's (1994
37,060
Recommended Mutual Information Estimator for Continuous Variable
I am not sure i understand why this should be a very hard problem, at least in such a low-dimensional setting as you describe. I am not active in the fields of those who have authored the articles you cite, but I do not see why this could not be framed as a relatively simple statistical problem. An idea you could (perhaps) follow, is to relate it to the copula of $X$ and $Y$. The mutual information of $X$ and $Y$ is the Kullbach-Leibler divergence of their actual joint density $f(x, y),$ and their joint density under the assumption of independence $f^*(x, y) = f(x)f(y).$ If you write $$F(x, y) = C(F(x), G(y)),$$ (where $C$ is called a copula, and this is for a continous bivariate random vector a unique representation) such that $$f(x, y) = c(F(x), G(y))f(x)g(y),$$ where $c(u, v) = \frac{\partial C}{\partial u \partial v}(u, v)$ is the copula density of $X$ and $Y$, then their mutual information can be written as \begin{align*} I(X, Y) &= \underset{\mathbb{R}^2}{\int\int}\log\left(\frac{f(x, y)}{f(x)f(y)}\right)f(x, y)dxdy\\ &=\underset{\mathbb{R}^2}{\int\int}\log\left(c(F(x), G(y)\right)c(F(x), G(y))f(x)f(y)dxdy\\ &=\underset{\mathbb{I}^2}{\int\int}\log\left(c(u, v)\right)c(u, v)dudv\\ &= \mathbb{E}_{C}\left(\log\left(c(U, V)\right)\right). \end{align*} I would suggest to use the semiparametric approach where you first compute the so called pseudo observations $\hat F(x) = \frac{1}{n-1}\sum_{i=1}^nI(x_i < x),$ $\hat G(y) = \frac{1}{n-1}\sum_{i=1}^nI(y_i < y),$ and then try to find some parametric copula $C_\theta$ that fits well to $(U^*, V^*) = (\hat F(X), \hat G(Y)).$ Then, you can estimate the mutual information by computing the integral above by numerical integration, or Monte Carlo methods, replacing $c$ and $C$ by $c_{\hat\theta}$ and $C_{\hat\theta}.$ If you estimate $I(X, Y)$ by sampling from the estimated copulas, you could get a confidence interval by repeatedly doing this based on, say, $100$ samples from $C_\hat\theta,$ and then using empirical quantiles of these estimates. I am not sure about a normed mutual information. I do not know if it is possible to compute bounds on the mutual information, and I am not sure how to compute the mutual information between two perfectly dependent random variables, as this would correspond to computing the expectation of the log-copula density of either of $M(u, v) = \min(u, v)$ or $W(u, v) = \max(u + v -1 , 0),$ which do not exist as these are not absolutely continous probability measures.
Recommended Mutual Information Estimator for Continuous Variable
I am not sure i understand why this should be a very hard problem, at least in such a low-dimensional setting as you describe. I am not active in the fields of those who have authored the articles you
Recommended Mutual Information Estimator for Continuous Variable I am not sure i understand why this should be a very hard problem, at least in such a low-dimensional setting as you describe. I am not active in the fields of those who have authored the articles you cite, but I do not see why this could not be framed as a relatively simple statistical problem. An idea you could (perhaps) follow, is to relate it to the copula of $X$ and $Y$. The mutual information of $X$ and $Y$ is the Kullbach-Leibler divergence of their actual joint density $f(x, y),$ and their joint density under the assumption of independence $f^*(x, y) = f(x)f(y).$ If you write $$F(x, y) = C(F(x), G(y)),$$ (where $C$ is called a copula, and this is for a continous bivariate random vector a unique representation) such that $$f(x, y) = c(F(x), G(y))f(x)g(y),$$ where $c(u, v) = \frac{\partial C}{\partial u \partial v}(u, v)$ is the copula density of $X$ and $Y$, then their mutual information can be written as \begin{align*} I(X, Y) &= \underset{\mathbb{R}^2}{\int\int}\log\left(\frac{f(x, y)}{f(x)f(y)}\right)f(x, y)dxdy\\ &=\underset{\mathbb{R}^2}{\int\int}\log\left(c(F(x), G(y)\right)c(F(x), G(y))f(x)f(y)dxdy\\ &=\underset{\mathbb{I}^2}{\int\int}\log\left(c(u, v)\right)c(u, v)dudv\\ &= \mathbb{E}_{C}\left(\log\left(c(U, V)\right)\right). \end{align*} I would suggest to use the semiparametric approach where you first compute the so called pseudo observations $\hat F(x) = \frac{1}{n-1}\sum_{i=1}^nI(x_i < x),$ $\hat G(y) = \frac{1}{n-1}\sum_{i=1}^nI(y_i < y),$ and then try to find some parametric copula $C_\theta$ that fits well to $(U^*, V^*) = (\hat F(X), \hat G(Y)).$ Then, you can estimate the mutual information by computing the integral above by numerical integration, or Monte Carlo methods, replacing $c$ and $C$ by $c_{\hat\theta}$ and $C_{\hat\theta}.$ If you estimate $I(X, Y)$ by sampling from the estimated copulas, you could get a confidence interval by repeatedly doing this based on, say, $100$ samples from $C_\hat\theta,$ and then using empirical quantiles of these estimates. I am not sure about a normed mutual information. I do not know if it is possible to compute bounds on the mutual information, and I am not sure how to compute the mutual information between two perfectly dependent random variables, as this would correspond to computing the expectation of the log-copula density of either of $M(u, v) = \min(u, v)$ or $W(u, v) = \max(u + v -1 , 0),$ which do not exist as these are not absolutely continous probability measures.
Recommended Mutual Information Estimator for Continuous Variable I am not sure i understand why this should be a very hard problem, at least in such a low-dimensional setting as you describe. I am not active in the fields of those who have authored the articles you
37,061
What is the definition of dataset (for Bonferroni purposes)?
The justification for control of multiple tests has to do with the family of tests. The family of tests can be mutually independent, which is often the case when they are drawn from different datasets; if so, Bonferroni is a good way to control for FWER. But in general, the concept of a dataset doesn't even enter the picture when discussing multiplicity. It's assumed (incorrectly) that data in different datasets must, by design, be independent whereas two tests calculated with the same dataset must be dependent (also not necessarily correct). To justify and discuss the type of testing correction to use, one should consider the "family of tests". If the tests are dependent or correlated (that is to say that the $p$-value of one test actually depends on the $p$-value from another test), Bonferroni will be conservative. (NB: some rather dicey statistical practices can make Bonferroni anti-conservative, but that really boils down to non-transparency. For instance: test main hypothesis A. If main hypothesis non-significant, test hypotheses A and B and control with Bonferroni. here you allowed yourself to test B only because A was negative, this makes tests A and B negatively correlated even if the data contributing to these tests are independent.) When the tests are independent, Bonferroni as you know is non-conservative in controlling the FWER. There is some grey area with respect to what constitutes a family of tests. This can be illustrated by considering subgroup analyses, here a global test may or may not have been significant, then the sample population is divvied up into K distinct groups. These groups are likely independent because they are arbitrary combinations of independent data from the parent dataset. You can view them as K distinct datasets, or 1 divided dataset, it doesn't matter. The point is that you conduct K tests. If you report the global hypothesis: at least one group showed heterogeneity of effect from the other groups, then you don't have to control for multiple comparisons. If, on the other hand, you report specific subgroup findings, you have to control for the K number of tests it took you to sniff that finding out. This is the XKCD Jelly Bean comic in a nutshell.
What is the definition of dataset (for Bonferroni purposes)?
The justification for control of multiple tests has to do with the family of tests. The family of tests can be mutually independent, which is often the case when they are drawn from different datasets
What is the definition of dataset (for Bonferroni purposes)? The justification for control of multiple tests has to do with the family of tests. The family of tests can be mutually independent, which is often the case when they are drawn from different datasets; if so, Bonferroni is a good way to control for FWER. But in general, the concept of a dataset doesn't even enter the picture when discussing multiplicity. It's assumed (incorrectly) that data in different datasets must, by design, be independent whereas two tests calculated with the same dataset must be dependent (also not necessarily correct). To justify and discuss the type of testing correction to use, one should consider the "family of tests". If the tests are dependent or correlated (that is to say that the $p$-value of one test actually depends on the $p$-value from another test), Bonferroni will be conservative. (NB: some rather dicey statistical practices can make Bonferroni anti-conservative, but that really boils down to non-transparency. For instance: test main hypothesis A. If main hypothesis non-significant, test hypotheses A and B and control with Bonferroni. here you allowed yourself to test B only because A was negative, this makes tests A and B negatively correlated even if the data contributing to these tests are independent.) When the tests are independent, Bonferroni as you know is non-conservative in controlling the FWER. There is some grey area with respect to what constitutes a family of tests. This can be illustrated by considering subgroup analyses, here a global test may or may not have been significant, then the sample population is divvied up into K distinct groups. These groups are likely independent because they are arbitrary combinations of independent data from the parent dataset. You can view them as K distinct datasets, or 1 divided dataset, it doesn't matter. The point is that you conduct K tests. If you report the global hypothesis: at least one group showed heterogeneity of effect from the other groups, then you don't have to control for multiple comparisons. If, on the other hand, you report specific subgroup findings, you have to control for the K number of tests it took you to sniff that finding out. This is the XKCD Jelly Bean comic in a nutshell.
What is the definition of dataset (for Bonferroni purposes)? The justification for control of multiple tests has to do with the family of tests. The family of tests can be mutually independent, which is often the case when they are drawn from different datasets
37,062
What is the definition of dataset (for Bonferroni purposes)?
This is a much harder question than one would think and I doubt there are clear answers. The answer is relatively clear when we talk about clinical trials for regulatory purposes (whatever the regulatory authority says). I have the impression that this is an area of pragmatic traditions that have evolved in a kind of ad-hoc and not necessarily philosophically consistent manner within each field of science. There are simply some standard conventions that are typically (but not always) followed in certain fields. However, even with a field where type I error rate control per study has a lot of tradition such as medicine, there is still a debate on this topic.
What is the definition of dataset (for Bonferroni purposes)?
This is a much harder question than one would think and I doubt there are clear answers. The answer is relatively clear when we talk about clinical trials for regulatory purposes (whatever the regulat
What is the definition of dataset (for Bonferroni purposes)? This is a much harder question than one would think and I doubt there are clear answers. The answer is relatively clear when we talk about clinical trials for regulatory purposes (whatever the regulatory authority says). I have the impression that this is an area of pragmatic traditions that have evolved in a kind of ad-hoc and not necessarily philosophically consistent manner within each field of science. There are simply some standard conventions that are typically (but not always) followed in certain fields. However, even with a field where type I error rate control per study has a lot of tradition such as medicine, there is still a debate on this topic.
What is the definition of dataset (for Bonferroni purposes)? This is a much harder question than one would think and I doubt there are clear answers. The answer is relatively clear when we talk about clinical trials for regulatory purposes (whatever the regulat
37,063
Is "batch normalization" applied for output layer as well?
It's probably a bad idea to apply batch norm on the last layer. I haven't seen any rigorous explanation of why, but it's probably because it introduces so much variance / randomness / regularization in the final outputs that it hurts training.
Is "batch normalization" applied for output layer as well?
It's probably a bad idea to apply batch norm on the last layer. I haven't seen any rigorous explanation of why, but it's probably because it introduces so much variance / randomness / regularization i
Is "batch normalization" applied for output layer as well? It's probably a bad idea to apply batch norm on the last layer. I haven't seen any rigorous explanation of why, but it's probably because it introduces so much variance / randomness / regularization in the final outputs that it hurts training.
Is "batch normalization" applied for output layer as well? It's probably a bad idea to apply batch norm on the last layer. I haven't seen any rigorous explanation of why, but it's probably because it introduces so much variance / randomness / regularization i
37,064
Can a logistic regression have both continuous and discrete variables as covariates or as regressors?
There is absolutely no problem, just code your categorical predictor(s) as dummy variables, or some other form of categorical-encoding. This can be used with all form of regression models. It is usually the type of the response ($Y$) variable which "dictates" the type of regression model that can be used, not the predictors. So, for a binary response, logistic regression, for a multinomial response, multinomial logistic regression, continuous response, muliple linear regression, and so on (there are of course alternatives). But in these decisions the type of predictor variable generally plays little role. See for instance Model for continuous response and a mix of continuous and categorical predictors and Predicting with both continuous and categorical features
Can a logistic regression have both continuous and discrete variables as covariates or as regressors
There is absolutely no problem, just code your categorical predictor(s) as dummy variables, or some other form of categorical-encoding. This can be used with all form of regression models. It is usual
Can a logistic regression have both continuous and discrete variables as covariates or as regressors? There is absolutely no problem, just code your categorical predictor(s) as dummy variables, or some other form of categorical-encoding. This can be used with all form of regression models. It is usually the type of the response ($Y$) variable which "dictates" the type of regression model that can be used, not the predictors. So, for a binary response, logistic regression, for a multinomial response, multinomial logistic regression, continuous response, muliple linear regression, and so on (there are of course alternatives). But in these decisions the type of predictor variable generally plays little role. See for instance Model for continuous response and a mix of continuous and categorical predictors and Predicting with both continuous and categorical features
Can a logistic regression have both continuous and discrete variables as covariates or as regressors There is absolutely no problem, just code your categorical predictor(s) as dummy variables, or some other form of categorical-encoding. This can be used with all form of regression models. It is usual
37,065
How to choose best proposal distribution for importance sampling
This is definitely an interesting question, but there is no clear answer as far as I can tell. Indeed, first, one has to define a criterion to optimise. For instance, this could be the variance: $$\min_{\mu,\sigma}\,\text{var}_{\mu,\sigma}\, h(X)f(X)\big/g_{\mu,\sigma}(X)$$or equivalently$$\min_{\mu,\sigma}\,\int \frac{h^2(x)f^2(x)}{g_{\mu,\sigma}(x)}\,\text{d}x$$for which there does exist a solution but one that is unlikely to be derived analytically. In a series of papers on population Monte Carlo methods that we wrote between 2005 and 2008, we construct a sequence of $\mu,\sigma$ towards deriving this optimum. Here is another reference aiming at an optimal step function. Other criteria could be used though, like minimising a functional distance between $|h(\cdot)|f(\cdot)$ and $g_{\mu,\sigma}(\cdot)$: $$\min_{\mu,\sigma}\,\mathcal{H}\{|h(\cdot)|f(\cdot),g_{\mu,\sigma}(\cdot)\}$$ where $\mathcal{H}$ can be the Hellinger distance, the Kullback-Leibler distance, the Wasserstein distance, or something else. The second issue is about the derivation of this optimum, which like the original one (which derivation dates back to the early days of importance sampling and not to our book),is most likely unavailable in realistic settings.
How to choose best proposal distribution for importance sampling
This is definitely an interesting question, but there is no clear answer as far as I can tell. Indeed, first, one has to define a criterion to optimise. For instance, this could be the variance: $$\mi
How to choose best proposal distribution for importance sampling This is definitely an interesting question, but there is no clear answer as far as I can tell. Indeed, first, one has to define a criterion to optimise. For instance, this could be the variance: $$\min_{\mu,\sigma}\,\text{var}_{\mu,\sigma}\, h(X)f(X)\big/g_{\mu,\sigma}(X)$$or equivalently$$\min_{\mu,\sigma}\,\int \frac{h^2(x)f^2(x)}{g_{\mu,\sigma}(x)}\,\text{d}x$$for which there does exist a solution but one that is unlikely to be derived analytically. In a series of papers on population Monte Carlo methods that we wrote between 2005 and 2008, we construct a sequence of $\mu,\sigma$ towards deriving this optimum. Here is another reference aiming at an optimal step function. Other criteria could be used though, like minimising a functional distance between $|h(\cdot)|f(\cdot)$ and $g_{\mu,\sigma}(\cdot)$: $$\min_{\mu,\sigma}\,\mathcal{H}\{|h(\cdot)|f(\cdot),g_{\mu,\sigma}(\cdot)\}$$ where $\mathcal{H}$ can be the Hellinger distance, the Kullback-Leibler distance, the Wasserstein distance, or something else. The second issue is about the derivation of this optimum, which like the original one (which derivation dates back to the early days of importance sampling and not to our book),is most likely unavailable in realistic settings.
How to choose best proposal distribution for importance sampling This is definitely an interesting question, but there is no clear answer as far as I can tell. Indeed, first, one has to define a criterion to optimise. For instance, this could be the variance: $$\mi
37,066
How to choose best proposal distribution for importance sampling
According to the paper "The sample size required in importance sampling" (Chatterjee & Diaconis, 2007, https://arxiv.org/pdf/1511.01437.pdf) the sample size required for importance sampling is approximately $$ \exp (D_{KL}(|h(\cdot)|f(\cdot) \ || \ g)) $$ Therefore, $D_{KL}(|h(\cdot)|f(\cdot) \ || \ g)$ should be used as a criterion if computationally tractable.
How to choose best proposal distribution for importance sampling
According to the paper "The sample size required in importance sampling" (Chatterjee & Diaconis, 2007, https://arxiv.org/pdf/1511.01437.pdf) the sample size required for importance sampling is approxi
How to choose best proposal distribution for importance sampling According to the paper "The sample size required in importance sampling" (Chatterjee & Diaconis, 2007, https://arxiv.org/pdf/1511.01437.pdf) the sample size required for importance sampling is approximately $$ \exp (D_{KL}(|h(\cdot)|f(\cdot) \ || \ g)) $$ Therefore, $D_{KL}(|h(\cdot)|f(\cdot) \ || \ g)$ should be used as a criterion if computationally tractable.
How to choose best proposal distribution for importance sampling According to the paper "The sample size required in importance sampling" (Chatterjee & Diaconis, 2007, https://arxiv.org/pdf/1511.01437.pdf) the sample size required for importance sampling is approxi
37,067
regression coefficient on sum of regressors
With a great deal of prodding (full credit to @whuber) I seem to have solved it: We re-write $y = \beta_1X_1 + \beta_2X_2 + \epsilon$ as $y = a(X_1 + X_2) + b(X_1 - X_2) + \epsilon$ $y = aX_1 + aX_2 + bX_1 - bX_2 + \epsilon$, $y = (a + b)X_1 + (a - b)X_2 + \epsilon$, therefore $\beta_1 = (a+b)$ and $\beta_2 = (a - b)$. Solving for $a$ and $b$ we get: $a = (\beta_1 + \beta_2)/2$ and $b = (\beta_1 - \beta_2)/2$ What I estimate is equivalent to $y = \delta(X_1 + X_2) + u,$ $u = b(X_1 - X_2) + \epsilon$. We know that the $k$th coefficient of a multiple regression can be recovered by first partialling out the regressors other than $k$. Thus, if I let $z = X_1 + X_2$ and $q = X_1 - X_2$, the regression coefficient $b$ in: $y = az + bq + \epsilon$ can be obtained with the steps (1) $y = \delta z + u$, (2) $q = \lambda z + e$ (3) $u = be + \epsilon$. Substituting expressions back in, $y = \delta z + be + \epsilon$ from (1). $y = \delta z + b(q - \lambda z) + \epsilon$ from (2). Therefore: $y = (\delta - b \lambda)z + bq + \epsilon$. Now we know that $(\delta - b\lambda ) = a = (\beta_1 + \beta_2)/2$, so we solve for $\delta$ which yields: $\delta = (\beta_1 + \beta_2)/2 + \lambda (\beta_1 - \beta_2)/2$ Here is some R code to check the solution, or to play around with: rep.func <- function(N = 100, b1 = 2, b2 = 10, s1 = 1, s2 = 5) { x1 <- rnorm(N, 0, s1) x2 <- rnorm(N, 0, s2) eps <- rnorm(N) y <- x1*b1 + x2*b2 + eps z <- x1 + x2 q <- x1 - x2 lambda <- lm(q ~ z - 1)$coefficients est.delta <- lm(y ~ z - 1)$coefficients est.betas <- lm(y ~ x1 + x2 - 1)$coefficients derived.delta <- sum(est.betas)/2 + lambda * (est.betas[1] - est.betas[2])/2 c("est.delta" = est.delta, "derived.delta" = derived.delta) } rep.func() #> est.delta.z derived.delta.z #> 9.77236 9.77236 library(ggplot2) res <- t(replicate(1000, rep.func())) all.equal(res[,1], res[,2]) #> [1] TRUE ggplot(as.data.frame(res), aes(est.delta.z, derived.delta.z)) + geom_point() + geom_smooth(method='lm') + theme_minimal() Update for case with P predictors, September 2020 Returning to this much later to generalize to case with P predictors at request. The underlying principle is the same: we are going to re-parameterize the true data generating process so that it contains a term for the quantity we are interested in, determine the value of the re-parameterized coefficients in terms of the original coefficients, evaluate the effect of ommitted variable bias on the estimation of the re-parameterized coefficient With $P$ predictors the true data generating process is: $$y = \sum_{p=1}^{P} \beta_p x_p + \epsilon$$. This true data generating process can be re-parameterized in a way that is mathematically equivalent as $$ y = a (\sum_{p=1}^{P} x_p) + \sum_{p=2}^{P} b_p (x_1 - x_p) + \epsilon \\ y = (a + \sum_{p=2}^{P} b_p) x_1 + \sum_{p=2}^{P}(a - b_p)x_p + \epsilon $$ Now we can solve for these new parameters (a and b's) in terms of the old parameters ($\beta$'s). $$ a + \sum_{p=2}^{P} b_p = \beta_1 \\ a - b_2 = \beta_2 \\ ... \\ a - b_P = \beta_P $$ therefore $$ a = \frac{\sum_{p=1}^{P} \beta_P}{P} = \bar{\beta} \\ b_p = \bar{\beta} - \beta_p $$. Now lets simplify our life a little by setting $$ z = \sum_{p=1}^{P}x_p \\ Q = x_1 - x_p \\ $$ so we can write $$ y = \bar{\beta}z + QA' + \epsilon $$ where $Q$ is an $N \times (P-1)$ matrix of our column differences and $A$ is a $(P-1)$-length row-vector collecting coefficients. We now move to problem 3, namely that we are not actually estimating the model above we are estimating $$ y = \delta z + u $$ We just repeat the process above for when P = 2 (the application of Frisch-Waughl-Lovell) but try not to lose track of dimensions: First we partial $z$ out of each column of $Q$ with some abuse of notation $$ q_p = \lambda_p z + e_p $$ so $\Lambda$ would be a vector of length $(P-1)$, and $e$ would be an $N$ by $(P-1)$ matrix. Then we can re-write $u$ with $z$ removed: $$ u = eA' + \epsilon $$ Plug-in terms $$ y = \delta z + eA' + \epsilon \\ y = \delta z + QA' - (\Lambda A') z + \epsilon \\ y = (\delta - \Lambda A') z + QA' + \epsilon \\ \delta = \bar{\beta} + \Lambda A' $$ In words, this seems to say that the regressor in the short regression of $y$ on the sum of predictors, will be equal to the average of the regression coefficients in the original model, plus a 'bias' term equal in magnitude to the inner product of the ommitted coefficients in the reparameterization and the regression coefficients from a regression of the ommitted variables on the included variable. Since its always risky to get your math from randos on the internet here's a simulation to support the derivation: ## Load mvtnorm because more interesting # when predictors are correlated library(mvtnorm) library(ggplot2) # create correlation matrix set.seed(42) rep_func <- function(N = 1000, P =10) { # how the predictors are correlated sig <- matrix(round(runif(P^2),2), nrow = P) diag(sig) <- 1:P sig[lower.tri(sig)] <- t(sig)[lower.tri(sig)] # Draw covariates X <- matrix(rmvnorm(N, mean = 1:P, sigma = sig), nrow = N) # draw true parameters betas <- rnorm(P) # draw true errors eps <- rnorm(N) # gen y y <- X %*% betas + eps # predictor sums Z <- rowSums(X) # create some helpers x1 <- X[,1] Q <- x1 - X[,2:P] # delta through regression of y on sum of predictors delta <- lm(y ~ Z - 1)$coef # true coefficients from reparameterization agg.reg <- lm(y ~ Z + Q - 1)$coef a <- agg.reg[1] A <- agg.reg[2:P] # lambdas lambda <- lm(Q ~ Z - 1)$coef # compare deltas delta_est <- sum(A * lambda) + mean(betas) c("lm_delta" = delta[[1]], "derived_delta" = delta_est) } rep_func() #> lm_delta derived_delta #> 0.3196803 0.3229088 res <- as.data.frame(t(replicate(1000, rep_func()))) #> Warning in rmvnorm(N, mean = 1:P, sigma = sig): sigma is numerically not #> positive semidefinite ggplot(res, aes(lm_delta - derived_delta)) + geom_density() + geom_vline(xintercept = 0) + hrbrthemes::theme_ipsum() + xlim(c(-1*sd(res$lm_delta), 1*sd(res$lm_delta))) + ggtitle("LM estimated delta - derived delta", subtitle = "X-axis +/- 1 standard error of estimate") Created on 2020-09-20 by the reprex package (v0.3.0)
regression coefficient on sum of regressors
With a great deal of prodding (full credit to @whuber) I seem to have solved it: We re-write $y = \beta_1X_1 + \beta_2X_2 + \epsilon$ as $y = a(X_1 + X_2) + b(X_1 - X_2) + \epsilon$ $y = aX_1 + aX_2 +
regression coefficient on sum of regressors With a great deal of prodding (full credit to @whuber) I seem to have solved it: We re-write $y = \beta_1X_1 + \beta_2X_2 + \epsilon$ as $y = a(X_1 + X_2) + b(X_1 - X_2) + \epsilon$ $y = aX_1 + aX_2 + bX_1 - bX_2 + \epsilon$, $y = (a + b)X_1 + (a - b)X_2 + \epsilon$, therefore $\beta_1 = (a+b)$ and $\beta_2 = (a - b)$. Solving for $a$ and $b$ we get: $a = (\beta_1 + \beta_2)/2$ and $b = (\beta_1 - \beta_2)/2$ What I estimate is equivalent to $y = \delta(X_1 + X_2) + u,$ $u = b(X_1 - X_2) + \epsilon$. We know that the $k$th coefficient of a multiple regression can be recovered by first partialling out the regressors other than $k$. Thus, if I let $z = X_1 + X_2$ and $q = X_1 - X_2$, the regression coefficient $b$ in: $y = az + bq + \epsilon$ can be obtained with the steps (1) $y = \delta z + u$, (2) $q = \lambda z + e$ (3) $u = be + \epsilon$. Substituting expressions back in, $y = \delta z + be + \epsilon$ from (1). $y = \delta z + b(q - \lambda z) + \epsilon$ from (2). Therefore: $y = (\delta - b \lambda)z + bq + \epsilon$. Now we know that $(\delta - b\lambda ) = a = (\beta_1 + \beta_2)/2$, so we solve for $\delta$ which yields: $\delta = (\beta_1 + \beta_2)/2 + \lambda (\beta_1 - \beta_2)/2$ Here is some R code to check the solution, or to play around with: rep.func <- function(N = 100, b1 = 2, b2 = 10, s1 = 1, s2 = 5) { x1 <- rnorm(N, 0, s1) x2 <- rnorm(N, 0, s2) eps <- rnorm(N) y <- x1*b1 + x2*b2 + eps z <- x1 + x2 q <- x1 - x2 lambda <- lm(q ~ z - 1)$coefficients est.delta <- lm(y ~ z - 1)$coefficients est.betas <- lm(y ~ x1 + x2 - 1)$coefficients derived.delta <- sum(est.betas)/2 + lambda * (est.betas[1] - est.betas[2])/2 c("est.delta" = est.delta, "derived.delta" = derived.delta) } rep.func() #> est.delta.z derived.delta.z #> 9.77236 9.77236 library(ggplot2) res <- t(replicate(1000, rep.func())) all.equal(res[,1], res[,2]) #> [1] TRUE ggplot(as.data.frame(res), aes(est.delta.z, derived.delta.z)) + geom_point() + geom_smooth(method='lm') + theme_minimal() Update for case with P predictors, September 2020 Returning to this much later to generalize to case with P predictors at request. The underlying principle is the same: we are going to re-parameterize the true data generating process so that it contains a term for the quantity we are interested in, determine the value of the re-parameterized coefficients in terms of the original coefficients, evaluate the effect of ommitted variable bias on the estimation of the re-parameterized coefficient With $P$ predictors the true data generating process is: $$y = \sum_{p=1}^{P} \beta_p x_p + \epsilon$$. This true data generating process can be re-parameterized in a way that is mathematically equivalent as $$ y = a (\sum_{p=1}^{P} x_p) + \sum_{p=2}^{P} b_p (x_1 - x_p) + \epsilon \\ y = (a + \sum_{p=2}^{P} b_p) x_1 + \sum_{p=2}^{P}(a - b_p)x_p + \epsilon $$ Now we can solve for these new parameters (a and b's) in terms of the old parameters ($\beta$'s). $$ a + \sum_{p=2}^{P} b_p = \beta_1 \\ a - b_2 = \beta_2 \\ ... \\ a - b_P = \beta_P $$ therefore $$ a = \frac{\sum_{p=1}^{P} \beta_P}{P} = \bar{\beta} \\ b_p = \bar{\beta} - \beta_p $$. Now lets simplify our life a little by setting $$ z = \sum_{p=1}^{P}x_p \\ Q = x_1 - x_p \\ $$ so we can write $$ y = \bar{\beta}z + QA' + \epsilon $$ where $Q$ is an $N \times (P-1)$ matrix of our column differences and $A$ is a $(P-1)$-length row-vector collecting coefficients. We now move to problem 3, namely that we are not actually estimating the model above we are estimating $$ y = \delta z + u $$ We just repeat the process above for when P = 2 (the application of Frisch-Waughl-Lovell) but try not to lose track of dimensions: First we partial $z$ out of each column of $Q$ with some abuse of notation $$ q_p = \lambda_p z + e_p $$ so $\Lambda$ would be a vector of length $(P-1)$, and $e$ would be an $N$ by $(P-1)$ matrix. Then we can re-write $u$ with $z$ removed: $$ u = eA' + \epsilon $$ Plug-in terms $$ y = \delta z + eA' + \epsilon \\ y = \delta z + QA' - (\Lambda A') z + \epsilon \\ y = (\delta - \Lambda A') z + QA' + \epsilon \\ \delta = \bar{\beta} + \Lambda A' $$ In words, this seems to say that the regressor in the short regression of $y$ on the sum of predictors, will be equal to the average of the regression coefficients in the original model, plus a 'bias' term equal in magnitude to the inner product of the ommitted coefficients in the reparameterization and the regression coefficients from a regression of the ommitted variables on the included variable. Since its always risky to get your math from randos on the internet here's a simulation to support the derivation: ## Load mvtnorm because more interesting # when predictors are correlated library(mvtnorm) library(ggplot2) # create correlation matrix set.seed(42) rep_func <- function(N = 1000, P =10) { # how the predictors are correlated sig <- matrix(round(runif(P^2),2), nrow = P) diag(sig) <- 1:P sig[lower.tri(sig)] <- t(sig)[lower.tri(sig)] # Draw covariates X <- matrix(rmvnorm(N, mean = 1:P, sigma = sig), nrow = N) # draw true parameters betas <- rnorm(P) # draw true errors eps <- rnorm(N) # gen y y <- X %*% betas + eps # predictor sums Z <- rowSums(X) # create some helpers x1 <- X[,1] Q <- x1 - X[,2:P] # delta through regression of y on sum of predictors delta <- lm(y ~ Z - 1)$coef # true coefficients from reparameterization agg.reg <- lm(y ~ Z + Q - 1)$coef a <- agg.reg[1] A <- agg.reg[2:P] # lambdas lambda <- lm(Q ~ Z - 1)$coef # compare deltas delta_est <- sum(A * lambda) + mean(betas) c("lm_delta" = delta[[1]], "derived_delta" = delta_est) } rep_func() #> lm_delta derived_delta #> 0.3196803 0.3229088 res <- as.data.frame(t(replicate(1000, rep_func()))) #> Warning in rmvnorm(N, mean = 1:P, sigma = sig): sigma is numerically not #> positive semidefinite ggplot(res, aes(lm_delta - derived_delta)) + geom_density() + geom_vline(xintercept = 0) + hrbrthemes::theme_ipsum() + xlim(c(-1*sd(res$lm_delta), 1*sd(res$lm_delta))) + ggtitle("LM estimated delta - derived delta", subtitle = "X-axis +/- 1 standard error of estimate") Created on 2020-09-20 by the reprex package (v0.3.0)
regression coefficient on sum of regressors With a great deal of prodding (full credit to @whuber) I seem to have solved it: We re-write $y = \beta_1X_1 + \beta_2X_2 + \epsilon$ as $y = a(X_1 + X_2) + b(X_1 - X_2) + \epsilon$ $y = aX_1 + aX_2 +
37,068
what is the intuition behind separate activation/memory paths in LSTM's?
In a vanilla RNN, there is only the activation path (also often referred to as the hidden-state $h_t$). LSTM added on the cell memory $c_t$ as a way to store information over long time-spans in particular. GRU, which was developed later, simplifies the LSTM by combining both the cell memory and the hidden-state. Therefore the intuition is that the cell memory stores longer-term information while the hidden-state is still used the same way as it is used in vanilla RNN, but later on, we discovered that it's possible to combine the two without too much degradation in performance. In other words, GRU is a sort of refinement on the ideas from LSTM. The cell memory is used to modify the activation path before the output, so intuitively, whatever relevant information in the long-term memory can be dumped into the short-term memory (the activations) right before an output needs to be extracted
what is the intuition behind separate activation/memory paths in LSTM's?
In a vanilla RNN, there is only the activation path (also often referred to as the hidden-state $h_t$). LSTM added on the cell memory $c_t$ as a way to store information over long time-spans in parti
what is the intuition behind separate activation/memory paths in LSTM's? In a vanilla RNN, there is only the activation path (also often referred to as the hidden-state $h_t$). LSTM added on the cell memory $c_t$ as a way to store information over long time-spans in particular. GRU, which was developed later, simplifies the LSTM by combining both the cell memory and the hidden-state. Therefore the intuition is that the cell memory stores longer-term information while the hidden-state is still used the same way as it is used in vanilla RNN, but later on, we discovered that it's possible to combine the two without too much degradation in performance. In other words, GRU is a sort of refinement on the ideas from LSTM. The cell memory is used to modify the activation path before the output, so intuitively, whatever relevant information in the long-term memory can be dumped into the short-term memory (the activations) right before an output needs to be extracted
what is the intuition behind separate activation/memory paths in LSTM's? In a vanilla RNN, there is only the activation path (also often referred to as the hidden-state $h_t$). LSTM added on the cell memory $c_t$ as a way to store information over long time-spans in parti
37,069
what is the intuition behind separate activation/memory paths in LSTM's?
To understand the intuition behind, one should probably know the evolution of the algorithms. 1. RNN An RNN network initially wants to model the sequence of inputs. By sharing the network parameters between the individual inputs, and using the output of previous input as part of the input for next computation, the sequence state can be accumulated along with the sequence, virtually achieving a variable-depth network. For this purpose, the most straightforward network design is to build a path between the hidden nodes (i.e., from the output of the hidden node to the input of it in the subsequent time-step). $$ c_t = \sigma( f \cdot c_{t-1} + g \cdot x_t) $$ Here, both $f$ and $g$ are parameters, hence single path suffices. This design is powerful enough to encode all the history information. But it has a problem of vanishing or exploding gradient. 2. Leaky Unit One way among others to overcome the problem is to use the leaky unit that provides linear self-connection in following way: $$ c_t = f\cdot c_{t-1} + (1-f) \cdot \hat x_t $$ Now since $c_t = f^{n}\cdot c_{t-n} + ...$, with $f$ being near one, the far distant history has no problem to be passed along. When $f$ being near zero, the history can be quickly forgotten. Leaky unit is a clever design. Then the problem is how to decide the value of $f$. It can be a constant, or a parameter, or a function of the history info. (It does not make much sense for $f$ to be a function of the input.) When we use a function for $f$, the function is called a gating function. Depending on the choice of $f$, leaky unit can be single or two paths. 3. LSTM The idea of using a gate function of the history info requires introducing another path between steps (i.e., from the output of hidden node to the input of the gating function.) So you have, $$ \begin{align*} f_t & = \sigma(h_{t-1}, x_t) \\ \end{align*} $$ And you know this is LSTM, if you have, $$ \begin{align*} c_t &= f_t \cdot c_{t-1} + i_t \cdot \hat x_t \\ h_t & = o_t \cdot c_t \\ & ... \end{align*} $$ With gating functions, the network can control very well how long and how short the memory should be. LSTM uses the output $h_{t-1}$ to gate not only the hidden node connection, but also the input and, especially the output from $c_{t}$ to $h_{t}$, which makes the two paths hard to be merged into one. Then $h_{t}$ is supposed to encode best the information for both long and short memory. 4. GRU As such, you definitely can use the cell state to compute the gating functions, but the original setup is more straightforward - with clean separation between gating and cell state. Inspired by the idea, one can come up with different designs. GRU is then designed to use single path, by removing the output gating and output the cell state directly. Then the cell state can be used by the subsequent step for both state update and gating function computation. You can interpret it differently anyway. For example, the reset gate in GRU can be considered as a shifted output gate of LSTM: it shifts from the output of current step (in LSTM) to the input of next step (in GRU). $$ \begin{align*} c_t &= f_t \cdot c_{t-1} + (1-f_t) \cdot \hat x_t \\ f_t & = \sigma(c_{t-1}, x_t) \\ & ... \end{align*} $$ A figure is better than a thousand words. You can further simplify GRU with fewer gates, for example, with the same update gate for reset gate. The point is, from the viewpoint of "path", there is no essential difference no matter if it is one or two.
what is the intuition behind separate activation/memory paths in LSTM's?
To understand the intuition behind, one should probably know the evolution of the algorithms. 1. RNN An RNN network initially wants to model the sequence of inputs. By sharing the network parameters b
what is the intuition behind separate activation/memory paths in LSTM's? To understand the intuition behind, one should probably know the evolution of the algorithms. 1. RNN An RNN network initially wants to model the sequence of inputs. By sharing the network parameters between the individual inputs, and using the output of previous input as part of the input for next computation, the sequence state can be accumulated along with the sequence, virtually achieving a variable-depth network. For this purpose, the most straightforward network design is to build a path between the hidden nodes (i.e., from the output of the hidden node to the input of it in the subsequent time-step). $$ c_t = \sigma( f \cdot c_{t-1} + g \cdot x_t) $$ Here, both $f$ and $g$ are parameters, hence single path suffices. This design is powerful enough to encode all the history information. But it has a problem of vanishing or exploding gradient. 2. Leaky Unit One way among others to overcome the problem is to use the leaky unit that provides linear self-connection in following way: $$ c_t = f\cdot c_{t-1} + (1-f) \cdot \hat x_t $$ Now since $c_t = f^{n}\cdot c_{t-n} + ...$, with $f$ being near one, the far distant history has no problem to be passed along. When $f$ being near zero, the history can be quickly forgotten. Leaky unit is a clever design. Then the problem is how to decide the value of $f$. It can be a constant, or a parameter, or a function of the history info. (It does not make much sense for $f$ to be a function of the input.) When we use a function for $f$, the function is called a gating function. Depending on the choice of $f$, leaky unit can be single or two paths. 3. LSTM The idea of using a gate function of the history info requires introducing another path between steps (i.e., from the output of hidden node to the input of the gating function.) So you have, $$ \begin{align*} f_t & = \sigma(h_{t-1}, x_t) \\ \end{align*} $$ And you know this is LSTM, if you have, $$ \begin{align*} c_t &= f_t \cdot c_{t-1} + i_t \cdot \hat x_t \\ h_t & = o_t \cdot c_t \\ & ... \end{align*} $$ With gating functions, the network can control very well how long and how short the memory should be. LSTM uses the output $h_{t-1}$ to gate not only the hidden node connection, but also the input and, especially the output from $c_{t}$ to $h_{t}$, which makes the two paths hard to be merged into one. Then $h_{t}$ is supposed to encode best the information for both long and short memory. 4. GRU As such, you definitely can use the cell state to compute the gating functions, but the original setup is more straightforward - with clean separation between gating and cell state. Inspired by the idea, one can come up with different designs. GRU is then designed to use single path, by removing the output gating and output the cell state directly. Then the cell state can be used by the subsequent step for both state update and gating function computation. You can interpret it differently anyway. For example, the reset gate in GRU can be considered as a shifted output gate of LSTM: it shifts from the output of current step (in LSTM) to the input of next step (in GRU). $$ \begin{align*} c_t &= f_t \cdot c_{t-1} + (1-f_t) \cdot \hat x_t \\ f_t & = \sigma(c_{t-1}, x_t) \\ & ... \end{align*} $$ A figure is better than a thousand words. You can further simplify GRU with fewer gates, for example, with the same update gate for reset gate. The point is, from the viewpoint of "path", there is no essential difference no matter if it is one or two.
what is the intuition behind separate activation/memory paths in LSTM's? To understand the intuition behind, one should probably know the evolution of the algorithms. 1. RNN An RNN network initially wants to model the sequence of inputs. By sharing the network parameters b
37,070
Choosing the number of clusters - clustering validation criterions vs domain theoretical considerations
The keys are finding meaningful clusters and what you value in the resulting clusters. Let me illustrate with a simple example. The example is two Gaussian clusters that are pretty well separated. Using k-means to divide the data into either 2 or 3 clusters we get these partitions: set.seed(1066) x = c(rnorm(200,0,1), rnorm(200,6,1)) y = rnorm(400,0,1) XY = data.frame(x,y) KM2 = kmeans(XY, 2) KM3 = kmeans(XY, 3) par(mfrow=c(1,2)) plot(XY, pch=20, col=KM2$cluster+1, asp=1) plot(XY, pch=20, col=KM3$cluster+1, asp=1) Silhouette says that you are better off with two clusters rather than three. library(cluster) plot(silhouette(KM2$cluster, dist(XY))) plot(silhouette(KM3$cluster, dist(XY))) It is useful to look at why the silhouette went down. First of all, it is easy to see that for the cluster on the right, the silhouette barely changed. The reason for the big drop in average silhouette is the cluster on the left that has been split in two. Why didn't silhouette like that? As I said, you need to look at what the metric favors. For each point, silhouette compares the average distance between the point and the other points in the same cluster with the average distance between that point and the nearest other cluster. When there were two clusters, points in each of the two clusters were well separated from the other cluster. Not so with three clusters. The points in the two clusters on the left are right up against each other. That is how the metric can go down. Silhouette not only rewards clusters where the points in a cluster are close together; it also punishes clusters that are not well separated from each other. So that gets to the "downstream purpose". There are times when having well separated clusters is not so important. For example, you can use k-means clustering on the colors in an image to group similar colors for image compression. In that case, as long as each cluster is reasonably consistent (compact) it does not matter if sometimes two clusters might be close to each other. However, often people use clustering as a way of understanding more fundamental structure in their data. For example, in the two Gaussians example above, two clusters shows the underlying structure better than three clusters. If you are looking for structure, you want the number of clusters that most closely represents natural groupings in your data. But these are two different goals: a grouping of points where points in the same cluster are near each other and a grouping that also separates different clusters Your argument that more clusters should always be better is OK as long as you only want points in the same cluster to be close. But that is not good if you are trying to discover underlying structure. The structure is what is in the data. Taking one cluster and calling it two is not an improvement.
Choosing the number of clusters - clustering validation criterions vs domain theoretical considerati
The keys are finding meaningful clusters and what you value in the resulting clusters. Let me illustrate with a simple example. The example is two Gaussian clusters that are pretty well separated. Us
Choosing the number of clusters - clustering validation criterions vs domain theoretical considerations The keys are finding meaningful clusters and what you value in the resulting clusters. Let me illustrate with a simple example. The example is two Gaussian clusters that are pretty well separated. Using k-means to divide the data into either 2 or 3 clusters we get these partitions: set.seed(1066) x = c(rnorm(200,0,1), rnorm(200,6,1)) y = rnorm(400,0,1) XY = data.frame(x,y) KM2 = kmeans(XY, 2) KM3 = kmeans(XY, 3) par(mfrow=c(1,2)) plot(XY, pch=20, col=KM2$cluster+1, asp=1) plot(XY, pch=20, col=KM3$cluster+1, asp=1) Silhouette says that you are better off with two clusters rather than three. library(cluster) plot(silhouette(KM2$cluster, dist(XY))) plot(silhouette(KM3$cluster, dist(XY))) It is useful to look at why the silhouette went down. First of all, it is easy to see that for the cluster on the right, the silhouette barely changed. The reason for the big drop in average silhouette is the cluster on the left that has been split in two. Why didn't silhouette like that? As I said, you need to look at what the metric favors. For each point, silhouette compares the average distance between the point and the other points in the same cluster with the average distance between that point and the nearest other cluster. When there were two clusters, points in each of the two clusters were well separated from the other cluster. Not so with three clusters. The points in the two clusters on the left are right up against each other. That is how the metric can go down. Silhouette not only rewards clusters where the points in a cluster are close together; it also punishes clusters that are not well separated from each other. So that gets to the "downstream purpose". There are times when having well separated clusters is not so important. For example, you can use k-means clustering on the colors in an image to group similar colors for image compression. In that case, as long as each cluster is reasonably consistent (compact) it does not matter if sometimes two clusters might be close to each other. However, often people use clustering as a way of understanding more fundamental structure in their data. For example, in the two Gaussians example above, two clusters shows the underlying structure better than three clusters. If you are looking for structure, you want the number of clusters that most closely represents natural groupings in your data. But these are two different goals: a grouping of points where points in the same cluster are near each other and a grouping that also separates different clusters Your argument that more clusters should always be better is OK as long as you only want points in the same cluster to be close. But that is not good if you are trying to discover underlying structure. The structure is what is in the data. Taking one cluster and calling it two is not an improvement.
Choosing the number of clusters - clustering validation criterions vs domain theoretical considerati The keys are finding meaningful clusters and what you value in the resulting clusters. Let me illustrate with a simple example. The example is two Gaussian clusters that are pretty well separated. Us
37,071
Choosing the number of clusters - clustering validation criterions vs domain theoretical considerations
Note that, cross validation can be also used in clustering problem. For example, in K means, increasing number of cluster will always decrease the objective we are fitting. An extreme case would be number of clusters equal to number of data points, and the objective is $0$. But that is an overfitted model and will fail on the testing set. My suggestion is checking the "clustering quality measure" on hold out testing data set.
Choosing the number of clusters - clustering validation criterions vs domain theoretical considerati
Note that, cross validation can be also used in clustering problem. For example, in K means, increasing number of cluster will always decrease the objective we are fitting. An extreme case would be n
Choosing the number of clusters - clustering validation criterions vs domain theoretical considerations Note that, cross validation can be also used in clustering problem. For example, in K means, increasing number of cluster will always decrease the objective we are fitting. An extreme case would be number of clusters equal to number of data points, and the objective is $0$. But that is an overfitted model and will fail on the testing set. My suggestion is checking the "clustering quality measure" on hold out testing data set.
Choosing the number of clusters - clustering validation criterions vs domain theoretical considerati Note that, cross validation can be also used in clustering problem. For example, in K means, increasing number of cluster will always decrease the objective we are fitting. An extreme case would be n
37,072
Prediction intervals for the outcome of a logistic regression with binomial response
One way this should work without bootstrapping (which in practice may be the fastest thing tho implement), would be: Assume that a normal approximation for the predicted log-odds ($x \hat{\beta}$) plus/minus its standard error works. Any logistic regression software will provide this. The percentiles of this distribution transform to probabilities via the anti-logit. One can find a (mixture of) beta distribution(s) that approximates the predictive distribution for the probability well. The predictive distribution for the outcome is then a (mixture of) beta-binomial distribution(s with the same mixing weights as used in step 3). Alternatively, one can "just" integrate out the log-odds from the joint predictive of outcome and log-odds, but I believe that will be a complete mess with no closed form solution.
Prediction intervals for the outcome of a logistic regression with binomial response
One way this should work without bootstrapping (which in practice may be the fastest thing tho implement), would be: Assume that a normal approximation for the predicted log-odds ($x \hat{\beta}$) pl
Prediction intervals for the outcome of a logistic regression with binomial response One way this should work without bootstrapping (which in practice may be the fastest thing tho implement), would be: Assume that a normal approximation for the predicted log-odds ($x \hat{\beta}$) plus/minus its standard error works. Any logistic regression software will provide this. The percentiles of this distribution transform to probabilities via the anti-logit. One can find a (mixture of) beta distribution(s) that approximates the predictive distribution for the probability well. The predictive distribution for the outcome is then a (mixture of) beta-binomial distribution(s with the same mixing weights as used in step 3). Alternatively, one can "just" integrate out the log-odds from the joint predictive of outcome and log-odds, but I believe that will be a complete mess with no closed form solution.
Prediction intervals for the outcome of a logistic regression with binomial response One way this should work without bootstrapping (which in practice may be the fastest thing tho implement), would be: Assume that a normal approximation for the predicted log-odds ($x \hat{\beta}$) pl
37,073
Difference between contextual anomaly and collective anomaly
That ECG timeseries is just one datastream, so it might not be the clearest example. If thinking about the presence of a pattern, I would say that missing a beat is just a regular anomaly. But can also be considered a contextual anomaly, the Y value is normal, but not at that particular point in time. A collective anomaly would require monitoring multiple datastreams, like the heartbeat of multiple persons. A contextual anomaly would require we have access to a different type of data from which we can infer the context. Let's imagine we have data of the heartbeat for many (1000) persons in a single city. BPM logged every 5 minutes for instance. The overall median BPM across all persons is say 80, and the 1% and 99% percentile say 30 and 180. A regular anomaly would be if a persons heartbeat value was less than 30 or higher than 180. Like 20 or 230. Example of values that would be normal could be 50 (very relaxed) or 150 (exercising). However, if the average across all 1000 people would be 150 BPM for one time interval, that is a collective anomaly. While fine individually, it is very unlikely that everyone is exercising at the same time! And if a person has a BPM of 150 at 5 AM in the morning, that is a likely contextual anomaly. The value is fine in general, but it's very unlikely that a person is exercising in the middle of the night! Here the context is time-of-day. Or if we have access to the state of the person, and the state == 'resting', and BPM is 150, that is also an contextual anomaly (with context being the persons state) - regardless of the time of day.
Difference between contextual anomaly and collective anomaly
That ECG timeseries is just one datastream, so it might not be the clearest example. If thinking about the presence of a pattern, I would say that missing a beat is just a regular anomaly. But can als
Difference between contextual anomaly and collective anomaly That ECG timeseries is just one datastream, so it might not be the clearest example. If thinking about the presence of a pattern, I would say that missing a beat is just a regular anomaly. But can also be considered a contextual anomaly, the Y value is normal, but not at that particular point in time. A collective anomaly would require monitoring multiple datastreams, like the heartbeat of multiple persons. A contextual anomaly would require we have access to a different type of data from which we can infer the context. Let's imagine we have data of the heartbeat for many (1000) persons in a single city. BPM logged every 5 minutes for instance. The overall median BPM across all persons is say 80, and the 1% and 99% percentile say 30 and 180. A regular anomaly would be if a persons heartbeat value was less than 30 or higher than 180. Like 20 or 230. Example of values that would be normal could be 50 (very relaxed) or 150 (exercising). However, if the average across all 1000 people would be 150 BPM for one time interval, that is a collective anomaly. While fine individually, it is very unlikely that everyone is exercising at the same time! And if a person has a BPM of 150 at 5 AM in the morning, that is a likely contextual anomaly. The value is fine in general, but it's very unlikely that a person is exercising in the middle of the night! Here the context is time-of-day. Or if we have access to the state of the person, and the state == 'resting', and BPM is 150, that is also an contextual anomaly (with context being the persons state) - regardless of the time of day.
Difference between contextual anomaly and collective anomaly That ECG timeseries is just one datastream, so it might not be the clearest example. If thinking about the presence of a pattern, I would say that missing a beat is just a regular anomaly. But can als
37,074
Difference between contextual anomaly and collective anomaly
In the same paper you mentioned in your question author says right after definitions of types of anomalies: It should be noted that while point anomalies can occur in any data set, collective anomalies can occur only in data sets in which data instances are related. In contrast, occurrence of contextual anomalies depends on the availability of context attributes in the data. A point anomaly or a collective anomaly can also be a contextual anomaly if analyzed with respect to a context. Thus a point anomaly detection problem or collective anomaly detection problem can be transformed to a contextual anomaly detection problem by incorporating the context information. So the answer to your first question is yes, this example can be seen as a set of contextual anomalies. In general, if you can define a context then it's a contextual anomaly. As for the last question, contextual anomalies and collective anomalies are detected with different techniques, which are briefly described in the same paper.
Difference between contextual anomaly and collective anomaly
In the same paper you mentioned in your question author says right after definitions of types of anomalies: It should be noted that while point anomalies can occur in any data set, collective anom
Difference between contextual anomaly and collective anomaly In the same paper you mentioned in your question author says right after definitions of types of anomalies: It should be noted that while point anomalies can occur in any data set, collective anomalies can occur only in data sets in which data instances are related. In contrast, occurrence of contextual anomalies depends on the availability of context attributes in the data. A point anomaly or a collective anomaly can also be a contextual anomaly if analyzed with respect to a context. Thus a point anomaly detection problem or collective anomaly detection problem can be transformed to a contextual anomaly detection problem by incorporating the context information. So the answer to your first question is yes, this example can be seen as a set of contextual anomalies. In general, if you can define a context then it's a contextual anomaly. As for the last question, contextual anomalies and collective anomalies are detected with different techniques, which are briefly described in the same paper.
Difference between contextual anomaly and collective anomaly In the same paper you mentioned in your question author says right after definitions of types of anomalies: It should be noted that while point anomalies can occur in any data set, collective anom
37,075
Why is $x_t = x_{t-1}+w_t$ not wide-sense/second-order stationary?
We need to assume only that There exists an index $t$ for which $\operatorname{Var}(X_{t})$ is finite. $\sigma^2 = \sigma^2_w$ is nonzero. The independence of $X_{t-1}$ and $w_t$ gives $$\operatorname{Var}(X_t) = \operatorname{Var}(X_{t-1}+w_t)=\operatorname{Var}(X_{t-1}) + \operatorname{Var}(w_t) = \operatorname{Var}(X_{t-1}) + \sigma^2.$$ Comparing the left and right sides in light of $(2)$ shows $\operatorname{Var}(X_{t-1})\ne \operatorname{Var}(X_{t}).$ (Assumption $(1)$ makes this a meaningful statement about finite numbers.) Consequently $(X_t)$ cannot be stationary--which, among other things, implies every $X_t$ has the same distribution--because it's not even second-order stationary.
Why is $x_t = x_{t-1}+w_t$ not wide-sense/second-order stationary?
We need to assume only that There exists an index $t$ for which $\operatorname{Var}(X_{t})$ is finite. $\sigma^2 = \sigma^2_w$ is nonzero. The independence of $X_{t-1}$ and $w_t$ gives $$\operatorna
Why is $x_t = x_{t-1}+w_t$ not wide-sense/second-order stationary? We need to assume only that There exists an index $t$ for which $\operatorname{Var}(X_{t})$ is finite. $\sigma^2 = \sigma^2_w$ is nonzero. The independence of $X_{t-1}$ and $w_t$ gives $$\operatorname{Var}(X_t) = \operatorname{Var}(X_{t-1}+w_t)=\operatorname{Var}(X_{t-1}) + \operatorname{Var}(w_t) = \operatorname{Var}(X_{t-1}) + \sigma^2.$$ Comparing the left and right sides in light of $(2)$ shows $\operatorname{Var}(X_{t-1})\ne \operatorname{Var}(X_{t}).$ (Assumption $(1)$ makes this a meaningful statement about finite numbers.) Consequently $(X_t)$ cannot be stationary--which, among other things, implies every $X_t$ has the same distribution--because it's not even second-order stationary.
Why is $x_t = x_{t-1}+w_t$ not wide-sense/second-order stationary? We need to assume only that There exists an index $t$ for which $\operatorname{Var}(X_{t})$ is finite. $\sigma^2 = \sigma^2_w$ is nonzero. The independence of $X_{t-1}$ and $w_t$ gives $$\operatorna
37,076
Why is $x_t = x_{t-1}+w_t$ not wide-sense/second-order stationary?
Now that I've finished a grad-level Time Series course, I can provide an answer. This is essentially exercise 2.8 in Brockwell and Davis' Introduction to Time Series and Forecasting, 3rd edition. For the $\text{AR}(1)$ model indicated above, we have $$x_t = \phi x_{t-1} + w_t\tag{*}$$ Using (*) above, for $n$ finite, we have $$\begin{align} x_t &= \phi x_{t-1} + w_t \\ &= \phi(\phi x_{t-2}+w_{t-1})+w_t \\ &= \phi^2 x_{t-2}+\phi w_{t-1}+w_t \\ &= \phi^2(\phi x_{t-3}+w_{t-2})+\phi w_{t-1}+w_t \\ &= \phi^3x_{t-3}+\phi^2w_{t-2}+\phi w_{t-1} + w_t \\ &\vdots \\ &= \phi^{n+1}x_{t-(n+1)}+\sum_{k=0}^{n}\phi^{k}w_{t-k}\text{.} \end{align}$$ This yields the equation $$x_t - \phi^{n+1}x_{t-(n+1)} = \sum_{k=0}^{n}\phi^kw_{t-k}\text{.}$$ With $w_t \overset{\text{iid}}{\sim}\mathcal{N}(0, \sigma^2_w)$, then $$\text{Var}\left(\sum_{k=0}^{n}\phi^kw_{t-k} \right) = \sum_{k=0}^{n}\phi^{2k}\sigma^2_w=(n+1)\sigma^2_w$$ with the assumption that $\phi = 1$. Assume by contradiction that the $x_t$ are stationary. Because the $x_t$ are stationary, the covariances $\text{Cov}(x_t, x_{t+h})$ are independent of $t$; in particular, $\text{Cov}(x_t, x_{t}) = \text{Var}(x_t)$ is independent of $t$. Write $\sigma^2_{X} = \text{Var}(x_t)$. Then $$\begin{align} \text{Var}(x_t - \phi^{n+1}x_{t-(n+1)}) &= \sigma^2_X + \phi^{2(n+1)}\sigma^2_X +2\cdot \text{Cov}(x_t, - \phi^{n+1}x_{t-(n+1)}) \\ &= \sigma^2_X + \phi^{2(n+1)}\sigma^2_X -2\phi^{n+1}\cdot\text{Cov}(x_t, x_{t-(n+1)}) \\ &\leq \sigma^2_X[1+\phi^{2(n+1)}] \tag{**} \\ &= 2\sigma^2_X \end{align}$$ hence for any $n$, $$(n+1)\sigma^2_w \leq 2\sigma^2_X\text{.}$$ Taking the limit as $n \to \infty$, it follows that $\sigma^2_X > \infty$, hence contradicting that $\sup_t \text{Var}(x_t) < \infty$ by stationarity. In (**), I made an assumption that $\text{Cov}(x_t, x_{t-(n+1)}) \geq 0$. To see why this is the case, write $$\begin{align} \text{Cov}(x_t, x_{t-(n+1)}) &= \text{Cov}\left(x_t, \dfrac{x_t - \sum_{k=0}^{n}\phi^k w_{t-k}}{\phi^{n+1}}\right) \\ &= \dfrac{1}{\phi^{n+1}}\text{Cov}\left(x_t, x_t-w_t \right) \\ &= \dfrac{\sigma^2_X}{\phi^{n+1}} \\ &\geq 0 \end{align}$$ due to independence of the $w_t$ from the $x_t$.
Why is $x_t = x_{t-1}+w_t$ not wide-sense/second-order stationary?
Now that I've finished a grad-level Time Series course, I can provide an answer. This is essentially exercise 2.8 in Brockwell and Davis' Introduction to Time Series and Forecasting, 3rd edition. For
Why is $x_t = x_{t-1}+w_t$ not wide-sense/second-order stationary? Now that I've finished a grad-level Time Series course, I can provide an answer. This is essentially exercise 2.8 in Brockwell and Davis' Introduction to Time Series and Forecasting, 3rd edition. For the $\text{AR}(1)$ model indicated above, we have $$x_t = \phi x_{t-1} + w_t\tag{*}$$ Using (*) above, for $n$ finite, we have $$\begin{align} x_t &= \phi x_{t-1} + w_t \\ &= \phi(\phi x_{t-2}+w_{t-1})+w_t \\ &= \phi^2 x_{t-2}+\phi w_{t-1}+w_t \\ &= \phi^2(\phi x_{t-3}+w_{t-2})+\phi w_{t-1}+w_t \\ &= \phi^3x_{t-3}+\phi^2w_{t-2}+\phi w_{t-1} + w_t \\ &\vdots \\ &= \phi^{n+1}x_{t-(n+1)}+\sum_{k=0}^{n}\phi^{k}w_{t-k}\text{.} \end{align}$$ This yields the equation $$x_t - \phi^{n+1}x_{t-(n+1)} = \sum_{k=0}^{n}\phi^kw_{t-k}\text{.}$$ With $w_t \overset{\text{iid}}{\sim}\mathcal{N}(0, \sigma^2_w)$, then $$\text{Var}\left(\sum_{k=0}^{n}\phi^kw_{t-k} \right) = \sum_{k=0}^{n}\phi^{2k}\sigma^2_w=(n+1)\sigma^2_w$$ with the assumption that $\phi = 1$. Assume by contradiction that the $x_t$ are stationary. Because the $x_t$ are stationary, the covariances $\text{Cov}(x_t, x_{t+h})$ are independent of $t$; in particular, $\text{Cov}(x_t, x_{t}) = \text{Var}(x_t)$ is independent of $t$. Write $\sigma^2_{X} = \text{Var}(x_t)$. Then $$\begin{align} \text{Var}(x_t - \phi^{n+1}x_{t-(n+1)}) &= \sigma^2_X + \phi^{2(n+1)}\sigma^2_X +2\cdot \text{Cov}(x_t, - \phi^{n+1}x_{t-(n+1)}) \\ &= \sigma^2_X + \phi^{2(n+1)}\sigma^2_X -2\phi^{n+1}\cdot\text{Cov}(x_t, x_{t-(n+1)}) \\ &\leq \sigma^2_X[1+\phi^{2(n+1)}] \tag{**} \\ &= 2\sigma^2_X \end{align}$$ hence for any $n$, $$(n+1)\sigma^2_w \leq 2\sigma^2_X\text{.}$$ Taking the limit as $n \to \infty$, it follows that $\sigma^2_X > \infty$, hence contradicting that $\sup_t \text{Var}(x_t) < \infty$ by stationarity. In (**), I made an assumption that $\text{Cov}(x_t, x_{t-(n+1)}) \geq 0$. To see why this is the case, write $$\begin{align} \text{Cov}(x_t, x_{t-(n+1)}) &= \text{Cov}\left(x_t, \dfrac{x_t - \sum_{k=0}^{n}\phi^k w_{t-k}}{\phi^{n+1}}\right) \\ &= \dfrac{1}{\phi^{n+1}}\text{Cov}\left(x_t, x_t-w_t \right) \\ &= \dfrac{\sigma^2_X}{\phi^{n+1}} \\ &\geq 0 \end{align}$$ due to independence of the $w_t$ from the $x_t$.
Why is $x_t = x_{t-1}+w_t$ not wide-sense/second-order stationary? Now that I've finished a grad-level Time Series course, I can provide an answer. This is essentially exercise 2.8 in Brockwell and Davis' Introduction to Time Series and Forecasting, 3rd edition. For
37,077
Variance and expectation of dot product
\begin{equation} \begin{aligned} E(\sum_{i=1}^{n} a_{i} b_{i}) &=\sum_{i=1}^{n}E( a_{i} b_{i}) \text{, due to linearity}\\ &= n E(XY) \text{ , due to i.i.d}\\ \end{aligned} \end{equation} Note that variance of sum of independent variables is equal to the sum of their variance. \begin{equation} \begin{aligned} var(\sum_{i=1}^{n} a_{i} b_{i}) &=\sum_{i=1}^{n}var( a_{i} b_{i}) \\ &=n~var(XY) \text{, due to i.i.d}\\ \end{aligned} \end{equation} Here $X,Y$ are independent are follows distribution $N(0,\sigma^2)$. You will have to use the property that $X$ and $Y$ are independent to evalute $E(XY)$ and $var(XY)$.
Variance and expectation of dot product
\begin{equation} \begin{aligned} E(\sum_{i=1}^{n} a_{i} b_{i}) &=\sum_{i=1}^{n}E( a_{i} b_{i}) \text{, due to linearity}\\ &= n E(XY) \text{ , due to i.i.d}\\ \end{aligned} \end{equation}
Variance and expectation of dot product \begin{equation} \begin{aligned} E(\sum_{i=1}^{n} a_{i} b_{i}) &=\sum_{i=1}^{n}E( a_{i} b_{i}) \text{, due to linearity}\\ &= n E(XY) \text{ , due to i.i.d}\\ \end{aligned} \end{equation} Note that variance of sum of independent variables is equal to the sum of their variance. \begin{equation} \begin{aligned} var(\sum_{i=1}^{n} a_{i} b_{i}) &=\sum_{i=1}^{n}var( a_{i} b_{i}) \\ &=n~var(XY) \text{, due to i.i.d}\\ \end{aligned} \end{equation} Here $X,Y$ are independent are follows distribution $N(0,\sigma^2)$. You will have to use the property that $X$ and $Y$ are independent to evalute $E(XY)$ and $var(XY)$.
Variance and expectation of dot product \begin{equation} \begin{aligned} E(\sum_{i=1}^{n} a_{i} b_{i}) &=\sum_{i=1}^{n}E( a_{i} b_{i}) \text{, due to linearity}\\ &= n E(XY) \text{ , due to i.i.d}\\ \end{aligned} \end{equation}
37,078
Epochs in keras meaning? [closed]
Since deep learning often separates training data into smaller batches when training, it is important to know when all the training examples have been processed a single time. This is called an epoch. There is a more detailed answer here: https://stackoverflow.com/a/31157729/7082163
Epochs in keras meaning? [closed]
Since deep learning often separates training data into smaller batches when training, it is important to know when all the training examples have been processed a single time. This is called an epoch.
Epochs in keras meaning? [closed] Since deep learning often separates training data into smaller batches when training, it is important to know when all the training examples have been processed a single time. This is called an epoch. There is a more detailed answer here: https://stackoverflow.com/a/31157729/7082163
Epochs in keras meaning? [closed] Since deep learning often separates training data into smaller batches when training, it is important to know when all the training examples have been processed a single time. This is called an epoch.
37,079
Epochs in keras meaning? [closed]
What is your batch size, training set size (num imgs)? But essentially, from this I can tell that you have finished the first epoch on a fit keras call with verbose=1. You have 7200 steps per epochs, which will mean your model will see (7200*batch_size) imgs. This may or may not be your entire training set, for steps per epochs it is common practice to use a steps_per_epoch = (training_set_size // batch_size) to ensure your model sees the entire training set in each epoch.
Epochs in keras meaning? [closed]
What is your batch size, training set size (num imgs)? But essentially, from this I can tell that you have finished the first epoch on a fit keras call with verbose=1. You have 7200 steps per epochs,
Epochs in keras meaning? [closed] What is your batch size, training set size (num imgs)? But essentially, from this I can tell that you have finished the first epoch on a fit keras call with verbose=1. You have 7200 steps per epochs, which will mean your model will see (7200*batch_size) imgs. This may or may not be your entire training set, for steps per epochs it is common practice to use a steps_per_epoch = (training_set_size // batch_size) to ensure your model sees the entire training set in each epoch.
Epochs in keras meaning? [closed] What is your batch size, training set size (num imgs)? But essentially, from this I can tell that you have finished the first epoch on a fit keras call with verbose=1. You have 7200 steps per epochs,
37,080
Rate of convergence of EM algorithm?
In the general case you need to verify that your problem setup satisfies certain properties for the EM algorithm to converge to a stationary point that is a local maximum. Further requirements are needed for global maximum. Assuming these criteria are met you can then quantify the rate of the convergence toward the global optimum. In the general case (and assuming you have global optimum) the most you can usually say is that the EM algorithm is a first order algorithm. First order algorithms are algorithms such that: $$|\theta^{k+1} - \theta^*| \leq \gamma |\theta^{k}-\theta^*|.$$ If $\gamma=1$ then convergence is linear and if $1<\gamma<2$ then the algorithm is said to have super-linear convergence and if $\gamma=2$ is quadratic convergence. The convergence rate really depends on the specifics of the problem. Many examples and an a pedagogic introduction to convergence rates of the EM algorithm are given in the book by McLachlin and Krishnan if you want more details. Xu and Jordan provide an in-depth study for the mixture of Gaussians case.
Rate of convergence of EM algorithm?
In the general case you need to verify that your problem setup satisfies certain properties for the EM algorithm to converge to a stationary point that is a local maximum. Further requirements are nee
Rate of convergence of EM algorithm? In the general case you need to verify that your problem setup satisfies certain properties for the EM algorithm to converge to a stationary point that is a local maximum. Further requirements are needed for global maximum. Assuming these criteria are met you can then quantify the rate of the convergence toward the global optimum. In the general case (and assuming you have global optimum) the most you can usually say is that the EM algorithm is a first order algorithm. First order algorithms are algorithms such that: $$|\theta^{k+1} - \theta^*| \leq \gamma |\theta^{k}-\theta^*|.$$ If $\gamma=1$ then convergence is linear and if $1<\gamma<2$ then the algorithm is said to have super-linear convergence and if $\gamma=2$ is quadratic convergence. The convergence rate really depends on the specifics of the problem. Many examples and an a pedagogic introduction to convergence rates of the EM algorithm are given in the book by McLachlin and Krishnan if you want more details. Xu and Jordan provide an in-depth study for the mixture of Gaussians case.
Rate of convergence of EM algorithm? In the general case you need to verify that your problem setup satisfies certain properties for the EM algorithm to converge to a stationary point that is a local maximum. Further requirements are nee
37,081
How to show that a sufficient statistic is NOT minimal sufficient?
As you stated: If there exist $x1,x2∈X$ such that $f(x1)=f(x2)$ but $g(x1)≠g(x2)$, then $g$ can not be written as a function of $f$, i.e. there exists no function $h$ with $g=h∘f$. So, for example, in the case where $X_1, ...., X_n$ are independent Bernoulli random variables. We can prove that $(x_1, ...., x_n)$ is not minimally sufficient by showing that it is not a function of $\sum x_i$. This is obvious, since the function must map $1$ to both $(1,0,0...,0,0,0)$ and $(0,0,0...,0,0,1)$.
How to show that a sufficient statistic is NOT minimal sufficient?
As you stated: If there exist $x1,x2∈X$ such that $f(x1)=f(x2)$ but $g(x1)≠g(x2)$, then $g$ can not be written as a function of $f$, i.e. there exists no function $h$ with $g=h∘f$. So, for example,
How to show that a sufficient statistic is NOT minimal sufficient? As you stated: If there exist $x1,x2∈X$ such that $f(x1)=f(x2)$ but $g(x1)≠g(x2)$, then $g$ can not be written as a function of $f$, i.e. there exists no function $h$ with $g=h∘f$. So, for example, in the case where $X_1, ...., X_n$ are independent Bernoulli random variables. We can prove that $(x_1, ...., x_n)$ is not minimally sufficient by showing that it is not a function of $\sum x_i$. This is obvious, since the function must map $1$ to both $(1,0,0...,0,0,0)$ and $(0,0,0...,0,0,1)$.
How to show that a sufficient statistic is NOT minimal sufficient? As you stated: If there exist $x1,x2∈X$ such that $f(x1)=f(x2)$ but $g(x1)≠g(x2)$, then $g$ can not be written as a function of $f$, i.e. there exists no function $h$ with $g=h∘f$. So, for example,
37,082
How to show that a sufficient statistic is NOT minimal sufficient?
I have been thinking about this problem some more recently, and here is what I have come up with. Let $\Omega$ be a probability space, then a random variable $X$ is a measurable function $X: \Omega \to \mathcal{X}$, where $\mathcal{X}$ is a measurable space ($\mathcal{X}$ has a designated $\sigma$-algebra, and $X$ is measurable with respect to this $\sigma$-algebra and the $\sigma$-algebra on $\Omega$). The distribution of $X$ is just the pullback measure on $\mathcal{X}$, i.e. $\mathbb{P}_{\mathcal{X}}(A) = \mathbb{P}_{\Omega}(X^{-1}(A))$. Then a statistic of $X$ is any measurable* function $f: \mathcal{X} \to \mathcal{Y}$, where $\mathcal{Y}$ is another arbitrary measurable space. Given two statistics $f: \mathcal{X} \to \mathcal{Y}$, $g: \mathcal{X} \to \mathcal{Z}$, what does it mean for "$g$ to be a function of $f$"? As far as I can tell, it seems to mean that there exists a measurable** function $h: \mathcal{Y} \to \mathcal{Z}$ such that $g = h \circ f$, i.e. that $g$ can be factored through by $f$. (In other words, "$g$ must be well-defined as a function on $f(\mathcal{X}) \subseteq \mathcal{Y}$".) So when is such factoring possible? Let's think in terms of equivalence relations. Specifically, define the equivalence relation $\sim_f$ on $\mathcal{X}$ by $x_1 \sim_f x_2 \iff f(x_1) = f(x_2)$, likewise, define the equivalence relation $\sim_g$ on $\mathcal{X}$ by $x_1 \sim_g x_2 \iff g(x_1) = g(x_2)$. Then in order for $g$ to be factorable by $f$, the equivalence relations $\sim_f$ and $\sim_g$ need to be compatible with each other, in the sense*** that for any $x_1, x_2 \in \mathcal{X}$, $x_1 \sim_f x_2 \implies x_1 \sim_g x_2$, i.e. $g$ can't take two elements which are equivalent under $f$ and map them to values which aren't equivalent under $g$, i.e. "$g$ can't undo the information reduction previously performed by $f$". In other words, $g$ has to be well-defined as a function on $\mathcal{X}/\sim_f \cong f(\mathcal{X})$, i.e. there exists has to exist a function $\tilde{g}: \mathcal{X}/\sim_f \to \mathcal{Z}$ such that $g = \tilde{g} \circ \pi_f$, where $\pi_f$ is the canonical projection $\mathcal{X} \to \mathcal{X}/\sim_f$. (For those uncomfortable with abstract non-sense, $\pi_f$ is essentially $f$, and $\tilde{g}$ is essentially $h$. The above formulation just makes analogies with other situations more clear.) In simplest possible words, $g$ can be written as function of $f$ if and only if, for any $x_1, x_2 \in \mathcal{X}$, $f(x_1) = f(x_2) \implies g(x_1) = g(x_2)$. For example, take $\mathcal{X} = \mathcal{Y} = \mathcal{Z} = \mathbb{R}$ and $X$ an arbitrary real-valued random variable, then $g: x \mapsto x^2$ can be written as a function of $f: x \mapsto x$, but not vice versa, because $x_1 = x_2 \implies x_1^2 = x_2^2$, but $1^2 = (-1)^2$ but $1 \not= -1$. In particular, assume that every equivalence class under $\sim_f$ is a singleton (i.e. $f$ is injective). Then $g$ can always be written as a function of $f$, since $\mathcal{X}/\sim_f \cong \mathcal{X}$, i.e. $f(x_1) = f(x_2) \implies x_1 = x_2$ means that $x_1 = x_2 \iff f(x_1) = f(x_2)$ (in general, for not-necessarily injective $f$, only one direction holds), so our condition becomes $x_1 = x_2 \implies g(x_1) = g(x_2)$, which is trivially satisfied for any $g: \mathcal{X} \to \mathcal{Z}$. (To define $h$, it can do anything it wants on $\mathcal{Y} \setminus f(\mathcal{X})$ as long as it's measurable, and then for any $y \in f(\mathcal{X})$, i.e. such that $y = f(x)$ for some $x \in \mathcal{X}$, define $h$ to be $h: y = f(x) \mapsto g(x)$. This is well-defined when $f$ is injective because there is a unique $x \in \mathcal{X}$ such that $f(x) = y$. More generally, this is only defined when, regardless of which $x$ we choose in $f^{-1}(y)$, $g(x)$ still is the same value, i.e. $f(x_1)=f(x_2)\ (=y) \implies g(x_1)=g(x_2)$.) Also, looking at Theorem 3.11 in Keener, its statement is kind of clunky, but thinking in the above terms, I believe it can be re-written as: Suppose $T$ is a sufficient statistic****. Then a sufficient condition for $T$ to be minimal sufficient is that it can be written as a function of the likelihood ratio. From this it becomes immediately clear that the likelihood ratio has to itself be minimal sufficient. This also leads to the conclusion that: If there exist $x_1, x_2 \in \mathcal{X}$ such that $f(x_1)=f(x_2)$ but $g(x_1) \not= g(x_2)$, then $g$ can not be written as a function of $f$, i.e. there exists no function $h$ with $g = h \circ f$. Thus the condition isn't actually as difficult to show as I had thought. *Keener doesn't address the issue of whether a statistic needs to be a measurable or just an arbitrary function or not. However, I am pretty sure that a statistic has to be a measurable function, because otherwise we couldn't define a distribution for it, i.e. a pullback measure. **If $h$ were not measurable, we would have a contradiction because both $f$ and $g$ are measurable and the composition of measurable functions is again measurable. At the very least, $h$ has to be measurable restricted to $f(\mathcal{X}) \subseteq \mathcal{Y}$, although I think this would mean in most reasonable cases that $h$ would have to agree on $f(\mathcal{X})$ with a function that is measurable on all of $\mathcal{Y}$ (take $h|_{f(\mathcal{X})}$ on $f(\mathcal{X})$ and e.g. $z$ on $Y \setminus f(\mathcal{X})$ if there exists a measurable point $z \in \mathcal{Z}$, note that both $f(\mathcal{X})$ and $Y \setminus f(\mathcal{X})$ should be measurable in $Y$) so w.l.o.g. $h$ can be assumed to be measurable on all of $\mathcal{Y}$. ***At least this is necessary and sufficient for the existence of an arbitrary function factoring through $g$ and over $f$, and I think ** implies that if such an arbitrary function exists, this function also must be measurable, since both $f$ and $g$ are, i.e. it really would be a statistic $\mathcal{Y} \to \mathcal{Z}$. ****The condition given is equivalent to $T$ being sufficient by the factorization theorem, 3.6.
How to show that a sufficient statistic is NOT minimal sufficient?
I have been thinking about this problem some more recently, and here is what I have come up with. Let $\Omega$ be a probability space, then a random variable $X$ is a measurable function $X: \Omega \t
How to show that a sufficient statistic is NOT minimal sufficient? I have been thinking about this problem some more recently, and here is what I have come up with. Let $\Omega$ be a probability space, then a random variable $X$ is a measurable function $X: \Omega \to \mathcal{X}$, where $\mathcal{X}$ is a measurable space ($\mathcal{X}$ has a designated $\sigma$-algebra, and $X$ is measurable with respect to this $\sigma$-algebra and the $\sigma$-algebra on $\Omega$). The distribution of $X$ is just the pullback measure on $\mathcal{X}$, i.e. $\mathbb{P}_{\mathcal{X}}(A) = \mathbb{P}_{\Omega}(X^{-1}(A))$. Then a statistic of $X$ is any measurable* function $f: \mathcal{X} \to \mathcal{Y}$, where $\mathcal{Y}$ is another arbitrary measurable space. Given two statistics $f: \mathcal{X} \to \mathcal{Y}$, $g: \mathcal{X} \to \mathcal{Z}$, what does it mean for "$g$ to be a function of $f$"? As far as I can tell, it seems to mean that there exists a measurable** function $h: \mathcal{Y} \to \mathcal{Z}$ such that $g = h \circ f$, i.e. that $g$ can be factored through by $f$. (In other words, "$g$ must be well-defined as a function on $f(\mathcal{X}) \subseteq \mathcal{Y}$".) So when is such factoring possible? Let's think in terms of equivalence relations. Specifically, define the equivalence relation $\sim_f$ on $\mathcal{X}$ by $x_1 \sim_f x_2 \iff f(x_1) = f(x_2)$, likewise, define the equivalence relation $\sim_g$ on $\mathcal{X}$ by $x_1 \sim_g x_2 \iff g(x_1) = g(x_2)$. Then in order for $g$ to be factorable by $f$, the equivalence relations $\sim_f$ and $\sim_g$ need to be compatible with each other, in the sense*** that for any $x_1, x_2 \in \mathcal{X}$, $x_1 \sim_f x_2 \implies x_1 \sim_g x_2$, i.e. $g$ can't take two elements which are equivalent under $f$ and map them to values which aren't equivalent under $g$, i.e. "$g$ can't undo the information reduction previously performed by $f$". In other words, $g$ has to be well-defined as a function on $\mathcal{X}/\sim_f \cong f(\mathcal{X})$, i.e. there exists has to exist a function $\tilde{g}: \mathcal{X}/\sim_f \to \mathcal{Z}$ such that $g = \tilde{g} \circ \pi_f$, where $\pi_f$ is the canonical projection $\mathcal{X} \to \mathcal{X}/\sim_f$. (For those uncomfortable with abstract non-sense, $\pi_f$ is essentially $f$, and $\tilde{g}$ is essentially $h$. The above formulation just makes analogies with other situations more clear.) In simplest possible words, $g$ can be written as function of $f$ if and only if, for any $x_1, x_2 \in \mathcal{X}$, $f(x_1) = f(x_2) \implies g(x_1) = g(x_2)$. For example, take $\mathcal{X} = \mathcal{Y} = \mathcal{Z} = \mathbb{R}$ and $X$ an arbitrary real-valued random variable, then $g: x \mapsto x^2$ can be written as a function of $f: x \mapsto x$, but not vice versa, because $x_1 = x_2 \implies x_1^2 = x_2^2$, but $1^2 = (-1)^2$ but $1 \not= -1$. In particular, assume that every equivalence class under $\sim_f$ is a singleton (i.e. $f$ is injective). Then $g$ can always be written as a function of $f$, since $\mathcal{X}/\sim_f \cong \mathcal{X}$, i.e. $f(x_1) = f(x_2) \implies x_1 = x_2$ means that $x_1 = x_2 \iff f(x_1) = f(x_2)$ (in general, for not-necessarily injective $f$, only one direction holds), so our condition becomes $x_1 = x_2 \implies g(x_1) = g(x_2)$, which is trivially satisfied for any $g: \mathcal{X} \to \mathcal{Z}$. (To define $h$, it can do anything it wants on $\mathcal{Y} \setminus f(\mathcal{X})$ as long as it's measurable, and then for any $y \in f(\mathcal{X})$, i.e. such that $y = f(x)$ for some $x \in \mathcal{X}$, define $h$ to be $h: y = f(x) \mapsto g(x)$. This is well-defined when $f$ is injective because there is a unique $x \in \mathcal{X}$ such that $f(x) = y$. More generally, this is only defined when, regardless of which $x$ we choose in $f^{-1}(y)$, $g(x)$ still is the same value, i.e. $f(x_1)=f(x_2)\ (=y) \implies g(x_1)=g(x_2)$.) Also, looking at Theorem 3.11 in Keener, its statement is kind of clunky, but thinking in the above terms, I believe it can be re-written as: Suppose $T$ is a sufficient statistic****. Then a sufficient condition for $T$ to be minimal sufficient is that it can be written as a function of the likelihood ratio. From this it becomes immediately clear that the likelihood ratio has to itself be minimal sufficient. This also leads to the conclusion that: If there exist $x_1, x_2 \in \mathcal{X}$ such that $f(x_1)=f(x_2)$ but $g(x_1) \not= g(x_2)$, then $g$ can not be written as a function of $f$, i.e. there exists no function $h$ with $g = h \circ f$. Thus the condition isn't actually as difficult to show as I had thought. *Keener doesn't address the issue of whether a statistic needs to be a measurable or just an arbitrary function or not. However, I am pretty sure that a statistic has to be a measurable function, because otherwise we couldn't define a distribution for it, i.e. a pullback measure. **If $h$ were not measurable, we would have a contradiction because both $f$ and $g$ are measurable and the composition of measurable functions is again measurable. At the very least, $h$ has to be measurable restricted to $f(\mathcal{X}) \subseteq \mathcal{Y}$, although I think this would mean in most reasonable cases that $h$ would have to agree on $f(\mathcal{X})$ with a function that is measurable on all of $\mathcal{Y}$ (take $h|_{f(\mathcal{X})}$ on $f(\mathcal{X})$ and e.g. $z$ on $Y \setminus f(\mathcal{X})$ if there exists a measurable point $z \in \mathcal{Z}$, note that both $f(\mathcal{X})$ and $Y \setminus f(\mathcal{X})$ should be measurable in $Y$) so w.l.o.g. $h$ can be assumed to be measurable on all of $\mathcal{Y}$. ***At least this is necessary and sufficient for the existence of an arbitrary function factoring through $g$ and over $f$, and I think ** implies that if such an arbitrary function exists, this function also must be measurable, since both $f$ and $g$ are, i.e. it really would be a statistic $\mathcal{Y} \to \mathcal{Z}$. ****The condition given is equivalent to $T$ being sufficient by the factorization theorem, 3.6.
How to show that a sufficient statistic is NOT minimal sufficient? I have been thinking about this problem some more recently, and here is what I have come up with. Let $\Omega$ be a probability space, then a random variable $X$ is a measurable function $X: \Omega \t
37,083
AUC score less than 0.5 for logistic regression
UPDATE: Sycorax posted the following link in the comments: Can a random forest be used for feature selection in multiple linear regression? deals with this problem and describes why this might not work too well. Similar explanation: your data/model might suffer from the Curse of dimensionality, as logistic regression is prone to fall to this curse. Several points: (might be comments with enough reputation) pipe.fit(X_train, y_train) Where did you define the training data? Have you tried class_weight="balanced" for logistic regression? This might produce a different rate of misclassification. What were the results without the RFE step?
AUC score less than 0.5 for logistic regression
UPDATE: Sycorax posted the following link in the comments: Can a random forest be used for feature selection in multiple linear regression? deals with this problem and describes why this might not wor
AUC score less than 0.5 for logistic regression UPDATE: Sycorax posted the following link in the comments: Can a random forest be used for feature selection in multiple linear regression? deals with this problem and describes why this might not work too well. Similar explanation: your data/model might suffer from the Curse of dimensionality, as logistic regression is prone to fall to this curse. Several points: (might be comments with enough reputation) pipe.fit(X_train, y_train) Where did you define the training data? Have you tried class_weight="balanced" for logistic regression? This might produce a different rate of misclassification. What were the results without the RFE step?
AUC score less than 0.5 for logistic regression UPDATE: Sycorax posted the following link in the comments: Can a random forest be used for feature selection in multiple linear regression? deals with this problem and describes why this might not wor
37,084
How to do permutation test on model coefficients when including an interaction term?
As I'm just starting with permutation tests, I though a question was a good idea. Indeed, thanks to comments by @Glen_b and @user43849, I perceived many misunderstandings and inconsistencies of the theory from my part. For one, I was thinking about testing the magnitude of the coefficient instead of the effect, which is what actual interest. So, as I'm learning, an actual answer to be criticized sounded just as good. To answer this question and appoint a permutation strategy that complies with my requirements, I resorted to Anderson MJ, Legendre P. "An empirical comparison of permutation methods for tests of partial regression coefficients in a linear model." Journal of statistical computation and simulation 62.3 (1999): 271-303. There, the authors do empirical comparisons between four permutational strategies, in addition to normal theory $t$-statistic tests: Permutation of Raw Data (Manly, 1991, 1997) Permutation of Residuals under Reduced Model (Freedman & Lane, 1983) Permutation of Residuals under Reduced Model (Kennedy, 1995) Permutation of Residuals under Full Model (ter Braak, 1990, 1992) Here I'll quote the description given to the strategy put forward by Manly. Given a model $Y=\mu+\beta_{1\cdot2}X+\beta_{2\cdot1}Z+\epsilon$: The Variable Y is regressed on X and Z together (using least squares) to obtain an estimate $b_{2\cdot 1}$ of $\beta_{2\cdot 1}$ and a value of the usual $t$-statistic, $t_\text{ref}$ for testing $\beta_{2\cdot 1}=0$ for the real data. We hereafter refer to this as the reference value of $t$ The Y values are permuted randomly to obtain permuted values Y*. The Y* values are regressed on X and Z (unpermuted) together to obtain an estimate $b_{2\cdot 1}^*$ of $\beta_{2\cdot 1}$ and a value of $t^*$ for the permuted data. Steps 2-3 are repeated a large number of times, yielding a distribution of values of $t^*$ under permutation. The absolute value of the reference value $t_\text{ref}$ is placed in the distribution of absolute values of $t^*$ obtained under permutation (for a two-tailed $t$-test). The probability is calculated as the proportion of values in this distribution greater than or equal, in absolute value, to the absolute value of $t_\text{ref}$ (Hope, 1968) So this strategy conserves the covariance of the independent variables X and Z. Other methods focus on the testing of partial coefficients in isolation, and these are discussed in the text. Also, possible drawbacks of the strategy of permutation of raw data are given both in the text and in the literature.
How to do permutation test on model coefficients when including an interaction term?
As I'm just starting with permutation tests, I though a question was a good idea. Indeed, thanks to comments by @Glen_b and @user43849, I perceived many misunderstandings and inconsistencies of the th
How to do permutation test on model coefficients when including an interaction term? As I'm just starting with permutation tests, I though a question was a good idea. Indeed, thanks to comments by @Glen_b and @user43849, I perceived many misunderstandings and inconsistencies of the theory from my part. For one, I was thinking about testing the magnitude of the coefficient instead of the effect, which is what actual interest. So, as I'm learning, an actual answer to be criticized sounded just as good. To answer this question and appoint a permutation strategy that complies with my requirements, I resorted to Anderson MJ, Legendre P. "An empirical comparison of permutation methods for tests of partial regression coefficients in a linear model." Journal of statistical computation and simulation 62.3 (1999): 271-303. There, the authors do empirical comparisons between four permutational strategies, in addition to normal theory $t$-statistic tests: Permutation of Raw Data (Manly, 1991, 1997) Permutation of Residuals under Reduced Model (Freedman & Lane, 1983) Permutation of Residuals under Reduced Model (Kennedy, 1995) Permutation of Residuals under Full Model (ter Braak, 1990, 1992) Here I'll quote the description given to the strategy put forward by Manly. Given a model $Y=\mu+\beta_{1\cdot2}X+\beta_{2\cdot1}Z+\epsilon$: The Variable Y is regressed on X and Z together (using least squares) to obtain an estimate $b_{2\cdot 1}$ of $\beta_{2\cdot 1}$ and a value of the usual $t$-statistic, $t_\text{ref}$ for testing $\beta_{2\cdot 1}=0$ for the real data. We hereafter refer to this as the reference value of $t$ The Y values are permuted randomly to obtain permuted values Y*. The Y* values are regressed on X and Z (unpermuted) together to obtain an estimate $b_{2\cdot 1}^*$ of $\beta_{2\cdot 1}$ and a value of $t^*$ for the permuted data. Steps 2-3 are repeated a large number of times, yielding a distribution of values of $t^*$ under permutation. The absolute value of the reference value $t_\text{ref}$ is placed in the distribution of absolute values of $t^*$ obtained under permutation (for a two-tailed $t$-test). The probability is calculated as the proportion of values in this distribution greater than or equal, in absolute value, to the absolute value of $t_\text{ref}$ (Hope, 1968) So this strategy conserves the covariance of the independent variables X and Z. Other methods focus on the testing of partial coefficients in isolation, and these are discussed in the text. Also, possible drawbacks of the strategy of permutation of raw data are given both in the text and in the literature.
How to do permutation test on model coefficients when including an interaction term? As I'm just starting with permutation tests, I though a question was a good idea. Indeed, thanks to comments by @Glen_b and @user43849, I perceived many misunderstandings and inconsistencies of the th
37,085
Are more features always better?
It depends on what you want your model to achieve. Are these features necessary to your model? For example, gene expression dataset usually have 10000 features (one for each gene), but they are all usually necessary to help determine significant genetic pathways. If the features are not helpful, then a small feature size that provides a similar accuracy to a model with a large feature is always more helpful because performance increases in terms of obtaining classification/regression results faster. Too many features is often a bad thing. It may lead to overfitting, which makes your model specifically fit to your data, and makes the model perform horribly with another dataset. Another thing to note is that a larger feature usually requires a larger sample size, otherwise you will also be doing a lot of regularization. That is why there is are lot of research papers in the field of feature reduction.
Are more features always better?
It depends on what you want your model to achieve. Are these features necessary to your model? For example, gene expression dataset usually have 10000 features (one for each gene), but they are all
Are more features always better? It depends on what you want your model to achieve. Are these features necessary to your model? For example, gene expression dataset usually have 10000 features (one for each gene), but they are all usually necessary to help determine significant genetic pathways. If the features are not helpful, then a small feature size that provides a similar accuracy to a model with a large feature is always more helpful because performance increases in terms of obtaining classification/regression results faster. Too many features is often a bad thing. It may lead to overfitting, which makes your model specifically fit to your data, and makes the model perform horribly with another dataset. Another thing to note is that a larger feature usually requires a larger sample size, otherwise you will also be doing a lot of regularization. That is why there is are lot of research papers in the field of feature reduction.
Are more features always better? It depends on what you want your model to achieve. Are these features necessary to your model? For example, gene expression dataset usually have 10000 features (one for each gene), but they are all
37,086
Are more features always better?
The probability of a spurious feature-target correlation in the training set is small, but nonzero. So, we use a test set. The probability of a spurious feature-target correlation in the training set that also holds in the test set is even smaller. However, with each new feature (hypothesis), you increase the risk that this occurs. It's worse with a small number of observations (and better with more). But, say that your friend has the first 100 features and you have 1000 and you're trying to predict housing prices. It may be that location is the 101$^{st}$ feature. There is something to be said for restricting the variance of the model while keeping all of the features---e.g., with shrinkage, dropout, or ensembles. I think that the answer to your question is that more information is always better, but that it comes with a risk.
Are more features always better?
The probability of a spurious feature-target correlation in the training set is small, but nonzero. So, we use a test set. The probability of a spurious feature-target correlation in the training set
Are more features always better? The probability of a spurious feature-target correlation in the training set is small, but nonzero. So, we use a test set. The probability of a spurious feature-target correlation in the training set that also holds in the test set is even smaller. However, with each new feature (hypothesis), you increase the risk that this occurs. It's worse with a small number of observations (and better with more). But, say that your friend has the first 100 features and you have 1000 and you're trying to predict housing prices. It may be that location is the 101$^{st}$ feature. There is something to be said for restricting the variance of the model while keeping all of the features---e.g., with shrinkage, dropout, or ensembles. I think that the answer to your question is that more information is always better, but that it comes with a risk.
Are more features always better? The probability of a spurious feature-target correlation in the training set is small, but nonzero. So, we use a test set. The probability of a spurious feature-target correlation in the training set
37,087
Use Fisher's Exact Test or a Hypergeometric Test?
Hypergeometric test assesses the extremeness of observing x or more of "good" cases (overlap) and thus same as a one-sided Fisher's exact test (where the alternative hypothesis is "greater" in R jargon). If you do not care about the directionality then you can use two-sided Fisher's exact test.
Use Fisher's Exact Test or a Hypergeometric Test?
Hypergeometric test assesses the extremeness of observing x or more of "good" cases (overlap) and thus same as a one-sided Fisher's exact test (where the alternative hypothesis is "greater" in R jargo
Use Fisher's Exact Test or a Hypergeometric Test? Hypergeometric test assesses the extremeness of observing x or more of "good" cases (overlap) and thus same as a one-sided Fisher's exact test (where the alternative hypothesis is "greater" in R jargon). If you do not care about the directionality then you can use two-sided Fisher's exact test.
Use Fisher's Exact Test or a Hypergeometric Test? Hypergeometric test assesses the extremeness of observing x or more of "good" cases (overlap) and thus same as a one-sided Fisher's exact test (where the alternative hypothesis is "greater" in R jargo
37,088
Use Fisher's Exact Test or a Hypergeometric Test?
Just a comment to show the result of R commands, both approaches being the same. > phyper(15, 150, 400-150, 50) [1] 0.1549789 > fisher.test(matrix(c(15, 50-15, 150-15, 400 - 50 - 150 + 15), nr = 2), alternative = "less")$p.value [1] 0.1549789
Use Fisher's Exact Test or a Hypergeometric Test?
Just a comment to show the result of R commands, both approaches being the same. > phyper(15, 150, 400-150, 50) [1] 0.1549789 > fisher.test(matrix(c(15, 50-15, 150-15, 400 - 50 - 150 + 15), nr = 2),
Use Fisher's Exact Test or a Hypergeometric Test? Just a comment to show the result of R commands, both approaches being the same. > phyper(15, 150, 400-150, 50) [1] 0.1549789 > fisher.test(matrix(c(15, 50-15, 150-15, 400 - 50 - 150 + 15), nr = 2), alternative = "less")$p.value [1] 0.1549789
Use Fisher's Exact Test or a Hypergeometric Test? Just a comment to show the result of R commands, both approaches being the same. > phyper(15, 150, 400-150, 50) [1] 0.1549789 > fisher.test(matrix(c(15, 50-15, 150-15, 400 - 50 - 150 + 15), nr = 2),
37,089
Repeated measures ANOVA vs. factorial ANOVA with subject factor: understanding "error strata" and Error() term in aov
... two-way ANOVA tests the effect of A by comparing SS of A with the residual SS, while RM-ANOVA tests the effect of A by comparing SS of A with the A⋅subject interaction SS. 1) Does this difference automatically follow from the repeated-measures structure of the data, or is it some convention? It follows from the repeated-measures structure of the data. The basic principle of analysis of variance is that we compare the variation between levels of a treatment to the variation between the units that received that treatment. What makes the repeated measure case somewhat tricky is estimating this second variation. In this simplest case, the thing we're interested in are the differences between the levels of A. So how many units have we measured that difference on? It's the number of subjects, not the number of observations. That is, each subject gives us an additional independent piece of information about the difference, not each observation. Adding more repeated measures increases the accuracy of our information about each subject, but doesn't give us more subjects. What the RM-Anova does when using the A--subject interaction as the error term is to correctly use the variation in differences between levels of A between subjects as the variation to test the A level effect. Using the observational error instead uses the variation in the repeated measures on each individual, which is not correct. Consider a case where you take more and more data on just a couple individuals. If using the observation level error, you would eventually reach statistical significance, even though you only have a couple individuals. You need more individuals, not more data on them, to really increase the power. 2) Does this difference between two-way ANOVA and RM-ANOVA correspond to testing two different nulls? If so, what exactly are they and why would we use different nulls in these two cases? Nope, same null hypothesis. What's different is how we estimate the test statistic and its null distribution. 3) Two-way ANOVA's test can be understood as an F-test between two nested models: the full model, and the model without A. Can RM-ANOVA be understood in a similar way? Yes, but not perhaps in the way you're hoping for. As you see in the output from aov, one way of thinking about these kinds of models is that they're really several models in one, with one model for each level. One can fit the models for higher levels individually by averaging the data over the lower levels. That is, an RM-Anova test for A is equivalent to a standard Anova on the averaged data. Then one can compare models in the usual way. > library(plyr) > d2 <- ddply(d, ~Xw1 + id, summarize, Y=mean(Y)) > a1 <- aov(Y ~ id, d2) > a2 <- aov(Y ~ Xw1+id, d2) > anova(a1, a2) Analysis of Variance Table Model 1: Y ~ id Model 2: Y ~ Xw1 + id Res.Df RSS Df Sum of Sq F Pr(>F) 1 40 55475 2 38 23717 2 31758 25.442 9.734e-08 *** --- Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1 Alternatively, one can fit the full aov with all the data but without the term of interest, and then compare the fit with the full aov with the term of interest, but then to compare models you need to pick out the level of the model you've changed (here the id:Xw1 level) and then you can compare those two models. > summary(aov(Y ~ 1 + Error(id/Xw1), d)) Error: id Df Sum Sq Mean Sq F value Pr(>F) Residuals 19 31359 1650 Error: id:Xw1 Df Sum Sq Mean Sq F value Pr(>F) Residuals 40 166426 4161 Error: Within Df Sum Sq Mean Sq F value Pr(>F) Residuals 120 340490 2837 > (F <- ((166426 - 71151)/2) / (71151/38)) [1] 25.44202 > pf(F, 2, 38, lower=FALSE) [1] 9.732778e-08
Repeated measures ANOVA vs. factorial ANOVA with subject factor: understanding "error strata" and Er
... two-way ANOVA tests the effect of A by comparing SS of A with the residual SS, while RM-ANOVA tests the effect of A by comparing SS of A with the A⋅subject interaction SS. 1) Does this differ
Repeated measures ANOVA vs. factorial ANOVA with subject factor: understanding "error strata" and Error() term in aov ... two-way ANOVA tests the effect of A by comparing SS of A with the residual SS, while RM-ANOVA tests the effect of A by comparing SS of A with the A⋅subject interaction SS. 1) Does this difference automatically follow from the repeated-measures structure of the data, or is it some convention? It follows from the repeated-measures structure of the data. The basic principle of analysis of variance is that we compare the variation between levels of a treatment to the variation between the units that received that treatment. What makes the repeated measure case somewhat tricky is estimating this second variation. In this simplest case, the thing we're interested in are the differences between the levels of A. So how many units have we measured that difference on? It's the number of subjects, not the number of observations. That is, each subject gives us an additional independent piece of information about the difference, not each observation. Adding more repeated measures increases the accuracy of our information about each subject, but doesn't give us more subjects. What the RM-Anova does when using the A--subject interaction as the error term is to correctly use the variation in differences between levels of A between subjects as the variation to test the A level effect. Using the observational error instead uses the variation in the repeated measures on each individual, which is not correct. Consider a case where you take more and more data on just a couple individuals. If using the observation level error, you would eventually reach statistical significance, even though you only have a couple individuals. You need more individuals, not more data on them, to really increase the power. 2) Does this difference between two-way ANOVA and RM-ANOVA correspond to testing two different nulls? If so, what exactly are they and why would we use different nulls in these two cases? Nope, same null hypothesis. What's different is how we estimate the test statistic and its null distribution. 3) Two-way ANOVA's test can be understood as an F-test between two nested models: the full model, and the model without A. Can RM-ANOVA be understood in a similar way? Yes, but not perhaps in the way you're hoping for. As you see in the output from aov, one way of thinking about these kinds of models is that they're really several models in one, with one model for each level. One can fit the models for higher levels individually by averaging the data over the lower levels. That is, an RM-Anova test for A is equivalent to a standard Anova on the averaged data. Then one can compare models in the usual way. > library(plyr) > d2 <- ddply(d, ~Xw1 + id, summarize, Y=mean(Y)) > a1 <- aov(Y ~ id, d2) > a2 <- aov(Y ~ Xw1+id, d2) > anova(a1, a2) Analysis of Variance Table Model 1: Y ~ id Model 2: Y ~ Xw1 + id Res.Df RSS Df Sum of Sq F Pr(>F) 1 40 55475 2 38 23717 2 31758 25.442 9.734e-08 *** --- Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1 Alternatively, one can fit the full aov with all the data but without the term of interest, and then compare the fit with the full aov with the term of interest, but then to compare models you need to pick out the level of the model you've changed (here the id:Xw1 level) and then you can compare those two models. > summary(aov(Y ~ 1 + Error(id/Xw1), d)) Error: id Df Sum Sq Mean Sq F value Pr(>F) Residuals 19 31359 1650 Error: id:Xw1 Df Sum Sq Mean Sq F value Pr(>F) Residuals 40 166426 4161 Error: Within Df Sum Sq Mean Sq F value Pr(>F) Residuals 120 340490 2837 > (F <- ((166426 - 71151)/2) / (71151/38)) [1] 25.44202 > pf(F, 2, 38, lower=FALSE) [1] 9.732778e-08
Repeated measures ANOVA vs. factorial ANOVA with subject factor: understanding "error strata" and Er ... two-way ANOVA tests the effect of A by comparing SS of A with the residual SS, while RM-ANOVA tests the effect of A by comparing SS of A with the A⋅subject interaction SS. 1) Does this differ
37,090
Repeated measures ANOVA vs. factorial ANOVA with subject factor: understanding "error strata" and Error() term in aov
This note depends on results contained in Moser's Linear Models: A Mean Model Approach. I'll cite some results from this book in what follows. When I saw your question, I started looking through the book: this note is just the way my thoughts were organized after. Let $y \sim \mathcal{N}_n(\mu, \Sigma)$ be the response, with $\mu$ containing the fixed effects and $\Sigma$ containing the random effects. Take $y^T A_i y$ to be the sums of squares corresponding to each term (covariates and interactions) in the model. Note that these sums of squares are invariant to whether terms are fixed or random. Assume that each $A_i$ is symmetric and idempotent, which will be true in most models of interest. When it holds that $$I = \sum_i A_i,$$ which amounts to the sums of squares corresponding to a decomposition into orthogonal subspaces since we've assumed the $A_i$ are projectors, and $$\Sigma = \sum_i c_i A_i,$$ by Cochran's theorem (lemma 3.4.1), \begin{equation} y^T A_i y \sim c_i \chi^2_{d_i} (\mu^T A_i \mu/c_i), \end{equation} for $d_i = tr(A_i)$, and $y^T A_j y$ is independent of $y^T A_k y$ for $j \ne k$. The term $$\tilde{F} = \frac{y^T A_j y / d_j}{y^T A_k y / d_k} \sim \frac{c_j \chi_{d_j}^2(\mu^T A_j \mu / c_j)/d_j}{c_k \chi_{d_k}^2(\mu^T A_k \mu / c_k)/d_k}$$ is indeed a (central) $F$ statistic if and only if \begin{align*} \frac{c_j}{c_k} & = 1 , \tag{1} \\ \mu^T A_j \mu & = 0 , \tag{2} \\ \mu^T A_k \mu & = 0 , \textrm{ and }\tag{3} \end{align*} When these three conditions are satisfied, we can compute $p$-values corresponding to the statistic $\tilde{F}$. These terms basically just aid in computability since the $c_i$'s depend on variance components and the the noncentrality parameters depend on the mean $\mu$. The second condition ensures that $\tilde{F}$ will have (at least) a noncentral $F$ distribution. Under the second condition, the third condition gives that $\tilde{F}$ has a central $F$ distribution. The expected mean squares ($\mathrm{EMS}$) corresponding to the $i^\mathrm{th}$ sum of squares $y^T A_i y$ is $$\mathrm{EMS}_i := \frac{1}{tr(A_i)} \mathbb{E} [y^T A_i y] = \frac{tr(A_i \Sigma) + \mu^T A_i \mu}{tr(A_i)} = c_i + \frac{\mu^T A_i \mu}{tr(A_i)},$$ where $tr(A_i\Sigma) = c_i \, tr(A_i)$ due to cor 3.1.2. The ratio $$\frac{\mathrm{EMS}_j}{\mathrm{EMS}_k} = \frac{c_j + \frac{\mu^T A_j \mu}{tr(A_j)}}{c_k + \frac{\mu^T A_k \mu}{tr(A_k)}} = 1$$ if conditions $(1)$, $(2)$, and $(3)$ hold. This is why people inspect the ratio of $\mathrm{EMS}$ when determining which sums of squares to divide to form a $F$ statistic to test a particular null hypothesis. We use conditions $(1), (2)$, and $(3)$ to specify the null hypothesis. In my experience, when the term (corresponding to $j$) that we're interested in testing is random, we make the null hypothesis be $c_j/c_k = 1$, and, when it's fixed, we make the null hypothesis be $y^T A_j y = 0$. In particular, these amount to us being able to choose $k$ so that the rest of conditions $(1), (2)$ and $(3)$ are satisfied. Such a choice of $k$ isn't always possible, which leads to Behrens-Fisher-like difficulties. This doesn't explain anything particularly related to the problem at hand, but that just amounts to computing $\mu$ and $\Sigma$. I hope this is seen to be a useful way of thinking about the problem. Note that example 4.4.1 works out what all of the quantities above are in the two-way ANOVA example. The difference is due to the problem structure and not due to convention. These different approaches (two-way vs repeated measure) change $\mu$ and $\Sigma$, which changes the EMS, which changes which $k$ we choose to construct the test. Let's consider the model \begin{equation} y_{ijk} = \mu_0 + \mathrm{id}_i + \mathrm{Xw1}_{j} + \mathrm{id * Xw1}_{ij} + \mathrm{R(id * Xw1)}_{k(ij)}, \end{equation} where $i$ denotes the level of $\mathrm{id}$, etc. Here $k$ denotes which of the 3 replicates are being considered. We now introduce some helpful vector notation: write $y = (y_{111}, y_{112}, y_{113}, y_{121}, \dots y_{20,3,3})$. Since this data is balanced, we can make us of kronecker product notation. (As an aside, I was told that Charlie Van Loan once called the kronecker product "the operation of the 2000s!") Define $\bar{J} \in \mathbb{R}^{m \times m}$ to be the matrix with all entries equal to $\frac{1}{m}$ and $C=I-\bar{J}$ to be the centering matrix. (The centering matrix is so named since, for instance, $\|C x \|_2^2 = \sum_i (x_i - \bar{x})^2$ for a vector $x$.) With this kronecker product notation under out belt, we can find the matrices $A_i$ mentioned above. The sum of squares correspoding to $\mu_0$ is \begin{equation} SS(\mu_0) = n (\bar{y}_{\cdot\cdot\cdot})^2 = \|(\bar{J} \otimes \bar{J} \otimes \bar{J}) y\|_2^2 = y^T (\bar{J} \otimes \bar{J} \otimes \bar{J}) y, \end{equation} where the first component $\bar{J} \in \mathbb{R}^{20 \times 20}$, the second is in $\mathbb{R}^{3 \times 3}$, and the third is in $\mathbb{R}^{3 \times 3}$. Generally speaking, the matrices in those components will always be of that size. Also, the sum of squares due to $\mathrm{id}$ is \begin{equation} SS(\mathrm{id}) = \sum_{ijk} (\bar{y}_{i\cdot\cdot} - \bar{y}_{\cdot \cdot \cdot})^2 = \|(C \otimes \bar{J} \otimes \bar{J}) y\|_2^2 = y^T (C \otimes \bar{J} \otimes \bar{J}) y. \end{equation} Notice that $SS(\mathrm{id})$ does indeed measure the variation among levels of $\mathrm{id}$. Similarly, the other matrices are $A_{Xw1} = \bar{J} \otimes C \otimes \bar{J}$, $A_{id * Xw1} = C \otimes C \otimes \bar{J}$, and $A_{R()} = I \otimes I \otimes C$. This is shown to be consistent with aov by running code to give, for instance, the residual sum of squares $SS(\mathrm{R(id * Xw1)}) = y^T A_{R()} y$: mY <- c() for(j in 1:(nrow(d)/3)) { mY <- c(mY, rep(mean(d$Y[3*(j-1)+(1:3)]), 3)) } sum((d$Y - mY)^2) #this is the residual sum of squares At this point, we have to make some modeling choices. In particular, we have to decide whether $\mathrm{id}$ is a random effect. Let's first suppose that it isn't a random effect, so that all effects besides the replication are fixed. Then \begin{equation} \mathbb{E} [y_{ijk}] = \mu_{ij} = \mu_0 + \mathrm{id}_i + \mathrm{Xw1}_{jk} + \mathrm{id * Xw1}_{ij} \end{equation} and $R(\mathrm{id * Xw1})_{k(ij)} \sim_{iid} \mathcal{N}(0, \sigma^2)$. Notice that there's no dependence between distinct observations. In vector notation, we can write $$y \sim \mathcal{N} (\mu, \Sigma)$$ for $\mu = \mathbb{E} [y] = (\mu_{11}, \mu_{12}, \dots, \mu_{20,3}) \otimes \mathbf{1}_{3}$ and $\Sigma = \sigma^2 (I \otimes I \otimes I)$. Noticing that the sum of all $5$ of the $A$'s defined above is the identity, we know by cochran's theorem that, among other things, $$SS(\mathrm{Xw1}) = y^T A_{Xw1} y \sim \sigma^2 \chi^2_{(19)(1)(1)} (\mu^T A_{Xw1} \mu / \sigma^2)$$ and $$SS(\mathrm{R(id * Xw1)}) = y^T A_{R()} y \sim \sigma^2 \chi^2_{(20)(3)(2)} (\mu^T A_{R()} \mu / \sigma^2)$$ and these sums of squares are independent. Now, in line with what we discussed above, we want conditions $(1), (2),$ and $(3)$ to hold. Notice that condition $(1)$ holds (because there's no other variance components to complicate things.) What's really cool to notice now is that $\mu^T A_{R()} \mu = 0$, since $\mu$ is constant along this third "component" that is being centered by $A_{R()}$. This means that $(3)$ is behind us. Therefore we only have to fret about condition $(2)$: if we assume it (as a null hypothesis) then we're assuming that $0 = \mu^T A_{Xw1} \mu = \sum_{ijk} (\mu_{ij} - \bar{\mu}_{i \cdot})^2$, which is the same as $\mu_{ij} = \bar{\mu}_{i \cdot}$ for all $i,j$, which is the same as $\mathrm{Xw1}_j = 0$ and $\mathrm{id * Xw1}_{ij} = 0$ for all $i,j$ (since the mean level is in the other terms.) In summary, the null hypothesis can be seen to just be testing whether a noncentrality parameter is zero, which is equivalent to effects concerning the covariate being zero. The repeated measures case follows a similar line of reasoning, where we instead make the modeling choice that the $\mathrm{id}$ effect is random. There, condition $(1)$ will become the null hypothesis. Related to the R command, like you mention in the comments to the original post, this error term just specifies which terms are to be considered as random effects. (Note that all terms that are to be included in the model should be plainly input or input inside the Error() term. This is why there's a difference between id/Xw1 = id + id:Xw1 and id being in the Error term. Non-included terms are lumped in with the error in the sense that $A_{R()} + A_{id * Xw1}$ is relabeled as $A_{R()}$.) Here's the explicit details related to the repeated measures case where the terms related to $\mathrm{id}$ (which are $\mathrm{id}$ and $\mathrm{id * Xw1}$) are random. We'll see that this is the more interesting case. There we have the same sum of squares matrices (since they don't depend on whether a factor is fixed or random.) The covariance matrix there is \begin{align*} \Sigma & \stackrel{(a)}{=} \sigma^2_{id} (I \otimes J \otimes J) + \sigma^2_{id * Xw1} (I \otimes C \otimes J) + \sigma^2_{R()} (I \otimes I \otimes I) \\ & = \sigma^2_{id} (3)(3) (A_{\mu_0} + A_{id}) + \sigma^2_{id * Xw1} (3) (A_{Xw1} + A_{id * Xw1}) + \sigma^2_{R()} (A_{\mu_0} + A_{id} + A_{Xw1} + A_{id * Xw1} + A_{R()}) \\ & = ((3)(3)\sigma^2_{id} + \sigma^2_{R()})A_{\mu_0} + ((3)(3)\sigma^2_{id} + \sigma^2_{R()}) A_{id} + ((3)\sigma^2_{id * Xw1} + \sigma^2_{R()}) A_{Xw1} + ((3)\sigma^2_{id * Xw1} + \sigma^2_{R()}) A_{id * Xw1} + \sigma^2_{R()} A_{R()}, \end{align*} where $J$ is the matrix of all ones. The first and last summand on the right hand side of equality (a) offer intuitive explanations: the first summand shows that there's an additional source of correlation among observations with the same $\mathrm{id}$, and the third summand shows, as in the two-way example, the base source of variation. This second summand is less intuitive, but among observations with the same \mathrm{id}, it can be seen as increasing variation between observations with same $\mathrm{Xw1}$ while decreasing variation between observations with different $\mathrm{Xw1}$, due to the shape of $I \otimes C \otimes J$. Also, since all of the terms related to $\mathrm{id}$ are random, the mean is just due to $\mathrm{Xw1}$, so that $\mathbb{E} [y_{ijk}] = \mu_{j} = \mu_0 + \mathrm{Xw1}_j$, or $\mu = \mathbf{1} \otimes (\mu_1, \mu_2, \mu_3) \otimes \mathbf{1}$. Notice that, related to condition $(1)$: we have $$\frac{c_{Xw1} }{c_{id * Xw1}} = \frac{(3)\sigma^2_{id*Xw1} + \sigma^2_{R()}}{(3)\sigma^2_{id*Xw1} + \sigma^2_{R()}} = 1,$$ while $$\frac{c_{Xw1}}{c_{R()}} = \frac{(3)\sigma^2_{id*Xw1} + \sigma^2_{R()}}{\sigma^2_{R()}} \neq 1.$$ Further, related to condition $(3)$ both $\mu^T A_{Xw1*id} \mu = 0$ and $\mu^T A_{R()} \mu = 0$. Also, related to condition $(2)$: we see that \begin{align*} \mu^T A_{Xw1} \mu & = \|A_{Xw1} \mu\|_2^2 \\ & = \|(\bar{J} \otimes C \otimes \bar{J}) (\mathbf{1} \otimes (\mu_1, \mu_2 \mu_3)' \otimes \mathbf{1}) \|_2^2 \\ & = (20)(3) \|C (\mu_1, \mu_2 \mu_3)'\|_2^2 \\ & = (20)(3) \sum_j (Xw1_j)^2. \end{align*} Therefore, if the denominator sum of squares was the residual $\mathrm{R(id * Xw1)}$ like before, there would be both conditions $(1)$ and $(2)$ in the null hypothesis---since those are the two conditions that aren't satisfied without assumptions. However, if we were to use denominator sum of squares as the interaction, since condition $(1)$ is already satisfied, the null hypothesis would just be condition $(2)$. So, as you mention in your question, these different denominators just amount to different null hypotheses. This analysis technique we use allows the choice of which null hypothesis is being tested to be transparent. Indeed, we can see this by writing out the conditions mentioned in the previous paragraph more explicitly. Using the denominator as the residual sum of squares forces us to test $Xw1_j = 0$ for all $j$ and $\sigma^2_{id * Xw1} = 0$, while using the denominator as the interaction sum of squares allows us to simply test $Xw1_j = 0$ for all $j$.
Repeated measures ANOVA vs. factorial ANOVA with subject factor: understanding "error strata" and Er
This note depends on results contained in Moser's Linear Models: A Mean Model Approach. I'll cite some results from this book in what follows. When I saw your question, I started looking through the b
Repeated measures ANOVA vs. factorial ANOVA with subject factor: understanding "error strata" and Error() term in aov This note depends on results contained in Moser's Linear Models: A Mean Model Approach. I'll cite some results from this book in what follows. When I saw your question, I started looking through the book: this note is just the way my thoughts were organized after. Let $y \sim \mathcal{N}_n(\mu, \Sigma)$ be the response, with $\mu$ containing the fixed effects and $\Sigma$ containing the random effects. Take $y^T A_i y$ to be the sums of squares corresponding to each term (covariates and interactions) in the model. Note that these sums of squares are invariant to whether terms are fixed or random. Assume that each $A_i$ is symmetric and idempotent, which will be true in most models of interest. When it holds that $$I = \sum_i A_i,$$ which amounts to the sums of squares corresponding to a decomposition into orthogonal subspaces since we've assumed the $A_i$ are projectors, and $$\Sigma = \sum_i c_i A_i,$$ by Cochran's theorem (lemma 3.4.1), \begin{equation} y^T A_i y \sim c_i \chi^2_{d_i} (\mu^T A_i \mu/c_i), \end{equation} for $d_i = tr(A_i)$, and $y^T A_j y$ is independent of $y^T A_k y$ for $j \ne k$. The term $$\tilde{F} = \frac{y^T A_j y / d_j}{y^T A_k y / d_k} \sim \frac{c_j \chi_{d_j}^2(\mu^T A_j \mu / c_j)/d_j}{c_k \chi_{d_k}^2(\mu^T A_k \mu / c_k)/d_k}$$ is indeed a (central) $F$ statistic if and only if \begin{align*} \frac{c_j}{c_k} & = 1 , \tag{1} \\ \mu^T A_j \mu & = 0 , \tag{2} \\ \mu^T A_k \mu & = 0 , \textrm{ and }\tag{3} \end{align*} When these three conditions are satisfied, we can compute $p$-values corresponding to the statistic $\tilde{F}$. These terms basically just aid in computability since the $c_i$'s depend on variance components and the the noncentrality parameters depend on the mean $\mu$. The second condition ensures that $\tilde{F}$ will have (at least) a noncentral $F$ distribution. Under the second condition, the third condition gives that $\tilde{F}$ has a central $F$ distribution. The expected mean squares ($\mathrm{EMS}$) corresponding to the $i^\mathrm{th}$ sum of squares $y^T A_i y$ is $$\mathrm{EMS}_i := \frac{1}{tr(A_i)} \mathbb{E} [y^T A_i y] = \frac{tr(A_i \Sigma) + \mu^T A_i \mu}{tr(A_i)} = c_i + \frac{\mu^T A_i \mu}{tr(A_i)},$$ where $tr(A_i\Sigma) = c_i \, tr(A_i)$ due to cor 3.1.2. The ratio $$\frac{\mathrm{EMS}_j}{\mathrm{EMS}_k} = \frac{c_j + \frac{\mu^T A_j \mu}{tr(A_j)}}{c_k + \frac{\mu^T A_k \mu}{tr(A_k)}} = 1$$ if conditions $(1)$, $(2)$, and $(3)$ hold. This is why people inspect the ratio of $\mathrm{EMS}$ when determining which sums of squares to divide to form a $F$ statistic to test a particular null hypothesis. We use conditions $(1), (2)$, and $(3)$ to specify the null hypothesis. In my experience, when the term (corresponding to $j$) that we're interested in testing is random, we make the null hypothesis be $c_j/c_k = 1$, and, when it's fixed, we make the null hypothesis be $y^T A_j y = 0$. In particular, these amount to us being able to choose $k$ so that the rest of conditions $(1), (2)$ and $(3)$ are satisfied. Such a choice of $k$ isn't always possible, which leads to Behrens-Fisher-like difficulties. This doesn't explain anything particularly related to the problem at hand, but that just amounts to computing $\mu$ and $\Sigma$. I hope this is seen to be a useful way of thinking about the problem. Note that example 4.4.1 works out what all of the quantities above are in the two-way ANOVA example. The difference is due to the problem structure and not due to convention. These different approaches (two-way vs repeated measure) change $\mu$ and $\Sigma$, which changes the EMS, which changes which $k$ we choose to construct the test. Let's consider the model \begin{equation} y_{ijk} = \mu_0 + \mathrm{id}_i + \mathrm{Xw1}_{j} + \mathrm{id * Xw1}_{ij} + \mathrm{R(id * Xw1)}_{k(ij)}, \end{equation} where $i$ denotes the level of $\mathrm{id}$, etc. Here $k$ denotes which of the 3 replicates are being considered. We now introduce some helpful vector notation: write $y = (y_{111}, y_{112}, y_{113}, y_{121}, \dots y_{20,3,3})$. Since this data is balanced, we can make us of kronecker product notation. (As an aside, I was told that Charlie Van Loan once called the kronecker product "the operation of the 2000s!") Define $\bar{J} \in \mathbb{R}^{m \times m}$ to be the matrix with all entries equal to $\frac{1}{m}$ and $C=I-\bar{J}$ to be the centering matrix. (The centering matrix is so named since, for instance, $\|C x \|_2^2 = \sum_i (x_i - \bar{x})^2$ for a vector $x$.) With this kronecker product notation under out belt, we can find the matrices $A_i$ mentioned above. The sum of squares correspoding to $\mu_0$ is \begin{equation} SS(\mu_0) = n (\bar{y}_{\cdot\cdot\cdot})^2 = \|(\bar{J} \otimes \bar{J} \otimes \bar{J}) y\|_2^2 = y^T (\bar{J} \otimes \bar{J} \otimes \bar{J}) y, \end{equation} where the first component $\bar{J} \in \mathbb{R}^{20 \times 20}$, the second is in $\mathbb{R}^{3 \times 3}$, and the third is in $\mathbb{R}^{3 \times 3}$. Generally speaking, the matrices in those components will always be of that size. Also, the sum of squares due to $\mathrm{id}$ is \begin{equation} SS(\mathrm{id}) = \sum_{ijk} (\bar{y}_{i\cdot\cdot} - \bar{y}_{\cdot \cdot \cdot})^2 = \|(C \otimes \bar{J} \otimes \bar{J}) y\|_2^2 = y^T (C \otimes \bar{J} \otimes \bar{J}) y. \end{equation} Notice that $SS(\mathrm{id})$ does indeed measure the variation among levels of $\mathrm{id}$. Similarly, the other matrices are $A_{Xw1} = \bar{J} \otimes C \otimes \bar{J}$, $A_{id * Xw1} = C \otimes C \otimes \bar{J}$, and $A_{R()} = I \otimes I \otimes C$. This is shown to be consistent with aov by running code to give, for instance, the residual sum of squares $SS(\mathrm{R(id * Xw1)}) = y^T A_{R()} y$: mY <- c() for(j in 1:(nrow(d)/3)) { mY <- c(mY, rep(mean(d$Y[3*(j-1)+(1:3)]), 3)) } sum((d$Y - mY)^2) #this is the residual sum of squares At this point, we have to make some modeling choices. In particular, we have to decide whether $\mathrm{id}$ is a random effect. Let's first suppose that it isn't a random effect, so that all effects besides the replication are fixed. Then \begin{equation} \mathbb{E} [y_{ijk}] = \mu_{ij} = \mu_0 + \mathrm{id}_i + \mathrm{Xw1}_{jk} + \mathrm{id * Xw1}_{ij} \end{equation} and $R(\mathrm{id * Xw1})_{k(ij)} \sim_{iid} \mathcal{N}(0, \sigma^2)$. Notice that there's no dependence between distinct observations. In vector notation, we can write $$y \sim \mathcal{N} (\mu, \Sigma)$$ for $\mu = \mathbb{E} [y] = (\mu_{11}, \mu_{12}, \dots, \mu_{20,3}) \otimes \mathbf{1}_{3}$ and $\Sigma = \sigma^2 (I \otimes I \otimes I)$. Noticing that the sum of all $5$ of the $A$'s defined above is the identity, we know by cochran's theorem that, among other things, $$SS(\mathrm{Xw1}) = y^T A_{Xw1} y \sim \sigma^2 \chi^2_{(19)(1)(1)} (\mu^T A_{Xw1} \mu / \sigma^2)$$ and $$SS(\mathrm{R(id * Xw1)}) = y^T A_{R()} y \sim \sigma^2 \chi^2_{(20)(3)(2)} (\mu^T A_{R()} \mu / \sigma^2)$$ and these sums of squares are independent. Now, in line with what we discussed above, we want conditions $(1), (2),$ and $(3)$ to hold. Notice that condition $(1)$ holds (because there's no other variance components to complicate things.) What's really cool to notice now is that $\mu^T A_{R()} \mu = 0$, since $\mu$ is constant along this third "component" that is being centered by $A_{R()}$. This means that $(3)$ is behind us. Therefore we only have to fret about condition $(2)$: if we assume it (as a null hypothesis) then we're assuming that $0 = \mu^T A_{Xw1} \mu = \sum_{ijk} (\mu_{ij} - \bar{\mu}_{i \cdot})^2$, which is the same as $\mu_{ij} = \bar{\mu}_{i \cdot}$ for all $i,j$, which is the same as $\mathrm{Xw1}_j = 0$ and $\mathrm{id * Xw1}_{ij} = 0$ for all $i,j$ (since the mean level is in the other terms.) In summary, the null hypothesis can be seen to just be testing whether a noncentrality parameter is zero, which is equivalent to effects concerning the covariate being zero. The repeated measures case follows a similar line of reasoning, where we instead make the modeling choice that the $\mathrm{id}$ effect is random. There, condition $(1)$ will become the null hypothesis. Related to the R command, like you mention in the comments to the original post, this error term just specifies which terms are to be considered as random effects. (Note that all terms that are to be included in the model should be plainly input or input inside the Error() term. This is why there's a difference between id/Xw1 = id + id:Xw1 and id being in the Error term. Non-included terms are lumped in with the error in the sense that $A_{R()} + A_{id * Xw1}$ is relabeled as $A_{R()}$.) Here's the explicit details related to the repeated measures case where the terms related to $\mathrm{id}$ (which are $\mathrm{id}$ and $\mathrm{id * Xw1}$) are random. We'll see that this is the more interesting case. There we have the same sum of squares matrices (since they don't depend on whether a factor is fixed or random.) The covariance matrix there is \begin{align*} \Sigma & \stackrel{(a)}{=} \sigma^2_{id} (I \otimes J \otimes J) + \sigma^2_{id * Xw1} (I \otimes C \otimes J) + \sigma^2_{R()} (I \otimes I \otimes I) \\ & = \sigma^2_{id} (3)(3) (A_{\mu_0} + A_{id}) + \sigma^2_{id * Xw1} (3) (A_{Xw1} + A_{id * Xw1}) + \sigma^2_{R()} (A_{\mu_0} + A_{id} + A_{Xw1} + A_{id * Xw1} + A_{R()}) \\ & = ((3)(3)\sigma^2_{id} + \sigma^2_{R()})A_{\mu_0} + ((3)(3)\sigma^2_{id} + \sigma^2_{R()}) A_{id} + ((3)\sigma^2_{id * Xw1} + \sigma^2_{R()}) A_{Xw1} + ((3)\sigma^2_{id * Xw1} + \sigma^2_{R()}) A_{id * Xw1} + \sigma^2_{R()} A_{R()}, \end{align*} where $J$ is the matrix of all ones. The first and last summand on the right hand side of equality (a) offer intuitive explanations: the first summand shows that there's an additional source of correlation among observations with the same $\mathrm{id}$, and the third summand shows, as in the two-way example, the base source of variation. This second summand is less intuitive, but among observations with the same \mathrm{id}, it can be seen as increasing variation between observations with same $\mathrm{Xw1}$ while decreasing variation between observations with different $\mathrm{Xw1}$, due to the shape of $I \otimes C \otimes J$. Also, since all of the terms related to $\mathrm{id}$ are random, the mean is just due to $\mathrm{Xw1}$, so that $\mathbb{E} [y_{ijk}] = \mu_{j} = \mu_0 + \mathrm{Xw1}_j$, or $\mu = \mathbf{1} \otimes (\mu_1, \mu_2, \mu_3) \otimes \mathbf{1}$. Notice that, related to condition $(1)$: we have $$\frac{c_{Xw1} }{c_{id * Xw1}} = \frac{(3)\sigma^2_{id*Xw1} + \sigma^2_{R()}}{(3)\sigma^2_{id*Xw1} + \sigma^2_{R()}} = 1,$$ while $$\frac{c_{Xw1}}{c_{R()}} = \frac{(3)\sigma^2_{id*Xw1} + \sigma^2_{R()}}{\sigma^2_{R()}} \neq 1.$$ Further, related to condition $(3)$ both $\mu^T A_{Xw1*id} \mu = 0$ and $\mu^T A_{R()} \mu = 0$. Also, related to condition $(2)$: we see that \begin{align*} \mu^T A_{Xw1} \mu & = \|A_{Xw1} \mu\|_2^2 \\ & = \|(\bar{J} \otimes C \otimes \bar{J}) (\mathbf{1} \otimes (\mu_1, \mu_2 \mu_3)' \otimes \mathbf{1}) \|_2^2 \\ & = (20)(3) \|C (\mu_1, \mu_2 \mu_3)'\|_2^2 \\ & = (20)(3) \sum_j (Xw1_j)^2. \end{align*} Therefore, if the denominator sum of squares was the residual $\mathrm{R(id * Xw1)}$ like before, there would be both conditions $(1)$ and $(2)$ in the null hypothesis---since those are the two conditions that aren't satisfied without assumptions. However, if we were to use denominator sum of squares as the interaction, since condition $(1)$ is already satisfied, the null hypothesis would just be condition $(2)$. So, as you mention in your question, these different denominators just amount to different null hypotheses. This analysis technique we use allows the choice of which null hypothesis is being tested to be transparent. Indeed, we can see this by writing out the conditions mentioned in the previous paragraph more explicitly. Using the denominator as the residual sum of squares forces us to test $Xw1_j = 0$ for all $j$ and $\sigma^2_{id * Xw1} = 0$, while using the denominator as the interaction sum of squares allows us to simply test $Xw1_j = 0$ for all $j$.
Repeated measures ANOVA vs. factorial ANOVA with subject factor: understanding "error strata" and Er This note depends on results contained in Moser's Linear Models: A Mean Model Approach. I'll cite some results from this book in what follows. When I saw your question, I started looking through the b
37,091
Generative models for time series simulation
For time series, you want to use LSTM or other recurrent neural network instead of unsupervised generative models in deep learning. You can also convert it to a supervised model which uses $x_t$ to predict $x_{t+1}$ with whichever machine learning algorithm you like. As you can see in the blog post and in wikipedia of generative model: "In probability and statistics, a generative model is a model for randomly generating observable data values, typically given some hidden parameters." You should note the input to the generative model is some hidden parameters which are usually meaningless, while you want the input to be $x_t$ when generating $x_{t+1}$. You should also note in the blog post of OpenAI that "Autoregressive models such as PixelRNN instead train a network that models the conditional distribution of every individual pixel given previous pixels (to the left and to the top). This is similar to plugging the pixels of the image into a char-rnn, but the RNNs run both horizontally and vertically over the image instead of just a 1D sequence of characters." So the PixelRNN is basically like a recurrent neural network except that the sequence is on 2D directions while you only have time as your 1D direction. This still just leads you to LSTM. If you really really really want to use fancy algorithms such as GAN, here is what you can do: forget you have a time series. Usually when time series data are generated, the data are generated at one step after another according to $p(x_{t+1}|x_{1..t})$, which is like PixelRNN. Instead, just think about the data as a bunch of numbers, or a 1D image in analogy to image generation, and now you have a perfect analogy to image generation using GAN: each whole time series is a single training data for you GAN. This method totally ignores some characteristics of time series, for example causality, and just regards your data as a bunch of numbers. I highly doubt this will work well but I encourage you to try.
Generative models for time series simulation
For time series, you want to use LSTM or other recurrent neural network instead of unsupervised generative models in deep learning. You can also convert it to a supervised model which uses $x_t$ to pr
Generative models for time series simulation For time series, you want to use LSTM or other recurrent neural network instead of unsupervised generative models in deep learning. You can also convert it to a supervised model which uses $x_t$ to predict $x_{t+1}$ with whichever machine learning algorithm you like. As you can see in the blog post and in wikipedia of generative model: "In probability and statistics, a generative model is a model for randomly generating observable data values, typically given some hidden parameters." You should note the input to the generative model is some hidden parameters which are usually meaningless, while you want the input to be $x_t$ when generating $x_{t+1}$. You should also note in the blog post of OpenAI that "Autoregressive models such as PixelRNN instead train a network that models the conditional distribution of every individual pixel given previous pixels (to the left and to the top). This is similar to plugging the pixels of the image into a char-rnn, but the RNNs run both horizontally and vertically over the image instead of just a 1D sequence of characters." So the PixelRNN is basically like a recurrent neural network except that the sequence is on 2D directions while you only have time as your 1D direction. This still just leads you to LSTM. If you really really really want to use fancy algorithms such as GAN, here is what you can do: forget you have a time series. Usually when time series data are generated, the data are generated at one step after another according to $p(x_{t+1}|x_{1..t})$, which is like PixelRNN. Instead, just think about the data as a bunch of numbers, or a 1D image in analogy to image generation, and now you have a perfect analogy to image generation using GAN: each whole time series is a single training data for you GAN. This method totally ignores some characteristics of time series, for example causality, and just regards your data as a bunch of numbers. I highly doubt this will work well but I encourage you to try.
Generative models for time series simulation For time series, you want to use LSTM or other recurrent neural network instead of unsupervised generative models in deep learning. You can also convert it to a supervised model which uses $x_t$ to pr
37,092
Implication of grouped and ungrouped data for Poisson Regression
Since the sums of counts by combination of factors in the model together with the anti-logged offsets are the sufficient statistics for a Poisson distribution, there should be no difference between the two analyses. Any differing analysis results are due to software-usage errors. In this case, the problem is that the R glm function does not know what degrees of freedom to use. This can be a problem with some software, when you use sufficient statistics instead of individual observations. For example, PROC NLMIXED in SAS has the DF option in the PROC NLMIXED statement to deal with this type of problem. I am not sure what the equivalent option in glm is, but I assume it exists.
Implication of grouped and ungrouped data for Poisson Regression
Since the sums of counts by combination of factors in the model together with the anti-logged offsets are the sufficient statistics for a Poisson distribution, there should be no difference between th
Implication of grouped and ungrouped data for Poisson Regression Since the sums of counts by combination of factors in the model together with the anti-logged offsets are the sufficient statistics for a Poisson distribution, there should be no difference between the two analyses. Any differing analysis results are due to software-usage errors. In this case, the problem is that the R glm function does not know what degrees of freedom to use. This can be a problem with some software, when you use sufficient statistics instead of individual observations. For example, PROC NLMIXED in SAS has the DF option in the PROC NLMIXED statement to deal with this type of problem. I am not sure what the equivalent option in glm is, but I assume it exists.
Implication of grouped and ungrouped data for Poisson Regression Since the sums of counts by combination of factors in the model together with the anti-logged offsets are the sufficient statistics for a Poisson distribution, there should be no difference between th
37,093
Implication of grouped and ungrouped data for Poisson Regression
My expectation would be that the aggregated model will always have a lower deviance as it does not have to explain the variance within the groups. In the 1-dimensional linear case this is easier to see, as grouped data will usually have higher correlation. See: "Better fit" using aggregated data in comparison to disaggregated data: explanation?
Implication of grouped and ungrouped data for Poisson Regression
My expectation would be that the aggregated model will always have a lower deviance as it does not have to explain the variance within the groups. In the 1-dimensional linear case this is easier to se
Implication of grouped and ungrouped data for Poisson Regression My expectation would be that the aggregated model will always have a lower deviance as it does not have to explain the variance within the groups. In the 1-dimensional linear case this is easier to see, as grouped data will usually have higher correlation. See: "Better fit" using aggregated data in comparison to disaggregated data: explanation?
Implication of grouped and ungrouped data for Poisson Regression My expectation would be that the aggregated model will always have a lower deviance as it does not have to explain the variance within the groups. In the 1-dimensional linear case this is easier to se
37,094
Multi-Seasonal Time Series function in Python [closed]
If you have two (or n) specific seasonalities you want to adjust for, you could get each of them separately from statsmodels by calling sm.decompose() twice with the different frequency= parameters. Then you could subtract both those seasonal components from your raw signal. For an example where you have hourly data and want to seasonally adjust for daily and weekly effects... import statsmodels.api as sm daily_components = sm.tsa.seasonal_decompose(raw_series, period=24) weekly_components= sm.tsa.seasonal_decompose(raw_series, period=24*7) adjusted = raw_series - daily_components.seasonal - weekly_components.seasonal
Multi-Seasonal Time Series function in Python [closed]
If you have two (or n) specific seasonalities you want to adjust for, you could get each of them separately from statsmodels by calling sm.decompose() twice with the different frequency= parameters. T
Multi-Seasonal Time Series function in Python [closed] If you have two (or n) specific seasonalities you want to adjust for, you could get each of them separately from statsmodels by calling sm.decompose() twice with the different frequency= parameters. Then you could subtract both those seasonal components from your raw signal. For an example where you have hourly data and want to seasonally adjust for daily and weekly effects... import statsmodels.api as sm daily_components = sm.tsa.seasonal_decompose(raw_series, period=24) weekly_components= sm.tsa.seasonal_decompose(raw_series, period=24*7) adjusted = raw_series - daily_components.seasonal - weekly_components.seasonal
Multi-Seasonal Time Series function in Python [closed] If you have two (or n) specific seasonalities you want to adjust for, you could get each of them separately from statsmodels by calling sm.decompose() twice with the different frequency= parameters. T
37,095
Policy and value iteration algorithm convergence conditions
To answer your question, let me first write out some important (in)equalities. Bellman optimality equation: \begin{align} v_∗(s) &= \max_{a} \mathbb{E}[R_{t+1} + \gamma v_* (S_{t+1}) \mid S_t =s, A_t =a] \\ &= \max_{a} \sum_{s'}p(s'\mid s, a) \biggl[r(s, a, s') + \gamma v_∗(s')\biggl] \end{align} where $v_*(.)$ is the optimal value function. Policy improvement theorem (Pit): Let $\pi$ and $\pi'$ be any pair of deterministic policies such that, for all $s \in S$, $q_\pi(s, \pi'(s)) \geq v_\pi(s)$ Then the policy $\pi'$ must be as good as, or better than, $\pi$. That is, it must obtain greater or equal expected return from all states $s \in S: v_{\pi'} (s) \geq v_\pi(s)$. (find on page 89 of Sutton & Barto, Reinforcement learning: An Introduction book) We can improve a policy $\pi$ at every state by the following rule: \begin{align} \pi'(s) &= \arg \max_{a}q_π(s, a)\\ &= \arg \max_{a} \sum_{s'}p(s' \mid s, a)\biggl[r(s, a, s') + \gamma v_\pi(s')\biggl] \end{align} Our new policy $\pi'$ satisfies the condition of Pit and so is as good as or better than $\pi$. If $\pi'$ is as good as, but not better than $\pi$, then $v_{\pi'}(s)=v_{\pi}(s)$ for all $s$. From our definition of $\pi'$ we deduce, that: \begin{align} v_{\pi'}(s)&=\max_{a} \mathbb{E}\biggl[R_{t+1} + \gamma v_{ \pi'}(S_{t+1}) \mid S_t =s, A_t =a \biggl]\\ &= \max_{a}\sum_{s'}p(s' \mid s, a) \biggl[r(s, a, s') + \gamma v_{π'}(s') \biggl] \end{align} But this equality is the same as the Bellman optimality equation so $v_{\pi'}$ must equal $v_*$. From the above said, it is hopefully clear, that if we improve a policy and get the same value function, that we had before, the new policy must be one of the optimal policies. For more information, see Sutton & Barto (2012)
Policy and value iteration algorithm convergence conditions
To answer your question, let me first write out some important (in)equalities. Bellman optimality equation: \begin{align} v_∗(s) &= \max_{a} \mathbb{E}[R_{t+1} + \gamma v_* (S_{t+1}) \mid S_t =s, A
Policy and value iteration algorithm convergence conditions To answer your question, let me first write out some important (in)equalities. Bellman optimality equation: \begin{align} v_∗(s) &= \max_{a} \mathbb{E}[R_{t+1} + \gamma v_* (S_{t+1}) \mid S_t =s, A_t =a] \\ &= \max_{a} \sum_{s'}p(s'\mid s, a) \biggl[r(s, a, s') + \gamma v_∗(s')\biggl] \end{align} where $v_*(.)$ is the optimal value function. Policy improvement theorem (Pit): Let $\pi$ and $\pi'$ be any pair of deterministic policies such that, for all $s \in S$, $q_\pi(s, \pi'(s)) \geq v_\pi(s)$ Then the policy $\pi'$ must be as good as, or better than, $\pi$. That is, it must obtain greater or equal expected return from all states $s \in S: v_{\pi'} (s) \geq v_\pi(s)$. (find on page 89 of Sutton & Barto, Reinforcement learning: An Introduction book) We can improve a policy $\pi$ at every state by the following rule: \begin{align} \pi'(s) &= \arg \max_{a}q_π(s, a)\\ &= \arg \max_{a} \sum_{s'}p(s' \mid s, a)\biggl[r(s, a, s') + \gamma v_\pi(s')\biggl] \end{align} Our new policy $\pi'$ satisfies the condition of Pit and so is as good as or better than $\pi$. If $\pi'$ is as good as, but not better than $\pi$, then $v_{\pi'}(s)=v_{\pi}(s)$ for all $s$. From our definition of $\pi'$ we deduce, that: \begin{align} v_{\pi'}(s)&=\max_{a} \mathbb{E}\biggl[R_{t+1} + \gamma v_{ \pi'}(S_{t+1}) \mid S_t =s, A_t =a \biggl]\\ &= \max_{a}\sum_{s'}p(s' \mid s, a) \biggl[r(s, a, s') + \gamma v_{π'}(s') \biggl] \end{align} But this equality is the same as the Bellman optimality equation so $v_{\pi'}$ must equal $v_*$. From the above said, it is hopefully clear, that if we improve a policy and get the same value function, that we had before, the new policy must be one of the optimal policies. For more information, see Sutton & Barto (2012)
Policy and value iteration algorithm convergence conditions To answer your question, let me first write out some important (in)equalities. Bellman optimality equation: \begin{align} v_∗(s) &= \max_{a} \mathbb{E}[R_{t+1} + \gamma v_* (S_{t+1}) \mid S_t =s, A
37,096
Policy and value iteration algorithm convergence conditions
You're correct: either the current value function estimate or the current policy estimate can completely describe the state of the algorithm. Each one implies a unique next choice for the other. From the paper linked below, "Policy iteration continues until $V_{n+1} = V_n, α_{n+1} = α_n$." https://editorialexpress.com/jrust/research/siam_dp_paper.pdf
Policy and value iteration algorithm convergence conditions
You're correct: either the current value function estimate or the current policy estimate can completely describe the state of the algorithm. Each one implies a unique next choice for the other. From
Policy and value iteration algorithm convergence conditions You're correct: either the current value function estimate or the current policy estimate can completely describe the state of the algorithm. Each one implies a unique next choice for the other. From the paper linked below, "Policy iteration continues until $V_{n+1} = V_n, α_{n+1} = α_n$." https://editorialexpress.com/jrust/research/siam_dp_paper.pdf
Policy and value iteration algorithm convergence conditions You're correct: either the current value function estimate or the current policy estimate can completely describe the state of the algorithm. Each one implies a unique next choice for the other. From
37,097
Pooling levels of categorical variables for regression trees
I have implemented my solution to this. I wrote two functions: prox_matrix(df, target, features, cluster_dimension,trees = 10) Parameters df: Input dataframe target: Dependant variable you are trying to predict with the random forrest features: List of independent variables cluster_dimension: Dimension you would like to cluster/pool to add to your list of features trees: the number of trees to use in your Random Forest Returns D: DataFrame of the proximity matrix for the cluster_dimension Code Below def prox_matrix(df, target, features, cluster_dimension,trees = 10): #https://www.stat.berkeley.edu/~breiman/RandomForests/cc_home.htm#prox from sklearn.ensemble import RandomForestRegressor import numpy as np import pandas as pd #initialize datframe for independant variables independant = pd.DataFrame() #Handle Categoricals: This should really be added to RandomForestRegressor for column,data_type in df[features].dtypes.iteritems(): try: independant[column] = pd.to_numeric(df[column],downcast = 'integer') except ValueError: contains_nulls = df[column].isnull().values.any() dummies = pd.get_dummies(df[column],prefix=column,dummy_na=contains_nulls,drop_first=True) independant[dummies.columns] = dummies if len(independant.index) != len(df.index): raise Exception('independant variables not stored properly') #train Model clf = RandomForestRegressor(n_estimators=trees, n_jobs=-1) clf.fit(independant, df[target]) #Final leaf for each tree leaves = clf.apply(independant) #value in cluster dimension labels = df[cluster_dimension].values numerator_matrix = {} for i,value_i in enumerate(labels): for j,value_j in enumerate(labels): if i >= j: numerator_matrix[(value_i,value_j)] = numerator_matrix.get((value_i,value_j), 0) + np.count_nonzero(leaves[i]==leaves[j]) numerator_matrix[(value_j,value_i)] = numerator_matrix[(value_i,value_j)] #normalize by the total number of possible matchnig leaves prox_matrix = {key: 1.0 - float(x)/(trees*np.count_nonzero(labels==key[0])*np.count_nonzero(labels==key[1])) for key, x in numerator_matrix.iteritems()} #make sorted dataframe levels = np.unique(labels) D = pd.DataFrame(data=[[ prox_matrix[(i,j)] for i in levels] for j in levels],index=levels,columns=levels) return D kMedoids(D, k, tmax=100) Parameters D: Proximity/distance matrix k: Number of clusters tmax: Maximum number of iterations to check for convergence of clustering Returns M: List of mediods C: Dictionary mapping the clustered levels to each mediod S: Silhouette of each cluster for evaluation of performance Code Below def kMedoids(D, k, tmax=100): #https://www.researchgate.net/publication/272351873_NumPy_SciPy_Recipes_for_Data_Science_k-Medoids_Clustering import numpy as np import pandas as pd # determine dimensions of distance matrix D m, n = D.shape if m != n: raise Exception('matrix not symmetric') if sum(D.columns.values != D.index.values): raise Exception('rows and columns do not match') if k > n: raise Exception('too many medoids') #Some distance matricies will not have a 0 diagonal Dtemp =D.copy() np.fill_diagonal(Dtemp.values,0) # randomly initialize an array of k medoid indices M = list(Dtemp.sample(k).index.values) # initialize a dictionary to represent clusters Cnew = {} for t in xrange(tmax): # determine mapping to clusters J = Dtemp.loc[M].idxmin(axis='index') #Fill dictionary with cluster members C = {kappa: J[J==kappa].index.values for kappa in J.unique()} # update cluster medoids Cnew = {Dtemp.loc[C[kappa],C[kappa]].mean().idxmin() : C[kappa] for kappa in C.keys()} #Update mediod list M = Cnew.keys() # check for convergence (ie same clusters) if set(C.keys()) == set(Cnew.keys()): if not sum(set(C[kappa]) != set(Cnew[kappa]) for kappa in C.keys()): break else: print('did not converge') #Calculate silhouette S = {} for kappa_same in Cnew.keys(): a = Dtemp.loc[Cnew[kappa_same],Cnew[kappa_same]].mean().mean() b = np.min([Dtemp.loc[Cnew[kappa_other],Cnew[kappa_same]].mean().mean() for kappa_other in Cnew.keys() if kappa_other!=kappa_same]) S[kappa_same] = (b - a) / max(a, b) # return results return M, Cnew, S Notes: There are links to theory documentation in the code I used all records not strictly the OOB records. Follow up here The prox_matrix() method is very slow. I have done a few things to speed it up but most of the cost comes from the double loop. Updates welcome. The diagonal of the proximity matrix need not be zeros. I force this in the KMedoids method so that I get convergence.
Pooling levels of categorical variables for regression trees
I have implemented my solution to this. I wrote two functions: prox_matrix(df, target, features, cluster_dimension,trees = 10) Parameters df: Input dataframe target: Dependant variable you are try
Pooling levels of categorical variables for regression trees I have implemented my solution to this. I wrote two functions: prox_matrix(df, target, features, cluster_dimension,trees = 10) Parameters df: Input dataframe target: Dependant variable you are trying to predict with the random forrest features: List of independent variables cluster_dimension: Dimension you would like to cluster/pool to add to your list of features trees: the number of trees to use in your Random Forest Returns D: DataFrame of the proximity matrix for the cluster_dimension Code Below def prox_matrix(df, target, features, cluster_dimension,trees = 10): #https://www.stat.berkeley.edu/~breiman/RandomForests/cc_home.htm#prox from sklearn.ensemble import RandomForestRegressor import numpy as np import pandas as pd #initialize datframe for independant variables independant = pd.DataFrame() #Handle Categoricals: This should really be added to RandomForestRegressor for column,data_type in df[features].dtypes.iteritems(): try: independant[column] = pd.to_numeric(df[column],downcast = 'integer') except ValueError: contains_nulls = df[column].isnull().values.any() dummies = pd.get_dummies(df[column],prefix=column,dummy_na=contains_nulls,drop_first=True) independant[dummies.columns] = dummies if len(independant.index) != len(df.index): raise Exception('independant variables not stored properly') #train Model clf = RandomForestRegressor(n_estimators=trees, n_jobs=-1) clf.fit(independant, df[target]) #Final leaf for each tree leaves = clf.apply(independant) #value in cluster dimension labels = df[cluster_dimension].values numerator_matrix = {} for i,value_i in enumerate(labels): for j,value_j in enumerate(labels): if i >= j: numerator_matrix[(value_i,value_j)] = numerator_matrix.get((value_i,value_j), 0) + np.count_nonzero(leaves[i]==leaves[j]) numerator_matrix[(value_j,value_i)] = numerator_matrix[(value_i,value_j)] #normalize by the total number of possible matchnig leaves prox_matrix = {key: 1.0 - float(x)/(trees*np.count_nonzero(labels==key[0])*np.count_nonzero(labels==key[1])) for key, x in numerator_matrix.iteritems()} #make sorted dataframe levels = np.unique(labels) D = pd.DataFrame(data=[[ prox_matrix[(i,j)] for i in levels] for j in levels],index=levels,columns=levels) return D kMedoids(D, k, tmax=100) Parameters D: Proximity/distance matrix k: Number of clusters tmax: Maximum number of iterations to check for convergence of clustering Returns M: List of mediods C: Dictionary mapping the clustered levels to each mediod S: Silhouette of each cluster for evaluation of performance Code Below def kMedoids(D, k, tmax=100): #https://www.researchgate.net/publication/272351873_NumPy_SciPy_Recipes_for_Data_Science_k-Medoids_Clustering import numpy as np import pandas as pd # determine dimensions of distance matrix D m, n = D.shape if m != n: raise Exception('matrix not symmetric') if sum(D.columns.values != D.index.values): raise Exception('rows and columns do not match') if k > n: raise Exception('too many medoids') #Some distance matricies will not have a 0 diagonal Dtemp =D.copy() np.fill_diagonal(Dtemp.values,0) # randomly initialize an array of k medoid indices M = list(Dtemp.sample(k).index.values) # initialize a dictionary to represent clusters Cnew = {} for t in xrange(tmax): # determine mapping to clusters J = Dtemp.loc[M].idxmin(axis='index') #Fill dictionary with cluster members C = {kappa: J[J==kappa].index.values for kappa in J.unique()} # update cluster medoids Cnew = {Dtemp.loc[C[kappa],C[kappa]].mean().idxmin() : C[kappa] for kappa in C.keys()} #Update mediod list M = Cnew.keys() # check for convergence (ie same clusters) if set(C.keys()) == set(Cnew.keys()): if not sum(set(C[kappa]) != set(Cnew[kappa]) for kappa in C.keys()): break else: print('did not converge') #Calculate silhouette S = {} for kappa_same in Cnew.keys(): a = Dtemp.loc[Cnew[kappa_same],Cnew[kappa_same]].mean().mean() b = np.min([Dtemp.loc[Cnew[kappa_other],Cnew[kappa_same]].mean().mean() for kappa_other in Cnew.keys() if kappa_other!=kappa_same]) S[kappa_same] = (b - a) / max(a, b) # return results return M, Cnew, S Notes: There are links to theory documentation in the code I used all records not strictly the OOB records. Follow up here The prox_matrix() method is very slow. I have done a few things to speed it up but most of the cost comes from the double loop. Updates welcome. The diagonal of the proximity matrix need not be zeros. I force this in the KMedoids method so that I get convergence.
Pooling levels of categorical variables for regression trees I have implemented my solution to this. I wrote two functions: prox_matrix(df, target, features, cluster_dimension,trees = 10) Parameters df: Input dataframe target: Dependant variable you are try
37,098
Why is the sum of the sample autocorrelations of a stationary series equal to -1/2?
Let's start by representing the sum $S$ using the definition of the autocorrelation function: \begin{equation} S = \sum_{h=1}^{n-1} \hat{\rho}(h) = \sum_{h=1}^{n-1} \left(\frac{\frac{1}{n}\sum_{t=1}^{n-h}(X_t-\bar{X})(X_{t+h}-\bar{X})}{\frac{1}{n}\sum_{t=1}^{n}(X_t-\bar{X})^2}\right) \end{equation} Denominator does not depend on $h$ so we can simplify and move the front $\sum$ to the numerator, which gives us: \begin{equation} S = \frac{\sum_{h=1}^{n-1} \sum_{t=1}^{n-h} (X_t-\bar{X})(X_{t+h}-\bar{X})}{\sum_{t=1}^{n} (X_t-\bar{X})^2} \end{equation} Now consider the denominator. How do we represent in so we get an expression similar to the numerator? Set $Y_t=X_t-\bar{X}$. Then $\sum_{t=1}^{n}Y_t=0.$ The denominator here is $\sum_{t=1}^{n}Y_t^{2}$. We know that $\sum_{t=1}^{n}Y_t^{2} = \left(\sum_{t=1}^{n}Y_t\right)^2 - 2\sum_{h=1}^{n-1} \sum_{t=1}^{n-h}Y_t Y_{t+h}$, i.e. subtracting all unique pairs $\times$ 2. Because $\sum_{t=1}^{n}Y_t=0$, it follows that $\sum_{t=1}^{n}Y_t^{2} = - 2\sum_{h=1}^{n-1} \sum_{t=1}^{n-h}Y_t Y_{t+h}$. Plugging back in terms of X, the denominator becomes $- 2\sum_{h=1}^{n-1} \sum_{t=1}^{n-h}(X_t-\bar{X})(X_{t+h}-\bar{X})$. Then, \begin{equation} S=\frac{\sum_{h=1}^{n-1} \sum_{t=1}^{n-h}(X_t-\bar{X})(X_{t+h}-\bar{X})}{- 2\sum_{h=1}^{n-1} \sum_{t=1}^{n-h}(X_t-\bar{X})(X_{t+h}-\bar{X})}= -\frac{1}{2} \end{equation} Hope this helps!
Why is the sum of the sample autocorrelations of a stationary series equal to -1/2?
Let's start by representing the sum $S$ using the definition of the autocorrelation function: \begin{equation} S = \sum_{h=1}^{n-1} \hat{\rho}(h) = \sum_{h=1}^{n-1} \left(\frac{\frac{1}{n}\sum_{t=1}^{
Why is the sum of the sample autocorrelations of a stationary series equal to -1/2? Let's start by representing the sum $S$ using the definition of the autocorrelation function: \begin{equation} S = \sum_{h=1}^{n-1} \hat{\rho}(h) = \sum_{h=1}^{n-1} \left(\frac{\frac{1}{n}\sum_{t=1}^{n-h}(X_t-\bar{X})(X_{t+h}-\bar{X})}{\frac{1}{n}\sum_{t=1}^{n}(X_t-\bar{X})^2}\right) \end{equation} Denominator does not depend on $h$ so we can simplify and move the front $\sum$ to the numerator, which gives us: \begin{equation} S = \frac{\sum_{h=1}^{n-1} \sum_{t=1}^{n-h} (X_t-\bar{X})(X_{t+h}-\bar{X})}{\sum_{t=1}^{n} (X_t-\bar{X})^2} \end{equation} Now consider the denominator. How do we represent in so we get an expression similar to the numerator? Set $Y_t=X_t-\bar{X}$. Then $\sum_{t=1}^{n}Y_t=0.$ The denominator here is $\sum_{t=1}^{n}Y_t^{2}$. We know that $\sum_{t=1}^{n}Y_t^{2} = \left(\sum_{t=1}^{n}Y_t\right)^2 - 2\sum_{h=1}^{n-1} \sum_{t=1}^{n-h}Y_t Y_{t+h}$, i.e. subtracting all unique pairs $\times$ 2. Because $\sum_{t=1}^{n}Y_t=0$, it follows that $\sum_{t=1}^{n}Y_t^{2} = - 2\sum_{h=1}^{n-1} \sum_{t=1}^{n-h}Y_t Y_{t+h}$. Plugging back in terms of X, the denominator becomes $- 2\sum_{h=1}^{n-1} \sum_{t=1}^{n-h}(X_t-\bar{X})(X_{t+h}-\bar{X})$. Then, \begin{equation} S=\frac{\sum_{h=1}^{n-1} \sum_{t=1}^{n-h}(X_t-\bar{X})(X_{t+h}-\bar{X})}{- 2\sum_{h=1}^{n-1} \sum_{t=1}^{n-h}(X_t-\bar{X})(X_{t+h}-\bar{X})}= -\frac{1}{2} \end{equation} Hope this helps!
Why is the sum of the sample autocorrelations of a stationary series equal to -1/2? Let's start by representing the sum $S$ using the definition of the autocorrelation function: \begin{equation} S = \sum_{h=1}^{n-1} \hat{\rho}(h) = \sum_{h=1}^{n-1} \left(\frac{\frac{1}{n}\sum_{t=1}^{
37,099
How to compare clinical trial data to a natural history control
Years later, I've arrived at a satisfactory answer. This did indeed turn out to be to use a Cox proportional hazards counting model, which allows you to account for different left-truncation times (ages at which you started following the individuals) in addition to different right-censoring times. As noted in the question, this is implemented in R in the survival package coxph function, where time is the left-truncation time, time2 is the right-censoring time, event is what happened at the right-hand time, and you use type='counting' to specify the Cox counting model. The answers to specific questions raised in my post are: 1. Survival can indeed be computed with survfit — the model accounts for how the number of at-risk individuals can both grow and shrink over time as people enter and exit the age ranges where they were followed. An example for the toy dataset posted above would be plot(survfit(Surv(time=starting_age,time2=last_age,event=event,type='counting')~1, data=data_a)) 2. The model can compare the left-truncated prospective data and the non-left-truncated retrospective data, if you simply assume that the retrospective data are equivalent to following people from birth. This assumption may not be perfect but this is an inherent limitation of the dataset that no model is going to get around. Example code for the toy dataset above would be: data_c$starting_age = 0 data_c$last_age = data_c$age data_c$drug = FALSE nh_compare = rbind(data_a, data_c[,c('indiv_id','starting_age','last_age','event','drug')]) coxph(Surv(time=starting_age,time2=last_age,event=event,type='counting')~drug, data=nh_compare) 3. There appears to be no closed-form power calculation, instead we did this by bootstrapping. Our code to do this for our specific dataset appears here. 4. coxph allows for covariates, so for example in our code we used coxph(Surv(time=ascertainment_age,time2=surv_age,event=surv_status,type='counting')~asc+family_mutation,data=prore) where family_mutation is a covariate. We have published a paper where used this approach to calculate power for preventive clinical trials in genetic prion disease. You can read the details on bioRxiv and our R code is all in a public GitHub repo: https://github.com/ericminikel/prnp_onset/ Citation: Minikel EV, Vallabh SM, Orseth MC, Brandel JP, Haïk S, Laplanche JL, Zerr I, Parchi P, Capellari S, Safar J, Kenny J, Fong JC, Takada LT, Ponto C, Hermann P, Knipper T, Stehmann C, Kitamoto T, Ae R, Hamaguchi T, Sanjo N, Tsukamoto T, Mizusawa H, Collins SJ, Chiesa R, Roiter I, de Pedro-Cuesta J, Calero M, Geschwind MD, Yamada M, Nakamura Y, Mead S. Age at onset in genetic prion disease and the design of preventive clinical trials. Neurology. 2019 Jun 6. pii: 10.1212/WNL.0000000000007745. doi: 10.1212/WNL.0000000000007745. PubMed PMID: 31171647.
How to compare clinical trial data to a natural history control
Years later, I've arrived at a satisfactory answer. This did indeed turn out to be to use a Cox proportional hazards counting model, which allows you to account for different left-truncation times (ag
How to compare clinical trial data to a natural history control Years later, I've arrived at a satisfactory answer. This did indeed turn out to be to use a Cox proportional hazards counting model, which allows you to account for different left-truncation times (ages at which you started following the individuals) in addition to different right-censoring times. As noted in the question, this is implemented in R in the survival package coxph function, where time is the left-truncation time, time2 is the right-censoring time, event is what happened at the right-hand time, and you use type='counting' to specify the Cox counting model. The answers to specific questions raised in my post are: 1. Survival can indeed be computed with survfit — the model accounts for how the number of at-risk individuals can both grow and shrink over time as people enter and exit the age ranges where they were followed. An example for the toy dataset posted above would be plot(survfit(Surv(time=starting_age,time2=last_age,event=event,type='counting')~1, data=data_a)) 2. The model can compare the left-truncated prospective data and the non-left-truncated retrospective data, if you simply assume that the retrospective data are equivalent to following people from birth. This assumption may not be perfect but this is an inherent limitation of the dataset that no model is going to get around. Example code for the toy dataset above would be: data_c$starting_age = 0 data_c$last_age = data_c$age data_c$drug = FALSE nh_compare = rbind(data_a, data_c[,c('indiv_id','starting_age','last_age','event','drug')]) coxph(Surv(time=starting_age,time2=last_age,event=event,type='counting')~drug, data=nh_compare) 3. There appears to be no closed-form power calculation, instead we did this by bootstrapping. Our code to do this for our specific dataset appears here. 4. coxph allows for covariates, so for example in our code we used coxph(Surv(time=ascertainment_age,time2=surv_age,event=surv_status,type='counting')~asc+family_mutation,data=prore) where family_mutation is a covariate. We have published a paper where used this approach to calculate power for preventive clinical trials in genetic prion disease. You can read the details on bioRxiv and our R code is all in a public GitHub repo: https://github.com/ericminikel/prnp_onset/ Citation: Minikel EV, Vallabh SM, Orseth MC, Brandel JP, Haïk S, Laplanche JL, Zerr I, Parchi P, Capellari S, Safar J, Kenny J, Fong JC, Takada LT, Ponto C, Hermann P, Knipper T, Stehmann C, Kitamoto T, Ae R, Hamaguchi T, Sanjo N, Tsukamoto T, Mizusawa H, Collins SJ, Chiesa R, Roiter I, de Pedro-Cuesta J, Calero M, Geschwind MD, Yamada M, Nakamura Y, Mead S. Age at onset in genetic prion disease and the design of preventive clinical trials. Neurology. 2019 Jun 6. pii: 10.1212/WNL.0000000000007745. doi: 10.1212/WNL.0000000000007745. PubMed PMID: 31171647.
How to compare clinical trial data to a natural history control Years later, I've arrived at a satisfactory answer. This did indeed turn out to be to use a Cox proportional hazards counting model, which allows you to account for different left-truncation times (ag
37,100
How to compare clinical trial data to a natural history control
Eric, broadly speaking, your problem sounds severe enough that a search for off-the-shelf solutions seems misguided. Rather, you almost surely need recourse to bespoke modeling to exploit your special domain knowledge about the pathophysiology of the disease. Unless you use a modeling approach that enables you to bring such knowledge to bear, you might not stand a chance against the formidible 'opponent' you are facing! Your best first step might be figuring out just what 'special domain knowledge' you actually possess. Can you simulate the process that generated your data (i.e., the data-generating process or DGP), including the (left-truncation) process governing the entry of individuals into your data set? Once you can simulate the DGP, Bayesian methods should enable you to 'challenge' your simulation model with data—e.g., to estimate your model's parameters. Notwithstanding Odd Aalen's fin de siècle skepticism about Bayesian methods for survival analysis [1], I note that there is now at least one text on such approaches [2]. If I were faced with such a problem, I would be inclined first to explore it through simulation and Bayesian inference. Perhaps I would learn enough in that process to formulate simpler process models that might yield to more traditional frequentist estimation approaches. The interplay between simpler models and richer simulations might indeed yield its own valuable forms of insight and understanding. I hope you will eventually update us all here on what approach you eventually adopt, and how it works out! Aalen OO. Medical statistics - no time for complacency. Stat Methods Med Res. 2000;9(1):31-40. doi:10.1177/096228020000900105. Ibrahim JG, Chen M-H, Sinha D. Bayesian Survival Analysis. New York: Springer; 2010.
How to compare clinical trial data to a natural history control
Eric, broadly speaking, your problem sounds severe enough that a search for off-the-shelf solutions seems misguided. Rather, you almost surely need recourse to bespoke modeling to exploit your special
How to compare clinical trial data to a natural history control Eric, broadly speaking, your problem sounds severe enough that a search for off-the-shelf solutions seems misguided. Rather, you almost surely need recourse to bespoke modeling to exploit your special domain knowledge about the pathophysiology of the disease. Unless you use a modeling approach that enables you to bring such knowledge to bear, you might not stand a chance against the formidible 'opponent' you are facing! Your best first step might be figuring out just what 'special domain knowledge' you actually possess. Can you simulate the process that generated your data (i.e., the data-generating process or DGP), including the (left-truncation) process governing the entry of individuals into your data set? Once you can simulate the DGP, Bayesian methods should enable you to 'challenge' your simulation model with data—e.g., to estimate your model's parameters. Notwithstanding Odd Aalen's fin de siècle skepticism about Bayesian methods for survival analysis [1], I note that there is now at least one text on such approaches [2]. If I were faced with such a problem, I would be inclined first to explore it through simulation and Bayesian inference. Perhaps I would learn enough in that process to formulate simpler process models that might yield to more traditional frequentist estimation approaches. The interplay between simpler models and richer simulations might indeed yield its own valuable forms of insight and understanding. I hope you will eventually update us all here on what approach you eventually adopt, and how it works out! Aalen OO. Medical statistics - no time for complacency. Stat Methods Med Res. 2000;9(1):31-40. doi:10.1177/096228020000900105. Ibrahim JG, Chen M-H, Sinha D. Bayesian Survival Analysis. New York: Springer; 2010.
How to compare clinical trial data to a natural history control Eric, broadly speaking, your problem sounds severe enough that a search for off-the-shelf solutions seems misguided. Rather, you almost surely need recourse to bespoke modeling to exploit your special