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
31,201
Dimension reduction techniques for very small sample sizes
I would go for co-inertia analysis, which is an unspoken variant of canonical analysis. This would give you a linear combination of the 21 variables that has the highest co-inertia with a linear combination of childcare data (or with child care if it is a single quantitative variable). The trick of working with co-inertia instead of correlation is that you can still perform the computations when there are more variables than observations. Unfortunately, CIA is not very wide-spread. It was developed for ecology, where there is usually more variables than observation sites. You can find some technical information in Dray, Chessel and Thioulouse, Ecology 84(11), 3078-89, 2003. That said, the other comments/answers are right that 12 is a relatively small number and you will have to live with that...
Dimension reduction techniques for very small sample sizes
I would go for co-inertia analysis, which is an unspoken variant of canonical analysis. This would give you a linear combination of the 21 variables that has the highest co-inertia with a linear combi
Dimension reduction techniques for very small sample sizes I would go for co-inertia analysis, which is an unspoken variant of canonical analysis. This would give you a linear combination of the 21 variables that has the highest co-inertia with a linear combination of childcare data (or with child care if it is a single quantitative variable). The trick of working with co-inertia instead of correlation is that you can still perform the computations when there are more variables than observations. Unfortunately, CIA is not very wide-spread. It was developed for ecology, where there is usually more variables than observation sites. You can find some technical information in Dray, Chessel and Thioulouse, Ecology 84(11), 3078-89, 2003. That said, the other comments/answers are right that 12 is a relatively small number and you will have to live with that...
Dimension reduction techniques for very small sample sizes I would go for co-inertia analysis, which is an unspoken variant of canonical analysis. This would give you a linear combination of the 21 variables that has the highest co-inertia with a linear combi
31,202
Dimension reduction techniques for very small sample sizes
As Peter Ellis' comment/answer suggests you are talking about dimensionality reduction and not data reduction. You have changed the number of data points just the size of the space of covariates. Now Peter Flom is right that the PCA and FA methods can be tried with small sample sizes but it is not only the correlations that are likely to be poorly estimated but also that you could be fooled into dropping into too low dimensions because features may appear more highly correlated than they would have turn out to be with a larger sample. I would not recommend it.
Dimension reduction techniques for very small sample sizes
As Peter Ellis' comment/answer suggests you are talking about dimensionality reduction and not data reduction. You have changed the number of data points just the size of the space of covariates. Now
Dimension reduction techniques for very small sample sizes As Peter Ellis' comment/answer suggests you are talking about dimensionality reduction and not data reduction. You have changed the number of data points just the size of the space of covariates. Now Peter Flom is right that the PCA and FA methods can be tried with small sample sizes but it is not only the correlations that are likely to be poorly estimated but also that you could be fooled into dropping into too low dimensions because features may appear more highly correlated than they would have turn out to be with a larger sample. I would not recommend it.
Dimension reduction techniques for very small sample sizes As Peter Ellis' comment/answer suggests you are talking about dimensionality reduction and not data reduction. You have changed the number of data points just the size of the space of covariates. Now
31,203
Dimension reduction techniques for very small sample sizes
Regularized exploratory factor analysis was designed with this problem in mind. The authors have Matlab code available.
Dimension reduction techniques for very small sample sizes
Regularized exploratory factor analysis was designed with this problem in mind. The authors have Matlab code available.
Dimension reduction techniques for very small sample sizes Regularized exploratory factor analysis was designed with this problem in mind. The authors have Matlab code available.
Dimension reduction techniques for very small sample sizes Regularized exploratory factor analysis was designed with this problem in mind. The authors have Matlab code available.
31,204
Coefficients change signs
Because the question appears to ask about data whereas the comments talk about random variables, a data-based answer seems worth presenting. Let's generate a small dataset. (Later, you can change this to a huge dataset if you wish, just to confirm that the phenomena shown below do not depend on the size of the dataset.) To get going, let one independent variable $x_1$ be a simple sequence $1,2,\ldots,n$. To obtain another independent variable $x_2$ with strong positive correlation, just perturb the values of $x_1$ up and down a little. Here, I alternately subtract and add $1$. It helps to rescale $x_2$, so let's just halve it. Finally, let's see what happens when we create a dependent variable $y$ that is a perfect linear combination of $x_1$ and $x_2$ (without error) but with one positive and one negative sign. The following commands in R make examples like this using n data: n <- 6 # (Later, try (say) n=10000 to see what happens.) x1 <- 1:n # E.g., 1 2 3 4 5 6 x2 <- (x1 + c(-1,1))/2 # E.g., 0 3/2 1 5/2 2 7/2 y <- x1 - x2 # E.g, 1 1/2 2 3/2 3 5/2 data <- cbind(x1,x2,y) Here's a picture: First notice the strong, consistent positive correlations among the variables: in each panel, the points trend from lower left to upper right. Correlations, however, are not regression coefficients. A good way to understand the multiple regression of $y$ on $x_1$ and $x_2$ is first to regress both $y$ and $x_2$ (separately) on $x_1$ (to remove the effects of $x_1$ from both $y$ and $x_2$) and then to regress the $y$ residuals on the $x_2$ residuals: the slope in that univariate regression will be the $x_2$ coefficient in the multivariate regression of $y$ on $x_1$ and $x_2$. The lower triangle of this scatterplot matrix has been decorated with linear fits (the diagonal lines) and their residuals (the vertical line segments). Take a close look at the left column of plots, depicting the residuals of regressions against $x_1$. Scanning from left to right, notice how each time the upper panel ($x_2$ vs $x_1$) shows a negative residual, the lower panel ($y$ vs $x_1$) shows a positive residual: these residuals are negatively correlated. That's the key insight: multiple regression peels away relationships that may otherwise be hidden by mutual associations among the independent variables. For the doubtful, we can confirm the graphical analysis with calculations. First, the covariance matrix (scaled to simplify the presentation): > cov(data) * 40 x1 x2 y x1 140 82 58 x2 82 59 23 y 58 23 35 The positive entries confirm the impression of positive correlation in the scatterplot matrix. Now, the multivariate regression: > summary(lm(y ~ x1+x2)) ... Estimate Std. Error t value Pr(>|t|) (Intercept) -7.252e-16 2.571e-16 -2.821e+00 0.0667 . x1 1.000e+00 1.476e-16 6.776e+15 <2e-16 *** x2 -1.000e+00 2.273e-16 -4.399e+15 <2e-16 *** One slope is +1 and the other is -1. Both are significant. (Of course the slopes are significant: $y$ is a linear function of $x_1$ and $x_2$ with no error. For a more realistic example, just add a little bit of random error to $y$. Provided the error is small, it can change neither the signs of the covariances nor the signs of the regression coefficients, nor can it make them "insignificant.")
Coefficients change signs
Because the question appears to ask about data whereas the comments talk about random variables, a data-based answer seems worth presenting. Let's generate a small dataset. (Later, you can change thi
Coefficients change signs Because the question appears to ask about data whereas the comments talk about random variables, a data-based answer seems worth presenting. Let's generate a small dataset. (Later, you can change this to a huge dataset if you wish, just to confirm that the phenomena shown below do not depend on the size of the dataset.) To get going, let one independent variable $x_1$ be a simple sequence $1,2,\ldots,n$. To obtain another independent variable $x_2$ with strong positive correlation, just perturb the values of $x_1$ up and down a little. Here, I alternately subtract and add $1$. It helps to rescale $x_2$, so let's just halve it. Finally, let's see what happens when we create a dependent variable $y$ that is a perfect linear combination of $x_1$ and $x_2$ (without error) but with one positive and one negative sign. The following commands in R make examples like this using n data: n <- 6 # (Later, try (say) n=10000 to see what happens.) x1 <- 1:n # E.g., 1 2 3 4 5 6 x2 <- (x1 + c(-1,1))/2 # E.g., 0 3/2 1 5/2 2 7/2 y <- x1 - x2 # E.g, 1 1/2 2 3/2 3 5/2 data <- cbind(x1,x2,y) Here's a picture: First notice the strong, consistent positive correlations among the variables: in each panel, the points trend from lower left to upper right. Correlations, however, are not regression coefficients. A good way to understand the multiple regression of $y$ on $x_1$ and $x_2$ is first to regress both $y$ and $x_2$ (separately) on $x_1$ (to remove the effects of $x_1$ from both $y$ and $x_2$) and then to regress the $y$ residuals on the $x_2$ residuals: the slope in that univariate regression will be the $x_2$ coefficient in the multivariate regression of $y$ on $x_1$ and $x_2$. The lower triangle of this scatterplot matrix has been decorated with linear fits (the diagonal lines) and their residuals (the vertical line segments). Take a close look at the left column of plots, depicting the residuals of regressions against $x_1$. Scanning from left to right, notice how each time the upper panel ($x_2$ vs $x_1$) shows a negative residual, the lower panel ($y$ vs $x_1$) shows a positive residual: these residuals are negatively correlated. That's the key insight: multiple regression peels away relationships that may otherwise be hidden by mutual associations among the independent variables. For the doubtful, we can confirm the graphical analysis with calculations. First, the covariance matrix (scaled to simplify the presentation): > cov(data) * 40 x1 x2 y x1 140 82 58 x2 82 59 23 y 58 23 35 The positive entries confirm the impression of positive correlation in the scatterplot matrix. Now, the multivariate regression: > summary(lm(y ~ x1+x2)) ... Estimate Std. Error t value Pr(>|t|) (Intercept) -7.252e-16 2.571e-16 -2.821e+00 0.0667 . x1 1.000e+00 1.476e-16 6.776e+15 <2e-16 *** x2 -1.000e+00 2.273e-16 -4.399e+15 <2e-16 *** One slope is +1 and the other is -1. Both are significant. (Of course the slopes are significant: $y$ is a linear function of $x_1$ and $x_2$ with no error. For a more realistic example, just add a little bit of random error to $y$. Provided the error is small, it can change neither the signs of the covariances nor the signs of the regression coefficients, nor can it make them "insignificant.")
Coefficients change signs Because the question appears to ask about data whereas the comments talk about random variables, a data-based answer seems worth presenting. Let's generate a small dataset. (Later, you can change thi
31,205
Recommended reading for understanding when the bootstrap will fail?
A good thorough review of bootstrap theory and applications is Davison and Hinkley, 1997. It's more up to date than your reference, goes a bit more gently, and has a lot of example (some of them in R). If that still looks too much, Mooney and Duval, 1993 is a simpler shorter introduction, and very good place to start. Davison and Hinkley have a discussion of situations where bootstrapping fails at the end of ch. 2 (section 2.6). In fact an 'estimate the maximum' problem is in Example 2.5. Unsurprisingly, in general the bootstrap fails when the empirical distribution function fails to stand in well for the real one. The specifics of failure -- concerning lack of approximate pivotally and edgeworth expansions -- are perhaps better left for the reading.
Recommended reading for understanding when the bootstrap will fail?
A good thorough review of bootstrap theory and applications is Davison and Hinkley, 1997. It's more up to date than your reference, goes a bit more gently, and has a lot of example (some of them in R
Recommended reading for understanding when the bootstrap will fail? A good thorough review of bootstrap theory and applications is Davison and Hinkley, 1997. It's more up to date than your reference, goes a bit more gently, and has a lot of example (some of them in R). If that still looks too much, Mooney and Duval, 1993 is a simpler shorter introduction, and very good place to start. Davison and Hinkley have a discussion of situations where bootstrapping fails at the end of ch. 2 (section 2.6). In fact an 'estimate the maximum' problem is in Example 2.5. Unsurprisingly, in general the bootstrap fails when the empirical distribution function fails to stand in well for the real one. The specifics of failure -- concerning lack of approximate pivotally and edgeworth expansions -- are perhaps better left for the reading.
Recommended reading for understanding when the bootstrap will fail? A good thorough review of bootstrap theory and applications is Davison and Hinkley, 1997. It's more up to date than your reference, goes a bit more gently, and has a lot of example (some of them in R
31,206
Recommended reading for understanding when the bootstrap will fail?
My book has a whole chapter on it (Chapter 9). The volume Exploring the Limits of Bootstrap is a conference proceeding that has research papers on it. Here are amazon links to these books. Bootstrap Methods: A Guide for Practitioners and Researchers Exploring the Limits of Bootstrap
Recommended reading for understanding when the bootstrap will fail?
My book has a whole chapter on it (Chapter 9). The volume Exploring the Limits of Bootstrap is a conference proceeding that has research papers on it. Here are amazon links to these books. Bootstrap
Recommended reading for understanding when the bootstrap will fail? My book has a whole chapter on it (Chapter 9). The volume Exploring the Limits of Bootstrap is a conference proceeding that has research papers on it. Here are amazon links to these books. Bootstrap Methods: A Guide for Practitioners and Researchers Exploring the Limits of Bootstrap
Recommended reading for understanding when the bootstrap will fail? My book has a whole chapter on it (Chapter 9). The volume Exploring the Limits of Bootstrap is a conference proceeding that has research papers on it. Here are amazon links to these books. Bootstrap
31,207
Can a -2 Log likelihood be calculated with only one model?
The statistical term deviance is thrown around a bit too much. Most of the time, programs return the deviance $$ D(y) = -2 \log{\{p(y | \hat{\theta})\}},$$ where $\hat{\theta}$ is your estimated parameter(s) from model fitting and $y$ is some potentially observed/observable occurrence of the random quantity in question. The more common deviance that you refer to would treat the deviance above as a function of two variables, both the data and the fitted parameters: $$ D(y,\hat{\theta}) = -2\log{\{p(y|\hat{\theta})\}}$$ and so if you had one $y$ value but two competing, fitted parameter values, $\hat{\theta}_{1}$ and $\hat{\theta}_{2}$, then you'd get the deviance you mentioned from $$-2(\log{\{p(y|\hat{\theta}_{1})\}} - \log{\{p(y|\hat{\theta}_{2})\}}). $$ You can read about the Matlab function that you mentioned, glmfit(), linked here. A more fruitful, though shorter, discussion of the deviance is linked here. The deviance statistic implicitly assumes two models: the first is your fitted model, returned by glmfit(), call this parameter vector $\hat{\theta}_{1}$. The second is the "full-model" (also called the "saturated model"), which is a model in which there is a free variable for every data point, call this parameter vector $\hat{\theta}_{s}$. Having so many free variables is obviously a stupid thing to do, but it does allow you to fit to that data exactly. So then, the deviance statistics is computed as the difference between the log likelihood computed at the fitted model and the saturated model. Let $Y=\{y_{1}, y_{2}, \cdots, y_{N}\}$ be the collection of the N data points. Then: $$DEV(\hat{\theta}_{1},Y) = -2\biggl[\log{p(Y|\hat{\theta}_{1})} - \log{p(Y|\hat{\theta}_{s})} \biggr]. $$ The terms above will be expanded into summations over the individual data points $y_{i}$ by the independence assumption. If you want to use this computation to calculate the log-likelihood of the model, then you'll need to first calculate the log-likelihood of the saturated model. Here is a link that explains some ideas for computing this... but the catch is that in any case, you're going to need to write down a function that computes the log-likelihood for your type of data, and in that case it's probably just better to create your own function that computes the log-likelihood yourself, rather than backtracking it out of a deviance calculation. See Chapter 6 of Bayesian Data Analysis for some good discussion of deviance. As for your second point about the likelihood test statistic, yes it sounds like you basically know the right thing to do. But in many cases, you'll consider the null hypothesis to be something that expert, external knowledge lets you guess ahead of time (like some coefficient being equal to zero). It's not necessarily something that comes as the result of doing model fitting.
Can a -2 Log likelihood be calculated with only one model?
The statistical term deviance is thrown around a bit too much. Most of the time, programs return the deviance $$ D(y) = -2 \log{\{p(y | \hat{\theta})\}},$$ where $\hat{\theta}$ is your estimated par
Can a -2 Log likelihood be calculated with only one model? The statistical term deviance is thrown around a bit too much. Most of the time, programs return the deviance $$ D(y) = -2 \log{\{p(y | \hat{\theta})\}},$$ where $\hat{\theta}$ is your estimated parameter(s) from model fitting and $y$ is some potentially observed/observable occurrence of the random quantity in question. The more common deviance that you refer to would treat the deviance above as a function of two variables, both the data and the fitted parameters: $$ D(y,\hat{\theta}) = -2\log{\{p(y|\hat{\theta})\}}$$ and so if you had one $y$ value but two competing, fitted parameter values, $\hat{\theta}_{1}$ and $\hat{\theta}_{2}$, then you'd get the deviance you mentioned from $$-2(\log{\{p(y|\hat{\theta}_{1})\}} - \log{\{p(y|\hat{\theta}_{2})\}}). $$ You can read about the Matlab function that you mentioned, glmfit(), linked here. A more fruitful, though shorter, discussion of the deviance is linked here. The deviance statistic implicitly assumes two models: the first is your fitted model, returned by glmfit(), call this parameter vector $\hat{\theta}_{1}$. The second is the "full-model" (also called the "saturated model"), which is a model in which there is a free variable for every data point, call this parameter vector $\hat{\theta}_{s}$. Having so many free variables is obviously a stupid thing to do, but it does allow you to fit to that data exactly. So then, the deviance statistics is computed as the difference between the log likelihood computed at the fitted model and the saturated model. Let $Y=\{y_{1}, y_{2}, \cdots, y_{N}\}$ be the collection of the N data points. Then: $$DEV(\hat{\theta}_{1},Y) = -2\biggl[\log{p(Y|\hat{\theta}_{1})} - \log{p(Y|\hat{\theta}_{s})} \biggr]. $$ The terms above will be expanded into summations over the individual data points $y_{i}$ by the independence assumption. If you want to use this computation to calculate the log-likelihood of the model, then you'll need to first calculate the log-likelihood of the saturated model. Here is a link that explains some ideas for computing this... but the catch is that in any case, you're going to need to write down a function that computes the log-likelihood for your type of data, and in that case it's probably just better to create your own function that computes the log-likelihood yourself, rather than backtracking it out of a deviance calculation. See Chapter 6 of Bayesian Data Analysis for some good discussion of deviance. As for your second point about the likelihood test statistic, yes it sounds like you basically know the right thing to do. But in many cases, you'll consider the null hypothesis to be something that expert, external knowledge lets you guess ahead of time (like some coefficient being equal to zero). It's not necessarily something that comes as the result of doing model fitting.
Can a -2 Log likelihood be calculated with only one model? The statistical term deviance is thrown around a bit too much. Most of the time, programs return the deviance $$ D(y) = -2 \log{\{p(y | \hat{\theta})\}},$$ where $\hat{\theta}$ is your estimated par
31,208
Can I trust a regression if variables are autocorrelated?
The t-statistics are reliable in the absence of autocorrelation of the errors. The fact that the residuals don't display significant autocorrelation indicates, in a not terribly rigorous way, that the autocorrelation in your dependent variable is due to the autocorrelation in your independent variable. However, it's also important to remember that the difference between statistical significance and insignificance is not itself statistically significant in many cases, e.g., a t-statistic of 1.8 vs. a t-statistic of 2.8 is a difference of 1.0, hence the lack of rigor in the statement above. An alternative approach would be to model the data using time series analysis techniques, which, for R, are very briefly described in CRAN task view: Time Series Analysis. These techniques can get you sharper parameter estimates by explicitly modeling cross-time correlation structures, whereas, if you don't model them explicitly, you are implicitly assuming that the only such structure in the data is due to the independent variable.
Can I trust a regression if variables are autocorrelated?
The t-statistics are reliable in the absence of autocorrelation of the errors. The fact that the residuals don't display significant autocorrelation indicates, in a not terribly rigorous way, that th
Can I trust a regression if variables are autocorrelated? The t-statistics are reliable in the absence of autocorrelation of the errors. The fact that the residuals don't display significant autocorrelation indicates, in a not terribly rigorous way, that the autocorrelation in your dependent variable is due to the autocorrelation in your independent variable. However, it's also important to remember that the difference between statistical significance and insignificance is not itself statistically significant in many cases, e.g., a t-statistic of 1.8 vs. a t-statistic of 2.8 is a difference of 1.0, hence the lack of rigor in the statement above. An alternative approach would be to model the data using time series analysis techniques, which, for R, are very briefly described in CRAN task view: Time Series Analysis. These techniques can get you sharper parameter estimates by explicitly modeling cross-time correlation structures, whereas, if you don't model them explicitly, you are implicitly assuming that the only such structure in the data is due to the independent variable.
Can I trust a regression if variables are autocorrelated? The t-statistics are reliable in the absence of autocorrelation of the errors. The fact that the residuals don't display significant autocorrelation indicates, in a not terribly rigorous way, that th
31,209
Can I trust a regression if variables are autocorrelated?
The t-statistics are un-reliable in the presence of autocorrelation of the errors. Auto-correlation in the errors can be due either insufficient lag structures in the causal variables or insufficient dependent variable lag structure. Furthermore anomalies in the error structure cause one to incorrectly accept randomness thus care should be taken to alleviate the impact of Pulses, Level Shifts, Seasonal Pulses and/or Local Time Trends that may be present but untreated. The Durbin-Watson test only reveals significant auto-correlation of lag 1 .If there is say auto-correlation of say lag S where S is the frequency of measurement (4,7,12 etc.) the DW test will incorrectly suggest randomness.
Can I trust a regression if variables are autocorrelated?
The t-statistics are un-reliable in the presence of autocorrelation of the errors. Auto-correlation in the errors can be due either insufficient lag structures in the causal variables or insufficient
Can I trust a regression if variables are autocorrelated? The t-statistics are un-reliable in the presence of autocorrelation of the errors. Auto-correlation in the errors can be due either insufficient lag structures in the causal variables or insufficient dependent variable lag structure. Furthermore anomalies in the error structure cause one to incorrectly accept randomness thus care should be taken to alleviate the impact of Pulses, Level Shifts, Seasonal Pulses and/or Local Time Trends that may be present but untreated. The Durbin-Watson test only reveals significant auto-correlation of lag 1 .If there is say auto-correlation of say lag S where S is the frequency of measurement (4,7,12 etc.) the DW test will incorrectly suggest randomness.
Can I trust a regression if variables are autocorrelated? The t-statistics are un-reliable in the presence of autocorrelation of the errors. Auto-correlation in the errors can be due either insufficient lag structures in the causal variables or insufficient
31,210
Are decision forests and random forests the same thing?
At the Alglib page you cited, it says, "The RDF [Random decision forest] algorithm is a modification of the original Random Forest algorithm designed by Leo Breiman and Adele Cutler." A question at rapid-i.com refers to Ho TK (1998) The Random Subspace Method for Constructing Decision Forests. IEEE Trans Pattern Anal Mach Intel 20(8) 832-844 [Abstract] which might be yet another thing. At Breiman's web page at Berkeley, it says, "Random Forests(tm) is a trademark of Leo Breiman and Adele Cutler and is licensed exclusively to Salford Systems for the commercial release of the software. Our trademarks also include RF(tm), RandomForests(tm), RandomForest(tm) and Random Forest(tm)." So I conclude that there are subtle differences, but mostly it's a trademark issue regarding the name "random forest".
Are decision forests and random forests the same thing?
At the Alglib page you cited, it says, "The RDF [Random decision forest] algorithm is a modification of the original Random Forest algorithm designed by Leo Breiman and Adele Cutler." A questio
Are decision forests and random forests the same thing? At the Alglib page you cited, it says, "The RDF [Random decision forest] algorithm is a modification of the original Random Forest algorithm designed by Leo Breiman and Adele Cutler." A question at rapid-i.com refers to Ho TK (1998) The Random Subspace Method for Constructing Decision Forests. IEEE Trans Pattern Anal Mach Intel 20(8) 832-844 [Abstract] which might be yet another thing. At Breiman's web page at Berkeley, it says, "Random Forests(tm) is a trademark of Leo Breiman and Adele Cutler and is licensed exclusively to Salford Systems for the commercial release of the software. Our trademarks also include RF(tm), RandomForests(tm), RandomForest(tm) and Random Forest(tm)." So I conclude that there are subtle differences, but mostly it's a trademark issue regarding the name "random forest".
Are decision forests and random forests the same thing? At the Alglib page you cited, it says, "The RDF [Random decision forest] algorithm is a modification of the original Random Forest algorithm designed by Leo Breiman and Adele Cutler." A questio
31,211
How is the intercept computed in GLMnet?
I found that the intercept in GLMnet is computed after the new coefficients updates have converged. The intercept is computed with the means of the $y_i$'s and the mean of the $x_{ij}$'s. The formula is siimilar to the previous one I gave but with the $\beta_j$'s after the update loop : $\beta_0=\bar{y}-\sum_{j=1}^{p} \hat{\beta_j} \bar{x_j}$. In python this gives something like : self.intercept_ = ymean - np.dot(Xmean, self.coef_.T) which I found here on scikit-learn page. EDIT : the coefficients have to be standardized before : self.coef_ = self.coef_ / X_std $\beta_0=\bar{y}-\sum_{j=1}^{p} \frac{\hat{\beta_j} \bar{x_j}}{\sum_{i=1}^{n} x_{ij}^2}$.
How is the intercept computed in GLMnet?
I found that the intercept in GLMnet is computed after the new coefficients updates have converged. The intercept is computed with the means of the $y_i$'s and the mean of the $x_{ij}$'s. The formula
How is the intercept computed in GLMnet? I found that the intercept in GLMnet is computed after the new coefficients updates have converged. The intercept is computed with the means of the $y_i$'s and the mean of the $x_{ij}$'s. The formula is siimilar to the previous one I gave but with the $\beta_j$'s after the update loop : $\beta_0=\bar{y}-\sum_{j=1}^{p} \hat{\beta_j} \bar{x_j}$. In python this gives something like : self.intercept_ = ymean - np.dot(Xmean, self.coef_.T) which I found here on scikit-learn page. EDIT : the coefficients have to be standardized before : self.coef_ = self.coef_ / X_std $\beta_0=\bar{y}-\sum_{j=1}^{p} \frac{\hat{\beta_j} \bar{x_j}}{\sum_{i=1}^{n} x_{ij}^2}$.
How is the intercept computed in GLMnet? I found that the intercept in GLMnet is computed after the new coefficients updates have converged. The intercept is computed with the means of the $y_i$'s and the mean of the $x_{ij}$'s. The formula
31,212
How is the intercept computed in GLMnet?
which I take as the mean of the target variable I think this may be where you're going wrong: unlike the linear model, you can't reparameterise the predictors such that they will always be orthogonal to the intercept, hence the intercept cannot just be calculated as the mean.
How is the intercept computed in GLMnet?
which I take as the mean of the target variable I think this may be where you're going wrong: unlike the linear model, you can't reparameterise the predictors such that they will always be orthogonal
How is the intercept computed in GLMnet? which I take as the mean of the target variable I think this may be where you're going wrong: unlike the linear model, you can't reparameterise the predictors such that they will always be orthogonal to the intercept, hence the intercept cannot just be calculated as the mean.
How is the intercept computed in GLMnet? which I take as the mean of the target variable I think this may be where you're going wrong: unlike the linear model, you can't reparameterise the predictors such that they will always be orthogonal
31,213
Paired, repeated-measures ANOVA or a mixed model?
I don't think you can easily do what you want to do with RM-ANOVA since number of the repetitions are not the same for all subjects. Running mixed-effects models is very easy in R. In fact, by investing a little time to learn the fundamentals and the commands, it will open a lot of possibilities to you. I also find mixed-modeling much simpler to use and more flexible and almost never need to do RM-ANOVA directly. Finally, consider that with mixed modeling you can also account for the covariance structure of the residuals (RM-ANOVA simply assumes a diagonal structure) which can be important for many applications. There are two main packages for linear mixed modeling in R: nlme and lme4. The lme4 packages is the more modern one which is great for large datasets and also for the cases you deal with clustered data. Nlme is the older package and is mostly deprecated in favor of lme4. However, for repeated measures designs it is still better than lme4 since only nlme allows you to model the covariance structure of the residuals. The basic syntax of nlme is very simple. For example: fit.1 <- lme(dv ~ x + t, random=~1|subject, cor=corCompSymm()) Here I'm modeling the relationship between a dependent variable dv and a factor x and time-related covariate t. Subject is a random effect and I have used a compound symmetry structure for the covariance of the residuals. Now you can easily get the infamous p-values by: anova(fit.1) Finally, I can suggest you to read more about nlme using its definitive reference guide, Mixed Effects Models in S and S-Plus. Another good reference for beginners is Linear Mixed Models - a Practical Guide Using Statistical Software which compiles lots of examples of different applications of mixed modeling with code in R, SAS, SPSS, etc.
Paired, repeated-measures ANOVA or a mixed model?
I don't think you can easily do what you want to do with RM-ANOVA since number of the repetitions are not the same for all subjects. Running mixed-effects models is very easy in R. In fact, by investi
Paired, repeated-measures ANOVA or a mixed model? I don't think you can easily do what you want to do with RM-ANOVA since number of the repetitions are not the same for all subjects. Running mixed-effects models is very easy in R. In fact, by investing a little time to learn the fundamentals and the commands, it will open a lot of possibilities to you. I also find mixed-modeling much simpler to use and more flexible and almost never need to do RM-ANOVA directly. Finally, consider that with mixed modeling you can also account for the covariance structure of the residuals (RM-ANOVA simply assumes a diagonal structure) which can be important for many applications. There are two main packages for linear mixed modeling in R: nlme and lme4. The lme4 packages is the more modern one which is great for large datasets and also for the cases you deal with clustered data. Nlme is the older package and is mostly deprecated in favor of lme4. However, for repeated measures designs it is still better than lme4 since only nlme allows you to model the covariance structure of the residuals. The basic syntax of nlme is very simple. For example: fit.1 <- lme(dv ~ x + t, random=~1|subject, cor=corCompSymm()) Here I'm modeling the relationship between a dependent variable dv and a factor x and time-related covariate t. Subject is a random effect and I have used a compound symmetry structure for the covariance of the residuals. Now you can easily get the infamous p-values by: anova(fit.1) Finally, I can suggest you to read more about nlme using its definitive reference guide, Mixed Effects Models in S and S-Plus. Another good reference for beginners is Linear Mixed Models - a Practical Guide Using Statistical Software which compiles lots of examples of different applications of mixed modeling with code in R, SAS, SPSS, etc.
Paired, repeated-measures ANOVA or a mixed model? I don't think you can easily do what you want to do with RM-ANOVA since number of the repetitions are not the same for all subjects. Running mixed-effects models is very easy in R. In fact, by investi
31,214
Paired, repeated-measures ANOVA or a mixed model?
If you are looking for RM-ANOVA with mixed model by using R. You might want to check this out http://blog.gribblelab.org/2009/03/09/repeated-measures-anova-using-r/ There are great examples to demonstrate how to use mixed model to accomplish the RM-ANOVA. Based on my experience, SAS is a better tool to deal with the mixed model. If you are using SAS, you could check the SAS help "Proc Mixed" for RM-ANOVA.
Paired, repeated-measures ANOVA or a mixed model?
If you are looking for RM-ANOVA with mixed model by using R. You might want to check this out http://blog.gribblelab.org/2009/03/09/repeated-measures-anova-using-r/ There are great examples to demonst
Paired, repeated-measures ANOVA or a mixed model? If you are looking for RM-ANOVA with mixed model by using R. You might want to check this out http://blog.gribblelab.org/2009/03/09/repeated-measures-anova-using-r/ There are great examples to demonstrate how to use mixed model to accomplish the RM-ANOVA. Based on my experience, SAS is a better tool to deal with the mixed model. If you are using SAS, you could check the SAS help "Proc Mixed" for RM-ANOVA.
Paired, repeated-measures ANOVA or a mixed model? If you are looking for RM-ANOVA with mixed model by using R. You might want to check this out http://blog.gribblelab.org/2009/03/09/repeated-measures-anova-using-r/ There are great examples to demonst
31,215
What should I be aware of when using multiple regression to find "causal" relationships in my data?
You cannot "systemically avoid this problem in the future", because it should not be called a "problem". If the reality of the material world features strong covariates, then we should accept it as fact and adjust our theories and models in consequence. I like the question very much, and hope that what follows will not sound too disappointing. Here are some adjustments that might work for you. You will need to review a regression handbook before proceeding. Diagnose the issue, using correlation or post-estimation techniques like the Variance Inflation Factor (VIF). Use the tools mentioned by Peter Flom if you are using SAS or R. In Stata, use pwcorr to build a correlation matrix, gr matrix to build a scatterplot matrix, and vif to detect problematic tolerance levels of 1/VIF < 0.1. Measure the interaction effect by adding, for example, var3*var4 to the model. The coefficient will help you realise how much is at play between var3 and var4. This will only bring you so far as partially measuring the interaction, but it will not rescue your model from its limitations. Most importantly, if you detect strong multicollinearity or other issues like heteroscedasticity, you should ditch your model and start again. Model misspecification is the plague of regression analysis (and frequentist methods in general). Paul Schrodt has several excellent papers on the issue, including his recent "Seven Deadly Sins" that I like a lot. This answers your point on multicollinearity, and a lot of this can be learnt from the regression handbook over at UCLA Stat Computing. It does not answer your question on causality. Briefly put, regression is never causal. Neither is any statistical model: causal and statistical information are separate species. Read selectively from Judea Pearl (example) to learn more on the matter. All in all, this answer does not cancel out the value of regression analysis, or even of frequentist statistics (I happen to teach both). It does, however, reduce their scope of appropriateness, and also underlines the crucial role of your initial explanatory theory, which really determines the possibility of your model possessing causal properties.
What should I be aware of when using multiple regression to find "causal" relationships in my data?
You cannot "systemically avoid this problem in the future", because it should not be called a "problem". If the reality of the material world features strong covariates, then we should accept it as fa
What should I be aware of when using multiple regression to find "causal" relationships in my data? You cannot "systemically avoid this problem in the future", because it should not be called a "problem". If the reality of the material world features strong covariates, then we should accept it as fact and adjust our theories and models in consequence. I like the question very much, and hope that what follows will not sound too disappointing. Here are some adjustments that might work for you. You will need to review a regression handbook before proceeding. Diagnose the issue, using correlation or post-estimation techniques like the Variance Inflation Factor (VIF). Use the tools mentioned by Peter Flom if you are using SAS or R. In Stata, use pwcorr to build a correlation matrix, gr matrix to build a scatterplot matrix, and vif to detect problematic tolerance levels of 1/VIF < 0.1. Measure the interaction effect by adding, for example, var3*var4 to the model. The coefficient will help you realise how much is at play between var3 and var4. This will only bring you so far as partially measuring the interaction, but it will not rescue your model from its limitations. Most importantly, if you detect strong multicollinearity or other issues like heteroscedasticity, you should ditch your model and start again. Model misspecification is the plague of regression analysis (and frequentist methods in general). Paul Schrodt has several excellent papers on the issue, including his recent "Seven Deadly Sins" that I like a lot. This answers your point on multicollinearity, and a lot of this can be learnt from the regression handbook over at UCLA Stat Computing. It does not answer your question on causality. Briefly put, regression is never causal. Neither is any statistical model: causal and statistical information are separate species. Read selectively from Judea Pearl (example) to learn more on the matter. All in all, this answer does not cancel out the value of regression analysis, or even of frequentist statistics (I happen to teach both). It does, however, reduce their scope of appropriateness, and also underlines the crucial role of your initial explanatory theory, which really determines the possibility of your model possessing causal properties.
What should I be aware of when using multiple regression to find "causal" relationships in my data? You cannot "systemically avoid this problem in the future", because it should not be called a "problem". If the reality of the material world features strong covariates, then we should accept it as fa
31,216
What should I be aware of when using multiple regression to find "causal" relationships in my data?
If you want to see if the independent variables are correlated, that's easy - just test the correlations e.g. with PROC CORR in SAS, or cor in R, or whatever in whatever package you use. You might, though, want to test collinearity instead, or in addition. But that's only part of the problem for causation. More problematic is that some variable that is NOT in your data is involved. Classic examples: Students who hire tutors get worse grades than students who do not hire tutors. The amount of damage done by a fire is highly related to the number of firemen who show up. and (my favorite) if you regress IQ on astrological sign and age among children age 5 - 12, there is a significant interaction and a significant effect of sign on IQ, but only in young children. Reasons: 1. Yes. Because students who get really good grades tend not to hire tutors in the first place Yes, because bigger fires do more damage and bring more firemen The amount of school (in months) a kid has had depends on birth month. School systems have age cutoffs. So, one 6 year old may have had 11 months more school than another 6 year old. And all that is without getting into philosophy!
What should I be aware of when using multiple regression to find "causal" relationships in my data?
If you want to see if the independent variables are correlated, that's easy - just test the correlations e.g. with PROC CORR in SAS, or cor in R, or whatever in whatever package you use. You might, th
What should I be aware of when using multiple regression to find "causal" relationships in my data? If you want to see if the independent variables are correlated, that's easy - just test the correlations e.g. with PROC CORR in SAS, or cor in R, or whatever in whatever package you use. You might, though, want to test collinearity instead, or in addition. But that's only part of the problem for causation. More problematic is that some variable that is NOT in your data is involved. Classic examples: Students who hire tutors get worse grades than students who do not hire tutors. The amount of damage done by a fire is highly related to the number of firemen who show up. and (my favorite) if you regress IQ on astrological sign and age among children age 5 - 12, there is a significant interaction and a significant effect of sign on IQ, but only in young children. Reasons: 1. Yes. Because students who get really good grades tend not to hire tutors in the first place Yes, because bigger fires do more damage and bring more firemen The amount of school (in months) a kid has had depends on birth month. School systems have age cutoffs. So, one 6 year old may have had 11 months more school than another 6 year old. And all that is without getting into philosophy!
What should I be aware of when using multiple regression to find "causal" relationships in my data? If you want to see if the independent variables are correlated, that's easy - just test the correlations e.g. with PROC CORR in SAS, or cor in R, or whatever in whatever package you use. You might, th
31,217
What should I be aware of when using multiple regression to find "causal" relationships in my data?
The relationship between causation and association is basically in answering the following question: What else, besides the hypothesised causal relationship, could have caused $X$ and $Y$ to be related to each other? As long as the answer to this question is not "nothing" then you can only talk definitively about association. There can always be that one proposed "causal" relationship is actually a special case of the "correct" causal relationship - this is what happened between Newton's and Einstein's theory of gravity I think. Newton's causal relationship was a special case of Einstein's theory. And his theory will probably be a special case of some other theory. Additionally, any error at all in your data removes any chance of a definite causal relationship. This is because the phrase "A causes B" is somewhat of a deductive link between A and B. All you have to do to disprove this hypothesis is to find 1 case where B is not present but A is present (for then A is true, but this should mean that B is also true - but we observed B false). In a regression setting, it is much more constructive to think of prediction than of interpreting coefficients when looking at causation. So if you really do have a good reason to think that variable four is the "main cause" of variable $Y$ (your dependent variable), then you should be able to predict $Y$ with near certainty using variable four. If you cannot do this, then it is inappropriate to concluded that variable four causes $Y$. But if you can do this prediction to near certainty using all four variables - then this is indicating that particular combinations are "causing" $Y$. And whenever you propose a causal relationship you will almost certainly have to "prove it" by reproducing your results with new data - you will need to be able to predict what data will be seen, and be correct about it. You also need some kind of physical theory about the "causal mechanism" (when I push that button, the light comes on, when I push this button, the light changes color, etc.). If all you have is that the "regression coefficient was 0.7" this does little for establishing a causal mechanism which is at work.
What should I be aware of when using multiple regression to find "causal" relationships in my data?
The relationship between causation and association is basically in answering the following question: What else, besides the hypothesised causal relationship, could have caused $X$ and $Y$ to be relate
What should I be aware of when using multiple regression to find "causal" relationships in my data? The relationship between causation and association is basically in answering the following question: What else, besides the hypothesised causal relationship, could have caused $X$ and $Y$ to be related to each other? As long as the answer to this question is not "nothing" then you can only talk definitively about association. There can always be that one proposed "causal" relationship is actually a special case of the "correct" causal relationship - this is what happened between Newton's and Einstein's theory of gravity I think. Newton's causal relationship was a special case of Einstein's theory. And his theory will probably be a special case of some other theory. Additionally, any error at all in your data removes any chance of a definite causal relationship. This is because the phrase "A causes B" is somewhat of a deductive link between A and B. All you have to do to disprove this hypothesis is to find 1 case where B is not present but A is present (for then A is true, but this should mean that B is also true - but we observed B false). In a regression setting, it is much more constructive to think of prediction than of interpreting coefficients when looking at causation. So if you really do have a good reason to think that variable four is the "main cause" of variable $Y$ (your dependent variable), then you should be able to predict $Y$ with near certainty using variable four. If you cannot do this, then it is inappropriate to concluded that variable four causes $Y$. But if you can do this prediction to near certainty using all four variables - then this is indicating that particular combinations are "causing" $Y$. And whenever you propose a causal relationship you will almost certainly have to "prove it" by reproducing your results with new data - you will need to be able to predict what data will be seen, and be correct about it. You also need some kind of physical theory about the "causal mechanism" (when I push that button, the light comes on, when I push this button, the light changes color, etc.). If all you have is that the "regression coefficient was 0.7" this does little for establishing a causal mechanism which is at work.
What should I be aware of when using multiple regression to find "causal" relationships in my data? The relationship between causation and association is basically in answering the following question: What else, besides the hypothesised causal relationship, could have caused $X$ and $Y$ to be relate
31,218
What should I be aware of when using multiple regression to find "causal" relationships in my data?
I'm not sure what field your work is in, so this may or may not be of any help- but I'm most familiar with using SPSS with psychological constructs. In my experience, if I have a few variables predicting an outcome variable (or dependent variable) in a regression, and I have one or more independent variables show up as significant predictors, the next step is to see which ones are more incrementally important than others. One way to approach this is with hierarchical regression. This basically answers the question "If I already have 'variable four' to predict my outcome variable, do any of the other variables provide a statistically significant increase in predictive power?" SPSS has a pretty clear way of analyzing this, as I'm sure R and SAS do as well. So, I think hierarchical regression might be your next step in finding out if 'variable four' really is your best bet in predicting your outcome factor. The others who've responded have provided a good discussion of the issues in correlation-causation, so I'll leave that alone... Good luck!
What should I be aware of when using multiple regression to find "causal" relationships in my data?
I'm not sure what field your work is in, so this may or may not be of any help- but I'm most familiar with using SPSS with psychological constructs. In my experience, if I have a few variables predict
What should I be aware of when using multiple regression to find "causal" relationships in my data? I'm not sure what field your work is in, so this may or may not be of any help- but I'm most familiar with using SPSS with psychological constructs. In my experience, if I have a few variables predicting an outcome variable (or dependent variable) in a regression, and I have one or more independent variables show up as significant predictors, the next step is to see which ones are more incrementally important than others. One way to approach this is with hierarchical regression. This basically answers the question "If I already have 'variable four' to predict my outcome variable, do any of the other variables provide a statistically significant increase in predictive power?" SPSS has a pretty clear way of analyzing this, as I'm sure R and SAS do as well. So, I think hierarchical regression might be your next step in finding out if 'variable four' really is your best bet in predicting your outcome factor. The others who've responded have provided a good discussion of the issues in correlation-causation, so I'll leave that alone... Good luck!
What should I be aware of when using multiple regression to find "causal" relationships in my data? I'm not sure what field your work is in, so this may or may not be of any help- but I'm most familiar with using SPSS with psychological constructs. In my experience, if I have a few variables predict
31,219
How to calculate confidence intervals for pooled odd ratios in meta-analysis?
In most meta-analysis of odds ratios, the standard errors $se_i$ are based on the log odds ratios $log(OR_i)$. So, do you happen to know how your $se_i$ have been estimated (and what metric they reflect? $OR$ or $log(OR)$)? Given that the $se_i$ are based on $log(OR_i)$, then the pooled standard error (under a fixed effect model) can be easily computed. First, let's compute the weights for each effect size: $w_i = \frac{1}{se_i^2}$. Second, the pooled standard error is $se_{FEM} = \sqrt{\frac{1}{\sum w}}$. Furthermore, let $log(OR_{FEM})$ be the common effect (fixed effect model). Then, the ("pooled") 95% confidence interval is $log(OR_{FEM}) \pm 1.96 \cdot se_{FEM}$. Update Since BIBB kindly provided the data, I am able to run the 'full' meta-analysis in R. library(meta) or <- c(0.75, 0.85) se <- c(0.0937, 0.1029) logor <- log(or) (or.fem <- metagen(logor, se, sm = "OR")) > (or.fem <- metagen(logor, se, sm = "OR")) OR 95%-CI %W(fixed) %W(random) 1 0.75 [0.6242; 0.9012] 54.67 54.67 2 0.85 [0.6948; 1.0399] 45.33 45.33 Number of trials combined: 2 OR 95%-CI z p.value Fixed effect model 0.7938 [0.693; 0.9092] -3.3335 0.0009 Random effects model 0.7938 [0.693; 0.9092] -3.3335 0.0009 Quantifying heterogeneity: tau^2 < 0.0001; H = 1; I^2 = 0% Test of heterogeneity: Q d.f. p.value 0.81 1 0.3685 Method: Inverse variance method References See, e.g., Lipsey/Wilson (2001: 114)
How to calculate confidence intervals for pooled odd ratios in meta-analysis?
In most meta-analysis of odds ratios, the standard errors $se_i$ are based on the log odds ratios $log(OR_i)$. So, do you happen to know how your $se_i$ have been estimated (and what metric they refle
How to calculate confidence intervals for pooled odd ratios in meta-analysis? In most meta-analysis of odds ratios, the standard errors $se_i$ are based on the log odds ratios $log(OR_i)$. So, do you happen to know how your $se_i$ have been estimated (and what metric they reflect? $OR$ or $log(OR)$)? Given that the $se_i$ are based on $log(OR_i)$, then the pooled standard error (under a fixed effect model) can be easily computed. First, let's compute the weights for each effect size: $w_i = \frac{1}{se_i^2}$. Second, the pooled standard error is $se_{FEM} = \sqrt{\frac{1}{\sum w}}$. Furthermore, let $log(OR_{FEM})$ be the common effect (fixed effect model). Then, the ("pooled") 95% confidence interval is $log(OR_{FEM}) \pm 1.96 \cdot se_{FEM}$. Update Since BIBB kindly provided the data, I am able to run the 'full' meta-analysis in R. library(meta) or <- c(0.75, 0.85) se <- c(0.0937, 0.1029) logor <- log(or) (or.fem <- metagen(logor, se, sm = "OR")) > (or.fem <- metagen(logor, se, sm = "OR")) OR 95%-CI %W(fixed) %W(random) 1 0.75 [0.6242; 0.9012] 54.67 54.67 2 0.85 [0.6948; 1.0399] 45.33 45.33 Number of trials combined: 2 OR 95%-CI z p.value Fixed effect model 0.7938 [0.693; 0.9092] -3.3335 0.0009 Random effects model 0.7938 [0.693; 0.9092] -3.3335 0.0009 Quantifying heterogeneity: tau^2 < 0.0001; H = 1; I^2 = 0% Test of heterogeneity: Q d.f. p.value 0.81 1 0.3685 Method: Inverse variance method References See, e.g., Lipsey/Wilson (2001: 114)
How to calculate confidence intervals for pooled odd ratios in meta-analysis? In most meta-analysis of odds ratios, the standard errors $se_i$ are based on the log odds ratios $log(OR_i)$. So, do you happen to know how your $se_i$ have been estimated (and what metric they refle
31,220
How to calculate confidence intervals for pooled odd ratios in meta-analysis?
Actually, you could use software like METAL which is specifically designed for meta-analyses in GWA context. It's awkward that plink doesn't give the confidence interval. However, you can get the CI because you have the final OR (take $\log(\text{OR})$) and the $p$-value (hence the $z$) for the fixed effect. Bernd's method is even more precise. Beware that I would be more worried about the effect direction as it looks like you only have summary stats for each study but nothing to be sure which is the OR allele. Unless you know it is done on the same allele. Christian
How to calculate confidence intervals for pooled odd ratios in meta-analysis?
Actually, you could use software like METAL which is specifically designed for meta-analyses in GWA context. It's awkward that plink doesn't give the confidence interval. However, you can get the CI
How to calculate confidence intervals for pooled odd ratios in meta-analysis? Actually, you could use software like METAL which is specifically designed for meta-analyses in GWA context. It's awkward that plink doesn't give the confidence interval. However, you can get the CI because you have the final OR (take $\log(\text{OR})$) and the $p$-value (hence the $z$) for the fixed effect. Bernd's method is even more precise. Beware that I would be more worried about the effect direction as it looks like you only have summary stats for each study but nothing to be sure which is the OR allele. Unless you know it is done on the same allele. Christian
How to calculate confidence intervals for pooled odd ratios in meta-analysis? Actually, you could use software like METAL which is specifically designed for meta-analyses in GWA context. It's awkward that plink doesn't give the confidence interval. However, you can get the CI
31,221
How to calculate confidence intervals for pooled odd ratios in meta-analysis?
This is a comment (don't have enough rep. points). If you know the sample size (#cases and #controls) in each study, and the odds ratio for a SNP, you can reconstruct the 2x2 table of case/control by a/b (where a and b are the two alleles) for each of the two studies. Then you can just add those counts to get a table for the meta-study, and use this to compute the combined odds-ratio and confidence intervals.
How to calculate confidence intervals for pooled odd ratios in meta-analysis?
This is a comment (don't have enough rep. points). If you know the sample size (#cases and #controls) in each study, and the odds ratio for a SNP, you can reconstruct the 2x2 table of case/control by
How to calculate confidence intervals for pooled odd ratios in meta-analysis? This is a comment (don't have enough rep. points). If you know the sample size (#cases and #controls) in each study, and the odds ratio for a SNP, you can reconstruct the 2x2 table of case/control by a/b (where a and b are the two alleles) for each of the two studies. Then you can just add those counts to get a table for the meta-study, and use this to compute the combined odds-ratio and confidence intervals.
How to calculate confidence intervals for pooled odd ratios in meta-analysis? This is a comment (don't have enough rep. points). If you know the sample size (#cases and #controls) in each study, and the odds ratio for a SNP, you can reconstruct the 2x2 table of case/control by
31,222
How to calculate confidence intervals for pooled odd ratios in meta-analysis?
Here is code to get CIs for meta-analysis as in PLINK: getCI = function(mn1, se1, method){ remov = c(0, NA) mn = mn1[! mn1 %in% remov] se = se1[! mn1 %in% remov] vars <- se^2 vwts <- 1/vars fixedsumm <- sum(vwts * mn)/sum(vwts) Q <- sum(((mn - fixedsumm)^2)/vars) df <- length(mn) - 1 tau2 <- max(0, (Q - df)/(sum(vwts) - sum(vwts^2)/sum(vwts)) ) if (method == "fixed"){ wt <- 1/vars } else { wt <- 1/(vars + tau2) } summ <- sum(wt * mn)/sum(wt) if (method == "fixed") varsum <- sum(wt * wt * vars)/(sum(wt)^2) else varsum <- sum(wt * wt * (vars + tau2))/(sum(wt)^2) summtest <- summ/sqrt(varsum) df <- length(vars) - 1 se.summary <- sqrt(varsum) pval = 1 - pchisq(summtest^2,1) pvalhet = 1 - pchisq(Q, df) L95 = summ - 1.96*se.summary U95 = summ + 1.96*se.summary # out = c(round(c(summ,L95,U95),2), format(pval,scientific=TRUE), pvalhet) # c("OR","L95","U95","p","ph") # return(out) out = c(paste(round(summ,3), ' [', round(L95,3), ', ', round(U95,3), ']', sep=""), format(pval, scientific=TRUE), round(pvalhet,3)) # c("OR","L95","U95","p","ph") return(out) } Calling R function: getCI(log(plinkORs), plinkSEs)
How to calculate confidence intervals for pooled odd ratios in meta-analysis?
Here is code to get CIs for meta-analysis as in PLINK: getCI = function(mn1, se1, method){ remov = c(0, NA) mn = mn1[! mn1 %in% remov] se = se1[! mn1 %in% remov] vars <- se^2
How to calculate confidence intervals for pooled odd ratios in meta-analysis? Here is code to get CIs for meta-analysis as in PLINK: getCI = function(mn1, se1, method){ remov = c(0, NA) mn = mn1[! mn1 %in% remov] se = se1[! mn1 %in% remov] vars <- se^2 vwts <- 1/vars fixedsumm <- sum(vwts * mn)/sum(vwts) Q <- sum(((mn - fixedsumm)^2)/vars) df <- length(mn) - 1 tau2 <- max(0, (Q - df)/(sum(vwts) - sum(vwts^2)/sum(vwts)) ) if (method == "fixed"){ wt <- 1/vars } else { wt <- 1/(vars + tau2) } summ <- sum(wt * mn)/sum(wt) if (method == "fixed") varsum <- sum(wt * wt * vars)/(sum(wt)^2) else varsum <- sum(wt * wt * (vars + tau2))/(sum(wt)^2) summtest <- summ/sqrt(varsum) df <- length(vars) - 1 se.summary <- sqrt(varsum) pval = 1 - pchisq(summtest^2,1) pvalhet = 1 - pchisq(Q, df) L95 = summ - 1.96*se.summary U95 = summ + 1.96*se.summary # out = c(round(c(summ,L95,U95),2), format(pval,scientific=TRUE), pvalhet) # c("OR","L95","U95","p","ph") # return(out) out = c(paste(round(summ,3), ' [', round(L95,3), ', ', round(U95,3), ']', sep=""), format(pval, scientific=TRUE), round(pvalhet,3)) # c("OR","L95","U95","p","ph") return(out) } Calling R function: getCI(log(plinkORs), plinkSEs)
How to calculate confidence intervals for pooled odd ratios in meta-analysis? Here is code to get CIs for meta-analysis as in PLINK: getCI = function(mn1, se1, method){ remov = c(0, NA) mn = mn1[! mn1 %in% remov] se = se1[! mn1 %in% remov] vars <- se^2
31,223
In R how do I reference\lookup in the cdf of standard normal distribution table?
The functions you are looking for are either dnorm, pnorm or qnorm, depending on exactly what you are looking for. dnorm(x) gives the density function at x. pnorm(x) gives the probability that a random value is less than x. qnorm(p) is the inverse of pnorm, giving the value of x for which getting a random value less than x has probability p. See the help page for these functions to see how to change the parameters and values.
In R how do I reference\lookup in the cdf of standard normal distribution table?
The functions you are looking for are either dnorm, pnorm or qnorm, depending on exactly what you are looking for. dnorm(x) gives the density function at x. pnorm(x) gives the probability that a rando
In R how do I reference\lookup in the cdf of standard normal distribution table? The functions you are looking for are either dnorm, pnorm or qnorm, depending on exactly what you are looking for. dnorm(x) gives the density function at x. pnorm(x) gives the probability that a random value is less than x. qnorm(p) is the inverse of pnorm, giving the value of x for which getting a random value less than x has probability p. See the help page for these functions to see how to change the parameters and values.
In R how do I reference\lookup in the cdf of standard normal distribution table? The functions you are looking for are either dnorm, pnorm or qnorm, depending on exactly what you are looking for. dnorm(x) gives the density function at x. pnorm(x) gives the probability that a rando
31,224
Am I specifying my lmer model correctly?
Your model specification is fine. The varying intercept for Ward, specified in lmer as you've done with (1 | Ward), is saying that subjects within each ward might be more similar to each other on Selfreject for reasons other than WardSize or Gender, so you are controlling for between-ward heterogeneity. You can think of the "1" as a column of 1s (i.e., a constant) in the data to which an intercept is fit. Usually the "1" is implied automatically in lm, for instance lm(Y ~ X1 + X2) actually specifies lm(Y ~ 1 + X1 + X2) Now that you have your basic model, you can start asking further questions like "Does the relationship between BSItotal and Selfreject differ between wards?" lmer(formula=Selfreject ~ WardSize + WAS + Gender + BSITotal + (1 + BSITotal | Ward)) That is, both the intercept and the slope of BSITotal can differ between wards. If you haven't picked it up yet, Gelman & Hill's Data Analysis Using Regression and Multilevel Model/Hierarchical Models is a great book that explains fitting models like this with lmer.
Am I specifying my lmer model correctly?
Your model specification is fine. The varying intercept for Ward, specified in lmer as you've done with (1 | Ward), is saying that subjects within each ward might be more similar to each other on Sel
Am I specifying my lmer model correctly? Your model specification is fine. The varying intercept for Ward, specified in lmer as you've done with (1 | Ward), is saying that subjects within each ward might be more similar to each other on Selfreject for reasons other than WardSize or Gender, so you are controlling for between-ward heterogeneity. You can think of the "1" as a column of 1s (i.e., a constant) in the data to which an intercept is fit. Usually the "1" is implied automatically in lm, for instance lm(Y ~ X1 + X2) actually specifies lm(Y ~ 1 + X1 + X2) Now that you have your basic model, you can start asking further questions like "Does the relationship between BSItotal and Selfreject differ between wards?" lmer(formula=Selfreject ~ WardSize + WAS + Gender + BSITotal + (1 + BSITotal | Ward)) That is, both the intercept and the slope of BSITotal can differ between wards. If you haven't picked it up yet, Gelman & Hill's Data Analysis Using Regression and Multilevel Model/Hierarchical Models is a great book that explains fitting models like this with lmer.
Am I specifying my lmer model correctly? Your model specification is fine. The varying intercept for Ward, specified in lmer as you've done with (1 | Ward), is saying that subjects within each ward might be more similar to each other on Sel
31,225
Am I specifying my lmer model correctly?
Here is a link to an explanation by Douglas Bates (who wrote lme4) as to why it's not necessary to specify the level for fixed effects.
Am I specifying my lmer model correctly?
Here is a link to an explanation by Douglas Bates (who wrote lme4) as to why it's not necessary to specify the level for fixed effects.
Am I specifying my lmer model correctly? Here is a link to an explanation by Douglas Bates (who wrote lme4) as to why it's not necessary to specify the level for fixed effects.
Am I specifying my lmer model correctly? Here is a link to an explanation by Douglas Bates (who wrote lme4) as to why it's not necessary to specify the level for fixed effects.
31,226
Is sample kurtosis hopelessly biased?
There's a bias correction. It's not huge. I believe the sampling variance of the kurtosis is proportional to the eighth (!) central moment, which can be enormous for a lognormal distribution. You would need millions of trials (or far more) in a simulation to detect bias unless the CV is tiny. (Plot a histogram of kvals to see how extraordinarily skewed they are.) The correct kurtosis is indeed about 113.9364. As far as R style goes, it can be convenient to encapsulate the simulation in a function so you can easily modify the sample size or number of trials.
Is sample kurtosis hopelessly biased?
There's a bias correction. It's not huge. I believe the sampling variance of the kurtosis is proportional to the eighth (!) central moment, which can be enormous for a lognormal distribution. You w
Is sample kurtosis hopelessly biased? There's a bias correction. It's not huge. I believe the sampling variance of the kurtosis is proportional to the eighth (!) central moment, which can be enormous for a lognormal distribution. You would need millions of trials (or far more) in a simulation to detect bias unless the CV is tiny. (Plot a histogram of kvals to see how extraordinarily skewed they are.) The correct kurtosis is indeed about 113.9364. As far as R style goes, it can be convenient to encapsulate the simulation in a function so you can easily modify the sample size or number of trials.
Is sample kurtosis hopelessly biased? There's a bias correction. It's not huge. I believe the sampling variance of the kurtosis is proportional to the eighth (!) central moment, which can be enormous for a lognormal distribution. You w
31,227
Is sample kurtosis hopelessly biased?
[Just on the R Style - @whuber has answered the Kurtsosis Q] This was a bit too complicated to stick into a comment. For such simple loops like the one you use, we can combine @whuber's suggestion of encapsulating the simulation in a function with the replicate() function. replicate() takes care of allocation and running the loop for you. An example is given below: require(moments) foo <- function(size, trials, meanlog = 0, sdlog = 1) { replicate(trials, kurtosis(rlnorm(size, meanlog = meanlog, sdlog = sdlog))) } We use it like this: > set.seed(1) > out <- foo(2048, 10000) > summary(out) Min. 1st Qu. Median Mean 3rd Qu. Max. 10.93 28.77 39.99 62.53 62.58 1557.00 Note that I use the rlnorm() function to generate the log-normal random variable. It is equivalent to exp(rnorm()) in your loop but uses the correct tool, and we allow our function to pass on user-specified parameters of the log-normal distribution. > set.seed(123) > exp(rnorm(1)) [1] 0.5709374 > set.seed(123) > rlnorm(1) [1] 0.5709374
Is sample kurtosis hopelessly biased?
[Just on the R Style - @whuber has answered the Kurtsosis Q] This was a bit too complicated to stick into a comment. For such simple loops like the one you use, we can combine @whuber's suggestion of
Is sample kurtosis hopelessly biased? [Just on the R Style - @whuber has answered the Kurtsosis Q] This was a bit too complicated to stick into a comment. For such simple loops like the one you use, we can combine @whuber's suggestion of encapsulating the simulation in a function with the replicate() function. replicate() takes care of allocation and running the loop for you. An example is given below: require(moments) foo <- function(size, trials, meanlog = 0, sdlog = 1) { replicate(trials, kurtosis(rlnorm(size, meanlog = meanlog, sdlog = sdlog))) } We use it like this: > set.seed(1) > out <- foo(2048, 10000) > summary(out) Min. 1st Qu. Median Mean 3rd Qu. Max. 10.93 28.77 39.99 62.53 62.58 1557.00 Note that I use the rlnorm() function to generate the log-normal random variable. It is equivalent to exp(rnorm()) in your loop but uses the correct tool, and we allow our function to pass on user-specified parameters of the log-normal distribution. > set.seed(123) > exp(rnorm(1)) [1] 0.5709374 > set.seed(123) > rlnorm(1) [1] 0.5709374
Is sample kurtosis hopelessly biased? [Just on the R Style - @whuber has answered the Kurtsosis Q] This was a bit too complicated to stick into a comment. For such simple loops like the one you use, we can combine @whuber's suggestion of
31,228
Visualization of connections between groups
What you describe in your example is not only a network of relationships, but a network of "flows" between all groups. Like you suggested in a) (and as Jeromy said as well) your graphic will likely be a visualization of one group (or node) linked to other groups. Most of my knowledge of this subject is visualizing flows between geographic spaces, but many of the same issues still apply. I think this paper does a good job summarizing visualization techniques in regards to mapping flows. From spatial interaction data to spatial interaction information? Geovisualisation and spatial structures of migration from the 2001 UK census by: Alasdair Rae Computers, Environment and Urban Systems, Vol. 33, No. 3. (May 2009), pp. 161-178. (PDF here) Typically visualizing flows in geographic space has three main problems. One is that it is difficult to distinguish between in-flows and out-flows. The second is that long lines tend to dominate the graphic. Three is that over-lapping or too many flows tend to make the graphic look very noisy. The second problem may be solved by however you organize the nodes on your graphic (like Jeromy suggested cluster nodes together with strong relationships). It may also be easier to use small multiple graphs to distinguish between in-flows, out-flows, and reciprocal flows (i.e. map your nodes to a specific space and then have seperate graphics displaying in-flows, out-flows). I have not seen any examples of flows in networks like you describe, so I do not know if the self-organizing graphics have the problem of over-lapping lines. If you have experience programming in Python you may want to check out the NetworkX package. (The Gephi package Ars linked to looks pretty awesome as well). This is similar in nature to questions brought up on the GIS stackexchange forum, and here is a question with answers you may be interested in. Good Luck
Visualization of connections between groups
What you describe in your example is not only a network of relationships, but a network of "flows" between all groups. Like you suggested in a) (and as Jeromy said as well) your graphic will likely b
Visualization of connections between groups What you describe in your example is not only a network of relationships, but a network of "flows" between all groups. Like you suggested in a) (and as Jeromy said as well) your graphic will likely be a visualization of one group (or node) linked to other groups. Most of my knowledge of this subject is visualizing flows between geographic spaces, but many of the same issues still apply. I think this paper does a good job summarizing visualization techniques in regards to mapping flows. From spatial interaction data to spatial interaction information? Geovisualisation and spatial structures of migration from the 2001 UK census by: Alasdair Rae Computers, Environment and Urban Systems, Vol. 33, No. 3. (May 2009), pp. 161-178. (PDF here) Typically visualizing flows in geographic space has three main problems. One is that it is difficult to distinguish between in-flows and out-flows. The second is that long lines tend to dominate the graphic. Three is that over-lapping or too many flows tend to make the graphic look very noisy. The second problem may be solved by however you organize the nodes on your graphic (like Jeromy suggested cluster nodes together with strong relationships). It may also be easier to use small multiple graphs to distinguish between in-flows, out-flows, and reciprocal flows (i.e. map your nodes to a specific space and then have seperate graphics displaying in-flows, out-flows). I have not seen any examples of flows in networks like you describe, so I do not know if the self-organizing graphics have the problem of over-lapping lines. If you have experience programming in Python you may want to check out the NetworkX package. (The Gephi package Ars linked to looks pretty awesome as well). This is similar in nature to questions brought up on the GIS stackexchange forum, and here is a question with answers you may be interested in. Good Luck
Visualization of connections between groups What you describe in your example is not only a network of relationships, but a network of "flows" between all groups. Like you suggested in a) (and as Jeromy said as well) your graphic will likely b
31,229
Visualization of connections between groups
Gephi is pretty good for visualization directed or undirected graphs/networks. Another option might be Walrus.
Visualization of connections between groups
Gephi is pretty good for visualization directed or undirected graphs/networks. Another option might be Walrus.
Visualization of connections between groups Gephi is pretty good for visualization directed or undirected graphs/networks. Another option might be Walrus.
Visualization of connections between groups Gephi is pretty good for visualization directed or undirected graphs/networks. Another option might be Walrus.
31,230
Visualization of connections between groups
A quick couple of thoughts: I've used multidimensional scaling to visualise connections between team members (i.e., a weighted network). Nodes with stronger connections then appear closer in the figure. Here's some resources for implementing in R. You could present a standard graph where line thickness is based on strength of connection.
Visualization of connections between groups
A quick couple of thoughts: I've used multidimensional scaling to visualise connections between team members (i.e., a weighted network). Nodes with stronger connections then appear closer in the figu
Visualization of connections between groups A quick couple of thoughts: I've used multidimensional scaling to visualise connections between team members (i.e., a weighted network). Nodes with stronger connections then appear closer in the figure. Here's some resources for implementing in R. You could present a standard graph where line thickness is based on strength of connection.
Visualization of connections between groups A quick couple of thoughts: I've used multidimensional scaling to visualise connections between team members (i.e., a weighted network). Nodes with stronger connections then appear closer in the figu
31,231
Visualization of connections between groups
An alternative to multidimentional scaling is making a map of the each group's position to one another as a SOM (Self Organising Maps). Just like you see with a geographic map of the United States with Kansas in the middle, the groups that are positioned near the middle of your SOM map would be the groups that are most connected to other groups. Here is a python SOM module
Visualization of connections between groups
An alternative to multidimentional scaling is making a map of the each group's position to one another as a SOM (Self Organising Maps). Just like you see with a geographic map of the United States wit
Visualization of connections between groups An alternative to multidimentional scaling is making a map of the each group's position to one another as a SOM (Self Organising Maps). Just like you see with a geographic map of the United States with Kansas in the middle, the groups that are positioned near the middle of your SOM map would be the groups that are most connected to other groups. Here is a python SOM module
Visualization of connections between groups An alternative to multidimentional scaling is making a map of the each group's position to one another as a SOM (Self Organising Maps). Just like you see with a geographic map of the United States wit
31,232
Factor analysis of dyadic data
Structural equation models are better suited for this kind of data, e.g. by introducing an extra factor for couple which allows to account for the dependence structure (paired responses). David A. Kenny reviewed the main points for analysis dyadic data; although it doesn't focus on questionnaire analysis, it may help. A couple of references : Olsen, JA and Kenny, DA (2006). Structural Equation Modeling With Interchangeable Dyads. Psychological Methods, 11(2), 127–141. McMahon,, JM, Pouget, ER, and Tortu, S (2006). A guide for multilevel modeling of dyadic data with binary outcomes using SAS PROC NLMIXED. Comput Stat Data Anal., 50(12), 3663–3680. Thompson, L and Walker, AJ (1982). The Dyad as the Unit of Analysis: Conceptual and Methodological Issues. Journal of Marriage and the Family, 889-900. Newsom, JT (2002). A multilevel structural equation model for dyadic data. Structural Equation Modeling, 9(3), 441-447. González, J, Tuerlinckx, F, and De Boeck, P (2009). Analyzing structural relations in multivariate dyadic binary data. Applied Multivariate Research, 13, 77-92. Gill, PS (2005). Bayesian Analysis of Dyadic Data. For more thorough description of the models for dyadic data (although not restrained to item analysis), I would suggest Kenny, DA, Kashy, DA, and Cook, WL (2006). Dyadic Data Analysis. Guilford Press. Card, NA, Selig, JP, and Little, TD (2008). Modeling Dyadic and Interdependent Data in the Developmental and Behavioral Sciences. Mahwah, NJ: Lawrence Erlbaum Associates.
Factor analysis of dyadic data
Structural equation models are better suited for this kind of data, e.g. by introducing an extra factor for couple which allows to account for the dependence structure (paired responses). David A. Ken
Factor analysis of dyadic data Structural equation models are better suited for this kind of data, e.g. by introducing an extra factor for couple which allows to account for the dependence structure (paired responses). David A. Kenny reviewed the main points for analysis dyadic data; although it doesn't focus on questionnaire analysis, it may help. A couple of references : Olsen, JA and Kenny, DA (2006). Structural Equation Modeling With Interchangeable Dyads. Psychological Methods, 11(2), 127–141. McMahon,, JM, Pouget, ER, and Tortu, S (2006). A guide for multilevel modeling of dyadic data with binary outcomes using SAS PROC NLMIXED. Comput Stat Data Anal., 50(12), 3663–3680. Thompson, L and Walker, AJ (1982). The Dyad as the Unit of Analysis: Conceptual and Methodological Issues. Journal of Marriage and the Family, 889-900. Newsom, JT (2002). A multilevel structural equation model for dyadic data. Structural Equation Modeling, 9(3), 441-447. González, J, Tuerlinckx, F, and De Boeck, P (2009). Analyzing structural relations in multivariate dyadic binary data. Applied Multivariate Research, 13, 77-92. Gill, PS (2005). Bayesian Analysis of Dyadic Data. For more thorough description of the models for dyadic data (although not restrained to item analysis), I would suggest Kenny, DA, Kashy, DA, and Cook, WL (2006). Dyadic Data Analysis. Guilford Press. Card, NA, Selig, JP, and Little, TD (2008). Modeling Dyadic and Interdependent Data in the Developmental and Behavioral Sciences. Mahwah, NJ: Lawrence Erlbaum Associates.
Factor analysis of dyadic data Structural equation models are better suited for this kind of data, e.g. by introducing an extra factor for couple which allows to account for the dependence structure (paired responses). David A. Ken
31,233
Factor analysis of dyadic data
Yes, s/he can run a factor analysis on dyadic data. I would start with Kenny et al.'s (2006) "Dyadic Data Analysis". It is a great and extremly helpful book! Another option is "Modeling Dyadic and Interdependent Data in the Developmental and Behavioral Sciences" (Card et al. 2008). (If your anonymous read is able to read German, s/he might be interested in this presentation "Dyadische Datenanalyse: Lineare Strukturgleichungsmodelle").
Factor analysis of dyadic data
Yes, s/he can run a factor analysis on dyadic data. I would start with Kenny et al.'s (2006) "Dyadic Data Analysis". It is a great and extremly helpful book! Another option is "Modeling Dyadic and In
Factor analysis of dyadic data Yes, s/he can run a factor analysis on dyadic data. I would start with Kenny et al.'s (2006) "Dyadic Data Analysis". It is a great and extremly helpful book! Another option is "Modeling Dyadic and Interdependent Data in the Developmental and Behavioral Sciences" (Card et al. 2008). (If your anonymous read is able to read German, s/he might be interested in this presentation "Dyadische Datenanalyse: Lineare Strukturgleichungsmodelle").
Factor analysis of dyadic data Yes, s/he can run a factor analysis on dyadic data. I would start with Kenny et al.'s (2006) "Dyadic Data Analysis". It is a great and extremly helpful book! Another option is "Modeling Dyadic and In
31,234
When was the earliest appearance of Empirical Cumulative Distribution Plots?
It was in 1933. According to M.A. Stephens, Kolmogorov first formalized the notion of empirical distribution function. Additionally, according to D.A. Darling, it was originally used to define the Kolmogorov-Smirnov statistic, so it was in fact Empirical Cumulative Distribution Function. Stephens, M.A. (1992). Introduction to Kolmogorov (1933) On the Empirical Determination of a Distribution. In: Kotz, S., Johnson, N.L. (eds) Breakthroughs in Statistics. Springer Series in Statistics. Springer, New York, NY. https://doi.org/10.1007/978-1-4612-4380-9_9 Darling, D. A. The Kolmogorov-Smirnov, Cramer-von Mises Tests. The Annals of Mathematical Statistics, vol. 28, no. 4, 1957, pp. 823–38. JSTOR, http://www.jstor.org/stable/2237048. Accessed 15 Nov. 2022.
When was the earliest appearance of Empirical Cumulative Distribution Plots?
It was in 1933. According to M.A. Stephens, Kolmogorov first formalized the notion of empirical distribution function. Additionally, according to D.A. Darling, it was originally used to define the Kol
When was the earliest appearance of Empirical Cumulative Distribution Plots? It was in 1933. According to M.A. Stephens, Kolmogorov first formalized the notion of empirical distribution function. Additionally, according to D.A. Darling, it was originally used to define the Kolmogorov-Smirnov statistic, so it was in fact Empirical Cumulative Distribution Function. Stephens, M.A. (1992). Introduction to Kolmogorov (1933) On the Empirical Determination of a Distribution. In: Kotz, S., Johnson, N.L. (eds) Breakthroughs in Statistics. Springer Series in Statistics. Springer, New York, NY. https://doi.org/10.1007/978-1-4612-4380-9_9 Darling, D. A. The Kolmogorov-Smirnov, Cramer-von Mises Tests. The Annals of Mathematical Statistics, vol. 28, no. 4, 1957, pp. 823–38. JSTOR, http://www.jstor.org/stable/2237048. Accessed 15 Nov. 2022.
When was the earliest appearance of Empirical Cumulative Distribution Plots? It was in 1933. According to M.A. Stephens, Kolmogorov first formalized the notion of empirical distribution function. Additionally, according to D.A. Darling, it was originally used to define the Kol
31,235
Testing if a sample follows a given distribution
There are various ways in which to test whether a sample might have been randomly chosen from a given distribution. These might include checking to see if the sample mean is consistent with the population, and similarly for variances, or other parameters. I interpret your question to seek a test whether the distribution of the sample (perhaps as expressed in its empirical CDF) is consistent with the population distribution. For example, suppose we happen to have a sample of size $n = 500$ from an exponential distribution with mean $2$ and rate $1/2$ and so also standard deviation $2.$ A fictitious sample to these specifications is sampled and summarized in R below. set.seed(2022) x = rexp(500, 1/2) summary(x); sd(x) Min. 1st Qu. Median Mean 3rd Qu. Max. 0.007349 0.569684 1.371701 1.987886 2.703088 12.677304 [1] 1.923795 # sample SD Not knowing how the sample was obtained, you might have guessed that it could be from the population $\mathsf{Norm}(\mu=2, \sigma=2)$. boxplot(x, horizontal=T, pch=19, col="skyblue2") The shape of the boxplot already suggests that this is not a normal sample. One could use a Kolmogorov-Smirnov goodness-of-fit test in R to test the null hypothesis that the population is $\mathsf{Norm}(\mu=2, \sigma=2).$ This null hypothesis is strongly rejected with P-value very nearly $0.$ ks.test(x, pnorm, 2, 2) One-sample Kolmogorov-Smirnov test data: x D = 0.15955, p-value = 1.762e-11 alternative hypothesis: two-sided More generally, if you had no idea of the population mean and standard deviation, you could use one of several tests to see if the sample is consistent with any normal distribution. One such test is the Shapiro-Wilk test, shown below using R; the null hypothesis of normality is strongly rejected. shapiro.test(x) Shapiro-Wilk normality test data: x W = 0.83826, p-value < 2.2e-16 Note: It is important to remember that the K-S test is for a particular population distribution with all parameters known. It is cheating to estimate the parameters from the sample. The K-S test does not reject the null hypothesis that the data x are from $\mathsf{Exp}(\mathrm{rate}= 1/2),$ but strongly rejects that the population might have been $\mathsf{Exp}(\mathrm{rate}= 1).$ ks.test(x, pexp, 1/2) One-sample Kolmogorov-Smirnov test data: x D = 0.020534, p-value = 0.9843 alternative hypothesis: two-sided ks.test(x, pexp, 1) One-sample Kolmogorov-Smirnov test data: x D = 0.25929, p-value < 2.2e-16 alternative hypothesis: two-sided The K-S test compares the empirical CDF (ECDF) of the sample with the CDF of the population distribution. The test statistic $D$ is the maximum vertical distance between the two. The plots below illustrate a good fit between ECDF and CDF at left, and a poor fit at right. R code for figure: par(mfrow=c(1,2)) hdr1="Good fit to EXP(1/2)" plot(ecdf(x), main=hdr1) curve(pexp(x, 1/2), add=T, col="green3", lwd=3) hdr2="Bad fit to EXP(1)" plot(ecdf(x), main=hdr2) curve(pexp(x, 1), add=T, col="red", lwd=2) par(mfrow=c(1,1))
Testing if a sample follows a given distribution
There are various ways in which to test whether a sample might have been randomly chosen from a given distribution. These might include checking to see if the sample mean is consistent with the popula
Testing if a sample follows a given distribution There are various ways in which to test whether a sample might have been randomly chosen from a given distribution. These might include checking to see if the sample mean is consistent with the population, and similarly for variances, or other parameters. I interpret your question to seek a test whether the distribution of the sample (perhaps as expressed in its empirical CDF) is consistent with the population distribution. For example, suppose we happen to have a sample of size $n = 500$ from an exponential distribution with mean $2$ and rate $1/2$ and so also standard deviation $2.$ A fictitious sample to these specifications is sampled and summarized in R below. set.seed(2022) x = rexp(500, 1/2) summary(x); sd(x) Min. 1st Qu. Median Mean 3rd Qu. Max. 0.007349 0.569684 1.371701 1.987886 2.703088 12.677304 [1] 1.923795 # sample SD Not knowing how the sample was obtained, you might have guessed that it could be from the population $\mathsf{Norm}(\mu=2, \sigma=2)$. boxplot(x, horizontal=T, pch=19, col="skyblue2") The shape of the boxplot already suggests that this is not a normal sample. One could use a Kolmogorov-Smirnov goodness-of-fit test in R to test the null hypothesis that the population is $\mathsf{Norm}(\mu=2, \sigma=2).$ This null hypothesis is strongly rejected with P-value very nearly $0.$ ks.test(x, pnorm, 2, 2) One-sample Kolmogorov-Smirnov test data: x D = 0.15955, p-value = 1.762e-11 alternative hypothesis: two-sided More generally, if you had no idea of the population mean and standard deviation, you could use one of several tests to see if the sample is consistent with any normal distribution. One such test is the Shapiro-Wilk test, shown below using R; the null hypothesis of normality is strongly rejected. shapiro.test(x) Shapiro-Wilk normality test data: x W = 0.83826, p-value < 2.2e-16 Note: It is important to remember that the K-S test is for a particular population distribution with all parameters known. It is cheating to estimate the parameters from the sample. The K-S test does not reject the null hypothesis that the data x are from $\mathsf{Exp}(\mathrm{rate}= 1/2),$ but strongly rejects that the population might have been $\mathsf{Exp}(\mathrm{rate}= 1).$ ks.test(x, pexp, 1/2) One-sample Kolmogorov-Smirnov test data: x D = 0.020534, p-value = 0.9843 alternative hypothesis: two-sided ks.test(x, pexp, 1) One-sample Kolmogorov-Smirnov test data: x D = 0.25929, p-value < 2.2e-16 alternative hypothesis: two-sided The K-S test compares the empirical CDF (ECDF) of the sample with the CDF of the population distribution. The test statistic $D$ is the maximum vertical distance between the two. The plots below illustrate a good fit between ECDF and CDF at left, and a poor fit at right. R code for figure: par(mfrow=c(1,2)) hdr1="Good fit to EXP(1/2)" plot(ecdf(x), main=hdr1) curve(pexp(x, 1/2), add=T, col="green3", lwd=3) hdr2="Bad fit to EXP(1)" plot(ecdf(x), main=hdr2) curve(pexp(x, 1), add=T, col="red", lwd=2) par(mfrow=c(1,1))
Testing if a sample follows a given distribution There are various ways in which to test whether a sample might have been randomly chosen from a given distribution. These might include checking to see if the sample mean is consistent with the popula
31,236
Testing if a sample follows a given distribution
All standard hypothesis testing follows the following steps: Formulate a null hypothesis. This should rigorously state conditions under which one can calculate probabilities (e.g. "The observations are all drawn from independent normal distributions with $\mu = 0$ and $\sigma = 1$.") Choose an $\alpha$ Choose a statistical variable $X$ Collect data Calculate the statistic $x$ from the data Reject the null if $P(X\ge x|H_0)\le\alpha$ (Note that $X$ is a random variable with a probability distribution, while $x$ is a particular value that that variable takes; $P(X\ge x|H_0)$ is the probability, given the null hypothesis, of getting something as or more extreme than what you actually saw.) So to test whether a sample follows a given distribution, you need some metric for measuring "distance" from a given distribution, and then you use that as your statistic. How can I formally express this as a hypothesis testing problem? All you need is some function $f: ((\mathbb R \rightarrow \mathbb R) \times \mathbb R ^n) \rightarrow \mathbb R$. That is, a function that takes an ordered pair as input and gives a real number as output, where the first element of the ordered pair is a PDF and the second element is a sample of $n$ observations. Once you have such a function, you can find what that function gives for your sample, then calculate the probability, given the null hypothesis (the null hypothesis in this case is that the sample came from the proposed distribution) that you would get a sample for which the function would give a result greater than or equal to what you actually got. Also, is this unique? No. Every function gives a different test. Two attributes to look for in choosing the function are tractability (how easy is it to calculate $P(X\ge x|H_0)$) and power (how well does the function correspond to what we think of "agreeing" with the distribution). If you think someone is deliberately trying to fake a particular distribution, then you might want a function tailored to what errors you think they might make (for instance, someone faking a normal distribution might focus on getting the mean and sd correct, but ignore the kurtosis).
Testing if a sample follows a given distribution
All standard hypothesis testing follows the following steps: Formulate a null hypothesis. This should rigorously state conditions under which one can calculate probabilities (e.g. "The observations a
Testing if a sample follows a given distribution All standard hypothesis testing follows the following steps: Formulate a null hypothesis. This should rigorously state conditions under which one can calculate probabilities (e.g. "The observations are all drawn from independent normal distributions with $\mu = 0$ and $\sigma = 1$.") Choose an $\alpha$ Choose a statistical variable $X$ Collect data Calculate the statistic $x$ from the data Reject the null if $P(X\ge x|H_0)\le\alpha$ (Note that $X$ is a random variable with a probability distribution, while $x$ is a particular value that that variable takes; $P(X\ge x|H_0)$ is the probability, given the null hypothesis, of getting something as or more extreme than what you actually saw.) So to test whether a sample follows a given distribution, you need some metric for measuring "distance" from a given distribution, and then you use that as your statistic. How can I formally express this as a hypothesis testing problem? All you need is some function $f: ((\mathbb R \rightarrow \mathbb R) \times \mathbb R ^n) \rightarrow \mathbb R$. That is, a function that takes an ordered pair as input and gives a real number as output, where the first element of the ordered pair is a PDF and the second element is a sample of $n$ observations. Once you have such a function, you can find what that function gives for your sample, then calculate the probability, given the null hypothesis (the null hypothesis in this case is that the sample came from the proposed distribution) that you would get a sample for which the function would give a result greater than or equal to what you actually got. Also, is this unique? No. Every function gives a different test. Two attributes to look for in choosing the function are tractability (how easy is it to calculate $P(X\ge x|H_0)$) and power (how well does the function correspond to what we think of "agreeing" with the distribution). If you think someone is deliberately trying to fake a particular distribution, then you might want a function tailored to what errors you think they might make (for instance, someone faking a normal distribution might focus on getting the mean and sd correct, but ignore the kurtosis).
Testing if a sample follows a given distribution All standard hypothesis testing follows the following steps: Formulate a null hypothesis. This should rigorously state conditions under which one can calculate probabilities (e.g. "The observations a
31,237
Looking for a measure of variance of variance?
The term you are looking for is called heteroscedasticity. As for testing if you have heteroscedasticity, the tests basically proceed as you guessed, except that often you use the fact that you know the underlying model (i.e. some type of regression model), and so you don't exactly "split" up the data. At the extreme, this is precisely what you do for grouped data. See the detection section of the wiki link for some common tests. Looking at the test statistic of some of these tests should give you a sense of how to measure it. Again, given some model (such as a regression model), this is usually done by taking the residuals of your model and seeing if the variance of the residuals changes as a function of the regressors. Hopefully this is enough to get you going!
Looking for a measure of variance of variance?
The term you are looking for is called heteroscedasticity. As for testing if you have heteroscedasticity, the tests basically proceed as you guessed, except that often you use the fact that you know t
Looking for a measure of variance of variance? The term you are looking for is called heteroscedasticity. As for testing if you have heteroscedasticity, the tests basically proceed as you guessed, except that often you use the fact that you know the underlying model (i.e. some type of regression model), and so you don't exactly "split" up the data. At the extreme, this is precisely what you do for grouped data. See the detection section of the wiki link for some common tests. Looking at the test statistic of some of these tests should give you a sense of how to measure it. Again, given some model (such as a regression model), this is usually done by taking the residuals of your model and seeing if the variance of the residuals changes as a function of the regressors. Hopefully this is enough to get you going!
Looking for a measure of variance of variance? The term you are looking for is called heteroscedasticity. As for testing if you have heteroscedasticity, the tests basically proceed as you guessed, except that often you use the fact that you know t
31,238
Looking for a measure of variance of variance?
In quant finance there are several models that incorporate such a concept. For instance, SABR model looks as follows in a simplest form: $$dF_t=\sigma_t \left(F_t\right)^\beta\, dW_t,$$ $$d\sigma_t=\alpha\sigma^{}_t\, dZ_t,$$ were, $\alpha$ is the variance of the variance of the changes in rate series $F_t$. In order to estimate the variance of the variance it's best to have some kind of a model in mind. The variance is not directly observed, to start with. This makes measuring variance of variance even more difficult. If you have a model, then you can come up with a fitting approach to extract the parameter from the data.
Looking for a measure of variance of variance?
In quant finance there are several models that incorporate such a concept. For instance, SABR model looks as follows in a simplest form: $$dF_t=\sigma_t \left(F_t\right)^\beta\, dW_t,$$ $$d\sigma_t=\a
Looking for a measure of variance of variance? In quant finance there are several models that incorporate such a concept. For instance, SABR model looks as follows in a simplest form: $$dF_t=\sigma_t \left(F_t\right)^\beta\, dW_t,$$ $$d\sigma_t=\alpha\sigma^{}_t\, dZ_t,$$ were, $\alpha$ is the variance of the variance of the changes in rate series $F_t$. In order to estimate the variance of the variance it's best to have some kind of a model in mind. The variance is not directly observed, to start with. This makes measuring variance of variance even more difficult. If you have a model, then you can come up with a fitting approach to extract the parameter from the data.
Looking for a measure of variance of variance? In quant finance there are several models that incorporate such a concept. For instance, SABR model looks as follows in a simplest form: $$dF_t=\sigma_t \left(F_t\right)^\beta\, dW_t,$$ $$d\sigma_t=\a
31,239
Uniformly Distributed Residuals in Linear Regression
There are a few things we can say about this situation the condition of normality of residuals only needs to hold approximately. If the sample size is small then it can be difficult to distiguish a uniform from a normal distribution, and it is reasonable in such circumstances to assess the residuals as plausibly normal. With a large sample size this obviously is not the case. the estimates will be unbiased the estimates will be consistent the regression coefficient estimators will not be t distributed if using least squares, so the associated p values will be unreliable.
Uniformly Distributed Residuals in Linear Regression
There are a few things we can say about this situation the condition of normality of residuals only needs to hold approximately. If the sample size is small then it can be difficult to distiguish a u
Uniformly Distributed Residuals in Linear Regression There are a few things we can say about this situation the condition of normality of residuals only needs to hold approximately. If the sample size is small then it can be difficult to distiguish a uniform from a normal distribution, and it is reasonable in such circumstances to assess the residuals as plausibly normal. With a large sample size this obviously is not the case. the estimates will be unbiased the estimates will be consistent the regression coefficient estimators will not be t distributed if using least squares, so the associated p values will be unreliable.
Uniformly Distributed Residuals in Linear Regression There are a few things we can say about this situation the condition of normality of residuals only needs to hold approximately. If the sample size is small then it can be difficult to distiguish a u
31,240
Uniformly Distributed Residuals in Linear Regression
A classic linear regression model works under the assumption that the data can be modeled as y = Ax + b + eta where eta ~ N(0,sigma) . if your residuals are uniformly distributed, it means that the above assumptions doesn't hold. However, this linear regression can still work for you, depending on the application- both a uniform and Gaussian model are symmetric, with E(data) = median(data). So even though the data is not really 'Gaussian', the line that best fit the data (according to the mean/median) will be the same (again, depending on the application). An option that might work for you is Bayesian Linear Regression (BLR): in BLR, you can choose your model assumptions: eta ~ U(-1,1), eta ~ N(0,sigma) or eta ~ Beta(2,2) are all valid assumptions. anything that best fit your data
Uniformly Distributed Residuals in Linear Regression
A classic linear regression model works under the assumption that the data can be modeled as y = Ax + b + eta where eta ~ N(0,sigma) . if your residuals are uniformly distributed, it means that the a
Uniformly Distributed Residuals in Linear Regression A classic linear regression model works under the assumption that the data can be modeled as y = Ax + b + eta where eta ~ N(0,sigma) . if your residuals are uniformly distributed, it means that the above assumptions doesn't hold. However, this linear regression can still work for you, depending on the application- both a uniform and Gaussian model are symmetric, with E(data) = median(data). So even though the data is not really 'Gaussian', the line that best fit the data (according to the mean/median) will be the same (again, depending on the application). An option that might work for you is Bayesian Linear Regression (BLR): in BLR, you can choose your model assumptions: eta ~ U(-1,1), eta ~ N(0,sigma) or eta ~ Beta(2,2) are all valid assumptions. anything that best fit your data
Uniformly Distributed Residuals in Linear Regression A classic linear regression model works under the assumption that the data can be modeled as y = Ax + b + eta where eta ~ N(0,sigma) . if your residuals are uniformly distributed, it means that the a
31,241
What is the definition of machine learning (vs classical statistics), and can methods such as MCMC and bootstrapping be considered ML? [duplicate]
In my view, MCMC/bootstrapping/permutation methods all fall under the category of computational techniques. They aren't tied down to a specific approach or way of thinking about a problem but rather an algorithmic approach to a class of problems. Techniques that involve resampling and iteration don't arise from a machine learning framework, they come out of mathematical theory; the main factor in their recent popularity in solving more classical statistical problems is simply computing power, not something borrowed from machine learning. There is very little in machine learning that cannot be motivated in some way from classical statistics and the related mathematics. I think it will always be easy to identify certain approaches that are "pure" machine learning, especially deep learning approaches, and more generally the "black box" machine learning approaches that are solely concerned with prediction. There will always be classical statistical approaches that don't relate to machine learning in any way. However, trying to draw any distinct boundary between them in the gray area is as fraught as trying to discriminate physics and chemistry where they intersect.
What is the definition of machine learning (vs classical statistics), and can methods such as MCMC a
In my view, MCMC/bootstrapping/permutation methods all fall under the category of computational techniques. They aren't tied down to a specific approach or way of thinking about a problem but rather a
What is the definition of machine learning (vs classical statistics), and can methods such as MCMC and bootstrapping be considered ML? [duplicate] In my view, MCMC/bootstrapping/permutation methods all fall under the category of computational techniques. They aren't tied down to a specific approach or way of thinking about a problem but rather an algorithmic approach to a class of problems. Techniques that involve resampling and iteration don't arise from a machine learning framework, they come out of mathematical theory; the main factor in their recent popularity in solving more classical statistical problems is simply computing power, not something borrowed from machine learning. There is very little in machine learning that cannot be motivated in some way from classical statistics and the related mathematics. I think it will always be easy to identify certain approaches that are "pure" machine learning, especially deep learning approaches, and more generally the "black box" machine learning approaches that are solely concerned with prediction. There will always be classical statistical approaches that don't relate to machine learning in any way. However, trying to draw any distinct boundary between them in the gray area is as fraught as trying to discriminate physics and chemistry where they intersect.
What is the definition of machine learning (vs classical statistics), and can methods such as MCMC a In my view, MCMC/bootstrapping/permutation methods all fall under the category of computational techniques. They aren't tied down to a specific approach or way of thinking about a problem but rather a
31,242
What is the definition of machine learning (vs classical statistics), and can methods such as MCMC and bootstrapping be considered ML? [duplicate]
Personally, I find it very hard to draw a line between the two, as there is clearly some overlapping. Machine Learning is a field that is based on classical statistics and USES statistic models heavily. Also, the mathematics behind Machine Learning can get extremely complicated, so I really would not use the mathematical argument as a discriminant. One important difference, at least to my eyes, is the one of the "modeling vs data-driven". Statistics usually requires the statistician to make assumptions about the structure and/or distribution of the data, trying to guess the relationships between the variables in order to write an appropriate model. A Machine Learning approach, on the other hand, will try to limit assumptions to a minimum and it will let the data "speak for itself". I will try to give an example with an algorithm that belongs to both statistical and machine learning literature: linear regression. A statistical approach would be to look at the variables at hand, and based on the knowledge on their meaning, try to understand which ones might interact and which ones might have a non-linear dependency, building a model accordingly. A fully ML approach would instead be to use a backward elimination process of features starting from a model containing every interaction and every polinomial expansion up to a certain degree, letting the data decide which ones are relevant. Of course these two approaches meet in the middle most of the time - statisticians also use forward and backward processes to build their models, as well as ML practicioners often work on the feature engineering in order to give them a better meaning. But this also leads back to the point that you made earlier: Statistics is more often about trying to understand the structure behind the data in an understandable manner, and explainablility is a big factor; Machine Learning on the other hand often focuses more on the prediction, and this allows it to avoid make models that would "oversimplify" the relationships to make them understandable, and instead use the data to infer the most efficient structure possible to forecast new values. Finally - on bootstrapping, MCMCs and so on: as Bryan mentioned before me, these are computational techniques, and they are used in both approaches. Also Cross Validation is a computational technique that is used in statistics, and the fact that it relies on iterations it does not make it ML. I would not put a label on every single algorithm, since Statistics and Machine Learning are deeply intertwined and use many common tools, such as the computational techniques that you mentions or many many models, so in the end when you're in the gray area between the two, the fact of "doing Statistics" or "doing Machine Learning" often depends on the mentality that you use when approaching the problem.
What is the definition of machine learning (vs classical statistics), and can methods such as MCMC a
Personally, I find it very hard to draw a line between the two, as there is clearly some overlapping. Machine Learning is a field that is based on classical statistics and USES statistic models heavil
What is the definition of machine learning (vs classical statistics), and can methods such as MCMC and bootstrapping be considered ML? [duplicate] Personally, I find it very hard to draw a line between the two, as there is clearly some overlapping. Machine Learning is a field that is based on classical statistics and USES statistic models heavily. Also, the mathematics behind Machine Learning can get extremely complicated, so I really would not use the mathematical argument as a discriminant. One important difference, at least to my eyes, is the one of the "modeling vs data-driven". Statistics usually requires the statistician to make assumptions about the structure and/or distribution of the data, trying to guess the relationships between the variables in order to write an appropriate model. A Machine Learning approach, on the other hand, will try to limit assumptions to a minimum and it will let the data "speak for itself". I will try to give an example with an algorithm that belongs to both statistical and machine learning literature: linear regression. A statistical approach would be to look at the variables at hand, and based on the knowledge on their meaning, try to understand which ones might interact and which ones might have a non-linear dependency, building a model accordingly. A fully ML approach would instead be to use a backward elimination process of features starting from a model containing every interaction and every polinomial expansion up to a certain degree, letting the data decide which ones are relevant. Of course these two approaches meet in the middle most of the time - statisticians also use forward and backward processes to build their models, as well as ML practicioners often work on the feature engineering in order to give them a better meaning. But this also leads back to the point that you made earlier: Statistics is more often about trying to understand the structure behind the data in an understandable manner, and explainablility is a big factor; Machine Learning on the other hand often focuses more on the prediction, and this allows it to avoid make models that would "oversimplify" the relationships to make them understandable, and instead use the data to infer the most efficient structure possible to forecast new values. Finally - on bootstrapping, MCMCs and so on: as Bryan mentioned before me, these are computational techniques, and they are used in both approaches. Also Cross Validation is a computational technique that is used in statistics, and the fact that it relies on iterations it does not make it ML. I would not put a label on every single algorithm, since Statistics and Machine Learning are deeply intertwined and use many common tools, such as the computational techniques that you mentions or many many models, so in the end when you're in the gray area between the two, the fact of "doing Statistics" or "doing Machine Learning" often depends on the mentality that you use when approaching the problem.
What is the definition of machine learning (vs classical statistics), and can methods such as MCMC a Personally, I find it very hard to draw a line between the two, as there is clearly some overlapping. Machine Learning is a field that is based on classical statistics and USES statistic models heavil
31,243
What is the definition of machine learning (vs classical statistics), and can methods such as MCMC and bootstrapping be considered ML? [duplicate]
Just for the sake of argument, I am putting my two cents here. As I find the answers above/below so far are pretty explanatory. David DN rounded your question up nicely, I think. This subject is very new and therefore, take what you get and run with it. I worked with stats and I worked in research. I also worked on predictive research. Even the big guys on the market, like YouTube, LinkedIn or any other social media using Algorithm, are not near perfect, because machine learning, although statistics is behind the calculations, all predictive matter is based on human behaviour and such bound to human research first. Then math. Then there is the learned and cultural influences. Once learned, there is a next step. In addition geographically, not everyone on the planet is on the same platform, meaning, statistically the learned differs on human behaviour outcome. And yet, machine learning is pretty intertwined from math, computational, psychology, linguistics, cultural. What would stats mean if there is no story behind it. I will suggest the approach, rather than thinking of 'the difference' as one or the other, think of the difference as how each field complements each other and what more can be done.
What is the definition of machine learning (vs classical statistics), and can methods such as MCMC a
Just for the sake of argument, I am putting my two cents here. As I find the answers above/below so far are pretty explanatory. David DN rounded your question up nicely, I think. This subject is ver
What is the definition of machine learning (vs classical statistics), and can methods such as MCMC and bootstrapping be considered ML? [duplicate] Just for the sake of argument, I am putting my two cents here. As I find the answers above/below so far are pretty explanatory. David DN rounded your question up nicely, I think. This subject is very new and therefore, take what you get and run with it. I worked with stats and I worked in research. I also worked on predictive research. Even the big guys on the market, like YouTube, LinkedIn or any other social media using Algorithm, are not near perfect, because machine learning, although statistics is behind the calculations, all predictive matter is based on human behaviour and such bound to human research first. Then math. Then there is the learned and cultural influences. Once learned, there is a next step. In addition geographically, not everyone on the planet is on the same platform, meaning, statistically the learned differs on human behaviour outcome. And yet, machine learning is pretty intertwined from math, computational, psychology, linguistics, cultural. What would stats mean if there is no story behind it. I will suggest the approach, rather than thinking of 'the difference' as one or the other, think of the difference as how each field complements each other and what more can be done.
What is the definition of machine learning (vs classical statistics), and can methods such as MCMC a Just for the sake of argument, I am putting my two cents here. As I find the answers above/below so far are pretty explanatory. David DN rounded your question up nicely, I think. This subject is ver
31,244
What is the definition of machine learning (vs classical statistics), and can methods such as MCMC and bootstrapping be considered ML? [duplicate]
Rather than giving a full response I would like add a factor in the distinction between the two. Let's make the example of a neural network used for classification, most of the times when people get the results they wanted they don't know exactly why they are getting those results. While statistics is more rigorous and always comes with a measure of the confidence that doesn't necessarily happen in ML. You wrote that ML skirts the more complicated mathematics by relying on iteration, but it may also rely on the combination of different algorithms in such a way that it would be difficult to estimate the contribution of each of them, that would be more difficult to justify in statistics, while in ML the main focus is on the results.
What is the definition of machine learning (vs classical statistics), and can methods such as MCMC a
Rather than giving a full response I would like add a factor in the distinction between the two. Let's make the example of a neural network used for classification, most of the times when people get t
What is the definition of machine learning (vs classical statistics), and can methods such as MCMC and bootstrapping be considered ML? [duplicate] Rather than giving a full response I would like add a factor in the distinction between the two. Let's make the example of a neural network used for classification, most of the times when people get the results they wanted they don't know exactly why they are getting those results. While statistics is more rigorous and always comes with a measure of the confidence that doesn't necessarily happen in ML. You wrote that ML skirts the more complicated mathematics by relying on iteration, but it may also rely on the combination of different algorithms in such a way that it would be difficult to estimate the contribution of each of them, that would be more difficult to justify in statistics, while in ML the main focus is on the results.
What is the definition of machine learning (vs classical statistics), and can methods such as MCMC a Rather than giving a full response I would like add a factor in the distinction between the two. Let's make the example of a neural network used for classification, most of the times when people get t
31,245
Theory behind Targeted Maximum Likelihood Estimation (TMLE)
Here is a very tentative (incomplete) answer. I will add more (e.g. the TMLE for ATE) later. It is fairly technical. One important thing to keep in mind is the separation between the data structure, statistical model & the parameter of interest, and the estimation of the target estimand (e.g. the actual TMLE procedure). Definition of statistical model Consider the point-treatment data structure $O=(W,A,Y)$ where $W$ are baseline covariates, $A$ is a binary treatment and $Y$ is an outcome variable. We assume $O$ is drawn from the probability distribution $P_0$. Let $\mathcal{O}$ be the set of possible values of $O$ (e.g. $\mathbb{R}^{d+2}$ if $W$ is d-dimensional). The statistical model $\mathcal{M}$ is a collection of probability distributions that we assume contains $P_0$. In the context of TMLE, we usually take $\mathcal{M}$ to be nonparametric so that it contains all possible probability distributions. For our data structure, we are only interested in certain nuisance components of $P_0$ rather than the entire probability distribution. In particular, we are interested in the distribution of $W$, $P_W$, the propensity score $g(W):=P_0(A=1|W)$, and the conditional mean of the outcome $Q(A,W):=E_0[Y|A,W]$. Definition of parameter Once, we have defined the data structure and statistical model, we can begin talking about our statistical quantity of interest, otherwise known as the target parameter (in this case ATE). Rigorously, the target parameter is a mapping from the statistical model to the real line (or more generally $\mathbb{R}^d$). That is a target parameter $\Psi: \mathcal{M} \mapsto \mathbb{R}$ assigns to each distribution $P \in \mathcal{M}$ the value $\Psi(P)$. The statistical estimand $\psi_0 := \Psi(P_0)$ is defined as the value of the parameter at the true data-generating distribution $P_0$. The ATE parameter is given by $\Psi_{ATE}(P) = E_{P,W}E_P[Y|A=1,W] - E_{P,W}E_P[Y|A=0,W]$. Theory of efficient influence function A useful reference is the following: https://arxiv.org/abs/1903.01706 which has a similar but more thorough treatment as below. Another great reference is the following: https://arxiv.org/pdf/2107.00681.pdf The efficient influence function (EIF) is determined by the statistical model $\mathcal{M}$ and the target parameter $\Psi$. It happens to be a very useful object for efficient estimation and inference, but computing it has nothing to do with estimation. Actually, for each $P$ in the statistical model $\mathcal{M}$, there is an efficient influence function. For this reason, we usually write the EIF as $D_P:O\mapsto D_P(O)$, where it is stressed that the EIF is indexed by $\mathcal{M}$. The efficient influence function $D_P$ can be viewed as the gradient of the parameter $\Psi$ at $P$ in the statistical model $\mathcal{M}$ (analogous to the notion of a gradient of a multivariate function from multivariate calculus). To rigorously define the EIF requires quite a bit of mathematics. In particular, we need to generalize the notions of (directional) derivatives and gradients to functionals (like $\Psi$) defined on infinite dimensional spaces (like $\mathcal{M}$). If you are familiar with aspects of differential geometry or manifold theory, specifically the concept of tangent spaces and derivative operators defined on them, and functional analysis, specifically Hilbert space theory and projections, then that will be very helpful. One key property of the EIF $D_P$ is that it satisfies for $P,P_1 \in \mathcal{M}$ that $$\Psi(P_1) = \Psi(P) + \int D_P(o)d(P_1-P)(o) + R(P_1,P),$$ where $R({P_1,P})$ is a remainder that goes to zero when $P_1$ tends towards $P$ in an appropriate sense. Thus, $D_P$ encodes local (first order derivative) information of $\Psi$ at $P$ and allows for a first order taylor expansion. I will take a shot at semi-rigorously defining the general notion of an efficient influence function. I will assume that each distribution in $\mathcal{M}$ has a density (with respect to the Lebesgue measure). We can thus view $\mathcal{M}$ as a collection of probability densities and $\Psi$ as a functional of densities. Let $P \in \mathcal{M}$ arbitrary and let $p$ be its density. First, we need to define the notion of a directional derivative of $\Psi$. This first requires defining paths through a given density $p$. To this end, for each $P \in \mathcal{M}$, define the Tangent Space: $$T_P\mathcal{M} := (O \mapsto h(O): E_{P}h(O)^2 < \infty,\, E_{P}h(O) = 0),$$ which is just the space of mean-zero and finite variance functions of $O$ (i.e. $L^2_0(P_0) \subset L^2(P_0)$). It is well-known that $T_P\mathcal{M}$ is a closed linear space that can be equipped with the inner product $$\langle h, g \rangle_P := E_P[h(O)g(O)]= \int h(o) g(o) p(o)do,$$ in which case it becomes a Hilbert space. For some $h \in T_P\mathcal{M}$, consider the path through $p$, $$p_{\varepsilon,h} = (1+ \varepsilon h)p,$$ where $\varepsilon \in \mathbb{R}$. Note that $$\int p_{\varepsilon,h}(o)do = \int p(o)d0 + \varepsilon E_P[h(O)] = 1 + 0 =1, $$ and for small enough $\varepsilon$, we have $p_{\varepsilon,h} \geq 0$. Therefore $p_{\varepsilon,h}$ is indeed a density corresponding with some distribution $P_{\varepsilon,h} \in \mathcal{M}$ for all $\varepsilon$ small enough. It is crucial that $P_{\varepsilon,h} \in \mathcal{M}$, which is not necessarily true for statistical models that are not fully nonparametric). We can define the derivative/direction/score of the path $P_{\varepsilon,h}$ as $$\frac{d}{d\varepsilon} \log p_{\varepsilon,h} \Big |_{\varepsilon = 0} = \frac{1}{p} \frac{d}{d\varepsilon} (1+ \varepsilon h)p |_{\varepsilon = 0} = \frac{ph}{p} = h.$$ Thus, the score of the path $P_{\varepsilon,h}$ is exactly equal to tangent space element $h$. (We use $\frac{d}{d\varepsilon,h} \log p_{\varepsilon,h} $ instead of $\frac{d}{d\varepsilon} p_{\varepsilon,h} $ due to nice properties of the former). $T_P\mathcal{M}$ is called the tangent space at $P$ because it encodes all possible directions one can move at $P$ while still staying in the statistical model. Given $h \in T_P\mathcal{M}$ and its corresponding path $P_{\varepsilon,h}$, we define the directional derivative of $\Psi$ in the direction $h$ as $$\frac{d}{d\varepsilon} \Psi(P_{\varepsilon,h}) := \lim_{\varepsilon \rightarrow 0} \frac{\Psi(P_{\varepsilon,h}) - \Psi(P_{0,h})}{\varepsilon}.$$ Note that $\varepsilon \mapsto \Psi(P_{\varepsilon,h})$ is just a univarate real-valued function so that this derivative can be computed using standard calculus. We now define the total derivative $d\Psi_P:T_P\mathcal{M} \mapsto \mathbb{R}$ of $\Psi$ pointwise as $$d\Psi_P(h) = \frac{d}{d\varepsilon} \Psi(P_{\varepsilon,h}).$$ Under some assumptions, $d\Psi_P$ is a linear and bounded/continuous map defined on the Hilbert space $T_P\mathcal{M}$. It then follows by Reisz representation theorem that there exists a unique gradient in $D_P \in T_P \mathcal{M}$ such that $$d\Psi_P(h) = \langle h, D_P \rangle_P = E_P h(O)D_P(O).$$ This gradient is exactly the efficient influence function of $\Psi$ at $P$. Under some conditions, one has that $$\Psi(P_{\varepsilon,h}) = \Psi(P) + \langle h, D_P \rangle_P + o(\varepsilon),$$ so that $D_P$ encodes a first order taylor expansion of $\Psi$ at $P$. Since $\mathcal{M}$ is convex at the density level, for any $P_1,P \in \mathcal{M}$, we can choose the path $p_{\varepsilon} = p + \varepsilon(p_1-p)$ which has score $h = \frac{p_1-p}{p}$ to find that $$\Psi(P_1) = \Psi(P) + \int D_P(o)d(P_1-P)(o) + R(P_1,P),$$ where $R(P_1,P)$ should go to zero as $P_1$ gets "close to" $P$. Key properties of the efficient influence function The efficient influence function $D_P$ has a number of key statistical and non-statistical properties. Firstly, as shown in the previous section, we have for smooth paths $P_{\varepsilon}$ with $P_{\varepsilon=0} = P$ and score $\frac{d}{d\varepsilon} \log p_{\varepsilon} \Big |_{\varepsilon=0} = h$ that $$d\Psi_P(h) = \frac{d}{d\varepsilon} \Psi(P_{\varepsilon}) \Big |_{\varepsilon=0} = E_P[D_P(O)h(O)].$$ Moreover, for any $P_1,P \in \mathcal{M}$ $$\Psi(P_1) = \Psi(P) + \int D_P(o)d(P_1-P)(o) + R(P_1,P),$$ where $R(P_1,P)$ should go to zero as $P_1$ gets "close to" $P$. Also, the EIF has mean-zero so the above simplifies to $\Psi(P_1) = \Psi(P) + \int D_P(o)dP_1(o) + R(P_1,P).$ Another property of $D_P$ is as follows. Consider the path $P_{\varepsilon}$ induced by the density $p_{\varepsilon} = (1 + \varepsilon \frac{D_P}{\sqrt{E_P[D_P(O)^2]}})p$. We say that this path moves in the direction of $D_P$. Since $D_P$ is mean zero, this is a locally valid path through probability distributions. I claim that this path is in the direction of steepest change of $\Psi$ at $P$ (just as the gradient is in multivariate calculus). To see why this is true, note for any other path with score $h$ (e.g. $\varepsilon \mapsto p(1+\varepsilon h)$ ) normalized to have $E_P[h(O)^2]=1$, we have the derivative of $\Psi$ along this path is $$d\Psi_P(h) = E_P[D_P(O)h(O)].$$ By the Cauchy-Schwartz inequality, we have $$d\Psi_P(h) = E_P[D_P(O)h(O)] \leq \sqrt{E_P[D_P(O)^2]} \sqrt{E_P[h(O)^2]} = \sqrt{E_P[D_P(O)^2]}.$$ Thus, the directional derivative can never exceed $\sqrt{E_P[D_P(O)^2]}$. However, we can compute $$d\Psi_P({D_P}/{\sqrt{E_P[D_P(O)^2]}}) = \frac{1}{\sqrt{E_P[D_P(O)^2]}}E_P[D_P(O)D_P(O)] = \sqrt{E_P[D_P(O)^2]} .$$ Thus, the path $P_{\varepsilon}$ in direction ${D_P}/{\sqrt{E_P[D_P(O)^2]}}$ has the maximal directional derivative along all paths through $P$. More generally, we can show that the normalized local maximal change in $\Psi$ is given by $$\sup_{h \in T_P\mathcal{M}}\frac{d\Psi_P(h)}{\sqrt{E_P[h(O)^2]}} = \sqrt{E_P[D_P(O)^2]}$$ which is achieved when $h = D_P$. (The key idea behind TMLE is to perform parametric maximum likelihood estimation along a path in the direction of $D_P$ as this will give us the largest change in $\Psi$ with the least amount of fitting.) The key statistical property is that $D_P$ encodes a generalization of the Cramer-Rao lower to bound to the infinite-dimensional statistical model $\mathcal{M}$. In particular, the best possible standardized variance for asymptotically unbiased estimators of $\Psi(P_0)$ (with some regularity conditions) is given by $E_{P_0} D_{P_0}(O)^2$ (The best possible distribution is Gaussian). (This is the backbone of semiparametric efficiency theory. See for example Asymptotic Statistics, van der Vaart, 2000 for an introduction to the relevant theory). Thus, if one is able to construct an estimator $\Psi_n$ such that $\sqrt{n}(\Psi_n - \Psi(P_0))$ has an asymptotic distribution being a mean-zero Gaussian random variable with variance $E_{P_0} D_{P_0}(O)^2$ then one knows that the estimator is efficient. Usually, we seek an estimator that satisfies $$\Psi_n - \Psi(P_0) = \frac{1}{n}\sum_{i=1}^n D_{P_0}(O_i) + o_P(n^{-1/2}).$$ Such an estimator is (when centered) asymptotically equivalent to the sample mean of $D_{P_0}(O)$ and therefore trivially has $\sqrt{n}(\Psi_n - \Psi(P_0))$ goes to a mean-zero Gaussian random variable with variance $E_{P_0} D_{P_0}(O)^2$ as desired. Somewhat confusingly $D_{P_0}$ is then called the "influence function" of the estimator $\Psi_n$. This is also why some sources might be confusing (e.g. robust statistics concerns itself with the influence functions of estimators). This is also why the efficient influence function is sometimes called the "canonical gradient". TMLE as well as double-robust estimators more generally (e.g. one-step efficient estimator) attempts to construct an estimator that is asymptotically equivalent to the sample mean of $D_{P_0}$. One Step efficient estimators The first nonparametric efficient estimator is the so-called one-step estimator. It is motivated by the first order taylor expansion of the previous section. Let $P_{n,0} \in \mathcal{M}$ be an initial estimator of $P_0$. Let $P_n$ denote the empirical measure. Almost always $\Psi(P_{n,0})$ is overly biased and will not be $\sqrt{n}$-consistent and therefore surely not efficient. The first order taylor expansions motivates performing a first-order bias correction (essentially one newton gradient descent step update in the parameter space). We can write (doing the taylor expansion at $P_{n,0}$ in the direction of the score $d(P_0-P_{n,0})/dP_{n,0}$), $$\Psi(P_{n,0}) - \Psi(P_0) = -d\Psi_{P_{n,0}}(d(P_0-P_{n,0})/dP_{n,0}) + R_{n,2}(P_{n,0},P_0) $$ $$= -\int D_{P_{n,0}}(o) dP_0(o) + R_{n,2}(P_{n,0},P_0)$$ where $R_{n,2}(P_{n,0},P_0)$ is a remainder term. Under some conditions, one can show that $R_{n,2}(P_{n,0},P_0) = o_P(n^{-1/2})$ so that it is asymptotically negligible. If we knew the true distribution $P_0$, a natural estimator would be $\Psi_{n,oracle} := \Psi(P_{n,0}) + \int D_{P_{n,0}}(o) dP_0(o) = \Psi(P_{n,0}) + E_{P_0}[D_{P_{n,0}}(O)]$ which would under conditions satisfy $\Psi_{n,oracle} - \Psi(P_0) = o_P(n^{-1/2})$ and be faster than $\sqrt{n}$-consistent. This is just a first-order gradient-descent/newton update for $\Psi$. Unfortunately, this estimator is impossible as we don't know $P_0$. Instead, we will look at an empirical version of this estimator given by $\Psi(P_{n,0}) + E_{P_n}[D_{P_{n,0}}(O)]$, which is tractable. Now, I am going to add $\int D_{P_{n,0}}(o) dP_n(o)$ to both sides to get $$\Psi(P_{n,0}) - \Psi(P_0) + \int D_{P_{n,0}}(o) dP_n(o) = \int D_{P_{n,0}}(o) d(P_n-P_0)(o) + R_{n,2}(P_{n,0},P_0).$$ This can be further written as $$\Psi(P_{n,0}) - \Psi(P_0) + \int D_{P_{n,0}}(o) dP_n(o) = \int D_{P_{0}}(o) d(P_n-P_0)(o) + \int (D_{P_{n,0}}(o)-D_{P_{0}}(o)) d(P_n-P_0)(o) + R_{n,2}(P_{n,0},P_0).$$ When $P_{n,0}$ is consistent for $P_0$, then $(D_{P_{n,0}}(o)-D_{P_{0}}(o))$ converges to zero in probability. In particular, $\int (D_{P_{n,0}}(o)-D_{P_{0}}(o)) d(P_n-P_0)(o) $ is the sample mean of something converging to zero and is therefore under some conditions $o_P(n^{-1/2})$. Putting it all together, we get $$\Psi(P_{n,0}) - \Psi(P_0) + \int D_{P_{n,0}}(o) dP_n(o) = \int D_{P_{0}}(o) d(P_n-P_0)(o) + o_P(n^{-1/2}) = \frac{1}{n}\sum_{i=1}^n D_{P_0}(O_i) + o_P(n^{-1/2})$$ as desired (last equality uses that $D_{P_0}$ is necessarily mean zero). Thus, $$\Psi(P_{n,0}) + \int D_{P_{n,0}}(o) dP_n(o) - \Psi(P_0) $$ $$= \Psi(P_{n,0}) + \frac{1}{n}\sum_{i=1}^n D_{P_{n,0}}(O_i) - \Psi(P_0) $$ is asymptotically equivalent to the sample mean of $D_{P_0}$. Thus, $\Psi(P_{n,0}) + \int D_{P_{n,0}}(o) dP_n(o)$ is an efficient estimator, under some conditions. The one-step estimator is given by $$\Psi_{n, onestep} = \Psi(P_{n,0}) + \frac{1}{n}\sum_{i=1}^n D_{P_{n,0}}(O_i).$$ It requires an initial estimator $\Psi(P_{n,0})$ of $\Psi(P_0)$ and an initial estimator $ D_{P_{n,0}}$ of the efficient influence function $ D_{P_{0}}$. It then bias corrects the initial estimator by performing a single gradient-descent-type update. It is important to note that the gradient descent occurs in the parameter space (the space of values of $\Psi(P_0)$, e.g. $\mathbb{R}$) and not in the model $\mathcal{M}$. This has some undesirable properties. First, $\Psi_{n, onestep}$ is usually not a substitution estimator. That is, there usually does not exist a probability distribution $P_{n}^* \in \mathcal{M}$ that satisfies $\Psi(P_n^*) = \Psi_{n, onestep}$. Because of this, $\Psi_{n, onestep}$ might give erratic and impossible values since it does not respect the constraints of the statistical model. For instance if $P \mapsto \Psi(P)$ takes values in $[0,1]$ then the substitution estimator $\Psi(P_{n,0})$ will also, but $ \Psi_{n, onestep}$ does not necessarily satisfy these constraints. This can lead to poor finite sample performance of the one-step estimator. This brings us to TMLE which allows one to construct an efficient substitution estimator $\Psi(P_n^*)$ of $\Psi(P_0)$. TMLE accomplishes this by performing gradient descent (specifically maximum likelihood estimation) in the statistical model $\mathcal{M}$. TMLE Targeted maximum likelihood estimation (TMLE) constructs an estimator that is both efficient and a substitution estimator. One way of thinking of TMLE is as a very special kind of one-step estimator. Suppose we had an estimator $P_n^*$ of $P_0$. The one-step estimator is given by $$\Psi(P_n^*) + \frac{1}{n}\sum_{i=1}^n D_{P_n^*}(O_i).$$ Now, suppose that $P_n^*$ satisfies $$\frac{1}{n}\sum_{i=1}^n D_{P_n^*}(O_i) = 0.$$ Then, we would have $$\Psi(P_n^*) = \Psi(P_n^*) +0 =\Psi(P_n^*) + \frac{1}{n}\sum_{i=1}^n D_{P_n^*}(O_i),$$ so that the substitution estimator $ \Psi(P_n^*) $ is equal to the one-step estimator and therefore is also efficient. TMLE provides a general template for updating/calibrating/targeting an arbitrary initial estimator $P_{n,0} \in \mathcal{M}$ into an updated estimator $P_n^*$ that satisfies $\frac{1}{n}\sum_{i=1}^n D_{P_n^*}(O_i)=0$. The key idea is the following. Construct a submodel/path $P_{n,\varepsilon}$ with $P_{n, \varepsilon = 0} = P_{n,0}$ that satisfies $\frac{d}{d\varepsilon} \log p_{n,\varepsilon} = D_{P_{n,\varepsilon}}$. Recalling the previous sections, $P_{n,\varepsilon}$ is a path that for each $\varepsilon$ locally moves in the direction of greatest change of $\Psi$. TMLE performs maximum likelihood estimation along this path (where the initial estimator ensures that this parametric model is close enough to $P_0$ to be useful). This can be viewed as functional gradient descent under the constraint that the empirical likelihood always increases. We update an initial estimator by performing gradient descent in the direction of maximum change of $\Psi$ (whether we go forwards to backwards depends on which direction increases the likelihood). We keep performing gradient descent until the empirical likelihood no longer increases. At this point, we have maximized an empirical likelihood and solved a certain score/derivative equation. This equation we solve is exactly $\frac{1}{n}\sum_{i=1}^n D_{P_n^*}(O_i)=0$. Consider the empirical log likelihood risk function: $$R_{n,Loglik}(P) = \frac{1}{n}\sum_{i=1}^n \log p(O_i).$$ In view of the above, we have $$\frac{d}{d\varepsilon} R_{n,Loglik}(P_{n,\varepsilon}) = \frac{1}{n}\sum_{i=1}^n \frac{d}{d\varepsilon} \log p_{n,\varepsilon}(O_i) \approx \frac{1}{n}\sum_{i=1}^n D_{P_{n,\varepsilon}}(O_i). $$ Let $\varepsilon_n^* = \text{argmin}_{\varepsilon}R_{n,Loglik}(P_{n,\varepsilon}) $ then we must have (since it is a minimizer) $$\frac{d}{d\varepsilon} R_{n,Loglik}(P_{n,\varepsilon}) \Big|_{\varepsilon = \varepsilon_n^*} = \frac{1}{n}\sum_{i=1}^n D_{P_{n,\varepsilon_n^*}}(O_i) = 0.$$ Thus, $P_n^* := P_{n,\varepsilon_n^*}$ has the desired property that $\frac{1}{n}\sum_{i=1}^n D_{P_{n,\varepsilon_n^*}}(O_i) = 0$. We call $P_n^*$ the TMLE. Such a path $P_{n,\varepsilon_n}$ can be approximately defined as follows. Fix a step size $\delta > 0$. Initialize $k=0$. Define $p_{n,\varepsilon=0} = p_{n,0}$. For $\varepsilon \in [0,\delta] = [k\delta,(k+1)\delta]$, define $p_{n,\varepsilon} = (1+\varepsilon D_{P_{n,0}})p_{n,0}$. Define $p_{n,k} = p_{n,\varepsilon k}$. Now, arguing recursively for $k=k+1$, for $\varepsilon \in [k\delta,(k+1)\delta]$, define $p_{n,\varepsilon} = (1+\varepsilon D_{P_{n,k}})p_{n,k}$. This path satisfies $$\frac{d}{d\varepsilon} \log p_{n,\varepsilon} \Big |_{\varepsilon = k \delta} = D_{P_{n,k\delta}},$$ so the violation of $\frac{d}{d\varepsilon} \log p_{n,\varepsilon} = D_{P_{n,\varepsilon}}$ is usually negligible as long as the step size $\delta$ is chosen small enough. Note in practice, we don't estimate the entire probability distribution $P_0$. We estimate key nuisance features like conditional means. A version of TMLE (targeted minimum loss estimation) instead performs the above in a lower dimensional feature space (e.g. the space of conditional means). In this case, we perform functional gradient descent in a lower dimensional space (but still infinite dimensional) under the constraint that the risk of the nuisance estimator does not increase (where the risk is given by some custom risk function). This is also where the "clever covariates" come into play (as a computational trick). A simple TMLE for the CDF of a univariate CDF at a point. Suppose we observe $n$ iid observations of a real-valued random variable $X \sim P_0$ with CDF $x \mapsto F_0(x)$. The statistical model $\mathcal{M}$ is given by all probability distributions on $\mathbb{R}$. The parameter of interest is the CDF at $t \in \mathbb{R}$, $$\Psi(P) = P(X \leq t)$$ and the estimand of interest is $\Psi(P_0) = F_0(t) = P_0(X \leq t)$. We will first compute the efficient influence function of $\Psi$. Let $p$ be some density associated with a $P \in \mathcal{M}$. Consider the path $p_{\varepsilon}: \varepsilon \mapsto (1+ \varepsilon h)p$ where $h$ satisfies $\int h(x) p(x)dx = 0$ and has finite variance. Let $P_{\varepsilon}$ be the path in $\mathcal{M}$ corresponding with density path $p_{\varepsilon}$. Note the directional/pathwise derivative is given by $$d\Psi(h) = \frac{d}{d\varepsilon} \Psi(P_{\varepsilon}) \Big |_{\varepsilon = 0} = \frac{d}{d\varepsilon} E_{P_{\varepsilon}}[1(X \leq t)] \Big |_{\varepsilon = 0}$$ $$ = \frac{d}{d\varepsilon} \int 1(x \leq t) (1+ \varepsilon h(x))p(x)dx \Big |_{\varepsilon = 0}$$ $$ = \int 1(x \leq t) h(x)p(x)dx = E_P[1(X\leq t) h(X)] .$$ Note that $ E_P[1(X\leq t) h(X)]$ corresponds with the $L^2(P)$-inner product of $1(X \leq t)$ and $h(X)$, where $h$ is actually an arbitrary element in the tangent space $T_P\mathcal{M}$. This might incorrectly suggest that $1(X\leq t)$ is the efficient influence function. This is incorrect because the efficient influence function must be contained in $T_P\mathcal{M}$ itself. $X \mapsto 1(X\leq t)$ has finite variance but it is not mean-zero, so it is not in the tangent space. In other words, $x \mapsto p(x)(1+\varepsilon 1(x\leq t))$ is not a valid probability density for any $\varepsilon$. Fortunately, there is an easy fix. Note the identity $$ E_P[1(X\leq t) h(X)] = E_P[[1(X\leq t) - P(X\leq t) ]h(X)],$$ where $1(X\leq t) - P(X\leq t) $ being mean-zero is contained in the tangent space. Thus, we have shown $$d\Psi(h) = \langle D_P, h \rangle_{L^2_0(P)} $$ for $D_P(X) := 1(X\leq t) - P(X\leq t)$ and all $h \in T_P\mathcal{M}$. It follows (from uniqueness) that $D_P$ is the efficient influence function of $\Psi$ at $P$. We can now construct an efficient one-step estimator. Let $p_n$ be an arbitrary initial estimator of the density $p_0$ corresponding with $P_0$. We have (slightly abusing notation) $$\Psi(p_n) = \int 1(x \leq t)p_n(x)dx,$$ $$D_{p_n}(x) = 1(x \leq t) - \int 1(x \leq t)p_n(x)dx.$$ The one-step estimator is given by $$\Psi_{n,onestep} = \Psi(p_n) + \frac{1}{n}\sum_{i=1}^n D_{p_n}(X_i) $$ $$= \int 1(x \leq t)p_n(x)dx + \frac{1}{n}\sum_{i=1}^n [1(X_i \leq t) - \int 1(x \leq t)p_n(x)dx] $$ $$ = + \frac{1}{n}\sum_{i=1}^n 1(X_i \leq t) + 0 = \frac{1}{n}\sum_{i=1}^n 1(X_i \leq t),$$ which is nothing else than the well-known empirical CDF estimator. Thus, the one-step estimator and the empirical CDF estimator are the same regardless of the initial estimator of the density (In this case, we remarkably don't even need $p_n$ to be consistent). We can also construct a TMLE for $\Psi(P_0)$. Define the empirical log-likelihood risk function: $$R_n(p) = -\frac{1}{n} \sum_{i=1}^n \log p(X_i).$$ Given an initial estimator $p_n$, we define the path $$p_{n,\varepsilon} = (1 + \varepsilon D_{p_n})p_n.$$ The TMLE $p_n^*$ is given by performing maximum likelihood along this path. In this case, $\varepsilon_n^* := \text{argmin}_{\varepsilon} R_n(p_{n,\varepsilon})$ has an analytical solution. The solution solves the following equation $$\frac{1}{n} \sum_{i=1}^n \frac{1}{(1 + \varepsilon_n^* D_{p_n}(X_i))p_n(X_i)} D_{p_n}(X_i)p_n(X_i) = 0$$ which is equivalent to $$\frac{1}{n} \sum_{i=1}^n \frac{ D_{p_n}(X_i)}{(1 + \varepsilon_n^* D_{p_n}(X_i))} = 0.$$ Note that $D_{p_n}$ is special because it is constant on $(-\infty,t]$ and $(t,\infty]$. So we can write $$ = \frac{1}{n} \sum_{i=1}^n 1(X_i \leq t) \frac{ D_{p_n}(X_i)}{(1 + \varepsilon_n^* D_{p_n}(X_i))} + \frac{1}{n} \sum_{i=1}^n 1(X_i >t) \frac{ D_{p_n}(X_i)}{(1 + \varepsilon_n^* D_{p_n}(X_i))} $$ $$ = \frac{ D_{p_n}(t_-)}{(1 + \varepsilon_n^* D_{p_n}(t_-))} \frac{1}{n} \sum_{i=1}^n 1(X_i \leq t) + \frac{ D_{p_n}(t_+)}{(1 + \varepsilon_n^* D_{p_n}(t_+))} \frac{1}{n} \sum_{i=1}^n 1(X_i >t) = 0$$ where $t_- < t < t_+$. This is equivalent to $$ D_{p_n}(t_-)(1 + \varepsilon_n^* D_{p_n}(t_+)) \frac{1}{n} \sum_{i=1}^n 1(X_i \leq t) + D_{p_n}(t_+)(1 + \varepsilon_n^* D_{p_n}(t_-)) \frac{1}{n} \sum_{i=1}^n 1(X_i >t) = 0$$ which is equivalent to $$ \varepsilon_n^*[D_{p_n}(t_-)D_{p_n}(t_+)]\frac{1}{n} \sum_{i=1}^n 1(X_i \leq t) + \varepsilon_n^*[D_{p_n}(t_-)D_{p_n}(t_+)]\frac{1}{n} \sum_{i=1}^n 1(X_i >t) = - D_{p_n}(t_-) \frac{1}{n} \sum_{i=1}^n 1(X_i \leq t) - D_{p_n}(t_+) \frac{1}{n} \sum_{i=1}^n 1(X_i >t)$$ which is equivalent to $$\varepsilon_n^* = -1 \cdot \frac{ D_{p_n}(t_-) \frac{1}{n} \sum_{i=1}^n 1(X_i \leq t) + D_{p_n}(t_+) \frac{1}{n} \sum_{i=1}^n 1(X_i >t)}{ D_{p_n}(t_-)D_{p_n}(t_+)}.$$ Now note that $D_{p_n}(t_-) = 1 - \Psi(p_n)$ and $D_{p_n}(t_+) = - \Psi(p_n)$ to find $$\varepsilon_n^* = -1 \cdot \frac{ ( 1 - \Psi(p_n)) \frac{1}{n} \sum_{i=1}^n 1(X_i \leq t) - \Psi(p_n)\frac{1}{n} \sum_{i=1}^n 1(X_i >t)}{ D_{p_n}(t_-)D_{p_n}(t_+)}$$ which is equivalent to $$\varepsilon_n^* = \frac{ \frac{1}{n} \sum_{i=1}^n 1(X_i \leq t) - \Psi(p_n)}{(1 - \Psi(p_n))(\Psi(p_n))},$$ which is a very elegant looking solution. One can show that the TMLE $p_n^*:= p_{n, \varepsilon_n^*}$ satisfies $\frac{1}{n} \sum_{i=1}^n D_{p_n^*}(X_i) = 0$ as desired so that the substitution TMLE $\Psi(p_n^*) = \int 1(x\leq t)p_n^*(x)dx$ is efficient, and in fact $\Psi(p_n^*) = \frac{1}{n} \sum_{i=1}^n 1(X_i \leq t)$ must necessarily hold since $\frac{1}{n} \sum_{i=1}^n D_{p_n^*}(X_i) = 0$. Thus, the TMLE is, like the one-step estimator, equal to the empirical CDF estimator. Here is R code that implements the TMLE and plots how the initial CDF and density estimates are changed by targeting. n <- 200 X <- rnorm(n , mean = 0, sd = 1) hist(X) #fit_density <- density(X) #ps <- fit_density$y xs <- seq(min(X), max(X), length = 1000) xs <- sort(c(X,xs)) ps <- rep(1/(max(xs) - min(xs)), length(xs)) get_density_preds <- function(grid, p_at_grid, x) { p_at_grid[which.min(abs(x-grid))] } get_CDF <- function(x, p, t) { #x: grid for values of X #p: density values at x #t: value to get CDF at sum(diff(x)*p[-1]*(x<=t)[-1]) # Sloppy Reimann sum integration } get_CDF <- Vectorize(get_CDF, vectorize.args = "t") num_steps <- 5 max_eps <- 1 t <- 1 p_i <- ps / get_CDF(xs, ps, max(xs)) # Path in direction of EIF path <- function(p, EIF, eps) { (1 + eps*EIF) * p } # Plot initial plot(xs, p_i, main = "Initial density estimate") plot(xs, get_CDF(xs, ps, xs) , main = "Initial CDF estimate") for(i in 1:3) { Psi <- get_CDF(xs, p_i, t) EIF <- (xs<=t) - Psi #EIF evaluated at grid EIF_empirical <- (X<=t) - Psi #EIF evaluated at observations # Check for convergence if(i>1 & abs(mean(EIF_empirical)) <= sd(EIF_empirical)/sqrt(n)/log(n)) { print(mean(EIF_empirical)) print("converged") break } # loglikelihood risk of density at epsilon along path risk_function <- function(eps) { p_eps <- path(p_i, EIF, eps) p_eps <- p_eps / get_CDF(xs, p_i, max(xs)) p_obs <- sapply(X, get_density_preds, grid = xs, p_at_grid = p_eps) mean( -log(p_obs)) } # Find risk minimizer along path best_eps <- optim(0, risk_function, method = "Brent", lower = -max_eps, upper = max_eps)$par analytical_eps <- mean(EIF_empirical)/(1-Psi)/Psi print("chosen numerical epsilon and analytical epsilon") print(c(best_eps, analytical_eps)) # Update initial estimator p_i <- path(p_i, EIF, analytical_eps) # Plot updates plot(xs, p_i, main = "Updated density estimates") plot(xs, get_CDF(xs, p_i, xs), main = "Updated CDF estimates") } Answer to comments: TMLE aims to construct an asymptotically unbiased estimate of the ATE by first constructing a path through an initial density estimator that is contained in the statistical model (which you should visually think of as a geometric surface but each point is actually a density function/probability distribution). This path has the property that it points in the direction of greatest change of the ATE (i.e. the direction of steepest ascent/descent). So If I am limited to taking only one small step away from the initial density estimator, a step along this path will give me a new density estimator with the most different ATE estimate. Given this path of steepest change of my target parameter, it makes sense to find the point along this path that maximizes the empirical log likelihood, which gives me the best density fit. Because this path is in the direction of steepest change of my parameter, this additional fitting done by the MLE is targeted towards my parameter of interest. It makes sure that all additional fitting that I do is maximally beneficial for giving me a better estimate for my parameter of interest.
Theory behind Targeted Maximum Likelihood Estimation (TMLE)
Here is a very tentative (incomplete) answer. I will add more (e.g. the TMLE for ATE) later. It is fairly technical. One important thing to keep in mind is the separation between the data structure, s
Theory behind Targeted Maximum Likelihood Estimation (TMLE) Here is a very tentative (incomplete) answer. I will add more (e.g. the TMLE for ATE) later. It is fairly technical. One important thing to keep in mind is the separation between the data structure, statistical model & the parameter of interest, and the estimation of the target estimand (e.g. the actual TMLE procedure). Definition of statistical model Consider the point-treatment data structure $O=(W,A,Y)$ where $W$ are baseline covariates, $A$ is a binary treatment and $Y$ is an outcome variable. We assume $O$ is drawn from the probability distribution $P_0$. Let $\mathcal{O}$ be the set of possible values of $O$ (e.g. $\mathbb{R}^{d+2}$ if $W$ is d-dimensional). The statistical model $\mathcal{M}$ is a collection of probability distributions that we assume contains $P_0$. In the context of TMLE, we usually take $\mathcal{M}$ to be nonparametric so that it contains all possible probability distributions. For our data structure, we are only interested in certain nuisance components of $P_0$ rather than the entire probability distribution. In particular, we are interested in the distribution of $W$, $P_W$, the propensity score $g(W):=P_0(A=1|W)$, and the conditional mean of the outcome $Q(A,W):=E_0[Y|A,W]$. Definition of parameter Once, we have defined the data structure and statistical model, we can begin talking about our statistical quantity of interest, otherwise known as the target parameter (in this case ATE). Rigorously, the target parameter is a mapping from the statistical model to the real line (or more generally $\mathbb{R}^d$). That is a target parameter $\Psi: \mathcal{M} \mapsto \mathbb{R}$ assigns to each distribution $P \in \mathcal{M}$ the value $\Psi(P)$. The statistical estimand $\psi_0 := \Psi(P_0)$ is defined as the value of the parameter at the true data-generating distribution $P_0$. The ATE parameter is given by $\Psi_{ATE}(P) = E_{P,W}E_P[Y|A=1,W] - E_{P,W}E_P[Y|A=0,W]$. Theory of efficient influence function A useful reference is the following: https://arxiv.org/abs/1903.01706 which has a similar but more thorough treatment as below. Another great reference is the following: https://arxiv.org/pdf/2107.00681.pdf The efficient influence function (EIF) is determined by the statistical model $\mathcal{M}$ and the target parameter $\Psi$. It happens to be a very useful object for efficient estimation and inference, but computing it has nothing to do with estimation. Actually, for each $P$ in the statistical model $\mathcal{M}$, there is an efficient influence function. For this reason, we usually write the EIF as $D_P:O\mapsto D_P(O)$, where it is stressed that the EIF is indexed by $\mathcal{M}$. The efficient influence function $D_P$ can be viewed as the gradient of the parameter $\Psi$ at $P$ in the statistical model $\mathcal{M}$ (analogous to the notion of a gradient of a multivariate function from multivariate calculus). To rigorously define the EIF requires quite a bit of mathematics. In particular, we need to generalize the notions of (directional) derivatives and gradients to functionals (like $\Psi$) defined on infinite dimensional spaces (like $\mathcal{M}$). If you are familiar with aspects of differential geometry or manifold theory, specifically the concept of tangent spaces and derivative operators defined on them, and functional analysis, specifically Hilbert space theory and projections, then that will be very helpful. One key property of the EIF $D_P$ is that it satisfies for $P,P_1 \in \mathcal{M}$ that $$\Psi(P_1) = \Psi(P) + \int D_P(o)d(P_1-P)(o) + R(P_1,P),$$ where $R({P_1,P})$ is a remainder that goes to zero when $P_1$ tends towards $P$ in an appropriate sense. Thus, $D_P$ encodes local (first order derivative) information of $\Psi$ at $P$ and allows for a first order taylor expansion. I will take a shot at semi-rigorously defining the general notion of an efficient influence function. I will assume that each distribution in $\mathcal{M}$ has a density (with respect to the Lebesgue measure). We can thus view $\mathcal{M}$ as a collection of probability densities and $\Psi$ as a functional of densities. Let $P \in \mathcal{M}$ arbitrary and let $p$ be its density. First, we need to define the notion of a directional derivative of $\Psi$. This first requires defining paths through a given density $p$. To this end, for each $P \in \mathcal{M}$, define the Tangent Space: $$T_P\mathcal{M} := (O \mapsto h(O): E_{P}h(O)^2 < \infty,\, E_{P}h(O) = 0),$$ which is just the space of mean-zero and finite variance functions of $O$ (i.e. $L^2_0(P_0) \subset L^2(P_0)$). It is well-known that $T_P\mathcal{M}$ is a closed linear space that can be equipped with the inner product $$\langle h, g \rangle_P := E_P[h(O)g(O)]= \int h(o) g(o) p(o)do,$$ in which case it becomes a Hilbert space. For some $h \in T_P\mathcal{M}$, consider the path through $p$, $$p_{\varepsilon,h} = (1+ \varepsilon h)p,$$ where $\varepsilon \in \mathbb{R}$. Note that $$\int p_{\varepsilon,h}(o)do = \int p(o)d0 + \varepsilon E_P[h(O)] = 1 + 0 =1, $$ and for small enough $\varepsilon$, we have $p_{\varepsilon,h} \geq 0$. Therefore $p_{\varepsilon,h}$ is indeed a density corresponding with some distribution $P_{\varepsilon,h} \in \mathcal{M}$ for all $\varepsilon$ small enough. It is crucial that $P_{\varepsilon,h} \in \mathcal{M}$, which is not necessarily true for statistical models that are not fully nonparametric). We can define the derivative/direction/score of the path $P_{\varepsilon,h}$ as $$\frac{d}{d\varepsilon} \log p_{\varepsilon,h} \Big |_{\varepsilon = 0} = \frac{1}{p} \frac{d}{d\varepsilon} (1+ \varepsilon h)p |_{\varepsilon = 0} = \frac{ph}{p} = h.$$ Thus, the score of the path $P_{\varepsilon,h}$ is exactly equal to tangent space element $h$. (We use $\frac{d}{d\varepsilon,h} \log p_{\varepsilon,h} $ instead of $\frac{d}{d\varepsilon} p_{\varepsilon,h} $ due to nice properties of the former). $T_P\mathcal{M}$ is called the tangent space at $P$ because it encodes all possible directions one can move at $P$ while still staying in the statistical model. Given $h \in T_P\mathcal{M}$ and its corresponding path $P_{\varepsilon,h}$, we define the directional derivative of $\Psi$ in the direction $h$ as $$\frac{d}{d\varepsilon} \Psi(P_{\varepsilon,h}) := \lim_{\varepsilon \rightarrow 0} \frac{\Psi(P_{\varepsilon,h}) - \Psi(P_{0,h})}{\varepsilon}.$$ Note that $\varepsilon \mapsto \Psi(P_{\varepsilon,h})$ is just a univarate real-valued function so that this derivative can be computed using standard calculus. We now define the total derivative $d\Psi_P:T_P\mathcal{M} \mapsto \mathbb{R}$ of $\Psi$ pointwise as $$d\Psi_P(h) = \frac{d}{d\varepsilon} \Psi(P_{\varepsilon,h}).$$ Under some assumptions, $d\Psi_P$ is a linear and bounded/continuous map defined on the Hilbert space $T_P\mathcal{M}$. It then follows by Reisz representation theorem that there exists a unique gradient in $D_P \in T_P \mathcal{M}$ such that $$d\Psi_P(h) = \langle h, D_P \rangle_P = E_P h(O)D_P(O).$$ This gradient is exactly the efficient influence function of $\Psi$ at $P$. Under some conditions, one has that $$\Psi(P_{\varepsilon,h}) = \Psi(P) + \langle h, D_P \rangle_P + o(\varepsilon),$$ so that $D_P$ encodes a first order taylor expansion of $\Psi$ at $P$. Since $\mathcal{M}$ is convex at the density level, for any $P_1,P \in \mathcal{M}$, we can choose the path $p_{\varepsilon} = p + \varepsilon(p_1-p)$ which has score $h = \frac{p_1-p}{p}$ to find that $$\Psi(P_1) = \Psi(P) + \int D_P(o)d(P_1-P)(o) + R(P_1,P),$$ where $R(P_1,P)$ should go to zero as $P_1$ gets "close to" $P$. Key properties of the efficient influence function The efficient influence function $D_P$ has a number of key statistical and non-statistical properties. Firstly, as shown in the previous section, we have for smooth paths $P_{\varepsilon}$ with $P_{\varepsilon=0} = P$ and score $\frac{d}{d\varepsilon} \log p_{\varepsilon} \Big |_{\varepsilon=0} = h$ that $$d\Psi_P(h) = \frac{d}{d\varepsilon} \Psi(P_{\varepsilon}) \Big |_{\varepsilon=0} = E_P[D_P(O)h(O)].$$ Moreover, for any $P_1,P \in \mathcal{M}$ $$\Psi(P_1) = \Psi(P) + \int D_P(o)d(P_1-P)(o) + R(P_1,P),$$ where $R(P_1,P)$ should go to zero as $P_1$ gets "close to" $P$. Also, the EIF has mean-zero so the above simplifies to $\Psi(P_1) = \Psi(P) + \int D_P(o)dP_1(o) + R(P_1,P).$ Another property of $D_P$ is as follows. Consider the path $P_{\varepsilon}$ induced by the density $p_{\varepsilon} = (1 + \varepsilon \frac{D_P}{\sqrt{E_P[D_P(O)^2]}})p$. We say that this path moves in the direction of $D_P$. Since $D_P$ is mean zero, this is a locally valid path through probability distributions. I claim that this path is in the direction of steepest change of $\Psi$ at $P$ (just as the gradient is in multivariate calculus). To see why this is true, note for any other path with score $h$ (e.g. $\varepsilon \mapsto p(1+\varepsilon h)$ ) normalized to have $E_P[h(O)^2]=1$, we have the derivative of $\Psi$ along this path is $$d\Psi_P(h) = E_P[D_P(O)h(O)].$$ By the Cauchy-Schwartz inequality, we have $$d\Psi_P(h) = E_P[D_P(O)h(O)] \leq \sqrt{E_P[D_P(O)^2]} \sqrt{E_P[h(O)^2]} = \sqrt{E_P[D_P(O)^2]}.$$ Thus, the directional derivative can never exceed $\sqrt{E_P[D_P(O)^2]}$. However, we can compute $$d\Psi_P({D_P}/{\sqrt{E_P[D_P(O)^2]}}) = \frac{1}{\sqrt{E_P[D_P(O)^2]}}E_P[D_P(O)D_P(O)] = \sqrt{E_P[D_P(O)^2]} .$$ Thus, the path $P_{\varepsilon}$ in direction ${D_P}/{\sqrt{E_P[D_P(O)^2]}}$ has the maximal directional derivative along all paths through $P$. More generally, we can show that the normalized local maximal change in $\Psi$ is given by $$\sup_{h \in T_P\mathcal{M}}\frac{d\Psi_P(h)}{\sqrt{E_P[h(O)^2]}} = \sqrt{E_P[D_P(O)^2]}$$ which is achieved when $h = D_P$. (The key idea behind TMLE is to perform parametric maximum likelihood estimation along a path in the direction of $D_P$ as this will give us the largest change in $\Psi$ with the least amount of fitting.) The key statistical property is that $D_P$ encodes a generalization of the Cramer-Rao lower to bound to the infinite-dimensional statistical model $\mathcal{M}$. In particular, the best possible standardized variance for asymptotically unbiased estimators of $\Psi(P_0)$ (with some regularity conditions) is given by $E_{P_0} D_{P_0}(O)^2$ (The best possible distribution is Gaussian). (This is the backbone of semiparametric efficiency theory. See for example Asymptotic Statistics, van der Vaart, 2000 for an introduction to the relevant theory). Thus, if one is able to construct an estimator $\Psi_n$ such that $\sqrt{n}(\Psi_n - \Psi(P_0))$ has an asymptotic distribution being a mean-zero Gaussian random variable with variance $E_{P_0} D_{P_0}(O)^2$ then one knows that the estimator is efficient. Usually, we seek an estimator that satisfies $$\Psi_n - \Psi(P_0) = \frac{1}{n}\sum_{i=1}^n D_{P_0}(O_i) + o_P(n^{-1/2}).$$ Such an estimator is (when centered) asymptotically equivalent to the sample mean of $D_{P_0}(O)$ and therefore trivially has $\sqrt{n}(\Psi_n - \Psi(P_0))$ goes to a mean-zero Gaussian random variable with variance $E_{P_0} D_{P_0}(O)^2$ as desired. Somewhat confusingly $D_{P_0}$ is then called the "influence function" of the estimator $\Psi_n$. This is also why some sources might be confusing (e.g. robust statistics concerns itself with the influence functions of estimators). This is also why the efficient influence function is sometimes called the "canonical gradient". TMLE as well as double-robust estimators more generally (e.g. one-step efficient estimator) attempts to construct an estimator that is asymptotically equivalent to the sample mean of $D_{P_0}$. One Step efficient estimators The first nonparametric efficient estimator is the so-called one-step estimator. It is motivated by the first order taylor expansion of the previous section. Let $P_{n,0} \in \mathcal{M}$ be an initial estimator of $P_0$. Let $P_n$ denote the empirical measure. Almost always $\Psi(P_{n,0})$ is overly biased and will not be $\sqrt{n}$-consistent and therefore surely not efficient. The first order taylor expansions motivates performing a first-order bias correction (essentially one newton gradient descent step update in the parameter space). We can write (doing the taylor expansion at $P_{n,0}$ in the direction of the score $d(P_0-P_{n,0})/dP_{n,0}$), $$\Psi(P_{n,0}) - \Psi(P_0) = -d\Psi_{P_{n,0}}(d(P_0-P_{n,0})/dP_{n,0}) + R_{n,2}(P_{n,0},P_0) $$ $$= -\int D_{P_{n,0}}(o) dP_0(o) + R_{n,2}(P_{n,0},P_0)$$ where $R_{n,2}(P_{n,0},P_0)$ is a remainder term. Under some conditions, one can show that $R_{n,2}(P_{n,0},P_0) = o_P(n^{-1/2})$ so that it is asymptotically negligible. If we knew the true distribution $P_0$, a natural estimator would be $\Psi_{n,oracle} := \Psi(P_{n,0}) + \int D_{P_{n,0}}(o) dP_0(o) = \Psi(P_{n,0}) + E_{P_0}[D_{P_{n,0}}(O)]$ which would under conditions satisfy $\Psi_{n,oracle} - \Psi(P_0) = o_P(n^{-1/2})$ and be faster than $\sqrt{n}$-consistent. This is just a first-order gradient-descent/newton update for $\Psi$. Unfortunately, this estimator is impossible as we don't know $P_0$. Instead, we will look at an empirical version of this estimator given by $\Psi(P_{n,0}) + E_{P_n}[D_{P_{n,0}}(O)]$, which is tractable. Now, I am going to add $\int D_{P_{n,0}}(o) dP_n(o)$ to both sides to get $$\Psi(P_{n,0}) - \Psi(P_0) + \int D_{P_{n,0}}(o) dP_n(o) = \int D_{P_{n,0}}(o) d(P_n-P_0)(o) + R_{n,2}(P_{n,0},P_0).$$ This can be further written as $$\Psi(P_{n,0}) - \Psi(P_0) + \int D_{P_{n,0}}(o) dP_n(o) = \int D_{P_{0}}(o) d(P_n-P_0)(o) + \int (D_{P_{n,0}}(o)-D_{P_{0}}(o)) d(P_n-P_0)(o) + R_{n,2}(P_{n,0},P_0).$$ When $P_{n,0}$ is consistent for $P_0$, then $(D_{P_{n,0}}(o)-D_{P_{0}}(o))$ converges to zero in probability. In particular, $\int (D_{P_{n,0}}(o)-D_{P_{0}}(o)) d(P_n-P_0)(o) $ is the sample mean of something converging to zero and is therefore under some conditions $o_P(n^{-1/2})$. Putting it all together, we get $$\Psi(P_{n,0}) - \Psi(P_0) + \int D_{P_{n,0}}(o) dP_n(o) = \int D_{P_{0}}(o) d(P_n-P_0)(o) + o_P(n^{-1/2}) = \frac{1}{n}\sum_{i=1}^n D_{P_0}(O_i) + o_P(n^{-1/2})$$ as desired (last equality uses that $D_{P_0}$ is necessarily mean zero). Thus, $$\Psi(P_{n,0}) + \int D_{P_{n,0}}(o) dP_n(o) - \Psi(P_0) $$ $$= \Psi(P_{n,0}) + \frac{1}{n}\sum_{i=1}^n D_{P_{n,0}}(O_i) - \Psi(P_0) $$ is asymptotically equivalent to the sample mean of $D_{P_0}$. Thus, $\Psi(P_{n,0}) + \int D_{P_{n,0}}(o) dP_n(o)$ is an efficient estimator, under some conditions. The one-step estimator is given by $$\Psi_{n, onestep} = \Psi(P_{n,0}) + \frac{1}{n}\sum_{i=1}^n D_{P_{n,0}}(O_i).$$ It requires an initial estimator $\Psi(P_{n,0})$ of $\Psi(P_0)$ and an initial estimator $ D_{P_{n,0}}$ of the efficient influence function $ D_{P_{0}}$. It then bias corrects the initial estimator by performing a single gradient-descent-type update. It is important to note that the gradient descent occurs in the parameter space (the space of values of $\Psi(P_0)$, e.g. $\mathbb{R}$) and not in the model $\mathcal{M}$. This has some undesirable properties. First, $\Psi_{n, onestep}$ is usually not a substitution estimator. That is, there usually does not exist a probability distribution $P_{n}^* \in \mathcal{M}$ that satisfies $\Psi(P_n^*) = \Psi_{n, onestep}$. Because of this, $\Psi_{n, onestep}$ might give erratic and impossible values since it does not respect the constraints of the statistical model. For instance if $P \mapsto \Psi(P)$ takes values in $[0,1]$ then the substitution estimator $\Psi(P_{n,0})$ will also, but $ \Psi_{n, onestep}$ does not necessarily satisfy these constraints. This can lead to poor finite sample performance of the one-step estimator. This brings us to TMLE which allows one to construct an efficient substitution estimator $\Psi(P_n^*)$ of $\Psi(P_0)$. TMLE accomplishes this by performing gradient descent (specifically maximum likelihood estimation) in the statistical model $\mathcal{M}$. TMLE Targeted maximum likelihood estimation (TMLE) constructs an estimator that is both efficient and a substitution estimator. One way of thinking of TMLE is as a very special kind of one-step estimator. Suppose we had an estimator $P_n^*$ of $P_0$. The one-step estimator is given by $$\Psi(P_n^*) + \frac{1}{n}\sum_{i=1}^n D_{P_n^*}(O_i).$$ Now, suppose that $P_n^*$ satisfies $$\frac{1}{n}\sum_{i=1}^n D_{P_n^*}(O_i) = 0.$$ Then, we would have $$\Psi(P_n^*) = \Psi(P_n^*) +0 =\Psi(P_n^*) + \frac{1}{n}\sum_{i=1}^n D_{P_n^*}(O_i),$$ so that the substitution estimator $ \Psi(P_n^*) $ is equal to the one-step estimator and therefore is also efficient. TMLE provides a general template for updating/calibrating/targeting an arbitrary initial estimator $P_{n,0} \in \mathcal{M}$ into an updated estimator $P_n^*$ that satisfies $\frac{1}{n}\sum_{i=1}^n D_{P_n^*}(O_i)=0$. The key idea is the following. Construct a submodel/path $P_{n,\varepsilon}$ with $P_{n, \varepsilon = 0} = P_{n,0}$ that satisfies $\frac{d}{d\varepsilon} \log p_{n,\varepsilon} = D_{P_{n,\varepsilon}}$. Recalling the previous sections, $P_{n,\varepsilon}$ is a path that for each $\varepsilon$ locally moves in the direction of greatest change of $\Psi$. TMLE performs maximum likelihood estimation along this path (where the initial estimator ensures that this parametric model is close enough to $P_0$ to be useful). This can be viewed as functional gradient descent under the constraint that the empirical likelihood always increases. We update an initial estimator by performing gradient descent in the direction of maximum change of $\Psi$ (whether we go forwards to backwards depends on which direction increases the likelihood). We keep performing gradient descent until the empirical likelihood no longer increases. At this point, we have maximized an empirical likelihood and solved a certain score/derivative equation. This equation we solve is exactly $\frac{1}{n}\sum_{i=1}^n D_{P_n^*}(O_i)=0$. Consider the empirical log likelihood risk function: $$R_{n,Loglik}(P) = \frac{1}{n}\sum_{i=1}^n \log p(O_i).$$ In view of the above, we have $$\frac{d}{d\varepsilon} R_{n,Loglik}(P_{n,\varepsilon}) = \frac{1}{n}\sum_{i=1}^n \frac{d}{d\varepsilon} \log p_{n,\varepsilon}(O_i) \approx \frac{1}{n}\sum_{i=1}^n D_{P_{n,\varepsilon}}(O_i). $$ Let $\varepsilon_n^* = \text{argmin}_{\varepsilon}R_{n,Loglik}(P_{n,\varepsilon}) $ then we must have (since it is a minimizer) $$\frac{d}{d\varepsilon} R_{n,Loglik}(P_{n,\varepsilon}) \Big|_{\varepsilon = \varepsilon_n^*} = \frac{1}{n}\sum_{i=1}^n D_{P_{n,\varepsilon_n^*}}(O_i) = 0.$$ Thus, $P_n^* := P_{n,\varepsilon_n^*}$ has the desired property that $\frac{1}{n}\sum_{i=1}^n D_{P_{n,\varepsilon_n^*}}(O_i) = 0$. We call $P_n^*$ the TMLE. Such a path $P_{n,\varepsilon_n}$ can be approximately defined as follows. Fix a step size $\delta > 0$. Initialize $k=0$. Define $p_{n,\varepsilon=0} = p_{n,0}$. For $\varepsilon \in [0,\delta] = [k\delta,(k+1)\delta]$, define $p_{n,\varepsilon} = (1+\varepsilon D_{P_{n,0}})p_{n,0}$. Define $p_{n,k} = p_{n,\varepsilon k}$. Now, arguing recursively for $k=k+1$, for $\varepsilon \in [k\delta,(k+1)\delta]$, define $p_{n,\varepsilon} = (1+\varepsilon D_{P_{n,k}})p_{n,k}$. This path satisfies $$\frac{d}{d\varepsilon} \log p_{n,\varepsilon} \Big |_{\varepsilon = k \delta} = D_{P_{n,k\delta}},$$ so the violation of $\frac{d}{d\varepsilon} \log p_{n,\varepsilon} = D_{P_{n,\varepsilon}}$ is usually negligible as long as the step size $\delta$ is chosen small enough. Note in practice, we don't estimate the entire probability distribution $P_0$. We estimate key nuisance features like conditional means. A version of TMLE (targeted minimum loss estimation) instead performs the above in a lower dimensional feature space (e.g. the space of conditional means). In this case, we perform functional gradient descent in a lower dimensional space (but still infinite dimensional) under the constraint that the risk of the nuisance estimator does not increase (where the risk is given by some custom risk function). This is also where the "clever covariates" come into play (as a computational trick). A simple TMLE for the CDF of a univariate CDF at a point. Suppose we observe $n$ iid observations of a real-valued random variable $X \sim P_0$ with CDF $x \mapsto F_0(x)$. The statistical model $\mathcal{M}$ is given by all probability distributions on $\mathbb{R}$. The parameter of interest is the CDF at $t \in \mathbb{R}$, $$\Psi(P) = P(X \leq t)$$ and the estimand of interest is $\Psi(P_0) = F_0(t) = P_0(X \leq t)$. We will first compute the efficient influence function of $\Psi$. Let $p$ be some density associated with a $P \in \mathcal{M}$. Consider the path $p_{\varepsilon}: \varepsilon \mapsto (1+ \varepsilon h)p$ where $h$ satisfies $\int h(x) p(x)dx = 0$ and has finite variance. Let $P_{\varepsilon}$ be the path in $\mathcal{M}$ corresponding with density path $p_{\varepsilon}$. Note the directional/pathwise derivative is given by $$d\Psi(h) = \frac{d}{d\varepsilon} \Psi(P_{\varepsilon}) \Big |_{\varepsilon = 0} = \frac{d}{d\varepsilon} E_{P_{\varepsilon}}[1(X \leq t)] \Big |_{\varepsilon = 0}$$ $$ = \frac{d}{d\varepsilon} \int 1(x \leq t) (1+ \varepsilon h(x))p(x)dx \Big |_{\varepsilon = 0}$$ $$ = \int 1(x \leq t) h(x)p(x)dx = E_P[1(X\leq t) h(X)] .$$ Note that $ E_P[1(X\leq t) h(X)]$ corresponds with the $L^2(P)$-inner product of $1(X \leq t)$ and $h(X)$, where $h$ is actually an arbitrary element in the tangent space $T_P\mathcal{M}$. This might incorrectly suggest that $1(X\leq t)$ is the efficient influence function. This is incorrect because the efficient influence function must be contained in $T_P\mathcal{M}$ itself. $X \mapsto 1(X\leq t)$ has finite variance but it is not mean-zero, so it is not in the tangent space. In other words, $x \mapsto p(x)(1+\varepsilon 1(x\leq t))$ is not a valid probability density for any $\varepsilon$. Fortunately, there is an easy fix. Note the identity $$ E_P[1(X\leq t) h(X)] = E_P[[1(X\leq t) - P(X\leq t) ]h(X)],$$ where $1(X\leq t) - P(X\leq t) $ being mean-zero is contained in the tangent space. Thus, we have shown $$d\Psi(h) = \langle D_P, h \rangle_{L^2_0(P)} $$ for $D_P(X) := 1(X\leq t) - P(X\leq t)$ and all $h \in T_P\mathcal{M}$. It follows (from uniqueness) that $D_P$ is the efficient influence function of $\Psi$ at $P$. We can now construct an efficient one-step estimator. Let $p_n$ be an arbitrary initial estimator of the density $p_0$ corresponding with $P_0$. We have (slightly abusing notation) $$\Psi(p_n) = \int 1(x \leq t)p_n(x)dx,$$ $$D_{p_n}(x) = 1(x \leq t) - \int 1(x \leq t)p_n(x)dx.$$ The one-step estimator is given by $$\Psi_{n,onestep} = \Psi(p_n) + \frac{1}{n}\sum_{i=1}^n D_{p_n}(X_i) $$ $$= \int 1(x \leq t)p_n(x)dx + \frac{1}{n}\sum_{i=1}^n [1(X_i \leq t) - \int 1(x \leq t)p_n(x)dx] $$ $$ = + \frac{1}{n}\sum_{i=1}^n 1(X_i \leq t) + 0 = \frac{1}{n}\sum_{i=1}^n 1(X_i \leq t),$$ which is nothing else than the well-known empirical CDF estimator. Thus, the one-step estimator and the empirical CDF estimator are the same regardless of the initial estimator of the density (In this case, we remarkably don't even need $p_n$ to be consistent). We can also construct a TMLE for $\Psi(P_0)$. Define the empirical log-likelihood risk function: $$R_n(p) = -\frac{1}{n} \sum_{i=1}^n \log p(X_i).$$ Given an initial estimator $p_n$, we define the path $$p_{n,\varepsilon} = (1 + \varepsilon D_{p_n})p_n.$$ The TMLE $p_n^*$ is given by performing maximum likelihood along this path. In this case, $\varepsilon_n^* := \text{argmin}_{\varepsilon} R_n(p_{n,\varepsilon})$ has an analytical solution. The solution solves the following equation $$\frac{1}{n} \sum_{i=1}^n \frac{1}{(1 + \varepsilon_n^* D_{p_n}(X_i))p_n(X_i)} D_{p_n}(X_i)p_n(X_i) = 0$$ which is equivalent to $$\frac{1}{n} \sum_{i=1}^n \frac{ D_{p_n}(X_i)}{(1 + \varepsilon_n^* D_{p_n}(X_i))} = 0.$$ Note that $D_{p_n}$ is special because it is constant on $(-\infty,t]$ and $(t,\infty]$. So we can write $$ = \frac{1}{n} \sum_{i=1}^n 1(X_i \leq t) \frac{ D_{p_n}(X_i)}{(1 + \varepsilon_n^* D_{p_n}(X_i))} + \frac{1}{n} \sum_{i=1}^n 1(X_i >t) \frac{ D_{p_n}(X_i)}{(1 + \varepsilon_n^* D_{p_n}(X_i))} $$ $$ = \frac{ D_{p_n}(t_-)}{(1 + \varepsilon_n^* D_{p_n}(t_-))} \frac{1}{n} \sum_{i=1}^n 1(X_i \leq t) + \frac{ D_{p_n}(t_+)}{(1 + \varepsilon_n^* D_{p_n}(t_+))} \frac{1}{n} \sum_{i=1}^n 1(X_i >t) = 0$$ where $t_- < t < t_+$. This is equivalent to $$ D_{p_n}(t_-)(1 + \varepsilon_n^* D_{p_n}(t_+)) \frac{1}{n} \sum_{i=1}^n 1(X_i \leq t) + D_{p_n}(t_+)(1 + \varepsilon_n^* D_{p_n}(t_-)) \frac{1}{n} \sum_{i=1}^n 1(X_i >t) = 0$$ which is equivalent to $$ \varepsilon_n^*[D_{p_n}(t_-)D_{p_n}(t_+)]\frac{1}{n} \sum_{i=1}^n 1(X_i \leq t) + \varepsilon_n^*[D_{p_n}(t_-)D_{p_n}(t_+)]\frac{1}{n} \sum_{i=1}^n 1(X_i >t) = - D_{p_n}(t_-) \frac{1}{n} \sum_{i=1}^n 1(X_i \leq t) - D_{p_n}(t_+) \frac{1}{n} \sum_{i=1}^n 1(X_i >t)$$ which is equivalent to $$\varepsilon_n^* = -1 \cdot \frac{ D_{p_n}(t_-) \frac{1}{n} \sum_{i=1}^n 1(X_i \leq t) + D_{p_n}(t_+) \frac{1}{n} \sum_{i=1}^n 1(X_i >t)}{ D_{p_n}(t_-)D_{p_n}(t_+)}.$$ Now note that $D_{p_n}(t_-) = 1 - \Psi(p_n)$ and $D_{p_n}(t_+) = - \Psi(p_n)$ to find $$\varepsilon_n^* = -1 \cdot \frac{ ( 1 - \Psi(p_n)) \frac{1}{n} \sum_{i=1}^n 1(X_i \leq t) - \Psi(p_n)\frac{1}{n} \sum_{i=1}^n 1(X_i >t)}{ D_{p_n}(t_-)D_{p_n}(t_+)}$$ which is equivalent to $$\varepsilon_n^* = \frac{ \frac{1}{n} \sum_{i=1}^n 1(X_i \leq t) - \Psi(p_n)}{(1 - \Psi(p_n))(\Psi(p_n))},$$ which is a very elegant looking solution. One can show that the TMLE $p_n^*:= p_{n, \varepsilon_n^*}$ satisfies $\frac{1}{n} \sum_{i=1}^n D_{p_n^*}(X_i) = 0$ as desired so that the substitution TMLE $\Psi(p_n^*) = \int 1(x\leq t)p_n^*(x)dx$ is efficient, and in fact $\Psi(p_n^*) = \frac{1}{n} \sum_{i=1}^n 1(X_i \leq t)$ must necessarily hold since $\frac{1}{n} \sum_{i=1}^n D_{p_n^*}(X_i) = 0$. Thus, the TMLE is, like the one-step estimator, equal to the empirical CDF estimator. Here is R code that implements the TMLE and plots how the initial CDF and density estimates are changed by targeting. n <- 200 X <- rnorm(n , mean = 0, sd = 1) hist(X) #fit_density <- density(X) #ps <- fit_density$y xs <- seq(min(X), max(X), length = 1000) xs <- sort(c(X,xs)) ps <- rep(1/(max(xs) - min(xs)), length(xs)) get_density_preds <- function(grid, p_at_grid, x) { p_at_grid[which.min(abs(x-grid))] } get_CDF <- function(x, p, t) { #x: grid for values of X #p: density values at x #t: value to get CDF at sum(diff(x)*p[-1]*(x<=t)[-1]) # Sloppy Reimann sum integration } get_CDF <- Vectorize(get_CDF, vectorize.args = "t") num_steps <- 5 max_eps <- 1 t <- 1 p_i <- ps / get_CDF(xs, ps, max(xs)) # Path in direction of EIF path <- function(p, EIF, eps) { (1 + eps*EIF) * p } # Plot initial plot(xs, p_i, main = "Initial density estimate") plot(xs, get_CDF(xs, ps, xs) , main = "Initial CDF estimate") for(i in 1:3) { Psi <- get_CDF(xs, p_i, t) EIF <- (xs<=t) - Psi #EIF evaluated at grid EIF_empirical <- (X<=t) - Psi #EIF evaluated at observations # Check for convergence if(i>1 & abs(mean(EIF_empirical)) <= sd(EIF_empirical)/sqrt(n)/log(n)) { print(mean(EIF_empirical)) print("converged") break } # loglikelihood risk of density at epsilon along path risk_function <- function(eps) { p_eps <- path(p_i, EIF, eps) p_eps <- p_eps / get_CDF(xs, p_i, max(xs)) p_obs <- sapply(X, get_density_preds, grid = xs, p_at_grid = p_eps) mean( -log(p_obs)) } # Find risk minimizer along path best_eps <- optim(0, risk_function, method = "Brent", lower = -max_eps, upper = max_eps)$par analytical_eps <- mean(EIF_empirical)/(1-Psi)/Psi print("chosen numerical epsilon and analytical epsilon") print(c(best_eps, analytical_eps)) # Update initial estimator p_i <- path(p_i, EIF, analytical_eps) # Plot updates plot(xs, p_i, main = "Updated density estimates") plot(xs, get_CDF(xs, p_i, xs), main = "Updated CDF estimates") } Answer to comments: TMLE aims to construct an asymptotically unbiased estimate of the ATE by first constructing a path through an initial density estimator that is contained in the statistical model (which you should visually think of as a geometric surface but each point is actually a density function/probability distribution). This path has the property that it points in the direction of greatest change of the ATE (i.e. the direction of steepest ascent/descent). So If I am limited to taking only one small step away from the initial density estimator, a step along this path will give me a new density estimator with the most different ATE estimate. Given this path of steepest change of my target parameter, it makes sense to find the point along this path that maximizes the empirical log likelihood, which gives me the best density fit. Because this path is in the direction of steepest change of my parameter, this additional fitting done by the MLE is targeted towards my parameter of interest. It makes sure that all additional fitting that I do is maximally beneficial for giving me a better estimate for my parameter of interest.
Theory behind Targeted Maximum Likelihood Estimation (TMLE) Here is a very tentative (incomplete) answer. I will add more (e.g. the TMLE for ATE) later. It is fairly technical. One important thing to keep in mind is the separation between the data structure, s
31,246
When should I use Validation rather than Cross Validation
Cross-validation as an alternative in case of a lack of training data is quite an understatement. Unless your sample size is very large, validation performance can vary widely among different random splits. Cross-validation suffers less from this, since it considers the results from multitude folds. Even better would be to average over multiple runs of cross-validation, each with a different random split into $k$ folds. What you consider ordinary validation is really just cross-validation with a single fold. Examples of where you might intentionally want to use $k=1$ over multiple folds include: Your cannot afford $k>1$ computationally; You have, say, millions of records and can confidently split your data randomly; You are performing external validation and want to demonstrate that your model still performs well on data from a source never before seen by the model. In case of the latter, your model would likely generalize better if you include data from multiple sources for training (e.g. data from different institutes, studies, or data bases). However, if you use all sources for training, you still don't have a real estimate of the performance on a new source.
When should I use Validation rather than Cross Validation
Cross-validation as an alternative in case of a lack of training data is quite an understatement. Unless your sample size is very large, validation performance can vary widely among different random s
When should I use Validation rather than Cross Validation Cross-validation as an alternative in case of a lack of training data is quite an understatement. Unless your sample size is very large, validation performance can vary widely among different random splits. Cross-validation suffers less from this, since it considers the results from multitude folds. Even better would be to average over multiple runs of cross-validation, each with a different random split into $k$ folds. What you consider ordinary validation is really just cross-validation with a single fold. Examples of where you might intentionally want to use $k=1$ over multiple folds include: Your cannot afford $k>1$ computationally; You have, say, millions of records and can confidently split your data randomly; You are performing external validation and want to demonstrate that your model still performs well on data from a source never before seen by the model. In case of the latter, your model would likely generalize better if you include data from multiple sources for training (e.g. data from different institutes, studies, or data bases). However, if you use all sources for training, you still don't have a real estimate of the performance on a new source.
When should I use Validation rather than Cross Validation Cross-validation as an alternative in case of a lack of training data is quite an understatement. Unless your sample size is very large, validation performance can vary widely among different random s
31,247
When should I use Validation rather than Cross Validation
Another drawback of CV (in addition to those in Frans Rodenburg's excellent answer) is when there is a dependency between samples, such as in a time series. In that case you can split into train/valid such that no training data has a dependency on any validation data. (E.g. in the case of time series, your validation data has the later timestamps.)
When should I use Validation rather than Cross Validation
Another drawback of CV (in addition to those in Frans Rodenburg's excellent answer) is when there is a dependency between samples, such as in a time series. In that case you can split into train/valid
When should I use Validation rather than Cross Validation Another drawback of CV (in addition to those in Frans Rodenburg's excellent answer) is when there is a dependency between samples, such as in a time series. In that case you can split into train/valid such that no training data has a dependency on any validation data. (E.g. in the case of time series, your validation data has the later timestamps.)
When should I use Validation rather than Cross Validation Another drawback of CV (in addition to those in Frans Rodenburg's excellent answer) is when there is a dependency between samples, such as in a time series. In that case you can split into train/valid
31,248
Is Proximal Policy Optimization (PPO) an on-policy reinforcement learning algorithm?
A3C is an actor-critic method, which tend to be on-policy (A3C itself is too), because the actor gradient is still computed with an expectation over trajectories sampled from that same policy. TRPO and PPO are both on-policy. Basically they optimize a first-order approximation of the expected return while carefully ensuring that the approximation does not deviate too far from the underlying objective. Of course, this requires sampling new rollouts from the current policy frequently, so that the first-order approximation remains valid in a local region around the current parameter set $\theta$. To be very pedantic, I suppose you could say this is off-policy in the sense that we are approximating the expected return of some policy $\pi_{\theta}$ with rollouts sampled from a very slightly older $\pi_{\theta_\text{old}}$, but that's not really off-policy in the conventional sense.
Is Proximal Policy Optimization (PPO) an on-policy reinforcement learning algorithm?
A3C is an actor-critic method, which tend to be on-policy (A3C itself is too), because the actor gradient is still computed with an expectation over trajectories sampled from that same policy. TRPO an
Is Proximal Policy Optimization (PPO) an on-policy reinforcement learning algorithm? A3C is an actor-critic method, which tend to be on-policy (A3C itself is too), because the actor gradient is still computed with an expectation over trajectories sampled from that same policy. TRPO and PPO are both on-policy. Basically they optimize a first-order approximation of the expected return while carefully ensuring that the approximation does not deviate too far from the underlying objective. Of course, this requires sampling new rollouts from the current policy frequently, so that the first-order approximation remains valid in a local region around the current parameter set $\theta$. To be very pedantic, I suppose you could say this is off-policy in the sense that we are approximating the expected return of some policy $\pi_{\theta}$ with rollouts sampled from a very slightly older $\pi_{\theta_\text{old}}$, but that's not really off-policy in the conventional sense.
Is Proximal Policy Optimization (PPO) an on-policy reinforcement learning algorithm? A3C is an actor-critic method, which tend to be on-policy (A3C itself is too), because the actor gradient is still computed with an expectation over trajectories sampled from that same policy. TRPO an
31,249
Should exploratory data analysis include validation set?
Your question is related to this one about EDA on train vs. test and this one on the purpose of validation and test sets. Why have a validation set at all? A validation set allows you to explore and evaluate many models/hyperparameter settings. As you make decisions about which model to use, the validation set allows you to validate whether that decision was actually good, without overfitting to your test set. Similarly with EDA, if you make any decisions about your model (which features you are going to select, etc.), the validation set would help you validate whether your EDA decisions are good. Therefore, I would perform EDA only on the training set and use the validation set to evaluate the quality of any decisions you made on your training set. Edit Cross-validation (CV) complicates this a little. The core principle is that the validation set should help you validate any decisions you make. Making decisions based on the validation set will inflate (or deflate, as appropriate) any model scores on the validation set. These inflated scores will be more representative of the training set scores and less representative of the test set scores, thus defeating the purpose of a validation set. In k-fold CV, you could have k separate EDA phases, one performed on the train split of each fold. You would have to make decisions based solely on the results of each EDA without transferring decisions between each one. It would be difficult to remain unbiased in the later folds and impractical to analyze the data k times. Perhaps a more practical option would be to first make train/validation/test splits. Then perform EDA on the train set and tune your model using cross-validation on the train set. The model's hyperparameters would still be tuned with the benefits of CV. The validation set would then allow you to evaluate simultaneously both the decisions made in your EDA and the tuning process. The validation scores would be more representative of the test scores and you would be less likely to overfit. You would need a dataset large enough to handle all of this splitting. This is a very strict paradigm and I would be surprised to learn that researchers/professionals actually follow it. Somehow, you need to evaluate all your decisions empirically while balancing the fine-tuning of your model without overfitting to a particular subset of the data.
Should exploratory data analysis include validation set?
Your question is related to this one about EDA on train vs. test and this one on the purpose of validation and test sets. Why have a validation set at all? A validation set allows you to explore and e
Should exploratory data analysis include validation set? Your question is related to this one about EDA on train vs. test and this one on the purpose of validation and test sets. Why have a validation set at all? A validation set allows you to explore and evaluate many models/hyperparameter settings. As you make decisions about which model to use, the validation set allows you to validate whether that decision was actually good, without overfitting to your test set. Similarly with EDA, if you make any decisions about your model (which features you are going to select, etc.), the validation set would help you validate whether your EDA decisions are good. Therefore, I would perform EDA only on the training set and use the validation set to evaluate the quality of any decisions you made on your training set. Edit Cross-validation (CV) complicates this a little. The core principle is that the validation set should help you validate any decisions you make. Making decisions based on the validation set will inflate (or deflate, as appropriate) any model scores on the validation set. These inflated scores will be more representative of the training set scores and less representative of the test set scores, thus defeating the purpose of a validation set. In k-fold CV, you could have k separate EDA phases, one performed on the train split of each fold. You would have to make decisions based solely on the results of each EDA without transferring decisions between each one. It would be difficult to remain unbiased in the later folds and impractical to analyze the data k times. Perhaps a more practical option would be to first make train/validation/test splits. Then perform EDA on the train set and tune your model using cross-validation on the train set. The model's hyperparameters would still be tuned with the benefits of CV. The validation set would then allow you to evaluate simultaneously both the decisions made in your EDA and the tuning process. The validation scores would be more representative of the test scores and you would be less likely to overfit. You would need a dataset large enough to handle all of this splitting. This is a very strict paradigm and I would be surprised to learn that researchers/professionals actually follow it. Somehow, you need to evaluate all your decisions empirically while balancing the fine-tuning of your model without overfitting to a particular subset of the data.
Should exploratory data analysis include validation set? Your question is related to this one about EDA on train vs. test and this one on the purpose of validation and test sets. Why have a validation set at all? A validation set allows you to explore and e
31,250
Should exploratory data analysis include validation set?
You are talking about two different sets of steps in your post. Data visualization, Exploratory Data Analysis Model training, evaluation and testing In exploratory data analysis one analyzes the data sets to summarize their main characteristics, often with visual methods. So you should consider complete data set there. In case you split the data set into train, validate and test before EDA, you might be missing some important information in EDA. For example, you could miss the outliers because they are a part of test data. After you are done with EDA, you need to keep the data set intact for data pre-processing and transformation as well. After that you can split the data set. If you split data set before pre-processing and transformation, you would be training your model on one type of data set and testing on something else. For example, let us say you are trying to predict if a person should be given a loan or not. There is an attribute for 'salary' and 'age' in the data set. Let us say as a part of pre-processing you decide to apply normalization. If you split data set before pre-processing, you would be training your model on normalized 'salary' and 'age' data whereas evaluating, testing the model on the original 'salary' and 'age' data. Some people might want to do only EDA for insights and not go for model training and testing. So, you should always split the data set just before you start model training.
Should exploratory data analysis include validation set?
You are talking about two different sets of steps in your post. Data visualization, Exploratory Data Analysis Model training, evaluation and testing In exploratory data analysis one analyzes the d
Should exploratory data analysis include validation set? You are talking about two different sets of steps in your post. Data visualization, Exploratory Data Analysis Model training, evaluation and testing In exploratory data analysis one analyzes the data sets to summarize their main characteristics, often with visual methods. So you should consider complete data set there. In case you split the data set into train, validate and test before EDA, you might be missing some important information in EDA. For example, you could miss the outliers because they are a part of test data. After you are done with EDA, you need to keep the data set intact for data pre-processing and transformation as well. After that you can split the data set. If you split data set before pre-processing and transformation, you would be training your model on one type of data set and testing on something else. For example, let us say you are trying to predict if a person should be given a loan or not. There is an attribute for 'salary' and 'age' in the data set. Let us say as a part of pre-processing you decide to apply normalization. If you split data set before pre-processing, you would be training your model on normalized 'salary' and 'age' data whereas evaluating, testing the model on the original 'salary' and 'age' data. Some people might want to do only EDA for insights and not go for model training and testing. So, you should always split the data set just before you start model training.
Should exploratory data analysis include validation set? You are talking about two different sets of steps in your post. Data visualization, Exploratory Data Analysis Model training, evaluation and testing In exploratory data analysis one analyzes the d
31,251
Should exploratory data analysis include validation set?
My thinking is that it depends on what you are trying to accomplish. If your goal is to: Build a model that generalizes to unseen data: Then you want to keep the training, validation, and testing set separate for all stages of the pipeline. "Separate at the earliest possible opportunity" Understand the population: Then EDA on the entire dataset is permissible.
Should exploratory data analysis include validation set?
My thinking is that it depends on what you are trying to accomplish. If your goal is to: Build a model that generalizes to unseen data: Then you want to keep the training, validation, and testing set
Should exploratory data analysis include validation set? My thinking is that it depends on what you are trying to accomplish. If your goal is to: Build a model that generalizes to unseen data: Then you want to keep the training, validation, and testing set separate for all stages of the pipeline. "Separate at the earliest possible opportunity" Understand the population: Then EDA on the entire dataset is permissible.
Should exploratory data analysis include validation set? My thinking is that it depends on what you are trying to accomplish. If your goal is to: Build a model that generalizes to unseen data: Then you want to keep the training, validation, and testing set
31,252
When and how to avoid inappropriate use of Fisher's exact test
It's hard to read this quotation & not surmise that the author considers it a mere blunder to use Fisher's Exact Test when the marginal totals of a contingency table are not fixed by design. "Fisher's original use" of the test must refer to the famous lady tasting tea who "has been told in advance of what the test will consist, namely that she will be asked to taste eight cups, that these shall be four of each kind, [...]" (Fisher (1935), The Design of Experiments);† & then "an extremely narrow empirical context" parses as "a sampling scheme applicable to few studies carried out in practice". But it's not a blunder: conditioning on the sufficient statistic for the distribution of the data under the null hypothesis is a standard technique to eliminate nuisance parameters & come up with tests having the correct significance level (unconditionally too)—it's the whole basis of permutation tests, for example. The marginal totals contain very little information which you can use to estimate the parameter of interest, the odds ratio; & rather a lot about the precision with which you can estimate it: the argument is that the sample space obtained by conditioning on both is much more relevant for inference than that obtained by conditioning on one only, or on the total count only. It is a horribly coarse sample space, however, resulting in a lamentable loss of power. How should relevance of the sample space be balanced against information loss? How much coarsening of the sample space is acceptable before an asymptotically valid or an unconditional test is preferred? These are vexed questions, & the analysis of two-by-two contingency tables has been controversial for half a century or more. Given that this comes from a Bayesian text, I think the author's missed an opportunity to poke fun at the dilemmas a commitment to the use of frequentist methods can lead to—like Jaynes does in Probability Theory: The Logic of Science † In a paper published the same year as his book, he used an example in which, though the sampling scheme is not explicitly given, at most one margin could have been fixed in advance, & most likely just the total count was fixed. Like-sex twins of convicted criminals are categorized as monozygotic vs dizygotic & as convicted of crimes themselves vs not convicted in a two-by-two table (Fisher (1935), "The Logic of Inductive inference", JRSS, 98, 1, pp 39–82). [Edit: The data come from Lange (1929), Verbrechen als Schicksal: Studien am kriminellen Zwillingen. Wetzell (2000), Inventing the Criminal: A History of German Criminology, 1880–1945, p 162] describes Lange's data collection procedure; it's indeed the total count that was fixed by the study design.]
When and how to avoid inappropriate use of Fisher's exact test
It's hard to read this quotation & not surmise that the author considers it a mere blunder to use Fisher's Exact Test when the marginal totals of a contingency table are not fixed by design. "Fisher's
When and how to avoid inappropriate use of Fisher's exact test It's hard to read this quotation & not surmise that the author considers it a mere blunder to use Fisher's Exact Test when the marginal totals of a contingency table are not fixed by design. "Fisher's original use" of the test must refer to the famous lady tasting tea who "has been told in advance of what the test will consist, namely that she will be asked to taste eight cups, that these shall be four of each kind, [...]" (Fisher (1935), The Design of Experiments);† & then "an extremely narrow empirical context" parses as "a sampling scheme applicable to few studies carried out in practice". But it's not a blunder: conditioning on the sufficient statistic for the distribution of the data under the null hypothesis is a standard technique to eliminate nuisance parameters & come up with tests having the correct significance level (unconditionally too)—it's the whole basis of permutation tests, for example. The marginal totals contain very little information which you can use to estimate the parameter of interest, the odds ratio; & rather a lot about the precision with which you can estimate it: the argument is that the sample space obtained by conditioning on both is much more relevant for inference than that obtained by conditioning on one only, or on the total count only. It is a horribly coarse sample space, however, resulting in a lamentable loss of power. How should relevance of the sample space be balanced against information loss? How much coarsening of the sample space is acceptable before an asymptotically valid or an unconditional test is preferred? These are vexed questions, & the analysis of two-by-two contingency tables has been controversial for half a century or more. Given that this comes from a Bayesian text, I think the author's missed an opportunity to poke fun at the dilemmas a commitment to the use of frequentist methods can lead to—like Jaynes does in Probability Theory: The Logic of Science † In a paper published the same year as his book, he used an example in which, though the sampling scheme is not explicitly given, at most one margin could have been fixed in advance, & most likely just the total count was fixed. Like-sex twins of convicted criminals are categorized as monozygotic vs dizygotic & as convicted of crimes themselves vs not convicted in a two-by-two table (Fisher (1935), "The Logic of Inductive inference", JRSS, 98, 1, pp 39–82). [Edit: The data come from Lange (1929), Verbrechen als Schicksal: Studien am kriminellen Zwillingen. Wetzell (2000), Inventing the Criminal: A History of German Criminology, 1880–1945, p 162] describes Lange's data collection procedure; it's indeed the total count that was fixed by the study design.]
When and how to avoid inappropriate use of Fisher's exact test It's hard to read this quotation & not surmise that the author considers it a mere blunder to use Fisher's Exact Test when the marginal totals of a contingency table are not fixed by design. "Fisher's
31,253
Is it better to avoid ReLu as activation function if input data has plenty of negative values?
No, because the activation function of choice isn't applied directly on the input data. The earliest it is applied is after the first layer: $a(Wx+b)$, which is when the weights are properly initialized, leads to both positive and negative inputs into the activation. Edit: I specified proper initialization because it is important. Typically, weights are initialized to small random values distributed symmetrically about $0$, and biases are initialized to exactly $0$. This means that initially, inputs are split roughly evenly between positive and negative, which is a good starting point since we would like to be within the general region in which the nonlinearities of relu can be exploited.
Is it better to avoid ReLu as activation function if input data has plenty of negative values?
No, because the activation function of choice isn't applied directly on the input data. The earliest it is applied is after the first layer: $a(Wx+b)$, which is when the weights are properly initializ
Is it better to avoid ReLu as activation function if input data has plenty of negative values? No, because the activation function of choice isn't applied directly on the input data. The earliest it is applied is after the first layer: $a(Wx+b)$, which is when the weights are properly initialized, leads to both positive and negative inputs into the activation. Edit: I specified proper initialization because it is important. Typically, weights are initialized to small random values distributed symmetrically about $0$, and biases are initialized to exactly $0$. This means that initially, inputs are split roughly evenly between positive and negative, which is a good starting point since we would like to be within the general region in which the nonlinearities of relu can be exploited.
Is it better to avoid ReLu as activation function if input data has plenty of negative values? No, because the activation function of choice isn't applied directly on the input data. The earliest it is applied is after the first layer: $a(Wx+b)$, which is when the weights are properly initializ
31,254
Is it better to avoid ReLu as activation function if input data has plenty of negative values?
No, the data that feed into the activation function is already transformed, e.g., you are feeding X*W but not X.
Is it better to avoid ReLu as activation function if input data has plenty of negative values?
No, the data that feed into the activation function is already transformed, e.g., you are feeding X*W but not X.
Is it better to avoid ReLu as activation function if input data has plenty of negative values? No, the data that feed into the activation function is already transformed, e.g., you are feeding X*W but not X.
Is it better to avoid ReLu as activation function if input data has plenty of negative values? No, the data that feed into the activation function is already transformed, e.g., you are feeding X*W but not X.
31,255
Difference between "Sampling" and "Subsampling"?
A sample is a portion of the population. A subsample is a portion of the sample.
Difference between "Sampling" and "Subsampling"?
A sample is a portion of the population. A subsample is a portion of the sample.
Difference between "Sampling" and "Subsampling"? A sample is a portion of the population. A subsample is a portion of the sample.
Difference between "Sampling" and "Subsampling"? A sample is a portion of the population. A subsample is a portion of the sample.
31,256
Difference between "Sampling" and "Subsampling"?
@TinderForMidgets gave the exact definition for sample and subsample. In clustering practices, some kind of sampling can be implemented to avoid large computations. Usually some of these algorithms require starting points, and again, to reduce computation time, you take a subsample in your sample and assign them as your starting points. So these two perform two different functions in your clustering algorithms. To give completely exhaustive definition: Data Set is the entire collection of data to be analyzed. For inferential purposes, this may be treated as having been sampled from a population. All of the data set items will be classified by the process. Supersample is a subset of the data set chosen by simple random sampling. In our examples, it is the entire data set, but for larger data sets it will be considerably smaller. All computations prior to the final classification are performed on the supersample. For problems in moderate dimension (up to 50), the supersample will never need to be larger than 100,000–1,000,000 points, since the estimation error in a sample of this size is already too small to matter. Sample is one of several ($R_s$) of size $N_s$ chosen by simple random sampling from the supersample. All intensive search operations are conducted in the sample so that the supersample is only used for one iteration from the best solution found in the sample. The sample size $N_s$ should be chosen to be large enough to reflect the essential structure of the data, while being small enough to keep the computations feasible. Subsample is one of several ($R_r$) of size $N_r$ chosen by simple random sampling from the sample that is used to begin iterations on the sample. This number should be very small because great diversity in starting points generates diversity in solutions, and increases the chance of finding the best local maximum of the likelihood. Source
Difference between "Sampling" and "Subsampling"?
@TinderForMidgets gave the exact definition for sample and subsample. In clustering practices, some kind of sampling can be implemented to avoid large computations. Usually some of these algorithms re
Difference between "Sampling" and "Subsampling"? @TinderForMidgets gave the exact definition for sample and subsample. In clustering practices, some kind of sampling can be implemented to avoid large computations. Usually some of these algorithms require starting points, and again, to reduce computation time, you take a subsample in your sample and assign them as your starting points. So these two perform two different functions in your clustering algorithms. To give completely exhaustive definition: Data Set is the entire collection of data to be analyzed. For inferential purposes, this may be treated as having been sampled from a population. All of the data set items will be classified by the process. Supersample is a subset of the data set chosen by simple random sampling. In our examples, it is the entire data set, but for larger data sets it will be considerably smaller. All computations prior to the final classification are performed on the supersample. For problems in moderate dimension (up to 50), the supersample will never need to be larger than 100,000–1,000,000 points, since the estimation error in a sample of this size is already too small to matter. Sample is one of several ($R_s$) of size $N_s$ chosen by simple random sampling from the supersample. All intensive search operations are conducted in the sample so that the supersample is only used for one iteration from the best solution found in the sample. The sample size $N_s$ should be chosen to be large enough to reflect the essential structure of the data, while being small enough to keep the computations feasible. Subsample is one of several ($R_r$) of size $N_r$ chosen by simple random sampling from the sample that is used to begin iterations on the sample. This number should be very small because great diversity in starting points generates diversity in solutions, and increases the chance of finding the best local maximum of the likelihood. Source
Difference between "Sampling" and "Subsampling"? @TinderForMidgets gave the exact definition for sample and subsample. In clustering practices, some kind of sampling can be implemented to avoid large computations. Usually some of these algorithms re
31,257
Generalized Chi-Squared Distribution PDF
Your question is really a special case of https://math.stackexchange.com/questions/442472/sum-of-squares-of-dependent-gaussian-random-variables/442916#442916 (with $A=I$). But nevertheless: $X$ is multivariate normal ($n$ components) with expectation $m$ and positive definite covariance matrix $C$. We are interested in the distribution of $\| X\|^2 = X^T X$. Define $W = C^{-1/2}(X-m)$. Then $W$ is multivariate normal with expectation zero and covariance matrix $I$, the identity matrix. $X= C^{1/2}W +m$, so after some algebra $$ X^T X= (W+C^{-1/2}m)^T C (W+C^{-1/2}m) $$ Use the spectral theorem to write $C=P^T\Lambda P$ where $P$ is an orthogonal matrix (such that $P^T P = P P^T = I$) and $\Lambda$ is a diagonal matrix with positive diagonal elements $\lambda_1, \dotsc, \lambda_n$. Write $U=PW$, $U$ is also multivariate normal with mean zero and identity covariance matrix. Now, with some algebra we find that $$ X^TX= (U+b)^T \Lambda (U+b) = \sum_{j=1}^n \lambda_j (U_j+b_j)^2 $$ where $b_j= \Lambda^{-1/2} P m$, so that $X^TX$ is a linear combination of independent noncentral chisquare variables, each with one degree of freedom and noncentrality $b_j^2$. Except for special cases, it would be hard to find a closed exact expression for its density function (for instance, if all $\lambda_j$ are equal, it will be a constant times a noncentral chisquare). For some ideas which could be used, in particular saddlepoint approximation, see the posts Generic sum of Gamma random variables, How does saddlepoint approximation work? and for the needed moment generating functions, What is the moment generating function of the generalized (multivariate) chi-square distribution? There is a book-length treatment by Mathai and Provost https://books.google.no/books/about/Quadratic_Forms_in_Random_Variables.html?id=tFOqQgAACAAJ&redir_esc=y about quadratic forma in random variables. It gives a lot of different approximations, typically series expansions. There are also some exact (very complicated) results, but only for some special cases. I would go for the saddlepoint approximation! (I will try to come back and post some examples here, but not tonight ...) There is also an R package https://CRAN.R-project.org/package=CompQuadForm with some approximations.
Generalized Chi-Squared Distribution PDF
Your question is really a special case of https://math.stackexchange.com/questions/442472/sum-of-squares-of-dependent-gaussian-random-variables/442916#442916 (with $A=I$). But nevertheless: $X$ is
Generalized Chi-Squared Distribution PDF Your question is really a special case of https://math.stackexchange.com/questions/442472/sum-of-squares-of-dependent-gaussian-random-variables/442916#442916 (with $A=I$). But nevertheless: $X$ is multivariate normal ($n$ components) with expectation $m$ and positive definite covariance matrix $C$. We are interested in the distribution of $\| X\|^2 = X^T X$. Define $W = C^{-1/2}(X-m)$. Then $W$ is multivariate normal with expectation zero and covariance matrix $I$, the identity matrix. $X= C^{1/2}W +m$, so after some algebra $$ X^T X= (W+C^{-1/2}m)^T C (W+C^{-1/2}m) $$ Use the spectral theorem to write $C=P^T\Lambda P$ where $P$ is an orthogonal matrix (such that $P^T P = P P^T = I$) and $\Lambda$ is a diagonal matrix with positive diagonal elements $\lambda_1, \dotsc, \lambda_n$. Write $U=PW$, $U$ is also multivariate normal with mean zero and identity covariance matrix. Now, with some algebra we find that $$ X^TX= (U+b)^T \Lambda (U+b) = \sum_{j=1}^n \lambda_j (U_j+b_j)^2 $$ where $b_j= \Lambda^{-1/2} P m$, so that $X^TX$ is a linear combination of independent noncentral chisquare variables, each with one degree of freedom and noncentrality $b_j^2$. Except for special cases, it would be hard to find a closed exact expression for its density function (for instance, if all $\lambda_j$ are equal, it will be a constant times a noncentral chisquare). For some ideas which could be used, in particular saddlepoint approximation, see the posts Generic sum of Gamma random variables, How does saddlepoint approximation work? and for the needed moment generating functions, What is the moment generating function of the generalized (multivariate) chi-square distribution? There is a book-length treatment by Mathai and Provost https://books.google.no/books/about/Quadratic_Forms_in_Random_Variables.html?id=tFOqQgAACAAJ&redir_esc=y about quadratic forma in random variables. It gives a lot of different approximations, typically series expansions. There are also some exact (very complicated) results, but only for some special cases. I would go for the saddlepoint approximation! (I will try to come back and post some examples here, but not tonight ...) There is also an R package https://CRAN.R-project.org/package=CompQuadForm with some approximations.
Generalized Chi-Squared Distribution PDF Your question is really a special case of https://math.stackexchange.com/questions/442472/sum-of-squares-of-dependent-gaussian-random-variables/442916#442916 (with $A=I$). But nevertheless: $X$ is
31,258
What is the output of a tf.nn.dynamic_rnn()?
Yes, cell output equals to the hidden state. In case of LSTM, it's the short-term part of the tuple (second element of LSTMStateTuple), as can be seen in this picture: But for tf.nn.dynamic_rnn, the returned state may be different when the sequence is shorter (sequence_length argument). Take a look at this example: n_steps = 2 n_inputs = 3 n_neurons = 5 X = tf.placeholder(dtype=tf.float32, shape=[None, n_steps, n_inputs]) seq_length = tf.placeholder(tf.int32, [None]) basic_cell = tf.nn.rnn_cell.BasicRNNCell(num_units=n_neurons) outputs, states = tf.nn.dynamic_rnn(basic_cell, X, sequence_length=seq_length, dtype=tf.float32) X_batch = np.array([ # t = 0 t = 1 [[0, 1, 2], [9, 8, 7]], # instance 0 [[3, 4, 5], [0, 0, 0]], # instance 1 [[6, 7, 8], [6, 5, 4]], # instance 2 [[9, 0, 1], [3, 2, 1]], # instance 3 ]) seq_length_batch = np.array([2, 1, 2, 2]) with tf.Session() as sess: sess.run(tf.global_variables_initializer()) outputs_val, states_val = sess.run([outputs, states], feed_dict={X: X_batch, seq_length: seq_length_batch}) print(outputs_val) print() print(states_val) Here the input batch contains 4 sequences and one of them is short and padded with zeros. Upon running you should something like this: [[[ 0.2315362 -0.37939444 -0.625332 -0.80235624 0.2288385 ] [ 0.9999524 0.99987394 0.33580178 -0.9981791 0.99975705]] [[ 0.97374666 0.8373545 -0.7455188 -0.98751736 0.9658986 ] [ 0. 0. 0. 0. 0. ]] [[ 0.9994331 0.9929737 -0.8311569 -0.99928087 0.9990415 ] [ 0.9984355 0.9936006 0.3662448 -0.87244385 0.993848 ]] [[ 0.9962312 0.99659646 0.98880637 0.99548346 0.9997809 ] [ 0.9915743 0.9936939 0.4348318 0.8798458 0.95265496]]] [[ 0.9999524 0.99987394 0.33580178 -0.9981791 0.99975705] [ 0.97374666 0.8373545 -0.7455188 -0.98751736 0.9658986 ] [ 0.9984355 0.9936006 0.3662448 -0.87244385 0.993848 ] [ 0.9915743 0.9936939 0.4348318 0.8798458 0.95265496]] ... which indeed shows that state == output[1] for full sequences and state == output[0] for the short one. Also output[1] is a zero vector for this sequence. The same holds for LSTM and GRU cells. So the state is a convenient tensor that holds the last actual RNN state, ignoring the zeros. The output tensor holds the outputs of all cells, so it doesn't ignore the zeros. That's the reason for returning both of them.
What is the output of a tf.nn.dynamic_rnn()?
Yes, cell output equals to the hidden state. In case of LSTM, it's the short-term part of the tuple (second element of LSTMStateTuple), as can be seen in this picture: But for tf.nn.dynamic_rnn, the
What is the output of a tf.nn.dynamic_rnn()? Yes, cell output equals to the hidden state. In case of LSTM, it's the short-term part of the tuple (second element of LSTMStateTuple), as can be seen in this picture: But for tf.nn.dynamic_rnn, the returned state may be different when the sequence is shorter (sequence_length argument). Take a look at this example: n_steps = 2 n_inputs = 3 n_neurons = 5 X = tf.placeholder(dtype=tf.float32, shape=[None, n_steps, n_inputs]) seq_length = tf.placeholder(tf.int32, [None]) basic_cell = tf.nn.rnn_cell.BasicRNNCell(num_units=n_neurons) outputs, states = tf.nn.dynamic_rnn(basic_cell, X, sequence_length=seq_length, dtype=tf.float32) X_batch = np.array([ # t = 0 t = 1 [[0, 1, 2], [9, 8, 7]], # instance 0 [[3, 4, 5], [0, 0, 0]], # instance 1 [[6, 7, 8], [6, 5, 4]], # instance 2 [[9, 0, 1], [3, 2, 1]], # instance 3 ]) seq_length_batch = np.array([2, 1, 2, 2]) with tf.Session() as sess: sess.run(tf.global_variables_initializer()) outputs_val, states_val = sess.run([outputs, states], feed_dict={X: X_batch, seq_length: seq_length_batch}) print(outputs_val) print() print(states_val) Here the input batch contains 4 sequences and one of them is short and padded with zeros. Upon running you should something like this: [[[ 0.2315362 -0.37939444 -0.625332 -0.80235624 0.2288385 ] [ 0.9999524 0.99987394 0.33580178 -0.9981791 0.99975705]] [[ 0.97374666 0.8373545 -0.7455188 -0.98751736 0.9658986 ] [ 0. 0. 0. 0. 0. ]] [[ 0.9994331 0.9929737 -0.8311569 -0.99928087 0.9990415 ] [ 0.9984355 0.9936006 0.3662448 -0.87244385 0.993848 ]] [[ 0.9962312 0.99659646 0.98880637 0.99548346 0.9997809 ] [ 0.9915743 0.9936939 0.4348318 0.8798458 0.95265496]]] [[ 0.9999524 0.99987394 0.33580178 -0.9981791 0.99975705] [ 0.97374666 0.8373545 -0.7455188 -0.98751736 0.9658986 ] [ 0.9984355 0.9936006 0.3662448 -0.87244385 0.993848 ] [ 0.9915743 0.9936939 0.4348318 0.8798458 0.95265496]] ... which indeed shows that state == output[1] for full sequences and state == output[0] for the short one. Also output[1] is a zero vector for this sequence. The same holds for LSTM and GRU cells. So the state is a convenient tensor that holds the last actual RNN state, ignoring the zeros. The output tensor holds the outputs of all cells, so it doesn't ignore the zeros. That's the reason for returning both of them.
What is the output of a tf.nn.dynamic_rnn()? Yes, cell output equals to the hidden state. In case of LSTM, it's the short-term part of the tuple (second element of LSTMStateTuple), as can be seen in this picture: But for tf.nn.dynamic_rnn, the
31,259
What is the output of a tf.nn.dynamic_rnn()?
Possible copy of https://stackoverflow.com/questions/36817596/get-last-output-of-dynamic-rnn-in-tensorflow/49705930#49705930 Anyway let's go ahead with the answer. This code snip might help understand what's really being returned by the dynamic_rnn layer => Tuple of (outputs, final_output_state). So for an input with max sequence length of T time steps outputs is of the shape [Batch_size, T, num_inputs] (given time_major=False; default value) and it contains the output state at each timestep h1, h2.....hT. And final_output_state is of the shape [Batch_size,num_inputs] and has the final cell state cT and output state hT of each batch sequence. But since the dynamic_rnn is being used my guess is your sequence lengths vary for each batch. import tensorflow as tf import numpy as np from tensorflow.contrib import rnn tf.reset_default_graph() # Create input data X = np.random.randn(2, 10, 8) # The second example is of length 6 X[1,6:] = 0 X_lengths = [10, 6] cell = tf.nn.rnn_cell.LSTMCell(num_units=64, state_is_tuple=True) outputs, states = tf.nn.dynamic_rnn(cell=cell, dtype=tf.float64, sequence_length=X_lengths, inputs=X) result = tf.contrib.learn.run_n({"outputs": outputs, "states":states}, n=1, feed_dict=None) assert result[0]["outputs"].shape == (2, 10, 64) print result[0]["outputs"].shape print result[0]["states"].h.shape # the final outputs state and states returned must be equal for each # sequence assert(result[0]["outputs"][0][-1]==result[0]["states"].h[0]).all() assert(result[0]["outputs"][-1][5]==result[0]["states"].h[-1]).all() assert(result[0]["outputs"][-1][-1]==result[0]["states"].h[-1]).all() The final assertion will fail as the final state for the 2nd sequence is at 6th time step ie. the index 5 and the rest of the outputs from [6:9] are all 0s in the 2nd timestep
What is the output of a tf.nn.dynamic_rnn()?
Possible copy of https://stackoverflow.com/questions/36817596/get-last-output-of-dynamic-rnn-in-tensorflow/49705930#49705930 Anyway let's go ahead with the answer. This code snip might help understand
What is the output of a tf.nn.dynamic_rnn()? Possible copy of https://stackoverflow.com/questions/36817596/get-last-output-of-dynamic-rnn-in-tensorflow/49705930#49705930 Anyway let's go ahead with the answer. This code snip might help understand what's really being returned by the dynamic_rnn layer => Tuple of (outputs, final_output_state). So for an input with max sequence length of T time steps outputs is of the shape [Batch_size, T, num_inputs] (given time_major=False; default value) and it contains the output state at each timestep h1, h2.....hT. And final_output_state is of the shape [Batch_size,num_inputs] and has the final cell state cT and output state hT of each batch sequence. But since the dynamic_rnn is being used my guess is your sequence lengths vary for each batch. import tensorflow as tf import numpy as np from tensorflow.contrib import rnn tf.reset_default_graph() # Create input data X = np.random.randn(2, 10, 8) # The second example is of length 6 X[1,6:] = 0 X_lengths = [10, 6] cell = tf.nn.rnn_cell.LSTMCell(num_units=64, state_is_tuple=True) outputs, states = tf.nn.dynamic_rnn(cell=cell, dtype=tf.float64, sequence_length=X_lengths, inputs=X) result = tf.contrib.learn.run_n({"outputs": outputs, "states":states}, n=1, feed_dict=None) assert result[0]["outputs"].shape == (2, 10, 64) print result[0]["outputs"].shape print result[0]["states"].h.shape # the final outputs state and states returned must be equal for each # sequence assert(result[0]["outputs"][0][-1]==result[0]["states"].h[0]).all() assert(result[0]["outputs"][-1][5]==result[0]["states"].h[-1]).all() assert(result[0]["outputs"][-1][-1]==result[0]["states"].h[-1]).all() The final assertion will fail as the final state for the 2nd sequence is at 6th time step ie. the index 5 and the rest of the outputs from [6:9] are all 0s in the 2nd timestep
What is the output of a tf.nn.dynamic_rnn()? Possible copy of https://stackoverflow.com/questions/36817596/get-last-output-of-dynamic-rnn-in-tensorflow/49705930#49705930 Anyway let's go ahead with the answer. This code snip might help understand
31,260
Is GINI limited to binary classifiers or can we use it for multi-class classifiers as well?
The Gini impurity can definitely be used to quantify variance in a multi-class setting, not only in the binary case. Gini impurity is defined as $$ G(p) = \sum_{i=1}^{J}{p_i} \sum_{k \neq i}^{J}{p_k} = 1-\sum_{i=1}^{J}{(p_i)^{2}} $$ for the scenario with $J$ classes, each having probability $p_i...p_J$, where $|J|$ can be $>2$. More information can also be found here: https://en.wikipedia.org/wiki/Decision_tree_learning#Gini_impurity Possibly you had a difficult time finding help due to the ambiguity with the "Gini Coefficient" used in economics (https://en.wikipedia.org/wiki/Gini_coefficient).
Is GINI limited to binary classifiers or can we use it for multi-class classifiers as well?
The Gini impurity can definitely be used to quantify variance in a multi-class setting, not only in the binary case. Gini impurity is defined as $$ G(p) = \sum_{i=1}^{J}{p_i} \sum_{k \neq i}^{J}{p_k}
Is GINI limited to binary classifiers or can we use it for multi-class classifiers as well? The Gini impurity can definitely be used to quantify variance in a multi-class setting, not only in the binary case. Gini impurity is defined as $$ G(p) = \sum_{i=1}^{J}{p_i} \sum_{k \neq i}^{J}{p_k} = 1-\sum_{i=1}^{J}{(p_i)^{2}} $$ for the scenario with $J$ classes, each having probability $p_i...p_J$, where $|J|$ can be $>2$. More information can also be found here: https://en.wikipedia.org/wiki/Decision_tree_learning#Gini_impurity Possibly you had a difficult time finding help due to the ambiguity with the "Gini Coefficient" used in economics (https://en.wikipedia.org/wiki/Gini_coefficient).
Is GINI limited to binary classifiers or can we use it for multi-class classifiers as well? The Gini impurity can definitely be used to quantify variance in a multi-class setting, not only in the binary case. Gini impurity is defined as $$ G(p) = \sum_{i=1}^{J}{p_i} \sum_{k \neq i}^{J}{p_k}
31,261
Simulating data for an ordered logit model
Imagine you have one ordered categorical dependent variable, which is a Likert scale from 1 to 5 (I'll code it as y), and two independent variables that are normally and uniformly distributed (x1 and x2, respectively). What a basic ordered logistic regression does is predict $k - 1$ log odds, where $k$ is how many levels the dependent variable has (in this case, 4): First, the log of the sum of probabilities of being in 2, 3, 4, and 5 categories over the probability of being in the 1 category. Then, categories 3, 4, and 5 over the sum of 1 and 2, etc. These look like: $\text{ln}({\hat{\pi}_2 + \hat{\pi}_3 + \hat{\pi}_4 + \hat{\pi}_5 \over \hat{\pi}_1})$, $\text{ln}({\hat{\pi}_3 + \hat{\pi}_4 + \hat{\pi}_5 \over \hat{\pi}_1 + \hat{\pi}_2})$, $\text{ln}({\hat{\pi}_4 + \hat{\pi}_5 \over \hat{\pi}_1 + \hat{\pi}_2 + \hat{\pi}_3})$, $\text{ln}({\hat{\pi}_5 \over \hat{\pi}_1 + \hat{\pi}_2 + \hat{\pi}_3 + \hat{\pi}_4})$ For ease, let's call these log-odds 1, 2, 3, and 4, respectively. So how do we get these four log odds predictions? Each of them has their own equation: $\text{log-odds}_1 = b_{01} + b_1X_1 + b_2X_2$ $\text{log-odds}_2 = b_{02} + b_1X_1 + b_2X_2$ $\text{log-odds}_3 = b_{03} + b_1X_1 + b_2X_2$ $\text{log-odds}_4 = b_{04} + b_1X_1 + b_2X_2$ You will note that the only thing different about these equations is that they have a different intercept. This is the proportional odds or parallel regressions assumption. Now, we can simulate data based on this model. Since they are ordered, $b_{01} > b_{02} > b_{03} > b_{04}$ (i.e., because the odds of a, b, c, and d happening, for example, cannot be less than the odds of a, b, and c happening). First, let's make x1 and x2: set.seed(1839) n <- 150 x1 <- rnorm(n) x2 <- runif(n) Now, let's set the population parameters that predict the log-odds: b01 <- 1 b02 <- 0.05 b03 <- -0.05 b04 <- -1 b1 <- 0.8 b2 <- 0.5 Now, we can predict each of the log-odds, given the equations above: logodds1 <- b01 + b1 * x1 + b2 * x2 logodds2 <- b02 + b1 * x1 + b2 * x2 logodds3 <- b03 + b1 * x1 + b2 * x2 logodds4 <- b04 + b1 * x1 + b2 * x2 Now we can use $\text{logit}^{-1}$ to get the probability of the numerator for each person: inv_logit <- function(logit) exp(logit) / (1 + exp(logit)) prob_2to5 <- inv_logit(logodds1) prob_3to5 <- inv_logit(logodds2) prob_4to5 <- inv_logit(logodds3) prob_5 <- inv_logit(logodds4) Now, we can do subtraction to get the probability of each category itself: prob_1 <- 1 - prob_2to5 prob_2 <- prob_2to5 - prob_3to5 prob_3 <- prob_3to5 - prob_4to5 prob_4 <- prob_4to5 - prob_5 Just to make sure, are all probabilities above zero? > table(c(prob_1, prob_2, prob_3, prob_4, prob_5) > 0) TRUE 750 Cool. Now, we can use these probabilities to sample from numbers 1 through 5 (the categories of interest) to get our dependent variable, y: y <- c() for (i in 1:n) { y[i] <- sample( x = c(1:5), size = 1, prob = c(prob_1[i], prob_2[i], prob_3[i], prob_4[i], prob_5[i]) ) } I could have done an apply statement there, but I'm being lazy. Now, we can put these into a data.frame and run an ordinal regression: > dat <- data.frame(x1, x2, y = factor(y)) > > library(ordinal) > summary(clm(y ~ x1 + x2, data = dat)) formula: y ~ x1 + x2 data: dat link threshold nobs logLik AIC niter max.grad cond.H logit flexible 150 -204.23 420.47 8(1) 2.74e-07 2.2e+02 Coefficients: Estimate Std. Error z value Pr(>|z|) x1 0.8933 0.1786 5.003 5.65e-07 *** x2 0.5810 0.5595 1.038 0.299 --- Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1 Threshold coefficients: Estimate Std. Error z value 1|2 -1.25461 0.35426 -3.541 2|3 0.02907 0.33321 0.087 3|4 0.25541 0.33261 0.768 4|5 0.91630 0.34070 2.689 Note that we recovered the parameters OK, but not exactly. Why? The sample function has random error. You could write that into a function, do it a number of times, and see how many times you recover your parameters, etc. The code is not perfect, but it should get you started. It's also more verbose for instructional purposes. Since you're doing it in a Bayesian framework, I would really appreciate an answer to my CrossValidated question on choosing semi-informative priors for ordinal regression.
Simulating data for an ordered logit model
Imagine you have one ordered categorical dependent variable, which is a Likert scale from 1 to 5 (I'll code it as y), and two independent variables that are normally and uniformly distributed (x1 and
Simulating data for an ordered logit model Imagine you have one ordered categorical dependent variable, which is a Likert scale from 1 to 5 (I'll code it as y), and two independent variables that are normally and uniformly distributed (x1 and x2, respectively). What a basic ordered logistic regression does is predict $k - 1$ log odds, where $k$ is how many levels the dependent variable has (in this case, 4): First, the log of the sum of probabilities of being in 2, 3, 4, and 5 categories over the probability of being in the 1 category. Then, categories 3, 4, and 5 over the sum of 1 and 2, etc. These look like: $\text{ln}({\hat{\pi}_2 + \hat{\pi}_3 + \hat{\pi}_4 + \hat{\pi}_5 \over \hat{\pi}_1})$, $\text{ln}({\hat{\pi}_3 + \hat{\pi}_4 + \hat{\pi}_5 \over \hat{\pi}_1 + \hat{\pi}_2})$, $\text{ln}({\hat{\pi}_4 + \hat{\pi}_5 \over \hat{\pi}_1 + \hat{\pi}_2 + \hat{\pi}_3})$, $\text{ln}({\hat{\pi}_5 \over \hat{\pi}_1 + \hat{\pi}_2 + \hat{\pi}_3 + \hat{\pi}_4})$ For ease, let's call these log-odds 1, 2, 3, and 4, respectively. So how do we get these four log odds predictions? Each of them has their own equation: $\text{log-odds}_1 = b_{01} + b_1X_1 + b_2X_2$ $\text{log-odds}_2 = b_{02} + b_1X_1 + b_2X_2$ $\text{log-odds}_3 = b_{03} + b_1X_1 + b_2X_2$ $\text{log-odds}_4 = b_{04} + b_1X_1 + b_2X_2$ You will note that the only thing different about these equations is that they have a different intercept. This is the proportional odds or parallel regressions assumption. Now, we can simulate data based on this model. Since they are ordered, $b_{01} > b_{02} > b_{03} > b_{04}$ (i.e., because the odds of a, b, c, and d happening, for example, cannot be less than the odds of a, b, and c happening). First, let's make x1 and x2: set.seed(1839) n <- 150 x1 <- rnorm(n) x2 <- runif(n) Now, let's set the population parameters that predict the log-odds: b01 <- 1 b02 <- 0.05 b03 <- -0.05 b04 <- -1 b1 <- 0.8 b2 <- 0.5 Now, we can predict each of the log-odds, given the equations above: logodds1 <- b01 + b1 * x1 + b2 * x2 logodds2 <- b02 + b1 * x1 + b2 * x2 logodds3 <- b03 + b1 * x1 + b2 * x2 logodds4 <- b04 + b1 * x1 + b2 * x2 Now we can use $\text{logit}^{-1}$ to get the probability of the numerator for each person: inv_logit <- function(logit) exp(logit) / (1 + exp(logit)) prob_2to5 <- inv_logit(logodds1) prob_3to5 <- inv_logit(logodds2) prob_4to5 <- inv_logit(logodds3) prob_5 <- inv_logit(logodds4) Now, we can do subtraction to get the probability of each category itself: prob_1 <- 1 - prob_2to5 prob_2 <- prob_2to5 - prob_3to5 prob_3 <- prob_3to5 - prob_4to5 prob_4 <- prob_4to5 - prob_5 Just to make sure, are all probabilities above zero? > table(c(prob_1, prob_2, prob_3, prob_4, prob_5) > 0) TRUE 750 Cool. Now, we can use these probabilities to sample from numbers 1 through 5 (the categories of interest) to get our dependent variable, y: y <- c() for (i in 1:n) { y[i] <- sample( x = c(1:5), size = 1, prob = c(prob_1[i], prob_2[i], prob_3[i], prob_4[i], prob_5[i]) ) } I could have done an apply statement there, but I'm being lazy. Now, we can put these into a data.frame and run an ordinal regression: > dat <- data.frame(x1, x2, y = factor(y)) > > library(ordinal) > summary(clm(y ~ x1 + x2, data = dat)) formula: y ~ x1 + x2 data: dat link threshold nobs logLik AIC niter max.grad cond.H logit flexible 150 -204.23 420.47 8(1) 2.74e-07 2.2e+02 Coefficients: Estimate Std. Error z value Pr(>|z|) x1 0.8933 0.1786 5.003 5.65e-07 *** x2 0.5810 0.5595 1.038 0.299 --- Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1 Threshold coefficients: Estimate Std. Error z value 1|2 -1.25461 0.35426 -3.541 2|3 0.02907 0.33321 0.087 3|4 0.25541 0.33261 0.768 4|5 0.91630 0.34070 2.689 Note that we recovered the parameters OK, but not exactly. Why? The sample function has random error. You could write that into a function, do it a number of times, and see how many times you recover your parameters, etc. The code is not perfect, but it should get you started. It's also more verbose for instructional purposes. Since you're doing it in a Bayesian framework, I would really appreciate an answer to my CrossValidated question on choosing semi-informative priors for ordinal regression.
Simulating data for an ordered logit model Imagine you have one ordered categorical dependent variable, which is a Likert scale from 1 to 5 (I'll code it as y), and two independent variables that are normally and uniformly distributed (x1 and
31,262
Simulating data for an ordered logit model
thanks for the code, Mark! I have a question about the parameters that you listed: b01 <- 1 b02 <- 0.05 b03 <- -0.05 b04 <- -1 b1 <- 0.8 b2 <- 0.5 How can I come up with these parameters for a specific power analysis? Let's say I want to run a power analysis for an ordered regression with a dependent variable with six levels (1-6) and with one categorical, dichotomous predictor which predicts said dependent variable with OR = 1.5. How can I calculate the necessary parameters based on this information?
Simulating data for an ordered logit model
thanks for the code, Mark! I have a question about the parameters that you listed: b01 <- 1 b02 <- 0.05 b03 <- -0.05 b04 <- -1 b1 <- 0.8 b2 <- 0.5 How can I come up with these parameters for a speci
Simulating data for an ordered logit model thanks for the code, Mark! I have a question about the parameters that you listed: b01 <- 1 b02 <- 0.05 b03 <- -0.05 b04 <- -1 b1 <- 0.8 b2 <- 0.5 How can I come up with these parameters for a specific power analysis? Let's say I want to run a power analysis for an ordered regression with a dependent variable with six levels (1-6) and with one categorical, dichotomous predictor which predicts said dependent variable with OR = 1.5. How can I calculate the necessary parameters based on this information?
Simulating data for an ordered logit model thanks for the code, Mark! I have a question about the parameters that you listed: b01 <- 1 b02 <- 0.05 b03 <- -0.05 b04 <- -1 b1 <- 0.8 b2 <- 0.5 How can I come up with these parameters for a speci
31,263
Matrix factorization in recommender systems: adding a new user
Since your training matrix decomposition with gradient descent, I assume you have some loss function $L(X - PQ)$ where $L$ is squared Frobenius norm or something similar. When you add a new user (let's say rows of $X$ correspond to users, and $x$ is new user's row, so that $X$' is $X$ with concatenated $x$) your objective becomes $$L(X' - P'Q)$$ and if your loss is something that can be calculated by summing over rows, $$L(X' - P'Q) = L(X - PQ) + L(x - x_pQ)$$. If you already have trained $P, Q$ so that they minimize $L(X - PQ)$ then you have a guess for $P, Q$. If you want to incorporate new user, but not recompute everything, you could either optimize $L(x - x_pQ)$ with $Q$ fixed or changed.
Matrix factorization in recommender systems: adding a new user
Since your training matrix decomposition with gradient descent, I assume you have some loss function $L(X - PQ)$ where $L$ is squared Frobenius norm or something similar. When you add a new user (let'
Matrix factorization in recommender systems: adding a new user Since your training matrix decomposition with gradient descent, I assume you have some loss function $L(X - PQ)$ where $L$ is squared Frobenius norm or something similar. When you add a new user (let's say rows of $X$ correspond to users, and $x$ is new user's row, so that $X$' is $X$ with concatenated $x$) your objective becomes $$L(X' - P'Q)$$ and if your loss is something that can be calculated by summing over rows, $$L(X' - P'Q) = L(X - PQ) + L(x - x_pQ)$$. If you already have trained $P, Q$ so that they minimize $L(X - PQ)$ then you have a guess for $P, Q$. If you want to incorporate new user, but not recompute everything, you could either optimize $L(x - x_pQ)$ with $Q$ fixed or changed.
Matrix factorization in recommender systems: adding a new user Since your training matrix decomposition with gradient descent, I assume you have some loss function $L(X - PQ)$ where $L$ is squared Frobenius norm or something similar. When you add a new user (let'
31,264
Real life uses of Moment generating functions
You are right that mgf's can seem somewhat unmotivated in introductory courses. So, some examples of use. First, in discrete probability problems often we use the probability generating function, but that is only a different packaging of the mgf, see What is the difference between moment generating function and probability generating function?. The pgf can be used to solve some probability problems which could be hard to solve otherwise, for a recent example on this site, see PMF of the number of trials required for two successive heads or sum of $N$ gamma distributions with $N$ being a poisson distribution. Some not-so-obvious applications which still could be used in an introductory course, is given in Expectation of reciprocal of a variable, Expected value of $1/x$ when $x$ follows a Beta distribution and For independent RVs $X_1,X_2,X_3$, does $X_1+X_2\stackrel{d}{=}X_1+X_3$ imply $X_2\stackrel{d}{=}X_3$? . Another kind of use is constructing approximations of probability distributions, one example is the saddlepoint approximation, which take as starting point the natural logarithms of the mgf, called the cumulant generating function. See How does saddlepoint approximation work? and for some examples, see Bound for weighted sum of Poisson random variables and Generic sum of Gamma random variables Mgf's can also be used to prove limit theorems, for instance the poisson limit of binomial distributions Intuitively understand why the Poisson distribution is the limiting case of the binomial distribution can be proved via mgf's. Some examples (exercise sets with solutions) of actuarial use of mgf's can be found here: https://faculty.math.illinois.edu/~hildebr/370/370mgfproblemssol.pdf Search the internet with "moment generating function actuarial" will give lots of similar examples. The actuaries seem to be using mgf's to solve some problems (that arises for instances in premium calculations) that is difficult to solve otherwise. One example in section 3.5 page 21 and books about actuarial risk theory. One source of (estimated) mgf's for such applications could be empirical mgf's (strangely, I cannot find even one post here about empirical moment generating functions). A recent illuminating example is at out sister site: https://mathoverflow.net/questions/435496/why-should-the-logarithmic-series-distribution-model-the-number-of-items-bough
Real life uses of Moment generating functions
You are right that mgf's can seem somewhat unmotivated in introductory courses. So, some examples of use. First, in discrete probability problems often we use the probability generating function, bu
Real life uses of Moment generating functions You are right that mgf's can seem somewhat unmotivated in introductory courses. So, some examples of use. First, in discrete probability problems often we use the probability generating function, but that is only a different packaging of the mgf, see What is the difference between moment generating function and probability generating function?. The pgf can be used to solve some probability problems which could be hard to solve otherwise, for a recent example on this site, see PMF of the number of trials required for two successive heads or sum of $N$ gamma distributions with $N$ being a poisson distribution. Some not-so-obvious applications which still could be used in an introductory course, is given in Expectation of reciprocal of a variable, Expected value of $1/x$ when $x$ follows a Beta distribution and For independent RVs $X_1,X_2,X_3$, does $X_1+X_2\stackrel{d}{=}X_1+X_3$ imply $X_2\stackrel{d}{=}X_3$? . Another kind of use is constructing approximations of probability distributions, one example is the saddlepoint approximation, which take as starting point the natural logarithms of the mgf, called the cumulant generating function. See How does saddlepoint approximation work? and for some examples, see Bound for weighted sum of Poisson random variables and Generic sum of Gamma random variables Mgf's can also be used to prove limit theorems, for instance the poisson limit of binomial distributions Intuitively understand why the Poisson distribution is the limiting case of the binomial distribution can be proved via mgf's. Some examples (exercise sets with solutions) of actuarial use of mgf's can be found here: https://faculty.math.illinois.edu/~hildebr/370/370mgfproblemssol.pdf Search the internet with "moment generating function actuarial" will give lots of similar examples. The actuaries seem to be using mgf's to solve some problems (that arises for instances in premium calculations) that is difficult to solve otherwise. One example in section 3.5 page 21 and books about actuarial risk theory. One source of (estimated) mgf's for such applications could be empirical mgf's (strangely, I cannot find even one post here about empirical moment generating functions). A recent illuminating example is at out sister site: https://mathoverflow.net/questions/435496/why-should-the-logarithmic-series-distribution-model-the-number-of-items-bough
Real life uses of Moment generating functions You are right that mgf's can seem somewhat unmotivated in introductory courses. So, some examples of use. First, in discrete probability problems often we use the probability generating function, bu
31,265
Real life uses of Moment generating functions
Are there any real life examples of distributions where finding the expectation and variance is hard to do analytically and so the use of m.g.f's was needed? There are many problems where it is hard to find the mean and variance using their standard formulae as a sum/integral over the mass/density. One example where this is difficult, but not impossible, is the coupon collector's distribution, which has probability mass function: $$\mathbb{P}(T=t) = \frac{m!}{m^t} \cdot S(t-1, m-1) \quad \quad \quad \text{for all integers } t \geqslant m,$$ where the function $S$ denotes the Stirling numbers of the second kind. If you try to use the standard method here you will end up with a recursive formula involving the Stirling numbers, and this is cumbersome to work with. A simpler method to get the mean and variance is to derive the cumulant generating function (logarithm of the moment generating function) which no longer contains the Stirling numbers. It is then relatively simple to obtain the cumulants of the distribution. I recommend you give this exercise a try via both methods to see what I mean.
Real life uses of Moment generating functions
Are there any real life examples of distributions where finding the expectation and variance is hard to do analytically and so the use of m.g.f's was needed? There are many problems where it is hard
Real life uses of Moment generating functions Are there any real life examples of distributions where finding the expectation and variance is hard to do analytically and so the use of m.g.f's was needed? There are many problems where it is hard to find the mean and variance using their standard formulae as a sum/integral over the mass/density. One example where this is difficult, but not impossible, is the coupon collector's distribution, which has probability mass function: $$\mathbb{P}(T=t) = \frac{m!}{m^t} \cdot S(t-1, m-1) \quad \quad \quad \text{for all integers } t \geqslant m,$$ where the function $S$ denotes the Stirling numbers of the second kind. If you try to use the standard method here you will end up with a recursive formula involving the Stirling numbers, and this is cumbersome to work with. A simpler method to get the mean and variance is to derive the cumulant generating function (logarithm of the moment generating function) which no longer contains the Stirling numbers. It is then relatively simple to obtain the cumulants of the distribution. I recommend you give this exercise a try via both methods to see what I mean.
Real life uses of Moment generating functions Are there any real life examples of distributions where finding the expectation and variance is hard to do analytically and so the use of m.g.f's was needed? There are many problems where it is hard
31,266
How to prove whether the mean of a probability density function exists
There is no general technique, but there are some simple principles. One is to study the tail behavior of $f$ by comparing it to tractable functions. By definition, the expectation is the double limit (as $y$ and $z$ vary independently) $$E_{y,z}[f] = \lim_{y\to-\infty,z\to\infty}\int_y^z x f(x) dx = \lim_{y\to-\infty}\int_y^0 x f(x) dx+ \lim_{z\to\infty}\int_0^z x f(x) dx.$$ The treatment of the two integrals at the right is the same, so let's focus on the positive one. One behavior of $f$ that assures a limiting value is to compare it to the power $x^{-p}$. Suppose $p$ is a number for which $$\liminf_{x\to\infty} x^p f(x)\gt 0.$$ This means there exists an $\epsilon\gt 0$ and an $N\gt 1$ for which $x^p f(x) \ge \epsilon$ whenever $x\in[N,\infty)$. We may exploit this inequality by breaking the integration into the regions where $x\lt N$ and $x \ge N$ and applying it in the second region: $$\eqalign{ \int_0^z x f(x) dx &=\int_0^{N} x f(x) dx + \int_{N}^z x f(x) dx \\ &=\int_0^{N} x f(x) dx + \int_{N}^z x^{1-p} \left(x^p f(x)\right) dx \\ &\ge \int_0^{N} x f(x) dx + \int_{N}^z x^{1-p} \left(\epsilon\right) dx \\ &= \int_0^{N} x f(x) dx + \frac{\epsilon}{2-p}\left(z^{2-p} - {N}^{2-p}\right). }$$ Provided $p\lt 2$, the right hand side diverges as $z\to\infty$. When $p=2$ the integral evaluates to the logarithm, $$\int_{N}^z x^{1-2} \left(\epsilon\right) dx = \epsilon \left(\log(z) - \log(N)\right),$$ which also diverges. Comparable analysis shows that if $|x|^pf(x)\to 0$ for $p\gt 2$, then $E[X]$ exists. Similarly we may test whether any moment of $X$ exists: for $\alpha\gt 0$, the expectation of $|X|^\alpha$ exists when $|x|^{p+\alpha}f(x)\to 0$ for some $p\gt 1$ and does not exist when $\liminf |x|^{p+\alpha}f(x)\gt 0$ for some $p \le 1$. This addresses the "general question." Let's apply this insight to the question. By inspection it is clear that $a(x)\approx |x|/\sigma_1$ for large $|x|$. In evaluating $f$, we may therefore drop any additive terms that will eventually be swamped by $|x|$. Thus, up to a nonzero constant, for $x\gt 0$ $$f(x) \approx \frac{\mu_1 x}{\sigma_2 x^3}\phi\left(\frac{\mu_2 x}{\sigma_2 x}\right) = x^{-2}\frac{\mu_1}{\sigma_2}\exp\left(\left(-\frac{\mu_2}{2\sigma_2}\right)^2\right).$$ Thus $x^2 f(x)$ approaches a nonzero constant. By the preceding result, the expectation diverges. Since $2$ is the smallest value of $p$ that works in this argument--$|x|^pf(x)$ will go to zero as $|x|\to\infty$ for any $p\lt 2$--it is clear (and a more detailed analysis of $f$ will confirm) that the rate of divergence is logarithmic. That is, for large $|y|$ and $|z|$, $E_{y,z}[f]$ can be closely approximated by a linear combination of $\log(|y|)$ and $\log(|z|)$.
How to prove whether the mean of a probability density function exists
There is no general technique, but there are some simple principles. One is to study the tail behavior of $f$ by comparing it to tractable functions. By definition, the expectation is the double limi
How to prove whether the mean of a probability density function exists There is no general technique, but there are some simple principles. One is to study the tail behavior of $f$ by comparing it to tractable functions. By definition, the expectation is the double limit (as $y$ and $z$ vary independently) $$E_{y,z}[f] = \lim_{y\to-\infty,z\to\infty}\int_y^z x f(x) dx = \lim_{y\to-\infty}\int_y^0 x f(x) dx+ \lim_{z\to\infty}\int_0^z x f(x) dx.$$ The treatment of the two integrals at the right is the same, so let's focus on the positive one. One behavior of $f$ that assures a limiting value is to compare it to the power $x^{-p}$. Suppose $p$ is a number for which $$\liminf_{x\to\infty} x^p f(x)\gt 0.$$ This means there exists an $\epsilon\gt 0$ and an $N\gt 1$ for which $x^p f(x) \ge \epsilon$ whenever $x\in[N,\infty)$. We may exploit this inequality by breaking the integration into the regions where $x\lt N$ and $x \ge N$ and applying it in the second region: $$\eqalign{ \int_0^z x f(x) dx &=\int_0^{N} x f(x) dx + \int_{N}^z x f(x) dx \\ &=\int_0^{N} x f(x) dx + \int_{N}^z x^{1-p} \left(x^p f(x)\right) dx \\ &\ge \int_0^{N} x f(x) dx + \int_{N}^z x^{1-p} \left(\epsilon\right) dx \\ &= \int_0^{N} x f(x) dx + \frac{\epsilon}{2-p}\left(z^{2-p} - {N}^{2-p}\right). }$$ Provided $p\lt 2$, the right hand side diverges as $z\to\infty$. When $p=2$ the integral evaluates to the logarithm, $$\int_{N}^z x^{1-2} \left(\epsilon\right) dx = \epsilon \left(\log(z) - \log(N)\right),$$ which also diverges. Comparable analysis shows that if $|x|^pf(x)\to 0$ for $p\gt 2$, then $E[X]$ exists. Similarly we may test whether any moment of $X$ exists: for $\alpha\gt 0$, the expectation of $|X|^\alpha$ exists when $|x|^{p+\alpha}f(x)\to 0$ for some $p\gt 1$ and does not exist when $\liminf |x|^{p+\alpha}f(x)\gt 0$ for some $p \le 1$. This addresses the "general question." Let's apply this insight to the question. By inspection it is clear that $a(x)\approx |x|/\sigma_1$ for large $|x|$. In evaluating $f$, we may therefore drop any additive terms that will eventually be swamped by $|x|$. Thus, up to a nonzero constant, for $x\gt 0$ $$f(x) \approx \frac{\mu_1 x}{\sigma_2 x^3}\phi\left(\frac{\mu_2 x}{\sigma_2 x}\right) = x^{-2}\frac{\mu_1}{\sigma_2}\exp\left(\left(-\frac{\mu_2}{2\sigma_2}\right)^2\right).$$ Thus $x^2 f(x)$ approaches a nonzero constant. By the preceding result, the expectation diverges. Since $2$ is the smallest value of $p$ that works in this argument--$|x|^pf(x)$ will go to zero as $|x|\to\infty$ for any $p\lt 2$--it is clear (and a more detailed analysis of $f$ will confirm) that the rate of divergence is logarithmic. That is, for large $|y|$ and $|z|$, $E_{y,z}[f]$ can be closely approximated by a linear combination of $\log(|y|)$ and $\log(|z|)$.
How to prove whether the mean of a probability density function exists There is no general technique, but there are some simple principles. One is to study the tail behavior of $f$ by comparing it to tractable functions. By definition, the expectation is the double limi
31,267
gradient versus partial derivatives
Gradient is the partial derivatives : $$\nabla f = \left(\frac{\partial f}{\partial x_1};\frac{\partial f}{\partial x_2};...;\frac{\partial f}{\partial x_n}\right)$$ Eg : $f=x^2y$ $$\nabla f =(2xy;x^2)$$ Gradient gives the rate of change in every direction $e$ ($e$ is a unit vector) thanks to the dot product $\nabla f.e$ : Eg :$\nabla f.(0;1)=\frac{\partial f}{\partial y}$
gradient versus partial derivatives
Gradient is the partial derivatives : $$\nabla f = \left(\frac{\partial f}{\partial x_1};\frac{\partial f}{\partial x_2};...;\frac{\partial f}{\partial x_n}\right)$$ Eg : $f=x^2y$ $$\nabla f =(2xy;x^
gradient versus partial derivatives Gradient is the partial derivatives : $$\nabla f = \left(\frac{\partial f}{\partial x_1};\frac{\partial f}{\partial x_2};...;\frac{\partial f}{\partial x_n}\right)$$ Eg : $f=x^2y$ $$\nabla f =(2xy;x^2)$$ Gradient gives the rate of change in every direction $e$ ($e$ is a unit vector) thanks to the dot product $\nabla f.e$ : Eg :$\nabla f.(0;1)=\frac{\partial f}{\partial y}$
gradient versus partial derivatives Gradient is the partial derivatives : $$\nabla f = \left(\frac{\partial f}{\partial x_1};\frac{\partial f}{\partial x_2};...;\frac{\partial f}{\partial x_n}\right)$$ Eg : $f=x^2y$ $$\nabla f =(2xy;x^
31,268
gradient versus partial derivatives
If a function $f$ takes the parameters $x_1, \ldots, x_n$, then the partial derivatives w.r.t. the $x_i$ determine the gradient: \begin{equation} \nabla f = \frac{\partial f}{\partial x_1 }\mathbf{e}_1 + \cdots + \frac{\partial f}{\partial x_n }\mathbf{e}_n. \end{equation} If you look at the definition of the gradient-descent method, it is completely defined in terms of the gradient. how exactly is partial derivative different from gradient of a function? A partial derivative may be taken also w.r.t. a different variable, e.g., \begin{equation} \frac{\partial f}{\partial z }, \end{equation} where $z = z(x_1, \ldots, x_n)$ is some function of the xs.
gradient versus partial derivatives
If a function $f$ takes the parameters $x_1, \ldots, x_n$, then the partial derivatives w.r.t. the $x_i$ determine the gradient: \begin{equation} \nabla f = \frac{\partial f}{\partial x_1 }\mathbf{e}_
gradient versus partial derivatives If a function $f$ takes the parameters $x_1, \ldots, x_n$, then the partial derivatives w.r.t. the $x_i$ determine the gradient: \begin{equation} \nabla f = \frac{\partial f}{\partial x_1 }\mathbf{e}_1 + \cdots + \frac{\partial f}{\partial x_n }\mathbf{e}_n. \end{equation} If you look at the definition of the gradient-descent method, it is completely defined in terms of the gradient. how exactly is partial derivative different from gradient of a function? A partial derivative may be taken also w.r.t. a different variable, e.g., \begin{equation} \frac{\partial f}{\partial z }, \end{equation} where $z = z(x_1, \ldots, x_n)$ is some function of the xs.
gradient versus partial derivatives If a function $f$ takes the parameters $x_1, \ldots, x_n$, then the partial derivatives w.r.t. the $x_i$ determine the gradient: \begin{equation} \nabla f = \frac{\partial f}{\partial x_1 }\mathbf{e}_
31,269
How to distinguish episodic task and continuous tasks?
A continuous task never ends. Which means you're not given the reward at the end, since there is no end, but every so often during the task. For example, reading the internet to learn maths could be considered a continuous task. An episodic task lasts a finite amount of time. For example, playing a single game of Go is an episodic task, which you win or lose. In an episodic task, there might be only a single reward, at the end of the task, and one option is to distribute the reward evenly across all actions taken in that episode. In a continuous task, rewards might be assigned with discounting, so more recent reactions receive greater reward, and actions a long time in the past receive a vanishingly small reward. For example the reward could be geometric with distance in the past, with a discount factor $\lambda \in [0, 1]$.
How to distinguish episodic task and continuous tasks?
A continuous task never ends. Which means you're not given the reward at the end, since there is no end, but every so often during the task. For example, reading the internet to learn maths could be c
How to distinguish episodic task and continuous tasks? A continuous task never ends. Which means you're not given the reward at the end, since there is no end, but every so often during the task. For example, reading the internet to learn maths could be considered a continuous task. An episodic task lasts a finite amount of time. For example, playing a single game of Go is an episodic task, which you win or lose. In an episodic task, there might be only a single reward, at the end of the task, and one option is to distribute the reward evenly across all actions taken in that episode. In a continuous task, rewards might be assigned with discounting, so more recent reactions receive greater reward, and actions a long time in the past receive a vanishingly small reward. For example the reward could be geometric with distance in the past, with a discount factor $\lambda \in [0, 1]$.
How to distinguish episodic task and continuous tasks? A continuous task never ends. Which means you're not given the reward at the end, since there is no end, but every so often during the task. For example, reading the internet to learn maths could be c
31,270
How to distinguish episodic task and continuous tasks?
A continuous task can go on forever, an episodic task has at least one finite state (i.e. an end of the game). Mathematically speaking an episodic task has a state with transition probability 1 to itself and 0 anywhere else. This is highly interpretable, as gets clear in question 3.7 of the book: Is a maze (with reward 1 for escaping, else reward 0) episodic? Technically yes, there is a final state but theoretically it can still go on forever (running in circles). Treating this as episodic to train an agent will lead to him never reaching the end in a fixed amount of rounds per game and fixed amount of games, therefore not training at all.
How to distinguish episodic task and continuous tasks?
A continuous task can go on forever, an episodic task has at least one finite state (i.e. an end of the game). Mathematically speaking an episodic task has a state with transition probability 1 to its
How to distinguish episodic task and continuous tasks? A continuous task can go on forever, an episodic task has at least one finite state (i.e. an end of the game). Mathematically speaking an episodic task has a state with transition probability 1 to itself and 0 anywhere else. This is highly interpretable, as gets clear in question 3.7 of the book: Is a maze (with reward 1 for escaping, else reward 0) episodic? Technically yes, there is a final state but theoretically it can still go on forever (running in circles). Treating this as episodic to train an agent will lead to him never reaching the end in a fixed amount of rounds per game and fixed amount of games, therefore not training at all.
How to distinguish episodic task and continuous tasks? A continuous task can go on forever, an episodic task has at least one finite state (i.e. an end of the game). Mathematically speaking an episodic task has a state with transition probability 1 to its
31,271
How do I interpret a Cox hazard model survival curve?
Since the hazard depends on the covariates, so does the survival function. The model assumes that the hazard function of an individual with covariate vector $x$ is $$ h(t;x) = h_0(t) e^{\beta'x}. $$ Hence, the cumulative hazard of this individual is $$ H(t;x) = \int_0^t h(u;x) du=\int_0^t h_0(u) e^{\beta'x} du = H_0(t)e^{\beta'x}, $$ where we may define $H_0(t)=\int_0^t h_0(u) du$ as the baseline cumulative hazard. The survival function for an individual with covariate vector $x$ is in turn $$ S(t;x) = e^{-H(t;x)}=e^{-H_0 e^{\beta'x}}=S_0(t)^{e^{\beta'x}} $$ where we define $S_0(t) = e^{-H_0(t)}$ as the baseline survival function. Given estimates $\hat\beta$ and $\hat S_0(t)$ of the regression coefficients and the baseline survival function, an estimate the survival function for an individual with covariate vector $x$ is given by $\hat S(t;x)=\hat S_0(t)^{e^{\hat\beta'x}}$. To compute this in R you specify the value of your covariates in the newdata argument. For example if you want the survival function for individuals of age=70, do plot(survfit(fit, newdata=data.frame(age=70))) If you, as you do, omit the newdata argument, its default value equals the average values of the covariates in the sample (see ?survfit.coxph). So what is shown in your graph is an estimate of $S_0(t)^{e^{\beta'\bar x}}$.
How do I interpret a Cox hazard model survival curve?
Since the hazard depends on the covariates, so does the survival function. The model assumes that the hazard function of an individual with covariate vector $x$ is $$ h(t;x) = h_0(t) e^{\beta'x}. $$
How do I interpret a Cox hazard model survival curve? Since the hazard depends on the covariates, so does the survival function. The model assumes that the hazard function of an individual with covariate vector $x$ is $$ h(t;x) = h_0(t) e^{\beta'x}. $$ Hence, the cumulative hazard of this individual is $$ H(t;x) = \int_0^t h(u;x) du=\int_0^t h_0(u) e^{\beta'x} du = H_0(t)e^{\beta'x}, $$ where we may define $H_0(t)=\int_0^t h_0(u) du$ as the baseline cumulative hazard. The survival function for an individual with covariate vector $x$ is in turn $$ S(t;x) = e^{-H(t;x)}=e^{-H_0 e^{\beta'x}}=S_0(t)^{e^{\beta'x}} $$ where we define $S_0(t) = e^{-H_0(t)}$ as the baseline survival function. Given estimates $\hat\beta$ and $\hat S_0(t)$ of the regression coefficients and the baseline survival function, an estimate the survival function for an individual with covariate vector $x$ is given by $\hat S(t;x)=\hat S_0(t)^{e^{\hat\beta'x}}$. To compute this in R you specify the value of your covariates in the newdata argument. For example if you want the survival function for individuals of age=70, do plot(survfit(fit, newdata=data.frame(age=70))) If you, as you do, omit the newdata argument, its default value equals the average values of the covariates in the sample (see ?survfit.coxph). So what is shown in your graph is an estimate of $S_0(t)^{e^{\beta'\bar x}}$.
How do I interpret a Cox hazard model survival curve? Since the hazard depends on the covariates, so does the survival function. The model assumes that the hazard function of an individual with covariate vector $x$ is $$ h(t;x) = h_0(t) e^{\beta'x}. $$
31,272
How do I interpret a Cox hazard model survival curve?
We will have 20% subjects left (e.g., if we have 1000 people, by day 200, we should have 200 left)? or For a given person, it has 20% chance to survive at day 200? In its most pure form, the Kaplan-Meier curve in your example doesn't make any of the above statements. The first statement makes a forward looking projection will have. Basic survival curve only describes the past, your sample. Yes, 20% of your sample survived by day 200. Will 20% survive in next 200 days? Not necessarily. In order to make that statement you have to add more assumptions, build a model etc. The model doesn't even have to be statistical in a sense like logistic regression. For instance, it could PDE in epidemiology etc. Your second statement is probably based on some kind of homogeneity assumption: all people are the same.
How do I interpret a Cox hazard model survival curve?
We will have 20% subjects left (e.g., if we have 1000 people, by day 200, we should have 200 left)? or For a given person, it has 20% chance to survive at day 200? In its most pure form, the Kapl
How do I interpret a Cox hazard model survival curve? We will have 20% subjects left (e.g., if we have 1000 people, by day 200, we should have 200 left)? or For a given person, it has 20% chance to survive at day 200? In its most pure form, the Kaplan-Meier curve in your example doesn't make any of the above statements. The first statement makes a forward looking projection will have. Basic survival curve only describes the past, your sample. Yes, 20% of your sample survived by day 200. Will 20% survive in next 200 days? Not necessarily. In order to make that statement you have to add more assumptions, build a model etc. The model doesn't even have to be statistical in a sense like logistic regression. For instance, it could PDE in epidemiology etc. Your second statement is probably based on some kind of homogeneity assumption: all people are the same.
How do I interpret a Cox hazard model survival curve? We will have 20% subjects left (e.g., if we have 1000 people, by day 200, we should have 200 left)? or For a given person, it has 20% chance to survive at day 200? In its most pure form, the Kapl
31,273
How do I interpret a Cox hazard model survival curve?
Thanks for Jarle Tufto's answer. I think I should be able to answer it by myself: both statements are false. The curve generated is $S_0(t)$ but not $S(t)$. The baseline survival function $S_0(t)$ will equal to $S(t)$ only when $x=0$. Therefore the curve is NOT describing the whole population or any individual.
How do I interpret a Cox hazard model survival curve?
Thanks for Jarle Tufto's answer. I think I should be able to answer it by myself: both statements are false. The curve generated is $S_0(t)$ but not $S(t)$. The baseline survival function $S_0(t)$ wi
How do I interpret a Cox hazard model survival curve? Thanks for Jarle Tufto's answer. I think I should be able to answer it by myself: both statements are false. The curve generated is $S_0(t)$ but not $S(t)$. The baseline survival function $S_0(t)$ will equal to $S(t)$ only when $x=0$. Therefore the curve is NOT describing the whole population or any individual.
How do I interpret a Cox hazard model survival curve? Thanks for Jarle Tufto's answer. I think I should be able to answer it by myself: both statements are false. The curve generated is $S_0(t)$ but not $S(t)$. The baseline survival function $S_0(t)$ wi
31,274
How do I interpret a Cox hazard model survival curve?
Your first option is correct. Generally, $S(t) = 0.2$ indicates that 20 % of initial patients have survived till day $t$, without taking into account censoring. On censored data, it is not exactly correct to say that 20 % were still alive that day, since some were lost to follow-up earlier and their status is unknown. A better way to put it would be estimated fraction of patients still alive that day is 20 %. The second option (chance to survive one more day, given survival until $t$) is $1-h(t)$, with $h(t)$ denoting the hazard function. Regarding assumptions: I thought that the usual coefficient tests in a Cox regression setting do assume independence, conditional on observed covariates? Even the Kaplan-Meier estimate seems to require independence between survival time and censoring (reference). But I might be wrong, so corrections are welcome.
How do I interpret a Cox hazard model survival curve?
Your first option is correct. Generally, $S(t) = 0.2$ indicates that 20 % of initial patients have survived till day $t$, without taking into account censoring. On censored data, it is not exactly cor
How do I interpret a Cox hazard model survival curve? Your first option is correct. Generally, $S(t) = 0.2$ indicates that 20 % of initial patients have survived till day $t$, without taking into account censoring. On censored data, it is not exactly correct to say that 20 % were still alive that day, since some were lost to follow-up earlier and their status is unknown. A better way to put it would be estimated fraction of patients still alive that day is 20 %. The second option (chance to survive one more day, given survival until $t$) is $1-h(t)$, with $h(t)$ denoting the hazard function. Regarding assumptions: I thought that the usual coefficient tests in a Cox regression setting do assume independence, conditional on observed covariates? Even the Kaplan-Meier estimate seems to require independence between survival time and censoring (reference). But I might be wrong, so corrections are welcome.
How do I interpret a Cox hazard model survival curve? Your first option is correct. Generally, $S(t) = 0.2$ indicates that 20 % of initial patients have survived till day $t$, without taking into account censoring. On censored data, it is not exactly cor
31,275
Bayesian lighthouse location estimation
This is a famous problem known as Gull's Lighthouse, from an example by Gull in 1988. It has deep implications when taken one additional step in both the social sciences and in physics. You actually have enough information to solve this problem through acceptance-rejection testing, but if you want to use MCMC feel free. Let's look at your problem another way, knowing that the Lighthouse is 100 m from shore is actually a lot of information. That piece is a big deal, otherwise you would have to solve both distance and location. As a side note, the Cauchy distribution is 636 semi-interquartile ranges wide at 99.99% HDR so if you were looking for narrow intervals, you can almost forget it. If you use a normal approximation, however, it will never converge as this problem violates the central limit theorem and if you estimate $\sigma$ as standard deviation then if $n$ is sample size then $s^2\to\infty$ as $n\to\infty$. If you did that, your estimates would get worse and worse as you added date points. You need to note that you are observing the set $\{x_i,i\in{1\dots{n}}\}$ and there is some point $\mu$ where the lighthouse would be perpendicular to the beach. Note that it is not the positioning of the $x_i$ which are uniformly distributed, but rather the angle, $\theta$. We did not observe the angle, only the set of points. The relationship of the points to the angle is $$\frac{x_i-\mu}{100}=\tan\theta.$$ In terms of the angle, this can be expressed as $$\theta=\tan^{-1}\left(\frac{x_i-\mu}{100}\right)$$ Since $$p(x_i|\mu,100)=p(\theta|\mu,100)|\frac{\mathrm{d}\theta}{\mathrm{d}x_i}|$$ and $\theta$ is uniform over the region $(-\pi/2,\pi/2)$ we know that $$p(x_i|\mu,100)=\frac{1}{\pi}|\frac{\mathrm{d}\theta}{\mathrm{d}x_i}|,$$ which is $$p(x_i|\mu,100)=\frac{1}{\pi}\frac{100}{100^2+(x_i-\mu)^2}.$$ So, by Bayes theorem, if the shore point perpendicular to the lighthouse is $(\mu,0)$, then the lighthouse is located at $(\mu,100)$. The estimator of this point, since you have no prior information on $\mu$ is $$p(\mu|x_1\dots{x_n},100)\propto\prod_{i=1}^n\frac{1}{\pi}\frac{100}{100^2+(x_i-\mu)^2},\forall\mu\in\Re.$$ If you want to make the problem more interesting, assume you do not know that the location is one hundred meters from shore. Your problem them becomes the two dimensional problem more suited to stan. Your problem then becomes $$p(\mu,\gamma|x_1\dots{x_n})\propto\prod_{i=1}^n\frac{1}{\pi}\frac{\gamma}{\gamma^2+(x_i-\mu)^2},\forall\mu\in\Re;\gamma\in\Re^{++}.$$ As a side note, this problem is related to the also famous Witch of Agnesi, studied by Maria Agnesi and published in 1748 and the more basic problem studied by Fermat and Grandi in 1703. She had included it in the very first true calculus textbook. It provided students an education from algebra through integral and differential equations.
Bayesian lighthouse location estimation
This is a famous problem known as Gull's Lighthouse, from an example by Gull in 1988. It has deep implications when taken one additional step in both the social sciences and in physics. You actually
Bayesian lighthouse location estimation This is a famous problem known as Gull's Lighthouse, from an example by Gull in 1988. It has deep implications when taken one additional step in both the social sciences and in physics. You actually have enough information to solve this problem through acceptance-rejection testing, but if you want to use MCMC feel free. Let's look at your problem another way, knowing that the Lighthouse is 100 m from shore is actually a lot of information. That piece is a big deal, otherwise you would have to solve both distance and location. As a side note, the Cauchy distribution is 636 semi-interquartile ranges wide at 99.99% HDR so if you were looking for narrow intervals, you can almost forget it. If you use a normal approximation, however, it will never converge as this problem violates the central limit theorem and if you estimate $\sigma$ as standard deviation then if $n$ is sample size then $s^2\to\infty$ as $n\to\infty$. If you did that, your estimates would get worse and worse as you added date points. You need to note that you are observing the set $\{x_i,i\in{1\dots{n}}\}$ and there is some point $\mu$ where the lighthouse would be perpendicular to the beach. Note that it is not the positioning of the $x_i$ which are uniformly distributed, but rather the angle, $\theta$. We did not observe the angle, only the set of points. The relationship of the points to the angle is $$\frac{x_i-\mu}{100}=\tan\theta.$$ In terms of the angle, this can be expressed as $$\theta=\tan^{-1}\left(\frac{x_i-\mu}{100}\right)$$ Since $$p(x_i|\mu,100)=p(\theta|\mu,100)|\frac{\mathrm{d}\theta}{\mathrm{d}x_i}|$$ and $\theta$ is uniform over the region $(-\pi/2,\pi/2)$ we know that $$p(x_i|\mu,100)=\frac{1}{\pi}|\frac{\mathrm{d}\theta}{\mathrm{d}x_i}|,$$ which is $$p(x_i|\mu,100)=\frac{1}{\pi}\frac{100}{100^2+(x_i-\mu)^2}.$$ So, by Bayes theorem, if the shore point perpendicular to the lighthouse is $(\mu,0)$, then the lighthouse is located at $(\mu,100)$. The estimator of this point, since you have no prior information on $\mu$ is $$p(\mu|x_1\dots{x_n},100)\propto\prod_{i=1}^n\frac{1}{\pi}\frac{100}{100^2+(x_i-\mu)^2},\forall\mu\in\Re.$$ If you want to make the problem more interesting, assume you do not know that the location is one hundred meters from shore. Your problem them becomes the two dimensional problem more suited to stan. Your problem then becomes $$p(\mu,\gamma|x_1\dots{x_n})\propto\prod_{i=1}^n\frac{1}{\pi}\frac{\gamma}{\gamma^2+(x_i-\mu)^2},\forall\mu\in\Re;\gamma\in\Re^{++}.$$ As a side note, this problem is related to the also famous Witch of Agnesi, studied by Maria Agnesi and published in 1748 and the more basic problem studied by Fermat and Grandi in 1703. She had included it in the very first true calculus textbook. It provided students an education from algebra through integral and differential equations.
Bayesian lighthouse location estimation This is a famous problem known as Gull's Lighthouse, from an example by Gull in 1988. It has deep implications when taken one additional step in both the social sciences and in physics. You actually
31,276
Bayesian lighthouse location estimation
The flashes' positions are modeled precisely by the Cauchy, as @user25459 said, so it's no coincidence that Stan is able to estimate the true values using this model (I use $\alpha$ for $\mu$, and $\beta$ for $\gamma$): model <- ' data { int<lower=0> N; real x_[N]; } parameters { real alpha; real<lower=0> beta; } model { alpha ~ uniform(0, 20); beta ~ uniform(0, 50); for (k in 1:N) { x_[k] ~ cauchy(alpha, beta); } } ' Let's try this in Stan: alpha <- 10 # unknown true values beta <- 30 ################## set.seed(123) N <- 100 theta_k <- runif(N,-pi/2,pi/2) x_k <- beta * tan(theta_k) + alpha stan_input <- list(x_=x_k, N=N) fit <- stan(model_code=model, data=stan_input, iter=1000, verbose=FALSE) fit2 <- stan(fit=fit, data=stan_input, iter=5000, warmup=2000, verbose=FALSE) print(fit2, pars=c("alpha", "beta")) Get us: Inference for Stan model: 36eef3c3637fb3a9564529926f8463fe. 4 chains, each with iter=5000; warmup=2000; thin=1; post-warmup draws per chain=3000, total post-warmup draws=12000. mean se_mean sd 2.5% 25% 50% 75% 97.5% n_eff Rhat alpha 8.96 0.05 3.91 1.61 6.13 8.95 11.68 16.80 7079 1 beta 30.29 0.05 4.18 22.84 27.45 29.98 32.88 39.18 8470 1 Samples were drawn using NUTS(diag_e) at Wed Jan 11 18:28:57 2017. For each parameter, n_eff is a crude measure of effective sample size, and Rhat is the potential scale reduction factor on split chains (at convergence, Rhat=1). Let's plot one of the samples: la <- extract(fit2) alpha_hats <- as.numeric(la$alpha) # vertical line is true value About the angles, notice that $$\theta_k = \arctan \frac{x_k - \alpha}{\beta}$$ Each $\theta_k$ is a function of two random vars, so is itself a random var. To find the empirical distribution of angle $\theta_k$ we use the random samples of $\alpha$ and $\beta$. theta_1 <- atan((x_k[1] - alpha_hats)/beta_hats) hist(theta_1, breaks=100, xlab=bquote(theta[1]), ylab="", main="Distribution for 1st angle", yaxt='n')
Bayesian lighthouse location estimation
The flashes' positions are modeled precisely by the Cauchy, as @user25459 said, so it's no coincidence that Stan is able to estimate the true values using this model (I use $\alpha$ for $\mu$, and $\b
Bayesian lighthouse location estimation The flashes' positions are modeled precisely by the Cauchy, as @user25459 said, so it's no coincidence that Stan is able to estimate the true values using this model (I use $\alpha$ for $\mu$, and $\beta$ for $\gamma$): model <- ' data { int<lower=0> N; real x_[N]; } parameters { real alpha; real<lower=0> beta; } model { alpha ~ uniform(0, 20); beta ~ uniform(0, 50); for (k in 1:N) { x_[k] ~ cauchy(alpha, beta); } } ' Let's try this in Stan: alpha <- 10 # unknown true values beta <- 30 ################## set.seed(123) N <- 100 theta_k <- runif(N,-pi/2,pi/2) x_k <- beta * tan(theta_k) + alpha stan_input <- list(x_=x_k, N=N) fit <- stan(model_code=model, data=stan_input, iter=1000, verbose=FALSE) fit2 <- stan(fit=fit, data=stan_input, iter=5000, warmup=2000, verbose=FALSE) print(fit2, pars=c("alpha", "beta")) Get us: Inference for Stan model: 36eef3c3637fb3a9564529926f8463fe. 4 chains, each with iter=5000; warmup=2000; thin=1; post-warmup draws per chain=3000, total post-warmup draws=12000. mean se_mean sd 2.5% 25% 50% 75% 97.5% n_eff Rhat alpha 8.96 0.05 3.91 1.61 6.13 8.95 11.68 16.80 7079 1 beta 30.29 0.05 4.18 22.84 27.45 29.98 32.88 39.18 8470 1 Samples were drawn using NUTS(diag_e) at Wed Jan 11 18:28:57 2017. For each parameter, n_eff is a crude measure of effective sample size, and Rhat is the potential scale reduction factor on split chains (at convergence, Rhat=1). Let's plot one of the samples: la <- extract(fit2) alpha_hats <- as.numeric(la$alpha) # vertical line is true value About the angles, notice that $$\theta_k = \arctan \frac{x_k - \alpha}{\beta}$$ Each $\theta_k$ is a function of two random vars, so is itself a random var. To find the empirical distribution of angle $\theta_k$ we use the random samples of $\alpha$ and $\beta$. theta_1 <- atan((x_k[1] - alpha_hats)/beta_hats) hist(theta_1, breaks=100, xlab=bquote(theta[1]), ylab="", main="Distribution for 1st angle", yaxt='n')
Bayesian lighthouse location estimation The flashes' positions are modeled precisely by the Cauchy, as @user25459 said, so it's no coincidence that Stan is able to estimate the true values using this model (I use $\alpha$ for $\mu$, and $\b
31,277
How should I approach this binary prediction problem?
First, I would see if the doctors agree with each other. You can't analyze 50 doctors separately, because you'll overfit the model - one doctor will look great, by chance. You might try to combine confidence and diagnosis into a 10 point scale. If a doctors says that the patient doesn't have cancer, and they are very confident, that's a 0. If the doc says they do have cancer and they are very confident, that's a 9. If they doc says they don't, and are not confident, that's a 5, etc. When you're trying to predict, you do some sort of regression analysis, but thinking about the causal ordering of these variables, it's the other way around. Whether the patient has cancer is the cause of the diagnosis, the outcome is the diagnosis. Your rows should be patients, and your columns should be doctors. You now have a situation that's common in psychometrics (which is why I added the tag). Then look at the relationships between the scores. Each patient has a mean score, and a score from each doctor. Does the mean score correlate positively with every doctor's score? If not, that doctor is probably not trustworthy (this is called the item-total correlation). Sometimes you remove one doctor from the total score (or mean score) and see if that doctor correlates with the mean of all the other doctors - this is the corrected item total correlation. You could calculate Cronbach's alpha (which is a form of intra-class correlation), and the alpha without each doctor. Alpha should always rise when you add a doctor, so if it rises when you remove a doctor, that doctor's rating is suspect (this doesn't often tell you anything different from the corrected item-total correlation). If you use R, this sort of thing is available in the psych package, using the function alpha. If you use Stata, the command is alpha, in SAS it's proc corr, and in SPSS it's under scale, reliability. Then you can calculate a score, as the mean score from each doctor, or the weighted mean (weighted by the correlation) and see if that score is predictive of the true diagnosis. Or you could skip that stage, and regress each doctor's score on diagnosis separately, and treat the regression parameters as weights. Feel free to ask for clarification, and if you want a book, I like Streiner and Norman's "Health Measurement Scales". -Edit: based on OPs additional info. Wow, that's a heck of a Cronbach's alpha. The only time I've seen it that high is when a mistake was made. I would now do logistic regression and look at the ROC curves. The difference between weighting by regression and correlation depends on how you believe the doctors are responding. Some docs might be generally more confident (without being more skillful), and hence they might use the extreme ranges more. If you want to correct for that, using correlation, rather than regression, does that. I would probably weight by regression, as this keeps the original data (and doesn't discard any information). Edit (2): I ran logistic regression models in R to see how well each predicted the output. tl/dr: there's nothing between them. Here's my code: d <- read.csv("Copy of Cancer data - Weightings.csv") mrc <- glm(cancer ~ weightrc, data = d, family = "binomial") mun <- glm(cancer ~ unweight, data = d, family = "binomial") mca <- glm(cancer ~ weightca, data = d, family = "binomial") mic <- glm(cancer ~ weightic, data = d, family = "binomial") d$prc <- predict(mrc, type = "response") d$pun <- predict(mun, type = "response") d$pca <- predict(mca, type = "response") d$pic <- predict(mic, type = "response") par(mfrow = c(2, 2)) roc(d$cancer, d$prc, ci = TRUE, plot = TRUE) roc(d$cancer, d$pun, ci = TRUE, plot = TRUE) roc(d$cancer, d$pca, ci = TRUE, plot = TRUE) roc(d$cancer, d$pic, ci = TRUE, plot = TRUE) And the output: > par(mfrow = c(2, 2)) > roc(d$cancer, d$prc, ci = TRUE, plot = TRUE) Call: roc.default(response = d$cancer, predictor = d$prc, ci = TRUE, plot = TRUE) Data: d$prc in 81 controls (d$cancer 0) < 27 cases (d$cancer 1). Area under the curve: 0.9831 95% CI: 0.9637-1 (DeLong) > roc(d$cancer, d$pun, ci = TRUE, plot = TRUE) Call: roc.default(response = d$cancer, predictor = d$pun, ci = TRUE, plot = TRUE) Data: d$pun in 81 controls (d$cancer 0) < 27 cases (d$cancer 1). Area under the curve: 0.9808 95% CI: 0.9602-1 (DeLong) > roc(d$cancer, d$pca, ci = TRUE, plot = TRUE) Call: roc.default(response = d$cancer, predictor = d$pca, ci = TRUE, plot = TRUE) Data: d$pca in 81 controls (d$cancer 0) < 27 cases (d$cancer 1). Area under the curve: 0.9854 95% CI: 0.9688-1 (DeLong) > roc(d$cancer, d$pic, ci = TRUE, plot = TRUE) Call: roc.default(response = d$cancer, predictor = d$pic, ci = TRUE, plot = TRUE) Data: d$pic in 81 controls (d$cancer 0) < 27 cases (d$cancer 1). Area under the curve: 0.9822 95% CI: 0.9623-1 (DeLong)
How should I approach this binary prediction problem?
First, I would see if the doctors agree with each other. You can't analyze 50 doctors separately, because you'll overfit the model - one doctor will look great, by chance. You might try to combine co
How should I approach this binary prediction problem? First, I would see if the doctors agree with each other. You can't analyze 50 doctors separately, because you'll overfit the model - one doctor will look great, by chance. You might try to combine confidence and diagnosis into a 10 point scale. If a doctors says that the patient doesn't have cancer, and they are very confident, that's a 0. If the doc says they do have cancer and they are very confident, that's a 9. If they doc says they don't, and are not confident, that's a 5, etc. When you're trying to predict, you do some sort of regression analysis, but thinking about the causal ordering of these variables, it's the other way around. Whether the patient has cancer is the cause of the diagnosis, the outcome is the diagnosis. Your rows should be patients, and your columns should be doctors. You now have a situation that's common in psychometrics (which is why I added the tag). Then look at the relationships between the scores. Each patient has a mean score, and a score from each doctor. Does the mean score correlate positively with every doctor's score? If not, that doctor is probably not trustworthy (this is called the item-total correlation). Sometimes you remove one doctor from the total score (or mean score) and see if that doctor correlates with the mean of all the other doctors - this is the corrected item total correlation. You could calculate Cronbach's alpha (which is a form of intra-class correlation), and the alpha without each doctor. Alpha should always rise when you add a doctor, so if it rises when you remove a doctor, that doctor's rating is suspect (this doesn't often tell you anything different from the corrected item-total correlation). If you use R, this sort of thing is available in the psych package, using the function alpha. If you use Stata, the command is alpha, in SAS it's proc corr, and in SPSS it's under scale, reliability. Then you can calculate a score, as the mean score from each doctor, or the weighted mean (weighted by the correlation) and see if that score is predictive of the true diagnosis. Or you could skip that stage, and regress each doctor's score on diagnosis separately, and treat the regression parameters as weights. Feel free to ask for clarification, and if you want a book, I like Streiner and Norman's "Health Measurement Scales". -Edit: based on OPs additional info. Wow, that's a heck of a Cronbach's alpha. The only time I've seen it that high is when a mistake was made. I would now do logistic regression and look at the ROC curves. The difference between weighting by regression and correlation depends on how you believe the doctors are responding. Some docs might be generally more confident (without being more skillful), and hence they might use the extreme ranges more. If you want to correct for that, using correlation, rather than regression, does that. I would probably weight by regression, as this keeps the original data (and doesn't discard any information). Edit (2): I ran logistic regression models in R to see how well each predicted the output. tl/dr: there's nothing between them. Here's my code: d <- read.csv("Copy of Cancer data - Weightings.csv") mrc <- glm(cancer ~ weightrc, data = d, family = "binomial") mun <- glm(cancer ~ unweight, data = d, family = "binomial") mca <- glm(cancer ~ weightca, data = d, family = "binomial") mic <- glm(cancer ~ weightic, data = d, family = "binomial") d$prc <- predict(mrc, type = "response") d$pun <- predict(mun, type = "response") d$pca <- predict(mca, type = "response") d$pic <- predict(mic, type = "response") par(mfrow = c(2, 2)) roc(d$cancer, d$prc, ci = TRUE, plot = TRUE) roc(d$cancer, d$pun, ci = TRUE, plot = TRUE) roc(d$cancer, d$pca, ci = TRUE, plot = TRUE) roc(d$cancer, d$pic, ci = TRUE, plot = TRUE) And the output: > par(mfrow = c(2, 2)) > roc(d$cancer, d$prc, ci = TRUE, plot = TRUE) Call: roc.default(response = d$cancer, predictor = d$prc, ci = TRUE, plot = TRUE) Data: d$prc in 81 controls (d$cancer 0) < 27 cases (d$cancer 1). Area under the curve: 0.9831 95% CI: 0.9637-1 (DeLong) > roc(d$cancer, d$pun, ci = TRUE, plot = TRUE) Call: roc.default(response = d$cancer, predictor = d$pun, ci = TRUE, plot = TRUE) Data: d$pun in 81 controls (d$cancer 0) < 27 cases (d$cancer 1). Area under the curve: 0.9808 95% CI: 0.9602-1 (DeLong) > roc(d$cancer, d$pca, ci = TRUE, plot = TRUE) Call: roc.default(response = d$cancer, predictor = d$pca, ci = TRUE, plot = TRUE) Data: d$pca in 81 controls (d$cancer 0) < 27 cases (d$cancer 1). Area under the curve: 0.9854 95% CI: 0.9688-1 (DeLong) > roc(d$cancer, d$pic, ci = TRUE, plot = TRUE) Call: roc.default(response = d$cancer, predictor = d$pic, ci = TRUE, plot = TRUE) Data: d$pic in 81 controls (d$cancer 0) < 27 cases (d$cancer 1). Area under the curve: 0.9822 95% CI: 0.9623-1 (DeLong)
How should I approach this binary prediction problem? First, I would see if the doctors agree with each other. You can't analyze 50 doctors separately, because you'll overfit the model - one doctor will look great, by chance. You might try to combine co
31,278
How should I approach this binary prediction problem?
Two out-of-the-box suggestions: You can use weights on the loss function of your logistic regression, so that the doctor who is very certain that the patient has cancer with P=1 gets double the impact has another who says he has cancer with P=0.75. Do not forget to properly transform your probabilities into weights. A family of models often neglected are ranking models. Within rankers there are three big groups: listwise, pointwise and pairwise ranking, depending on what your input is. It sounds like you could use pointwise ranking in your case.
How should I approach this binary prediction problem?
Two out-of-the-box suggestions: You can use weights on the loss function of your logistic regression, so that the doctor who is very certain that the patient has cancer with P=1 gets double the impac
How should I approach this binary prediction problem? Two out-of-the-box suggestions: You can use weights on the loss function of your logistic regression, so that the doctor who is very certain that the patient has cancer with P=1 gets double the impact has another who says he has cancer with P=0.75. Do not forget to properly transform your probabilities into weights. A family of models often neglected are ranking models. Within rankers there are three big groups: listwise, pointwise and pairwise ranking, depending on what your input is. It sounds like you could use pointwise ranking in your case.
How should I approach this binary prediction problem? Two out-of-the-box suggestions: You can use weights on the loss function of your logistic regression, so that the doctor who is very certain that the patient has cancer with P=1 gets double the impac
31,279
How should I approach this binary prediction problem?
(This is out of my area of expertise, so the answer by Jeremy Miles may be more reliable.) Here is one idea. First, imagine there is no confidence level. Then for each patient $i=1\ldots{N}$, they either have cancer or not $c_i\in\{0,1\}$, and each doctor $j=1\ldots{m}$ either diagnosed them with cancer or not, $d_{ij}\in\{0,1\}$. A simple approach is to assume that, while the doctors may agree or disagree on a given patient's diagnosis, if we know the patient's true status, then each doctor's diagnosis can be treated as independent. That is, the $d_{ij}$ are conditionally independent given $c_i$. This results in a well defined classifier known as Naive Bayes, with parameters that are easy to estimate. In particular, the primary parameters are the base rate, $p[c]\approx\tfrac{1}{N}\sum_ic_i$, and the conditional diagnosis likelihoods $$p\big[d_j|c\big]\approx\frac{\sum_id_{ij}c_i}{\sum_ic_i}$$ Note that this latter parameter is a weighted average of the diagnoses for doctor $j$, where the weights are the true patient conditions $c_i$. Now if this model is reasonable, then one way to incorporate the confidence levels is to adjust the weights. Then the conditional likelihoods would become $$p\big[d_j|c,w_j\big]\approx\frac{\sum_id_{ij}w_{ij}c_i}{\sum_iw_{ij}c_i}$$ Here $w_{ij}\geq{0}$ is a weight that accounts for the confidence level of $d_{ij}$. Note that if your weights are cast as probabilities $w\in[0,1]$, then you can use the "Bernoulli shortcut" formula $$p\big[d\mid{w}\big]=d^w(1-d)^{1-w}$$ to account for the $d=0$ case appropriately. Note: This requires that your software give 0^0=1 rather than 0^0=NaN, which is common but worth checking! Alternatively you can ensure $w\in(0,1)$, e.g. if confidence is $k\in\{1\ldots{K}\}$ then $w=k/(K+1)$ would work.
How should I approach this binary prediction problem?
(This is out of my area of expertise, so the answer by Jeremy Miles may be more reliable.) Here is one idea. First, imagine there is no confidence level. Then for each patient $i=1\ldots{N}$, they eit
How should I approach this binary prediction problem? (This is out of my area of expertise, so the answer by Jeremy Miles may be more reliable.) Here is one idea. First, imagine there is no confidence level. Then for each patient $i=1\ldots{N}$, they either have cancer or not $c_i\in\{0,1\}$, and each doctor $j=1\ldots{m}$ either diagnosed them with cancer or not, $d_{ij}\in\{0,1\}$. A simple approach is to assume that, while the doctors may agree or disagree on a given patient's diagnosis, if we know the patient's true status, then each doctor's diagnosis can be treated as independent. That is, the $d_{ij}$ are conditionally independent given $c_i$. This results in a well defined classifier known as Naive Bayes, with parameters that are easy to estimate. In particular, the primary parameters are the base rate, $p[c]\approx\tfrac{1}{N}\sum_ic_i$, and the conditional diagnosis likelihoods $$p\big[d_j|c\big]\approx\frac{\sum_id_{ij}c_i}{\sum_ic_i}$$ Note that this latter parameter is a weighted average of the diagnoses for doctor $j$, where the weights are the true patient conditions $c_i$. Now if this model is reasonable, then one way to incorporate the confidence levels is to adjust the weights. Then the conditional likelihoods would become $$p\big[d_j|c,w_j\big]\approx\frac{\sum_id_{ij}w_{ij}c_i}{\sum_iw_{ij}c_i}$$ Here $w_{ij}\geq{0}$ is a weight that accounts for the confidence level of $d_{ij}$. Note that if your weights are cast as probabilities $w\in[0,1]$, then you can use the "Bernoulli shortcut" formula $$p\big[d\mid{w}\big]=d^w(1-d)^{1-w}$$ to account for the $d=0$ case appropriately. Note: This requires that your software give 0^0=1 rather than 0^0=NaN, which is common but worth checking! Alternatively you can ensure $w\in(0,1)$, e.g. if confidence is $k\in\{1\ldots{K}\}$ then $w=k/(K+1)$ would work.
How should I approach this binary prediction problem? (This is out of my area of expertise, so the answer by Jeremy Miles may be more reliable.) Here is one idea. First, imagine there is no confidence level. Then for each patient $i=1\ldots{N}$, they eit
31,280
How should I approach this binary prediction problem?
From your question, it appears that what you want to test is your measurement system. In the process engineering realm, this would be an attribute measurement system analysis or MSA. This link provides some useful information on the sample size needed and the calculations run to conduct a study of this type. https://www.isixsigma.com/tools-templates/measurement-systems-analysis-msa-gage-rr/making-sense-attribute-gage-rr-calculations/ With this study, you would also need the doctor to diagnose the same patient with the same information at least twice. You can conduct this study one of two ways. You can use the simple cancer/no cancer rating to determine the agreement between physicians and by each physician. Ideally, they should also be able to diagnose with the same level of confidence. You can then use the full 10 point scale to test agreement between and by each physician. (Everyone should agree that cancer (5) is the same rating, that no cancer (1) is the same rating, &c.) The calculations in the linked website are simple to conduct in any platform you may be using for your tests.
How should I approach this binary prediction problem?
From your question, it appears that what you want to test is your measurement system. In the process engineering realm, this would be an attribute measurement system analysis or MSA. This link provi
How should I approach this binary prediction problem? From your question, it appears that what you want to test is your measurement system. In the process engineering realm, this would be an attribute measurement system analysis or MSA. This link provides some useful information on the sample size needed and the calculations run to conduct a study of this type. https://www.isixsigma.com/tools-templates/measurement-systems-analysis-msa-gage-rr/making-sense-attribute-gage-rr-calculations/ With this study, you would also need the doctor to diagnose the same patient with the same information at least twice. You can conduct this study one of two ways. You can use the simple cancer/no cancer rating to determine the agreement between physicians and by each physician. Ideally, they should also be able to diagnose with the same level of confidence. You can then use the full 10 point scale to test agreement between and by each physician. (Everyone should agree that cancer (5) is the same rating, that no cancer (1) is the same rating, &c.) The calculations in the linked website are simple to conduct in any platform you may be using for your tests.
How should I approach this binary prediction problem? From your question, it appears that what you want to test is your measurement system. In the process engineering realm, this would be an attribute measurement system analysis or MSA. This link provi
31,281
What does "def" above an equals sign mean?
The "def" can be read as "definition", "is defined" or "is defined to be". See for example Wikipedia, in the last sentence of this section (just before the subsection labelled "Science"): https://en.wikipedia.org/wiki/Triple_bar#Mathematics_and_philosophy which says (the first sentence refers to the triple bar symbol, but the second sentence talks about what you ask about): This symbol is also sometimes used in place of an equal sign for equations that define the symbol on the left-hand side of the equation, to contrast them with equations in which the terms on both sides of the equation were already defined.[13] An alternative notation for this usage is to typeset the letters "def" above an ordinary equality sign.[14] I think the actual definition of $\sigma^2_n$ and $\mu_n$ follow equation 17 in 19 and 24. See $(19)$ just under the part you quote, which defines $\sigma^2_n$ via $\frac{1}{\sigma^2_n}=\frac{1}{\sigma^2_0}+\frac{n}{\sigma^2}$. But isn't (19) derived by matching coefficients of (16) and (17)? Essentially, yes -- but Murphy is sort of putting the cart before the horse; he's sort of saying "I know how it is going to look like this, so here's what the variance and mean terms in it must be". Which if you've done these things a lot makes sense. It's actually no harder to derive it directly though, and even though the terms may differ from one problem to another, the structure of the solution is of the same form.] (17) explicitly states that it's definition, but really that is where the term-matching takes place and the definition of the symbol $\sigma^2_n$ is then made explicit in (18) and (19) and $\mu_n$ in the following equations (down to (24)). I regard (19) and (24) as the definitions of the new symbols introduced in (17). (17) is saying "when we complete the square, we collect the terms that represent the posterior variance and call that thing $\sigma^2_n$". (18) and (19) then simply explicitly state what those terms are (i.e. defines them) from simple inspection of (16). Outlining the derivation more directly: at (16), having collected the terms in $\mu^2$, $\mu$ and $\mu^0$, you have in the exponent something of the form $-\frac12(A\mu^2-2B\mu + C)$, at that point you can write it as $-\frac12 A[(\mu-B/A)^2] -\frac12[C-B^2/A]$ which (ignoring the constants at the end for the present) is by inspection a normal distribution with mean $B/A$ and variance $1/A$. That manipulation is called "completing the square" (write it out in smaller steps to see in detail what happens). He's just calling the $B/A$ (i.e. posterior mean) term "$\mu_n$" and the $1/A$ (posterior variance) term "$\sigma^2_n$" in order to have symbols to write down instead of writing the formulas every time -- and then writes out what that means in terms of what $B/A$ and $1/A$ consist of in the original setup.
What does "def" above an equals sign mean?
The "def" can be read as "definition", "is defined" or "is defined to be". See for example Wikipedia, in the last sentence of this section (just before the subsection labelled "Science"): https://en.w
What does "def" above an equals sign mean? The "def" can be read as "definition", "is defined" or "is defined to be". See for example Wikipedia, in the last sentence of this section (just before the subsection labelled "Science"): https://en.wikipedia.org/wiki/Triple_bar#Mathematics_and_philosophy which says (the first sentence refers to the triple bar symbol, but the second sentence talks about what you ask about): This symbol is also sometimes used in place of an equal sign for equations that define the symbol on the left-hand side of the equation, to contrast them with equations in which the terms on both sides of the equation were already defined.[13] An alternative notation for this usage is to typeset the letters "def" above an ordinary equality sign.[14] I think the actual definition of $\sigma^2_n$ and $\mu_n$ follow equation 17 in 19 and 24. See $(19)$ just under the part you quote, which defines $\sigma^2_n$ via $\frac{1}{\sigma^2_n}=\frac{1}{\sigma^2_0}+\frac{n}{\sigma^2}$. But isn't (19) derived by matching coefficients of (16) and (17)? Essentially, yes -- but Murphy is sort of putting the cart before the horse; he's sort of saying "I know how it is going to look like this, so here's what the variance and mean terms in it must be". Which if you've done these things a lot makes sense. It's actually no harder to derive it directly though, and even though the terms may differ from one problem to another, the structure of the solution is of the same form.] (17) explicitly states that it's definition, but really that is where the term-matching takes place and the definition of the symbol $\sigma^2_n$ is then made explicit in (18) and (19) and $\mu_n$ in the following equations (down to (24)). I regard (19) and (24) as the definitions of the new symbols introduced in (17). (17) is saying "when we complete the square, we collect the terms that represent the posterior variance and call that thing $\sigma^2_n$". (18) and (19) then simply explicitly state what those terms are (i.e. defines them) from simple inspection of (16). Outlining the derivation more directly: at (16), having collected the terms in $\mu^2$, $\mu$ and $\mu^0$, you have in the exponent something of the form $-\frac12(A\mu^2-2B\mu + C)$, at that point you can write it as $-\frac12 A[(\mu-B/A)^2] -\frac12[C-B^2/A]$ which (ignoring the constants at the end for the present) is by inspection a normal distribution with mean $B/A$ and variance $1/A$. That manipulation is called "completing the square" (write it out in smaller steps to see in detail what happens). He's just calling the $B/A$ (i.e. posterior mean) term "$\mu_n$" and the $1/A$ (posterior variance) term "$\sigma^2_n$" in order to have symbols to write down instead of writing the formulas every time -- and then writes out what that means in terms of what $B/A$ and $1/A$ consist of in the original setup.
What does "def" above an equals sign mean? The "def" can be read as "definition", "is defined" or "is defined to be". See for example Wikipedia, in the last sentence of this section (just before the subsection labelled "Science"): https://en.w
31,282
Effect size in GLMM
1) Is the z-value similar to the effect size? No, it is a Wald statistic to test the null hypothesis that the estimate is zero. 2) If not, how can I obtain the effect size for each variable? Since this is a generalized linear mixed model, you can't calculate effect sizes such as cohen's d, but since it is a logistic model with a logit link you can report odds ratios as effect sizes. The raw coefficients are on the log-odds scale, so to calculate the odds ratios, these are just exponentiated.
Effect size in GLMM
1) Is the z-value similar to the effect size? No, it is a Wald statistic to test the null hypothesis that the estimate is zero. 2) If not, how can I obtain the effect size for each variable? Since
Effect size in GLMM 1) Is the z-value similar to the effect size? No, it is a Wald statistic to test the null hypothesis that the estimate is zero. 2) If not, how can I obtain the effect size for each variable? Since this is a generalized linear mixed model, you can't calculate effect sizes such as cohen's d, but since it is a logistic model with a logit link you can report odds ratios as effect sizes. The raw coefficients are on the log-odds scale, so to calculate the odds ratios, these are just exponentiated.
Effect size in GLMM 1) Is the z-value similar to the effect size? No, it is a Wald statistic to test the null hypothesis that the estimate is zero. 2) If not, how can I obtain the effect size for each variable? Since
31,283
Effect size in GLMM
Want to improve this post? Provide detailed answers to this question, including citations and an explanation of why your answer is correct. Answers without enough detail may be edited or deleted. Here is for your second question. A new function has recently been added to the package emmeans to calculate effect sizes (Cohen´s d). To use it, you will need the GLMM adjusted, the Sigma, and the df. But, you need a trick to calculate the Sigma from a Mixed Model. Let me copy here a part of the information you can find at: https://rdrr.io/cran/emmeans/man/eff_size.html Oats.lme <- lme(yield ~ Variety + factor(nitro), random = ~ 1 | Block / Variety, data = Oats) VarCorr(Oats.lme) # Combine variance estimates totSD <- sqrt(214.4724 + 109.6931 + 162.5590); emmV <- emmeans(Oats.lme, ~ Variety); print(eff_size(emmV, sigma = totSD, edf = 5)); print(eff_size(emmV, sigma = totSD, edf = 51)
Effect size in GLMM
Want to improve this post? Provide detailed answers to this question, including citations and an explanation of why your answer is correct. Answers without enough detail may be edited or deleted.
Effect size in GLMM Want to improve this post? Provide detailed answers to this question, including citations and an explanation of why your answer is correct. Answers without enough detail may be edited or deleted. Here is for your second question. A new function has recently been added to the package emmeans to calculate effect sizes (Cohen´s d). To use it, you will need the GLMM adjusted, the Sigma, and the df. But, you need a trick to calculate the Sigma from a Mixed Model. Let me copy here a part of the information you can find at: https://rdrr.io/cran/emmeans/man/eff_size.html Oats.lme <- lme(yield ~ Variety + factor(nitro), random = ~ 1 | Block / Variety, data = Oats) VarCorr(Oats.lme) # Combine variance estimates totSD <- sqrt(214.4724 + 109.6931 + 162.5590); emmV <- emmeans(Oats.lme, ~ Variety); print(eff_size(emmV, sigma = totSD, edf = 5)); print(eff_size(emmV, sigma = totSD, edf = 51)
Effect size in GLMM Want to improve this post? Provide detailed answers to this question, including citations and an explanation of why your answer is correct. Answers without enough detail may be edited or deleted.
31,284
Consequences of exceeding sample size after determination of sample in power analysis
the danger occurs that "everything becomes significant" (even minor, practically irrelevant effects). This is not an argument against large sample sizes, it's a direct argument against hypothesis testing for your particular problem. If you have a problem rejecting for small effect sizes don't use ordinary hypothesis tests. It may be that you need an equivalence test (or perhaps a noninferiority test). It may be that you need an interval estimate of the effect size (i.e. a confidence interval). It may be that you need something else. This also relates to Position 3. If you have a notion of a "relevant effect" you should not be using ordinary hypothesis tests. If your position is not that more power is better, stop using those hypothesis tests. It's not the correct tool for that job.
Consequences of exceeding sample size after determination of sample in power analysis
the danger occurs that "everything becomes significant" (even minor, practically irrelevant effects). This is not an argument against large sample sizes, it's a direct argument against hypothesis te
Consequences of exceeding sample size after determination of sample in power analysis the danger occurs that "everything becomes significant" (even minor, practically irrelevant effects). This is not an argument against large sample sizes, it's a direct argument against hypothesis testing for your particular problem. If you have a problem rejecting for small effect sizes don't use ordinary hypothesis tests. It may be that you need an equivalence test (or perhaps a noninferiority test). It may be that you need an interval estimate of the effect size (i.e. a confidence interval). It may be that you need something else. This also relates to Position 3. If you have a notion of a "relevant effect" you should not be using ordinary hypothesis tests. If your position is not that more power is better, stop using those hypothesis tests. It's not the correct tool for that job.
Consequences of exceeding sample size after determination of sample in power analysis the danger occurs that "everything becomes significant" (even minor, practically irrelevant effects). This is not an argument against large sample sizes, it's a direct argument against hypothesis te
31,285
How do regression results change after standardization, as a general rule?
This method is called beta coefficients (at least by Wooldridge). We compute the Z-scores of all variables, and then run the regression on the transformed data. Now what happens? The slopes are different: before we had a slope of say $\hat \beta_1$, but now we have a slope of $\hat \sigma_1 /\hat \sigma_y \cdot \hat \beta_1$, where $\hat \sigma_i$ is the sample standard deviation. There is no intercept; or rather it will be estimated as very (very) close to 0. Hence the change in p-value of the intercept you mentioned. The interpretation of $\hat \beta_i$ is now: what happens with y, when we increase the standard deviation of $x_i$ by 1. In a sense, we can say something about the most "important" variable (but I dislike that word). One final note: just as you you stated, the p-values are not going to be different and so you will always have the same significance as before.
How do regression results change after standardization, as a general rule?
This method is called beta coefficients (at least by Wooldridge). We compute the Z-scores of all variables, and then run the regression on the transformed data. Now what happens? The slopes are differ
How do regression results change after standardization, as a general rule? This method is called beta coefficients (at least by Wooldridge). We compute the Z-scores of all variables, and then run the regression on the transformed data. Now what happens? The slopes are different: before we had a slope of say $\hat \beta_1$, but now we have a slope of $\hat \sigma_1 /\hat \sigma_y \cdot \hat \beta_1$, where $\hat \sigma_i$ is the sample standard deviation. There is no intercept; or rather it will be estimated as very (very) close to 0. Hence the change in p-value of the intercept you mentioned. The interpretation of $\hat \beta_i$ is now: what happens with y, when we increase the standard deviation of $x_i$ by 1. In a sense, we can say something about the most "important" variable (but I dislike that word). One final note: just as you you stated, the p-values are not going to be different and so you will always have the same significance as before.
How do regression results change after standardization, as a general rule? This method is called beta coefficients (at least by Wooldridge). We compute the Z-scores of all variables, and then run the regression on the transformed data. Now what happens? The slopes are differ
31,286
How do regression results change after standardization, as a general rule?
Yes, they are general for OLS. Let me take the example of a simple regression. We know the slope coefficient is $$ \hat\beta_1=\frac{\sum_i(x_i-\bar{x})(y_i-\bar{y})}{\sum_i(x_i-\bar{x})^2} $$ or $$ \hat\beta_1=\frac{\widehat{Cov}(y_i,x_i)}{\widehat{Var}(x_i)} $$ and the intercept estimate is $$ \hat\beta_0=\bar y-\hat\beta_1\bar x. $$ Standardizing yields $\bar x=\bar y=0$ and $\widehat{Var}(x_i)=\widehat{Var}(y_i)=1$. Hence, $$ \hat\beta_1=\widehat{Cov}(y_i,x_i)=\widehat{Corr}(y_i,x_i) $$ and $$ \hat\beta_0=0. $$ The standard errors are the square roots of the diagonal elements of $s^2(X'X)^{-1}$, e.g., $s.e.(\hat\beta_1)=s/(\sum_i(x_i-\bar{x})^2)^{1/2}$. In the scaled case, this standard error then becomes $$\tilde s/(n-1)^{1/2},$$ where $\tilde s$ is the square root of the error variance estimate of the scaled regression. We get $n-1$ in the denominator because $\widehat{Var}(x_i)=1/(n-1)\sum_i(x_i-\bar{x})^2=1$, so $\sum_i(x_i-\bar{x})^2=n-1$. Hence, the standard errors are different. The $t$-ratios are nevertheless the same. For the unscaled case, write \begin{align*} t&=\frac{\hat{\beta_1}}{s.e.(\hat\beta_1)}\\ &=\frac{\frac{\widehat{Cov}(y_i,x_i)}{\widehat{Var}(x_i)}}{s/(\sum_i(x_i-\bar{x})^2)^{1/2}}\\ &=\frac{\frac{\widehat{Cov}(y_i,x_i)}{\widehat{Var}(x_i)}}{s/((n-1)^{1/2}sd(x))}\\ &=(n-1)^{1/2}\frac{\widehat{Cov}(y_i,x_i)sd(x)}{s\widehat{Var}(x_i)}\\ &=(n-1)^{1/2}\frac{\widehat{Corr}(y_i,x_i)\widehat{Var}(x_i)sd(y)}{s\widehat{Var}(x_i)}\\ &=(n-1)^{1/2}\frac{\widehat{Corr}(y_i,x_i)sd(y)}{s}, \end{align*} where the 5th equality follows from rearranging $$ \widehat{Corr}(y_i,x_i)=\frac{\widehat{Cov}(x_i,y_i)}{sd(x)sd(y)} $$ For the unscaled case, write \begin{align*} \tilde t&=\frac{\widehat{Corr}(y_i,x_i)}{\frac{\tilde s}{(n-1)^{1/2}}}\\ \end{align*} An application of the Frisch Waugh Lovell theorem will demonstrate that scaling the regressor does nothing to the residuals. Scaling $y$, however, gives residuals $\tilde u_i$ which are related to the unscaled ones $\hat u_i$ via $\tilde u_i=\hat u_i/sd(y)$. Hence, $\tilde s=s/sd(y)$. Thus, \begin{align*} \tilde t&=\frac{(n-1)^{1/2}\widehat{Corr}(y_i,x_i)}{\frac{s}{sd(y)}}\\ &=\frac{(n-1)^{1/2}\widehat{Corr}(y_i,x_i)sd(y)}{s}=t\\ \end{align*} If the test statistics are the same, so will of course the p-values. That the standard error on the intercept is different follows from the fact that the scaled intercept is estimated to be zero very precisely. P.S.: scale achieves the goals of your function, too.
How do regression results change after standardization, as a general rule?
Yes, they are general for OLS. Let me take the example of a simple regression. We know the slope coefficient is $$ \hat\beta_1=\frac{\sum_i(x_i-\bar{x})(y_i-\bar{y})}{\sum_i(x_i-\bar{x})^2} $$ or $$ \
How do regression results change after standardization, as a general rule? Yes, they are general for OLS. Let me take the example of a simple regression. We know the slope coefficient is $$ \hat\beta_1=\frac{\sum_i(x_i-\bar{x})(y_i-\bar{y})}{\sum_i(x_i-\bar{x})^2} $$ or $$ \hat\beta_1=\frac{\widehat{Cov}(y_i,x_i)}{\widehat{Var}(x_i)} $$ and the intercept estimate is $$ \hat\beta_0=\bar y-\hat\beta_1\bar x. $$ Standardizing yields $\bar x=\bar y=0$ and $\widehat{Var}(x_i)=\widehat{Var}(y_i)=1$. Hence, $$ \hat\beta_1=\widehat{Cov}(y_i,x_i)=\widehat{Corr}(y_i,x_i) $$ and $$ \hat\beta_0=0. $$ The standard errors are the square roots of the diagonal elements of $s^2(X'X)^{-1}$, e.g., $s.e.(\hat\beta_1)=s/(\sum_i(x_i-\bar{x})^2)^{1/2}$. In the scaled case, this standard error then becomes $$\tilde s/(n-1)^{1/2},$$ where $\tilde s$ is the square root of the error variance estimate of the scaled regression. We get $n-1$ in the denominator because $\widehat{Var}(x_i)=1/(n-1)\sum_i(x_i-\bar{x})^2=1$, so $\sum_i(x_i-\bar{x})^2=n-1$. Hence, the standard errors are different. The $t$-ratios are nevertheless the same. For the unscaled case, write \begin{align*} t&=\frac{\hat{\beta_1}}{s.e.(\hat\beta_1)}\\ &=\frac{\frac{\widehat{Cov}(y_i,x_i)}{\widehat{Var}(x_i)}}{s/(\sum_i(x_i-\bar{x})^2)^{1/2}}\\ &=\frac{\frac{\widehat{Cov}(y_i,x_i)}{\widehat{Var}(x_i)}}{s/((n-1)^{1/2}sd(x))}\\ &=(n-1)^{1/2}\frac{\widehat{Cov}(y_i,x_i)sd(x)}{s\widehat{Var}(x_i)}\\ &=(n-1)^{1/2}\frac{\widehat{Corr}(y_i,x_i)\widehat{Var}(x_i)sd(y)}{s\widehat{Var}(x_i)}\\ &=(n-1)^{1/2}\frac{\widehat{Corr}(y_i,x_i)sd(y)}{s}, \end{align*} where the 5th equality follows from rearranging $$ \widehat{Corr}(y_i,x_i)=\frac{\widehat{Cov}(x_i,y_i)}{sd(x)sd(y)} $$ For the unscaled case, write \begin{align*} \tilde t&=\frac{\widehat{Corr}(y_i,x_i)}{\frac{\tilde s}{(n-1)^{1/2}}}\\ \end{align*} An application of the Frisch Waugh Lovell theorem will demonstrate that scaling the regressor does nothing to the residuals. Scaling $y$, however, gives residuals $\tilde u_i$ which are related to the unscaled ones $\hat u_i$ via $\tilde u_i=\hat u_i/sd(y)$. Hence, $\tilde s=s/sd(y)$. Thus, \begin{align*} \tilde t&=\frac{(n-1)^{1/2}\widehat{Corr}(y_i,x_i)}{\frac{s}{sd(y)}}\\ &=\frac{(n-1)^{1/2}\widehat{Corr}(y_i,x_i)sd(y)}{s}=t\\ \end{align*} If the test statistics are the same, so will of course the p-values. That the standard error on the intercept is different follows from the fact that the scaled intercept is estimated to be zero very precisely. P.S.: scale achieves the goals of your function, too.
How do regression results change after standardization, as a general rule? Yes, they are general for OLS. Let me take the example of a simple regression. We know the slope coefficient is $$ \hat\beta_1=\frac{\sum_i(x_i-\bar{x})(y_i-\bar{y})}{\sum_i(x_i-\bar{x})^2} $$ or $$ \
31,287
Can binary data be ordinal?
Two is a paltry number, barely plural, & a two-point scale left to its own devices needs only to distinguish before it can put its feet up: it's otiose to muse on whether equal intervals or equal ratios are meaningful when there's only a single interval or ratio to consider, or on whether ranking is meaningful when there's only one sequence a pair can have; all the operations you might want to perform on the data are unaffected by its representation, as @Tim has explained. It's only for the external relations of a binary variable that these things matter at all. The Jaccard index is a measure of similarity between two individuals each having several attributes represented by binary variables; you calculate the ratio of the number of attributes for which both have "1" to the number of attributes for which either have "1". Clearly the coding as "0" & "1" isn't arbitrary here (though we could swap it round for all variables at once & make a corresponding change to the calculation of the Jaccard index). This is the situation in which @ttnphns talks of "ordinal dichotomous variables", which seems fair enough. An example can be found in Faith et al. (2013), "The long-term stability of the human gut microbiota", Science, 341, 6141, where the Jaccard index is used to measure the similarity of the make-up of an individual's gut flora at different time points—the ratio of the number of bacterial strains in common over the total number of strains found. The choice of metric seems sensible—why take into account all the different strains absent at both time points? could an exhaustive list even be compiled? A more hum-drum example might be found in the various ways variables are often combined into indices, scores, or whatever; to serve as, say, descriptive statistics, or predictors in regression. To calculate the Charlson comorbidity index you add up dichotomous variables that indicate conditions such as myocardial infarct & congestive heart failure. Many conditions are coded with "0" & "1"; but as hemilplegia contributes 2, & malignant tumor 6, to the total score, I'm tempted to propose these as interval-scale dichotomous variables. Needless to say, how you align different binary scales in these kinds of situations depends on making decisions appropriate for the job at hand rather than somehow intuiting the true nature of each individual scale—an attribute coded "1" for the calculation of one Jaccard index might be coded "0" for the calculation of another. The paragraph above exemplifies something that's always the case with this business of scale types. Stevens points out various relationships between which features of how you represent data need to be considered meaningful & the kinds of operations you perform during your analysis: Scales are possible in the first place only because there is a certain isomorphism between what we can do with the aspects of objects and the properties of the numeral series. In dealing with the aspects of objects we invoke empirical operations for determining equality (classifying), for rank-ordering, and for determining when differences and when ratios between the aspects of objects are equal. The conventional series of numerals yields to analogous operations: we can identify the members of a numeral series and classify them. We know their order as given by convention. We can determine equal differences, as $8-6=4-2$, and equal ratios, as $\frac{8}{4}=\frac{6}{3}$. The isomorphism between these properties of the numeral series and certain empirical operations which we perform with objects permits the use of the series as a model to represent aspects of the empirical world. This is an instance of an important general principle: you don't want arbitrary or conventional decisions about how to write things down to materially affect your conclusions. The type of scale achieved depends upon the character of the basic empirical operations performed. These operations are limited ordinarily by the nature of the thing being scaled and by our choice of procedures, but, once selected, the operations determine that there will eventuate one or another of the scales listed in Table 1.1 [nominal, ordinal, interval, & ratio]. So you can't, for example, average scores on a five-point scale and claim that the interval between scale points doesn't matter: something's got to give (& note that it may well be the claim rather than the averaging—see e.g. here). It's a mistake to confuse this prohibition with the stipulation that first you need to determine the true scale type & then think about suitable methods of analysis. See Should types of data (nominal/ordinal/interval/ratio) really be considered types of variables?.
Can binary data be ordinal?
Two is a paltry number, barely plural, & a two-point scale left to its own devices needs only to distinguish before it can put its feet up: it's otiose to muse on whether equal intervals or equal rati
Can binary data be ordinal? Two is a paltry number, barely plural, & a two-point scale left to its own devices needs only to distinguish before it can put its feet up: it's otiose to muse on whether equal intervals or equal ratios are meaningful when there's only a single interval or ratio to consider, or on whether ranking is meaningful when there's only one sequence a pair can have; all the operations you might want to perform on the data are unaffected by its representation, as @Tim has explained. It's only for the external relations of a binary variable that these things matter at all. The Jaccard index is a measure of similarity between two individuals each having several attributes represented by binary variables; you calculate the ratio of the number of attributes for which both have "1" to the number of attributes for which either have "1". Clearly the coding as "0" & "1" isn't arbitrary here (though we could swap it round for all variables at once & make a corresponding change to the calculation of the Jaccard index). This is the situation in which @ttnphns talks of "ordinal dichotomous variables", which seems fair enough. An example can be found in Faith et al. (2013), "The long-term stability of the human gut microbiota", Science, 341, 6141, where the Jaccard index is used to measure the similarity of the make-up of an individual's gut flora at different time points—the ratio of the number of bacterial strains in common over the total number of strains found. The choice of metric seems sensible—why take into account all the different strains absent at both time points? could an exhaustive list even be compiled? A more hum-drum example might be found in the various ways variables are often combined into indices, scores, or whatever; to serve as, say, descriptive statistics, or predictors in regression. To calculate the Charlson comorbidity index you add up dichotomous variables that indicate conditions such as myocardial infarct & congestive heart failure. Many conditions are coded with "0" & "1"; but as hemilplegia contributes 2, & malignant tumor 6, to the total score, I'm tempted to propose these as interval-scale dichotomous variables. Needless to say, how you align different binary scales in these kinds of situations depends on making decisions appropriate for the job at hand rather than somehow intuiting the true nature of each individual scale—an attribute coded "1" for the calculation of one Jaccard index might be coded "0" for the calculation of another. The paragraph above exemplifies something that's always the case with this business of scale types. Stevens points out various relationships between which features of how you represent data need to be considered meaningful & the kinds of operations you perform during your analysis: Scales are possible in the first place only because there is a certain isomorphism between what we can do with the aspects of objects and the properties of the numeral series. In dealing with the aspects of objects we invoke empirical operations for determining equality (classifying), for rank-ordering, and for determining when differences and when ratios between the aspects of objects are equal. The conventional series of numerals yields to analogous operations: we can identify the members of a numeral series and classify them. We know their order as given by convention. We can determine equal differences, as $8-6=4-2$, and equal ratios, as $\frac{8}{4}=\frac{6}{3}$. The isomorphism between these properties of the numeral series and certain empirical operations which we perform with objects permits the use of the series as a model to represent aspects of the empirical world. This is an instance of an important general principle: you don't want arbitrary or conventional decisions about how to write things down to materially affect your conclusions. The type of scale achieved depends upon the character of the basic empirical operations performed. These operations are limited ordinarily by the nature of the thing being scaled and by our choice of procedures, but, once selected, the operations determine that there will eventuate one or another of the scales listed in Table 1.1 [nominal, ordinal, interval, & ratio]. So you can't, for example, average scores on a five-point scale and claim that the interval between scale points doesn't matter: something's got to give (& note that it may well be the claim rather than the averaging—see e.g. here). It's a mistake to confuse this prohibition with the stipulation that first you need to determine the true scale type & then think about suitable methods of analysis. See Should types of data (nominal/ordinal/interval/ratio) really be considered types of variables?.
Can binary data be ordinal? Two is a paltry number, barely plural, & a two-point scale left to its own devices needs only to distinguish before it can put its feet up: it's otiose to muse on whether equal intervals or equal rati
31,288
Can binary data be ordinal?
The general idea of ordinal data is that there is some order or gradation of different categories and exact numerical quantity of a particular value has no significance beyond its ability to establish a ranking over a set of data points (https://en.wikipedia.org/wiki/Ordinal_data) With ordinal data your categories are ordered, e.g. $a < b < c$, so you are interested in the relations between categories, $a < b$ and $b < c$, so $a < c$. In this case ordering matters and if you re-assigned the labels in random order you would loose important information. With binary data you have only two categories so knowing that $x > y$ provides you with the same information as knowing that $\neg(x^* < y^*)$, where $x^*$ and $y^*$ are $x$ and $y$ with reversed coding. In this case one category is compliment of another so their ordering does not matter. For example, with changing the labels in logistic regression you just get reversed signs of coefficients and this is what we expect, for more see the recent question on logistic regression (check @Scortchi's comment for the linked question). On the other hand, as @ttnphns noticed, there are similarity measures that make assumptions about coding of binary categories, like Jaccard index and in these cases it makes a difference how the categories are coded. Coding of the categories (e.g. as $0$ and $1$ or $-1$ and $+1$) in many cases could also make interpretation of the results easier (positive or negative influence). In both cases the difference concerns rather with coding of the variables rather than with information they carry.
Can binary data be ordinal?
The general idea of ordinal data is that there is some order or gradation of different categories and exact numerical quantity of a particular value has no significance beyond its ability to establ
Can binary data be ordinal? The general idea of ordinal data is that there is some order or gradation of different categories and exact numerical quantity of a particular value has no significance beyond its ability to establish a ranking over a set of data points (https://en.wikipedia.org/wiki/Ordinal_data) With ordinal data your categories are ordered, e.g. $a < b < c$, so you are interested in the relations between categories, $a < b$ and $b < c$, so $a < c$. In this case ordering matters and if you re-assigned the labels in random order you would loose important information. With binary data you have only two categories so knowing that $x > y$ provides you with the same information as knowing that $\neg(x^* < y^*)$, where $x^*$ and $y^*$ are $x$ and $y$ with reversed coding. In this case one category is compliment of another so their ordering does not matter. For example, with changing the labels in logistic regression you just get reversed signs of coefficients and this is what we expect, for more see the recent question on logistic regression (check @Scortchi's comment for the linked question). On the other hand, as @ttnphns noticed, there are similarity measures that make assumptions about coding of binary categories, like Jaccard index and in these cases it makes a difference how the categories are coded. Coding of the categories (e.g. as $0$ and $1$ or $-1$ and $+1$) in many cases could also make interpretation of the results easier (positive or negative influence). In both cases the difference concerns rather with coding of the variables rather than with information they carry.
Can binary data be ordinal? The general idea of ordinal data is that there is some order or gradation of different categories and exact numerical quantity of a particular value has no significance beyond its ability to establ
31,289
Citation for Statistical test for difference between two odds ratios?
From your two logistic regression models, you should have parameter estimates, $\hat\beta_{11}$ and $\hat\beta_{12}$ (where the second subscript refers to the model), and their standard errors. Note that these are on the scale of the log odds and that this is better—there is no need to convert them to odds ratios. If your $N$s are sufficient, these will be normally distributed, as @ssdecontrol explained. The Wald tests that come standard with logistic regression output assume they are normally distributed, for example. In addition, since they came from different models with different data, we can treat them as independent. If you want to test if they are equal, this is simply testing a linear combination of normally distributed parameter estimates, which is a pretty standard thing to do. You can calculate a test statistic as follows: $$ Z = \frac{\hat\beta_{12}-\hat\beta_{11}}{\sqrt{SE(\hat\beta_{12})^2 + SE(\hat\beta_{11})^2}} $$ The resulting $Z$ statistic can be compared to a standard normal distribution to compute the $p$-value. The quote about confidence intervals is somewhat heuristic in nature (even though correct). You should not try to use that to calculate significance.
Citation for Statistical test for difference between two odds ratios?
From your two logistic regression models, you should have parameter estimates, $\hat\beta_{11}$ and $\hat\beta_{12}$ (where the second subscript refers to the model), and their standard errors. Note
Citation for Statistical test for difference between two odds ratios? From your two logistic regression models, you should have parameter estimates, $\hat\beta_{11}$ and $\hat\beta_{12}$ (where the second subscript refers to the model), and their standard errors. Note that these are on the scale of the log odds and that this is better—there is no need to convert them to odds ratios. If your $N$s are sufficient, these will be normally distributed, as @ssdecontrol explained. The Wald tests that come standard with logistic regression output assume they are normally distributed, for example. In addition, since they came from different models with different data, we can treat them as independent. If you want to test if they are equal, this is simply testing a linear combination of normally distributed parameter estimates, which is a pretty standard thing to do. You can calculate a test statistic as follows: $$ Z = \frac{\hat\beta_{12}-\hat\beta_{11}}{\sqrt{SE(\hat\beta_{12})^2 + SE(\hat\beta_{11})^2}} $$ The resulting $Z$ statistic can be compared to a standard normal distribution to compute the $p$-value. The quote about confidence intervals is somewhat heuristic in nature (even though correct). You should not try to use that to calculate significance.
Citation for Statistical test for difference between two odds ratios? From your two logistic regression models, you should have parameter estimates, $\hat\beta_{11}$ and $\hat\beta_{12}$ (where the second subscript refers to the model), and their standard errors. Note
31,290
Citation for Statistical test for difference between two odds ratios?
Odds ratios are asymptotically Gaussian. Therefore their difference, as long as they are independent, is also asymptotically Gaussian, because the linear combination of independent Gaussian r.v.s is itself Gaussian. These are both fairly well-known and shouldn't require a citation. But just for assurance, both of those links are based on "authoritative" sources.
Citation for Statistical test for difference between two odds ratios?
Odds ratios are asymptotically Gaussian. Therefore their difference, as long as they are independent, is also asymptotically Gaussian, because the linear combination of independent Gaussian r.v.s is i
Citation for Statistical test for difference between two odds ratios? Odds ratios are asymptotically Gaussian. Therefore their difference, as long as they are independent, is also asymptotically Gaussian, because the linear combination of independent Gaussian r.v.s is itself Gaussian. These are both fairly well-known and shouldn't require a citation. But just for assurance, both of those links are based on "authoritative" sources.
Citation for Statistical test for difference between two odds ratios? Odds ratios are asymptotically Gaussian. Therefore their difference, as long as they are independent, is also asymptotically Gaussian, because the linear combination of independent Gaussian r.v.s is i
31,291
Understanding cluster plot and component variability
These are the first two principal components (see Principal component analysis, PCA). There is a huge amount of information on PCA on this site, including the encyclopedic thread, and, for you, this is my simple explanation. Because data may be multivariate it may be tedious to inspect all the many bivariate scatterplots. Instead, a single "summarising" scatterplot is more convenient, the scatterplot of the first two (or possibly the first three) principal components which were derived from the data. "48.76% of variability" says that, with your data, almost half of the information about the multivariate data is captured by this plot of components 1 and 2. If you add the 3rd component - by adding the 3rd axis or by means of a bubble scatterplot - the percent of explained variability will be higher, and you might find, perhaps, that the two clusters on the right do not mix and are more nearly separate in the space. While typically you can expect that a 1-2 or 1-2-3 component scatterplot will demonstrate clusters as separate (if there are any), there is no rule or guarantee that this will happen. Sometimes clusters appear distinct only in high dimensions capturing a small portion of variability, that is, in "weak" components. I would recommend you read these and other posts of this site: 1, 2, 3. You should also be aware that principal components can be quite different when PCA is based on unscaled variability ("on covariances") and on uniscaled variability ("on correlations").
Understanding cluster plot and component variability
These are the first two principal components (see Principal component analysis, PCA). There is a huge amount of information on PCA on this site, including the encyclopedic thread, and, for you, this i
Understanding cluster plot and component variability These are the first two principal components (see Principal component analysis, PCA). There is a huge amount of information on PCA on this site, including the encyclopedic thread, and, for you, this is my simple explanation. Because data may be multivariate it may be tedious to inspect all the many bivariate scatterplots. Instead, a single "summarising" scatterplot is more convenient, the scatterplot of the first two (or possibly the first three) principal components which were derived from the data. "48.76% of variability" says that, with your data, almost half of the information about the multivariate data is captured by this plot of components 1 and 2. If you add the 3rd component - by adding the 3rd axis or by means of a bubble scatterplot - the percent of explained variability will be higher, and you might find, perhaps, that the two clusters on the right do not mix and are more nearly separate in the space. While typically you can expect that a 1-2 or 1-2-3 component scatterplot will demonstrate clusters as separate (if there are any), there is no rule or guarantee that this will happen. Sometimes clusters appear distinct only in high dimensions capturing a small portion of variability, that is, in "weak" components. I would recommend you read these and other posts of this site: 1, 2, 3. You should also be aware that principal components can be quite different when PCA is based on unscaled variability ("on covariances") and on uniscaled variability ("on correlations").
Understanding cluster plot and component variability These are the first two principal components (see Principal component analysis, PCA). There is a huge amount of information on PCA on this site, including the encyclopedic thread, and, for you, this i
31,292
Why is variance (instead of standard deviation) the default measure of information content in principal components?
Reporting standard deviations instead of variances I think you are right in that standard deviation of each PC can perhaps be a more reasonable or a more intuitive (for some) measure of its "influence" than its variance. And actually it even has a clear mathematical interpretation: variances of PCs are eigenvalues of the covariance matrix, but standard deviations are singular values of the centered data matrix [only scaled by $1/\sqrt{n-1}$]. So yes, it is completely fine to report it. Moreover, e.g. R does report standard deviations of PCs rather than their variances. For example running this simple code: irispca <- princomp(iris[-5]) summary(irispca) results in this: Importance of components: Comp.1 Comp.2 Comp.3 Comp.4 Standard deviation 2.0494032 0.49097143 0.27872586 0.153870700 Proportion of Variance 0.9246187 0.05306648 0.01710261 0.005212184 Cumulative Proportion 0.9246187 0.97768521 0.99478782 1.000000000 There are standard deviations here, but not variances. Explained variance A PC that contains 95% of the data variance might contain only 80% of the variation in the data as measured in standard deviations: isn't the latter a better descriptor? However, note that after presenting standard deviations, R does not display a "proportion of standard deviation", but instead a proportion of variance. And there is a very good reason for that. Mathematically, total variance (being a trace of covariance matrix) is preserved under rotations. This means that the sum of variance of original variables is equal to the sum of variances of PCs. In case of the same Fisher Iris dataset, this sum is equal to $4.57$, and so we can say that PC1, having a variance of $2.05^2=4.20$ explains $92\%$ of the total variance. But the sum of standard deviations is not preserved! The sum of standard deviations of original variables is $3.79$. The sum of standard deviations of PCs is $2.98$. They are not equal! So if you want to say that PC1 with standard deviation $2.05$ explains $x\%$ of the "total standard deviation", what would you take as this total? There is no answer, because it simply does not make sense. The bottom line is that it is completely fine to look at the standard deviation of each PC and even compare them between each other, but if you want to talk about "explained" something, then only "explained variance" makes sense.
Why is variance (instead of standard deviation) the default measure of information content in princi
Reporting standard deviations instead of variances I think you are right in that standard deviation of each PC can perhaps be a more reasonable or a more intuitive (for some) measure of its "influence
Why is variance (instead of standard deviation) the default measure of information content in principal components? Reporting standard deviations instead of variances I think you are right in that standard deviation of each PC can perhaps be a more reasonable or a more intuitive (for some) measure of its "influence" than its variance. And actually it even has a clear mathematical interpretation: variances of PCs are eigenvalues of the covariance matrix, but standard deviations are singular values of the centered data matrix [only scaled by $1/\sqrt{n-1}$]. So yes, it is completely fine to report it. Moreover, e.g. R does report standard deviations of PCs rather than their variances. For example running this simple code: irispca <- princomp(iris[-5]) summary(irispca) results in this: Importance of components: Comp.1 Comp.2 Comp.3 Comp.4 Standard deviation 2.0494032 0.49097143 0.27872586 0.153870700 Proportion of Variance 0.9246187 0.05306648 0.01710261 0.005212184 Cumulative Proportion 0.9246187 0.97768521 0.99478782 1.000000000 There are standard deviations here, but not variances. Explained variance A PC that contains 95% of the data variance might contain only 80% of the variation in the data as measured in standard deviations: isn't the latter a better descriptor? However, note that after presenting standard deviations, R does not display a "proportion of standard deviation", but instead a proportion of variance. And there is a very good reason for that. Mathematically, total variance (being a trace of covariance matrix) is preserved under rotations. This means that the sum of variance of original variables is equal to the sum of variances of PCs. In case of the same Fisher Iris dataset, this sum is equal to $4.57$, and so we can say that PC1, having a variance of $2.05^2=4.20$ explains $92\%$ of the total variance. But the sum of standard deviations is not preserved! The sum of standard deviations of original variables is $3.79$. The sum of standard deviations of PCs is $2.98$. They are not equal! So if you want to say that PC1 with standard deviation $2.05$ explains $x\%$ of the "total standard deviation", what would you take as this total? There is no answer, because it simply does not make sense. The bottom line is that it is completely fine to look at the standard deviation of each PC and even compare them between each other, but if you want to talk about "explained" something, then only "explained variance" makes sense.
Why is variance (instead of standard deviation) the default measure of information content in princi Reporting standard deviations instead of variances I think you are right in that standard deviation of each PC can perhaps be a more reasonable or a more intuitive (for some) measure of its "influence
31,293
Linear independence vs statistical independence (PCA and ICA)
This is likely to be a duplicate of some older question(s), but I will briefly answer is nevertheless. For a non-technical explanation, I find quite helpful this figure from the Wikipedia article on Correlation and dependence: The numbers above each scatter plot show correlation coefficients between X and Y. Look at the last row: on each scatter plot the correlation is zero, i.e. X and Y are "linearly independent". However they are obviously not statistically independent: if you know the value of X, you can narrow down the possible values of Y. If X and Y were independent, it would mean that knowing X tells you nothing about Y. The purpose of ICA is to try to find independent components. In PCA you only get uncorrelated ("orthogonal") components; correlation between them is zero but they can very well be statistically dependent.
Linear independence vs statistical independence (PCA and ICA)
This is likely to be a duplicate of some older question(s), but I will briefly answer is nevertheless. For a non-technical explanation, I find quite helpful this figure from the Wikipedia article on C
Linear independence vs statistical independence (PCA and ICA) This is likely to be a duplicate of some older question(s), but I will briefly answer is nevertheless. For a non-technical explanation, I find quite helpful this figure from the Wikipedia article on Correlation and dependence: The numbers above each scatter plot show correlation coefficients between X and Y. Look at the last row: on each scatter plot the correlation is zero, i.e. X and Y are "linearly independent". However they are obviously not statistically independent: if you know the value of X, you can narrow down the possible values of Y. If X and Y were independent, it would mean that knowing X tells you nothing about Y. The purpose of ICA is to try to find independent components. In PCA you only get uncorrelated ("orthogonal") components; correlation between them is zero but they can very well be statistically dependent.
Linear independence vs statistical independence (PCA and ICA) This is likely to be a duplicate of some older question(s), but I will briefly answer is nevertheless. For a non-technical explanation, I find quite helpful this figure from the Wikipedia article on C
31,294
Analyzing up/down patterns in short time-series data
If the series is uncorrelated, unnecessarily taking differences injects auto-correlation . Even if the series is autocorrelated unwarranted differencing is inappropriate. Simple ideas and simple approaches often have unwanted side effects. The model identification process (ARIMA) starts with the original series and may result in differencing BUT it should never starts with unwarranted differencing unless there is a theoretical justification. If you wish you can post your short time series and I will use it to explain to you how to identify a model for this series. After receipt of data: The ACF of your data does not initially (or finally) indicate any ARIMA process here BOTH ACF and PACF and here just ACF: However there appears to be two level shifts in your data ... one at 1972 and the other at 1992 .. they appear to be nearly cancelling level shifts. A useful model might also include the incorporation of three unusual values at periods 1989,1959 and 1983. The equation then is and here with model statistics here: The Actual/Fit and Forecast is here with the residual plot here suggesting model sufficiency . This is confirmed by the acf of the residuals . Finally the fit and the forecast summarizes the findings . In summary the series ( probably a ratio) is without significant auto-regressive memory but does have some evidented deterministic structure (statistically significant). All models are wrong but some are useful (G.E.P. Box) . After some discussion .. If one were to model differences then one would get the following model ... with ACTUAL/FIT and FORECAST . Forecasts look eerily similar ... the MA coefficient effectively cancels the differencing operator.
Analyzing up/down patterns in short time-series data
If the series is uncorrelated, unnecessarily taking differences injects auto-correlation . Even if the series is autocorrelated unwarranted differencing is inappropriate. Simple ideas and simple appro
Analyzing up/down patterns in short time-series data If the series is uncorrelated, unnecessarily taking differences injects auto-correlation . Even if the series is autocorrelated unwarranted differencing is inappropriate. Simple ideas and simple approaches often have unwanted side effects. The model identification process (ARIMA) starts with the original series and may result in differencing BUT it should never starts with unwarranted differencing unless there is a theoretical justification. If you wish you can post your short time series and I will use it to explain to you how to identify a model for this series. After receipt of data: The ACF of your data does not initially (or finally) indicate any ARIMA process here BOTH ACF and PACF and here just ACF: However there appears to be two level shifts in your data ... one at 1972 and the other at 1992 .. they appear to be nearly cancelling level shifts. A useful model might also include the incorporation of three unusual values at periods 1989,1959 and 1983. The equation then is and here with model statistics here: The Actual/Fit and Forecast is here with the residual plot here suggesting model sufficiency . This is confirmed by the acf of the residuals . Finally the fit and the forecast summarizes the findings . In summary the series ( probably a ratio) is without significant auto-regressive memory but does have some evidented deterministic structure (statistically significant). All models are wrong but some are useful (G.E.P. Box) . After some discussion .. If one were to model differences then one would get the following model ... with ACTUAL/FIT and FORECAST . Forecasts look eerily similar ... the MA coefficient effectively cancels the differencing operator.
Analyzing up/down patterns in short time-series data If the series is uncorrelated, unnecessarily taking differences injects auto-correlation . Even if the series is autocorrelated unwarranted differencing is inappropriate. Simple ideas and simple appro
31,295
Analyzing up/down patterns in short time-series data
You can look at the up and downs as a random sequence, which is generated by some random process. For instance, let's assume that you're dealing with a stationary series $x_1,x_2,x_3,...,x_n \in f(x)$, where $f(x)$ is a probability distribution such as Gaussian, Poisson or anything else. This is stationary series. Now, you can create new variable $y_t$ such that $y_t=1:x_t<x_{t+1}$ and $y_t=0:x_t\ge x_{t+1}$, these are your ups and downs. This new sequence will form its own random sequence with interesting properties, see e.g. V Khil, Elena. "Markov properties of gaps between local maxima in a sequence of independent random variables." (2013). For instance, look at ACF and PACF of your series. There's nothing here. This doesn't seem like ARIMA model. It looks like uncorrelated sequence of $x_t$. This means that we could try applying known results for $y_t$, e.g. it's known that the average distance between two (up-down) pairs (or U-turns as some call them) is 3. In your data set the first peak (up-down) is 1957 and the last one is 2012, with 16 peaks in total. So, the average distance between peaks is 15/55=3.67. We know that the $\sigma=1.108$, and with 15 observations $\sigma_{15}=\sigma/\sqrt{15}=0.29$. So the mean distance between peaks is within $1.2\sigma_n$ from the theoretical mean. UPDATE: on cycles The graph in OP's question appears to suggest that there's some kind of long running cycle. There are several issues with this. If you generate a random sequence, sometimes something like a cycle may appear just randomly. So, with 58 data points which are purely observational data, it's impossible to declare a cycle without some kind of economic theory behind it. Nobody's going to take it seriously without the economic reasoning. For that you definitely need exogenous variables, I'm afraid. Check out this wonderful paper: The Summation of Random Causes as the Source of Cyclic Processes, Eugen Slutzky, Econometrica, Vol. 5, No. 2 (Apr., 1937), pp. 105-146. Basically, sometimes cycles are caused by some sort of MA process. This could be an illusion. I use this trick quite often in presentations. I show the actual data, then draw lines, circles or arrows to mess with my audience's brains :) The extra lines trick the brain into seeing trends which may not be there at all, or to make them look much stronger than they actually are.
Analyzing up/down patterns in short time-series data
You can look at the up and downs as a random sequence, which is generated by some random process. For instance, let's assume that you're dealing with a stationary series $x_1,x_2,x_3,...,x_n \in f(x)$
Analyzing up/down patterns in short time-series data You can look at the up and downs as a random sequence, which is generated by some random process. For instance, let's assume that you're dealing with a stationary series $x_1,x_2,x_3,...,x_n \in f(x)$, where $f(x)$ is a probability distribution such as Gaussian, Poisson or anything else. This is stationary series. Now, you can create new variable $y_t$ such that $y_t=1:x_t<x_{t+1}$ and $y_t=0:x_t\ge x_{t+1}$, these are your ups and downs. This new sequence will form its own random sequence with interesting properties, see e.g. V Khil, Elena. "Markov properties of gaps between local maxima in a sequence of independent random variables." (2013). For instance, look at ACF and PACF of your series. There's nothing here. This doesn't seem like ARIMA model. It looks like uncorrelated sequence of $x_t$. This means that we could try applying known results for $y_t$, e.g. it's known that the average distance between two (up-down) pairs (or U-turns as some call them) is 3. In your data set the first peak (up-down) is 1957 and the last one is 2012, with 16 peaks in total. So, the average distance between peaks is 15/55=3.67. We know that the $\sigma=1.108$, and with 15 observations $\sigma_{15}=\sigma/\sqrt{15}=0.29$. So the mean distance between peaks is within $1.2\sigma_n$ from the theoretical mean. UPDATE: on cycles The graph in OP's question appears to suggest that there's some kind of long running cycle. There are several issues with this. If you generate a random sequence, sometimes something like a cycle may appear just randomly. So, with 58 data points which are purely observational data, it's impossible to declare a cycle without some kind of economic theory behind it. Nobody's going to take it seriously without the economic reasoning. For that you definitely need exogenous variables, I'm afraid. Check out this wonderful paper: The Summation of Random Causes as the Source of Cyclic Processes, Eugen Slutzky, Econometrica, Vol. 5, No. 2 (Apr., 1937), pp. 105-146. Basically, sometimes cycles are caused by some sort of MA process. This could be an illusion. I use this trick quite often in presentations. I show the actual data, then draw lines, circles or arrows to mess with my audience's brains :) The extra lines trick the brain into seeing trends which may not be there at all, or to make them look much stronger than they actually are.
Analyzing up/down patterns in short time-series data You can look at the up and downs as a random sequence, which is generated by some random process. For instance, let's assume that you're dealing with a stationary series $x_1,x_2,x_3,...,x_n \in f(x)$
31,296
Analyzing up/down patterns in short time-series data
Aside 1: One thing we see is the appearance of a long cyclical trend in the data. This shouldn't affect the year-on-year analysis all that much* -- so for this very basic analysis I'll ignore that and treat the data as if they were homogeneous aside from the effect you're interested in. *(it will tend to reduce the number of opposite direction movement from what you'd expect with homogeneity -- so it will tend to lower the power of this test somewhat. We could try to quantify that impact, but I don't think there's a strong need unless it seems likely to be big enough to make a difference -- if it's already significant, adjusting for something that would make the p-value a bit smaller would be a waste of effort.) Aside 2: As expressed, your question seems to involve one-tailed alternative. I'll work on the basis that this is what you want. Let's start with a simple analysis directed straight at your basic question, which seems to be along the lines of "is an increase more likely to be followed by a decrease?" However, it's not as simple as it might first appear. In a stable series, with purely random data, an increase is more likely to be followed by a decrease. Note that the hypothesis we're considering involves three observations, which can be ordered in six possible ways: Of those six ways, 4 involve a change in direction. So a purely random series (irrespective of the distribution) should see a flip in direction 2/3 of the time. [This is closely related to a runs-up-and-down test, where you're interested in whether there are too many runs for it to be random. You could use that test instead.] I assume your actual interest is in whether it's higher than the random 2/3 rather than whether it's more than 1/2 as you seemed to be asking. $H_0:$ the series is "random" $H_1:$ a shift up or down is more likely to be followed by a shift in the opposite direction than you'd see with a random series Test statistic: proportion of shifts followed by shifts in the opposite direction. Because our triples overlap, I believe we have some dependence between triples, so we can't treat this as binomial (we could if we split the data into non-overlapping triples; that would work fine). Keeping that dependence in mind, we could still compute the distribution of the test statistic, but we don't need to in this case, because the observed proportion of direction reversed triples is just under the expected number of 2/3 for a random series, and we're only interested in more reversals than that. So we don't need to compute any further -- there's no evidence at all of a tendency to reverse (up-down or down-up) more than you'd get with a random series. [I really doubt the neglected mild cycle will have enough impact to move the expected proportion down anywhere near far enough for this to make a substantive difference.]
Analyzing up/down patterns in short time-series data
Aside 1: One thing we see is the appearance of a long cyclical trend in the data. This shouldn't affect the year-on-year analysis all that much* -- so for this very basic analysis I'll ignore that and
Analyzing up/down patterns in short time-series data Aside 1: One thing we see is the appearance of a long cyclical trend in the data. This shouldn't affect the year-on-year analysis all that much* -- so for this very basic analysis I'll ignore that and treat the data as if they were homogeneous aside from the effect you're interested in. *(it will tend to reduce the number of opposite direction movement from what you'd expect with homogeneity -- so it will tend to lower the power of this test somewhat. We could try to quantify that impact, but I don't think there's a strong need unless it seems likely to be big enough to make a difference -- if it's already significant, adjusting for something that would make the p-value a bit smaller would be a waste of effort.) Aside 2: As expressed, your question seems to involve one-tailed alternative. I'll work on the basis that this is what you want. Let's start with a simple analysis directed straight at your basic question, which seems to be along the lines of "is an increase more likely to be followed by a decrease?" However, it's not as simple as it might first appear. In a stable series, with purely random data, an increase is more likely to be followed by a decrease. Note that the hypothesis we're considering involves three observations, which can be ordered in six possible ways: Of those six ways, 4 involve a change in direction. So a purely random series (irrespective of the distribution) should see a flip in direction 2/3 of the time. [This is closely related to a runs-up-and-down test, where you're interested in whether there are too many runs for it to be random. You could use that test instead.] I assume your actual interest is in whether it's higher than the random 2/3 rather than whether it's more than 1/2 as you seemed to be asking. $H_0:$ the series is "random" $H_1:$ a shift up or down is more likely to be followed by a shift in the opposite direction than you'd see with a random series Test statistic: proportion of shifts followed by shifts in the opposite direction. Because our triples overlap, I believe we have some dependence between triples, so we can't treat this as binomial (we could if we split the data into non-overlapping triples; that would work fine). Keeping that dependence in mind, we could still compute the distribution of the test statistic, but we don't need to in this case, because the observed proportion of direction reversed triples is just under the expected number of 2/3 for a random series, and we're only interested in more reversals than that. So we don't need to compute any further -- there's no evidence at all of a tendency to reverse (up-down or down-up) more than you'd get with a random series. [I really doubt the neglected mild cycle will have enough impact to move the expected proportion down anywhere near far enough for this to make a substantive difference.]
Analyzing up/down patterns in short time-series data Aside 1: One thing we see is the appearance of a long cyclical trend in the data. This shouldn't affect the year-on-year analysis all that much* -- so for this very basic analysis I'll ignore that and
31,297
Analyzing up/down patterns in short time-series data
You could use a package called structural change which checks for breaks or level shifts in the data. I have had some success in automatically detecting level shifts for non-seasonal time series. I converted your "value" into a time series data. and used the following code to check for level shifts or change points or break points. The package also has nice features such as chow test to do chow test to test for structural breaks: require(strucchange) value.ts <- ts(data[,2],frequency = 1, start = (1956)) bp.value <- breakpoints(value.ts ~ 1) summary(bp.value) Following is the summary from the breakpont function: Breakpoints at observation number: m = 1 36 m = 2 16 31 m = 3 16 36 46 m = 4 16 24 36 46 m = 5 8 16 24 36 46 m = 6 8 16 24 33 41 49 Corresponding to breakdates: m = 1 1991 m = 2 1971 1986 m = 3 1971 1991 2001 m = 4 1971 1979 1991 2001 m = 5 1963 1971 1979 1991 2001 m = 6 1963 1971 1979 1988 1996 2004 Fit: m 0 1 2 3 4 5 6 RSS 0.8599316 0.7865981 0.5843395 0.5742085 0.5578739 0.5559645 0.5772778 BIC -71.5402819 -68.5892480 -77.7080112 -70.6015129 -64.1544916 -56.2324540 -45.9296608 As you can see the function identified possible breaks in your data and selected two structural breaks at 1971 and 1986 as shown in the plot below based on BIC criterion. The function also provided other alternative break points as listed in the output above. Hope this is helpful
Analyzing up/down patterns in short time-series data
You could use a package called structural change which checks for breaks or level shifts in the data. I have had some success in automatically detecting level shifts for non-seasonal time series. I co
Analyzing up/down patterns in short time-series data You could use a package called structural change which checks for breaks or level shifts in the data. I have had some success in automatically detecting level shifts for non-seasonal time series. I converted your "value" into a time series data. and used the following code to check for level shifts or change points or break points. The package also has nice features such as chow test to do chow test to test for structural breaks: require(strucchange) value.ts <- ts(data[,2],frequency = 1, start = (1956)) bp.value <- breakpoints(value.ts ~ 1) summary(bp.value) Following is the summary from the breakpont function: Breakpoints at observation number: m = 1 36 m = 2 16 31 m = 3 16 36 46 m = 4 16 24 36 46 m = 5 8 16 24 36 46 m = 6 8 16 24 33 41 49 Corresponding to breakdates: m = 1 1991 m = 2 1971 1986 m = 3 1971 1991 2001 m = 4 1971 1979 1991 2001 m = 5 1963 1971 1979 1991 2001 m = 6 1963 1971 1979 1988 1996 2004 Fit: m 0 1 2 3 4 5 6 RSS 0.8599316 0.7865981 0.5843395 0.5742085 0.5578739 0.5559645 0.5772778 BIC -71.5402819 -68.5892480 -77.7080112 -70.6015129 -64.1544916 -56.2324540 -45.9296608 As you can see the function identified possible breaks in your data and selected two structural breaks at 1971 and 1986 as shown in the plot below based on BIC criterion. The function also provided other alternative break points as listed in the output above. Hope this is helpful
Analyzing up/down patterns in short time-series data You could use a package called structural change which checks for breaks or level shifts in the data. I have had some success in automatically detecting level shifts for non-seasonal time series. I co
31,298
Should auto.arima in R ever report a model with higher AIC, AICC and BIC than other models considered?
auto.arima uses some approximations in order to speed up the processing. The final model is fitted using full MLE, but along the way the models are estimated using CSS unless you use the argument approximation=FALSE. This is explained in the help file: approximation If TRUE, estimation is via conditional sums of squares and the information criteria used for model selection are approximated. The final model is still computed using maximum likelihood estimation. Approximation should be used for long time series or a high seasonal period to avoid excessive computation times. The default setting is approximation=(length(x)>100 | frequency(x)>12), again this is specified in the help file. As you have 17544 observations, the default setting gives approximation=TRUE. Using the approximations, the best model found was a regression with ARIMA(5,1,0) errors with AICc of 2989.33. If you turn the approximations off, the best model has ARIMA(2,1,1) errors with an AICc of 2361.40. > fitauto = auto.arima(reprots[,"lnwocone"], approximation=FALSE, xreg=cbind(fourier(reprots[,"lnwocone"], K=11), reprots[,c("temp","sqt","humidity","windspeed","mist","rain")]), start.p=1, start.q=1, trace=TRUE, seasonal=FALSE) > fitauto Series: reprots[, "lnwocone"] ARIMA(2,1,1) with drift ... sigma^2 estimated as 0.08012: log likelihood=-1147.63 AIC=2361.27 AICc=2361.4 BIC=2617.76
Should auto.arima in R ever report a model with higher AIC, AICC and BIC than other models considere
auto.arima uses some approximations in order to speed up the processing. The final model is fitted using full MLE, but along the way the models are estimated using CSS unless you use the argument appr
Should auto.arima in R ever report a model with higher AIC, AICC and BIC than other models considered? auto.arima uses some approximations in order to speed up the processing. The final model is fitted using full MLE, but along the way the models are estimated using CSS unless you use the argument approximation=FALSE. This is explained in the help file: approximation If TRUE, estimation is via conditional sums of squares and the information criteria used for model selection are approximated. The final model is still computed using maximum likelihood estimation. Approximation should be used for long time series or a high seasonal period to avoid excessive computation times. The default setting is approximation=(length(x)>100 | frequency(x)>12), again this is specified in the help file. As you have 17544 observations, the default setting gives approximation=TRUE. Using the approximations, the best model found was a regression with ARIMA(5,1,0) errors with AICc of 2989.33. If you turn the approximations off, the best model has ARIMA(2,1,1) errors with an AICc of 2361.40. > fitauto = auto.arima(reprots[,"lnwocone"], approximation=FALSE, xreg=cbind(fourier(reprots[,"lnwocone"], K=11), reprots[,c("temp","sqt","humidity","windspeed","mist","rain")]), start.p=1, start.q=1, trace=TRUE, seasonal=FALSE) > fitauto Series: reprots[, "lnwocone"] ARIMA(2,1,1) with drift ... sigma^2 estimated as 0.08012: log likelihood=-1147.63 AIC=2361.27 AICc=2361.4 BIC=2617.76
Should auto.arima in R ever report a model with higher AIC, AICC and BIC than other models considere auto.arima uses some approximations in order to speed up the processing. The final model is fitted using full MLE, but along the way the models are estimated using CSS unless you use the argument appr
31,299
Do I need to have a Master's degree in "Statistics" in order to be qualified as a statistician? [closed]
Technically, no. You can get by with a Bachelor's but keep in mind you are competing with folks who will have a Master's or even Ph.D. The American Statistical Association recently came out with the GStat Certification, which will allow you to certify your bona fides as a new graduate. Statistics is a broad discipline, so you don't necessarily need a "Statistics" degree; you could get Operations Research, Data Analysis, or what you've listed. Experimental Design, Regression, and Multivariate look like a good foundation and would seem to qualify you. Also note that statisticians need some subject-matter knowledge, so it's actually good you are not going into a strictly stats degree program, especially since you have a Bachelor's in it already.
Do I need to have a Master's degree in "Statistics" in order to be qualified as a statistician? [clo
Technically, no. You can get by with a Bachelor's but keep in mind you are competing with folks who will have a Master's or even Ph.D. The American Statistical Association recently came out with the G
Do I need to have a Master's degree in "Statistics" in order to be qualified as a statistician? [closed] Technically, no. You can get by with a Bachelor's but keep in mind you are competing with folks who will have a Master's or even Ph.D. The American Statistical Association recently came out with the GStat Certification, which will allow you to certify your bona fides as a new graduate. Statistics is a broad discipline, so you don't necessarily need a "Statistics" degree; you could get Operations Research, Data Analysis, or what you've listed. Experimental Design, Regression, and Multivariate look like a good foundation and would seem to qualify you. Also note that statisticians need some subject-matter knowledge, so it's actually good you are not going into a strictly stats degree program, especially since you have a Bachelor's in it already.
Do I need to have a Master's degree in "Statistics" in order to be qualified as a statistician? [clo Technically, no. You can get by with a Bachelor's but keep in mind you are competing with folks who will have a Master's or even Ph.D. The American Statistical Association recently came out with the G
31,300
Do I need to have a Master's degree in "Statistics" in order to be qualified as a statistician? [closed]
I would say that to have the actual formal job title of 'Statistician' or 'Data Scientist', usually a Master's or above is required. But to actually perform that type of work with a different title, it is not entirely necessary. In fact, I have found that people from all sorts of backgrounds perform statistical analyses in a work setting (although not necessarily in a correct manner). But indeed many jobs that primarily use statistics every day do usually require a Masters or above (pharmaceutical, quantitative finance, economics, etc.). A lot of it depends on the job and the network you build to get the job. If you can convince someone that you are good enough for the job, then you may be able bypass the educational requirements in the job description. But also keep in mind that some of the reasons that they stress Masters or above (at least based on my experience) is the level of Mathematics and independent research that would be required to work independently in the given position. Good luck!
Do I need to have a Master's degree in "Statistics" in order to be qualified as a statistician? [clo
I would say that to have the actual formal job title of 'Statistician' or 'Data Scientist', usually a Master's or above is required. But to actually perform that type of work with a different title, i
Do I need to have a Master's degree in "Statistics" in order to be qualified as a statistician? [closed] I would say that to have the actual formal job title of 'Statistician' or 'Data Scientist', usually a Master's or above is required. But to actually perform that type of work with a different title, it is not entirely necessary. In fact, I have found that people from all sorts of backgrounds perform statistical analyses in a work setting (although not necessarily in a correct manner). But indeed many jobs that primarily use statistics every day do usually require a Masters or above (pharmaceutical, quantitative finance, economics, etc.). A lot of it depends on the job and the network you build to get the job. If you can convince someone that you are good enough for the job, then you may be able bypass the educational requirements in the job description. But also keep in mind that some of the reasons that they stress Masters or above (at least based on my experience) is the level of Mathematics and independent research that would be required to work independently in the given position. Good luck!
Do I need to have a Master's degree in "Statistics" in order to be qualified as a statistician? [clo I would say that to have the actual formal job title of 'Statistician' or 'Data Scientist', usually a Master's or above is required. But to actually perform that type of work with a different title, i