idx int64 1 56k | question stringlengths 15 155 | answer stringlengths 2 29.2k ⌀ | question_cut stringlengths 15 100 | answer_cut stringlengths 2 200 ⌀ | conversation stringlengths 47 29.3k | conversation_cut stringlengths 47 301 |
|---|---|---|---|---|---|---|
37,101 | What are the consequences of not including random effects in a linear model when they should be added? | There are 2 questions here:
...the population level predictions (based on the fixed effects coefficients) are virtually identical between these two models (standard vs. mixed). Interestingly, however, the Beta coefficients are rather different...
I find this hard to understand. If there are multiple predictors, it might be result of multicollinearity. This can cause different models to produce different coefficients but the same predictions.
...considering that I am interested in making population level predictions, is the negative consequence of failing to include random intercepts when appropriate that the parameter (Beta) estimates and their associated confidence intervals will be biased?
Failing to account for non-independence (whether through random effects or some other method) should at the very least bias estimates of uncertainty. It is also very likely to bias parameter estimates as well. Having an identical number of observations per individual might reduce or eliminate this bias.
Finally, if you are only interested in population level patterns, then you might not want to use mixed models at all. Consider Simpson's paradox: in the image below would you be interested in the positive relationship on the left, or the negative relationship on the right?
Image source: Tim Copeland at https://towardsdatascience.com/what-is-simpsons-paradox-4a53cd4e9ee2
Your choice should guide the analytical approach you take. The mixed model approach would capture the positive relationships on the left. But if you're interested in the pattern on the right, I think a linear model with HAC standard errors (to adjust the estimates of uncertainty) might meet your needs better. | What are the consequences of not including random effects in a linear model when they should be adde | There are 2 questions here:
...the population level predictions (based on the fixed effects coefficients) are virtually identical between these two models (standard vs. mixed). Interestingly, however | What are the consequences of not including random effects in a linear model when they should be added?
There are 2 questions here:
...the population level predictions (based on the fixed effects coefficients) are virtually identical between these two models (standard vs. mixed). Interestingly, however, the Beta coefficients are rather different...
I find this hard to understand. If there are multiple predictors, it might be result of multicollinearity. This can cause different models to produce different coefficients but the same predictions.
...considering that I am interested in making population level predictions, is the negative consequence of failing to include random intercepts when appropriate that the parameter (Beta) estimates and their associated confidence intervals will be biased?
Failing to account for non-independence (whether through random effects or some other method) should at the very least bias estimates of uncertainty. It is also very likely to bias parameter estimates as well. Having an identical number of observations per individual might reduce or eliminate this bias.
Finally, if you are only interested in population level patterns, then you might not want to use mixed models at all. Consider Simpson's paradox: in the image below would you be interested in the positive relationship on the left, or the negative relationship on the right?
Image source: Tim Copeland at https://towardsdatascience.com/what-is-simpsons-paradox-4a53cd4e9ee2
Your choice should guide the analytical approach you take. The mixed model approach would capture the positive relationships on the left. But if you're interested in the pattern on the right, I think a linear model with HAC standard errors (to adjust the estimates of uncertainty) might meet your needs better. | What are the consequences of not including random effects in a linear model when they should be adde
There are 2 questions here:
...the population level predictions (based on the fixed effects coefficients) are virtually identical between these two models (standard vs. mixed). Interestingly, however |
37,102 | Can negative autocorrelation at lags 1 and 2 happen? | The following DGP, an MA($2$) process, has negative autocorrelation at lags 1 and 2:
$$
Y_t=10-.5\cdot u_{t-1}-.25\cdot u_{t-2}+u_t
$$
Here's some R code to simulate the DGP and see the ACF for yourself:
library(stats)
library(forecast) # for the Acf() function
# number of "observations"
n<-500
# initialization periods
j<-1000
# choose parameters
alpha<-10
theta<-c(-.5,-.25)
Q<-length(theta)
# generate iid disturbances
u<-rnorm(n+j,0,2)
# define the DGP and generate data series iteratively
y<-rep(alpha,n+j)
for(k in (Q+1):(n+j)){
y[k]<-alpha + sum(theta*u[k-c(1:Q)]) + u[k]
}
# get rid of the initialization periods
Y<-y[-c(1:j)]
# confirm the parameters
arima(Y,c(0,0,Q))
# Call:
# arima(x = Y, order = c(0, 0, Q))
#
# Coefficients:
# ma1 ma2 intercept
# -0.4763 -0.2546 9.9979
# s.e. 0.0448 0.0485 0.0246
#
# sigma^2 estimated as 4.124: log likelihood = -1064.03, aic = 2134.05
# look at the ACF/PACF
par(mfrow=c(2,1))
Acf(Y)
pacf(Y) | Can negative autocorrelation at lags 1 and 2 happen? | The following DGP, an MA($2$) process, has negative autocorrelation at lags 1 and 2:
$$
Y_t=10-.5\cdot u_{t-1}-.25\cdot u_{t-2}+u_t
$$
Here's some R code to simulate the DGP and see the ACF for yourse | Can negative autocorrelation at lags 1 and 2 happen?
The following DGP, an MA($2$) process, has negative autocorrelation at lags 1 and 2:
$$
Y_t=10-.5\cdot u_{t-1}-.25\cdot u_{t-2}+u_t
$$
Here's some R code to simulate the DGP and see the ACF for yourself:
library(stats)
library(forecast) # for the Acf() function
# number of "observations"
n<-500
# initialization periods
j<-1000
# choose parameters
alpha<-10
theta<-c(-.5,-.25)
Q<-length(theta)
# generate iid disturbances
u<-rnorm(n+j,0,2)
# define the DGP and generate data series iteratively
y<-rep(alpha,n+j)
for(k in (Q+1):(n+j)){
y[k]<-alpha + sum(theta*u[k-c(1:Q)]) + u[k]
}
# get rid of the initialization periods
Y<-y[-c(1:j)]
# confirm the parameters
arima(Y,c(0,0,Q))
# Call:
# arima(x = Y, order = c(0, 0, Q))
#
# Coefficients:
# ma1 ma2 intercept
# -0.4763 -0.2546 9.9979
# s.e. 0.0448 0.0485 0.0246
#
# sigma^2 estimated as 4.124: log likelihood = -1064.03, aic = 2134.05
# look at the ACF/PACF
par(mfrow=c(2,1))
Acf(Y)
pacf(Y) | Can negative autocorrelation at lags 1 and 2 happen?
The following DGP, an MA($2$) process, has negative autocorrelation at lags 1 and 2:
$$
Y_t=10-.5\cdot u_{t-1}-.25\cdot u_{t-2}+u_t
$$
Here's some R code to simulate the DGP and see the ACF for yourse |
37,103 | What's the difference between exogenous variables and independent variables? | An independent variable is defined within the context of a dependent variable. In the context of a model the independent variables are input whereas the dependent variables are the targets (Input vs Output).
An exogenous variable is a variable whose state is independent of the state of other variables in a system.
To my understanding independent variables thus do not need to be exogenous, yet exogenous variables are naturally independent. | What's the difference between exogenous variables and independent variables? | An independent variable is defined within the context of a dependent variable. In the context of a model the independent variables are input whereas the dependent variables are the targets (Input vs O | What's the difference between exogenous variables and independent variables?
An independent variable is defined within the context of a dependent variable. In the context of a model the independent variables are input whereas the dependent variables are the targets (Input vs Output).
An exogenous variable is a variable whose state is independent of the state of other variables in a system.
To my understanding independent variables thus do not need to be exogenous, yet exogenous variables are naturally independent. | What's the difference between exogenous variables and independent variables?
An independent variable is defined within the context of a dependent variable. In the context of a model the independent variables are input whereas the dependent variables are the targets (Input vs O |
37,104 | Regression random forest and highly skewed response distribution | One might argue that this is a classification problem with a small rounding error rather than a regression design. RF is often referred to as resilient in dealing with skewness issues but it is not invincible. In this case, chances are almost none of the positive responses would make it into each small tree being grown, or into the OOB subset against which they are tested.
Inability to correctly predict your responses of interest is likely to be reflected in the overall r2, however, it would not be the most useful descriptor (most easily visualized in a simple linear regression equivalent of an r2 for the relationship between a cloud of zero points and a few outliers). Solutions listed there may still apply to alleviate the problem; however, I would reconsider the design as 1) an unbalanced classification problem and 2) if the subset of positive responses is sufficiently large, treating just the positive responses in the regression mode you are interested in. | Regression random forest and highly skewed response distribution | One might argue that this is a classification problem with a small rounding error rather than a regression design. RF is often referred to as resilient in dealing with skewness issues but it is not in | Regression random forest and highly skewed response distribution
One might argue that this is a classification problem with a small rounding error rather than a regression design. RF is often referred to as resilient in dealing with skewness issues but it is not invincible. In this case, chances are almost none of the positive responses would make it into each small tree being grown, or into the OOB subset against which they are tested.
Inability to correctly predict your responses of interest is likely to be reflected in the overall r2, however, it would not be the most useful descriptor (most easily visualized in a simple linear regression equivalent of an r2 for the relationship between a cloud of zero points and a few outliers). Solutions listed there may still apply to alleviate the problem; however, I would reconsider the design as 1) an unbalanced classification problem and 2) if the subset of positive responses is sufficiently large, treating just the positive responses in the regression mode you are interested in. | Regression random forest and highly skewed response distribution
One might argue that this is a classification problem with a small rounding error rather than a regression design. RF is often referred to as resilient in dealing with skewness issues but it is not in |
37,105 | Confidence interval for xgb-forecast | So, this is the answer! (mirror)
To build confidence limits for abnormally distributed data, you first need to build a quantile regression, rather than a linear regression, as it does by default.
For this it is necessary, using the derived derivatives from the article or simply copying the code on the python, to customize the variable 'objective'. It is also necessary to change the gradient function and the Gaussian function.
After everything is programmed, build a quantile regression for the 50th quantile (this will be the initial regression), and then two quantile regressions for the two boundaries of the interval (for example, 95 and 5). As a result, you get not only a more accurate model for the initial regression, but also the desired intervals. | Confidence interval for xgb-forecast | So, this is the answer! (mirror)
To build confidence limits for abnormally distributed data, you first need to build a quantile regression, rather than a linear regression, as it does by default.
For | Confidence interval for xgb-forecast
So, this is the answer! (mirror)
To build confidence limits for abnormally distributed data, you first need to build a quantile regression, rather than a linear regression, as it does by default.
For this it is necessary, using the derived derivatives from the article or simply copying the code on the python, to customize the variable 'objective'. It is also necessary to change the gradient function and the Gaussian function.
After everything is programmed, build a quantile regression for the 50th quantile (this will be the initial regression), and then two quantile regressions for the two boundaries of the interval (for example, 95 and 5). As a result, you get not only a more accurate model for the initial regression, but also the desired intervals. | Confidence interval for xgb-forecast
So, this is the answer! (mirror)
To build confidence limits for abnormally distributed data, you first need to build a quantile regression, rather than a linear regression, as it does by default.
For |
37,106 | How to test for goodness of fit for a logistic regression model? | You are on the right track, ROC is a common error measure for logistic regression models. More often, the Area Under The Receiver Operating Curve (AUROC) is used. The advantage is that this measure is numeric and can be compared to other validation runs / model setups of your logistic regression.
You can, for example, use cross-validation to asses the performance of your model. As this goodness of fit depends highly on your training and test sets, it is common to use many repetitions with different training and tests sets. At the end, you have a somewhat stable estimation of your model fit taking the mean of all repetitions.
There are several packages providing cross-validation approaches in R. Assuming you have a fitted model, you can e.g. use the sperrorest package with the following setup:
nspres <- sperrorest(data = data, formula = formula, # your data and formula here
model_fun = glm, model_args = list(family = "binomial"),
pred_fun = predict, pred_args = list(type = "response"),
smp_fun = partition_cv,
smp_args = list(repetition = 1:50, nfold = 10))
summary(nspres$pooled.err$train.auroc)
summary(nspres$pooled.err$test.auroc)
This will perform a cross-validation using 10 folds, 50 repetitions and give you a summary of the overall mean repetition error. | How to test for goodness of fit for a logistic regression model? | You are on the right track, ROC is a common error measure for logistic regression models. More often, the Area Under The Receiver Operating Curve (AUROC) is used. The advantage is that this measure is | How to test for goodness of fit for a logistic regression model?
You are on the right track, ROC is a common error measure for logistic regression models. More often, the Area Under The Receiver Operating Curve (AUROC) is used. The advantage is that this measure is numeric and can be compared to other validation runs / model setups of your logistic regression.
You can, for example, use cross-validation to asses the performance of your model. As this goodness of fit depends highly on your training and test sets, it is common to use many repetitions with different training and tests sets. At the end, you have a somewhat stable estimation of your model fit taking the mean of all repetitions.
There are several packages providing cross-validation approaches in R. Assuming you have a fitted model, you can e.g. use the sperrorest package with the following setup:
nspres <- sperrorest(data = data, formula = formula, # your data and formula here
model_fun = glm, model_args = list(family = "binomial"),
pred_fun = predict, pred_args = list(type = "response"),
smp_fun = partition_cv,
smp_args = list(repetition = 1:50, nfold = 10))
summary(nspres$pooled.err$train.auroc)
summary(nspres$pooled.err$test.auroc)
This will perform a cross-validation using 10 folds, 50 repetitions and give you a summary of the overall mean repetition error. | How to test for goodness of fit for a logistic regression model?
You are on the right track, ROC is a common error measure for logistic regression models. More often, the Area Under The Receiver Operating Curve (AUROC) is used. The advantage is that this measure is |
37,107 | Boxplot for data with a large number of zero values | You can use violin plots and logarithmic transformation (of course you should add some constant to avoid $log(0)$) to compare the distributions and their quantiles at different levels of some factor.
For the sake of illustration please see below zero-inflated data of the number of the cod parasite (A Beginner’s Guide to R, A.F. Zuur et al., 2009) in dependence of its sex:
df <- structure(list(Sex = c(0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L,
0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L,
0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 2L, 1L, 1L, 1L, 2L, 1L,
2L, 2L, 2L, 1L, 2L, 2L, 1L, 2L, 2L, 1L, 1L, 1L, 1L, 2L, 2L, 2L,
2L, 1L, 1L, 1L, 1L, 2L, 1L, 1L, 2L, 2L, 2L, 1L, 1L, 2L, 1L, 1L,
2L, 2L, 2L, 1L, 2L, 1L, 1L, 2L, 2L, 1L, 1L, 1L, 1L, 2L, 2L, 1L,
1L, 1L, 1L, 2L, 2L, 2L, 1L, 2L, 1L, 1L, 1L, 1L, 2L, 2L, 2L, 2L,
2L, 1L, 1L, 2L, 2L, 1L, 2L, 1L, 2L, 2L, 2L, 1L, 1L, 2L, 1L, 1L,
1L, 2L, 1L, 1L, 2L, 2L, 1L, 2L, 1L, 1L, 1L, 2L, 2L, 2L, 1L, 2L,
2L, 1L, 2L, 1L, 2L, 2L, 2L, 1L, 1L, 2L, 2L, 2L, 2L, 2L, 1L, 1L,
1L, 2L, 1L, 1L, 2L, 2L, 1L, 2L, 2L, 1L, 2L, 1L, 2L, 2L, 1L, 1L,
2L, 2L, 1L, 2L, 1L, 1L, 2L, 1L, 1L, 2L, 1L, 1L, 1L, 1L, 2L, 1L,
2L, 2L, 2L, 1L, 1L, 2L, 1L, 1L, 2L, 1L, 1L, 1L, 1L, 2L, 2L, 1L,
1L, 1L, 2L, 1L, 2L, 1L, 1L, 1L, 1L, 2L, 2L, 1L, 2L, 1L, 2L, 2L,
1L, 1L, 2L, 1L, 2L, 2L, 2L, 1L, 2L, 1L, 1L, 2L, 2L, 1L, 2L, 2L,
2L, 2L, 2L, 1L, 1L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 1L, 2L, 1L, 2L,
1L, 2L, 2L, 2L, 1L, 2L, 2L, 2L, 2L, 2L, 1L, 2L, 2L, 2L, 2L, 1L,
1L, 2L, 2L, 1L, 2L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 2L, 1L, 2L,
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 2L, 2L, 1L, 2L, 2L, 2L, 1L, 2L,
1L, 2L, 2L, 1L, 2L, 2L, 2L, 2L, 2L, 1L, 1L, 2L, 2L, 1L, 2L, 1L,
2L, 2L, 1L, 2L, 2L, 1L, 2L, 2L, 1L, 2L, 1L, 2L, 1L, 1L, 1L, 2L,
1L, 2L, 2L, 2L, 2L, 1L, 2L, 1L, 1L, 2L, 1L, 1L, 2L, 2L, 2L, 1L,
2L, 2L, 1L, 2L, 2L, 2L, 1L, 2L, 2L, 2L, 2L, 1L, 1L, 1L, 1L, 1L,
1L, 1L, 0L, 1L, 1L, 1L, 1L, 2L, 1L, 1L, 1L, 2L, 2L, 1L, 1L, 1L,
1L, 1L, 1L, 1L, 1L, 1L, 2L, 1L, 2L, 2L, 1L, 1L, 1L, 1L, 1L, 2L,
1L, 1L, 2L, 1L, 1L, 2L, 2L, 1L, 2L, 1L, 2L, 2L, 2L, 1L, 2L, 1L,
2L, 1L, 2L, 1L, 1L, 1L, 2L, 1L, 1L, 2L, 1L, 1L, 1L, 2L, 2L, 2L,
1L, 1L, 2L, 1L, 1L, 2L, 1L, 1L, 2L, 2L, 1L, 1L, 1L, 2L, 1L, 2L,
1L, 2L, 2L, 1L, 2L, 2L, 1L, 2L, 2L, 1L, 2L, 2L, 1L, 1L, 2L, 2L,
2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 1L, 1L, 1L, 2L,
1L, 1L, 1L, 1L, 2L, 1L, 1L, 1L, 2L, 2L, 1L, 1L, 2L, 2L, 1L, 2L,
1L, 2L, 1L, 2L, 2L, 2L, 1L, 1L, 2L, 2L, 1L, 1L, 1L, 2L, 2L, 1L,
2L, 2L, 2L, 1L, 2L, 1L, 2L, 1L, 2L, 1L, 2L, 1L, 2L, 2L, 1L, 1L,
1L, 2L, 1L, 1L, 1L, 1L, 2L, 2L, 2L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
2L, 1L, 1L, 2L, 2L, 2L, 1L, 2L, 1L, 2L, 2L, 2L, 2L, 2L, 2L, 2L,
2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 1L, 2L, 1L, 2L, 2L,
2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L,
2L, 1L, 1L, 2L, 2L, 2L, 2L, 1L, 2L, 2L, 2L, 1L, 2L, 1L, 2L, 2L,
1L, 2L, 2L, 2L, 1L, 1L, 2L, 1L, 1L, 1L, 1L, 1L, 2L, 2L, 1L, 2L,
1L, 1L, 1L, 1L, 2L, 2L, 2L, 1L, 1L, 1L, 2L, 1L, 1L, 1L, 2L, 1L,
1L, 1L, 1L, 1L, 1L, 2L, 2L, 1L, 1L, 2L, 1L, 1L, 2L, 1L, 1L, 1L,
1L, 2L, 2L, 1L, 0L, 0L, 0L, 0L, 2L, 1L, 1L, 1L, 2L, 1L, 1L, 2L,
1L, 1L, 1L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 1L, 2L,
1L, 2L, 2L, 2L, 1L, 1L, 1L, 2L, 2L, 1L, 0L, 0L, 1L, 2L, 1L, 2L,
2L, 1L, 1L, 1L, 1L, 2L, 2L, 2L, 1L, 1L, 1L, 2L, 1L, 2L, 2L, 2L,
2L, 1L, 2L, 1L, 1L, 2L, 2L, 1L, 2L, 2L, 2L, 0L, 0L, 1L, 1L, 2L,
2L, 2L, 2L, 1L, 1L, 1L, 2L, 1L, 1L, 1L, 2L, 2L, 1L, 2L, 1L, 1L,
0L, 2L, 2L, 2L, 1L, 2L, 1L, 2L, 1L, 2L, 2L, 1L, 2L, 2L, 1L, 2L,
2L, 0L, 0L, 0L, 1L, 1L, 1L, 1L, 2L, 2L, 2L, 1L, 2L, 1L, 1L, 1L,
1L, 1L, 1L, 1L, 1L, 1L, 1L, 2L, 0L, 1L, 1L, 2L, 1L, 1L, 1L, 1L,
1L, 1L, 2L, 2L, 2L, 2L, 2L, 2L, 1L, 1L, 1L, 0L, 1L, 1L, 2L, 1L,
2L, 2L, 1L, 0L, 1L, 1L, 1L, 0L, 1L, 2L, 2L, 1L, 2L, 1L, 2L, 2L,
1L, 2L, 1L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 1L, 2L, 1L, 1L, 2L, 2L,
2L, 1L, 1L, 1L, 1L, 1L, 2L, 2L, 1L, 2L, 1L, 2L, 1L, 2L, 0L, 0L,
2L, 2L, 1L, 1L, 1L, 2L, 1L, 1L, 0L, 2L, 1L, 0L, 0L, 1L, 1L, 0L,
2L, 0L, 2L, 0L, 1L, 0L, 0L, 2L, 2L, 1L, 0L, 0L, 1L, 1L, 1L, 1L,
1L, 1L, 1L, 2L, 2L, 1L, 2L, 1L, 1L, 2L, 1L, 1L, 2L, 1L, 1L, 1L,
2L, 2L, 2L, 2L, 2L, 2L, 1L, 2L, 2L, 2L, 2L, 1L, 2L, 1L, 2L, 2L,
2L, 1L, 1L, 2L, 1L, 1L, 1L, 1L, 2L, 2L, 2L, 2L, 1L, 1L, 1L, 1L,
2L, 2L, 1L, 1L, 2L, 1L, 1L, 2L, 2L, 2L, 1L, 2L, 2L, 1L, 1L, 2L,
1L, 1L, 1L, 1L, 1L, 2L, 2L, 1L, 2L, 1L, 1L, 1L, 2L, 2L, 2L, 1L,
2L, 1L, 2L, 1L, 1L, 2L, 1L, 2L, 2L, 1L, 1L, 1L, 2L, 1L, 1L, 1L,
2L, 2L, 2L, 2L, 1L, 2L, 1L, 1L, 2L, 1L, 2L, 2L, 1L, 2L, 2L, 2L,
1L, 2L, 1L, 1L, 2L, 1L, 2L, 1L, 2L, 2L, 1L, 2L, 1L, 1L, 1L, 1L,
2L, 2L, 2L, 2L, 1L, 2L, 2L, 2L, 2L, 1L, 1L, 2L, 1L, 2L, 2L, 1L,
1L, 2L, 2L, 1L, 1L, 1L, 2L, 1L, 1L, 2L, 2L, 1L, 1L, 2L, 1L, 1L,
1L, 2L, 2L, 2L, 1L, 1L, 2L, 1L, 2L, 2L, 1L, 2L, 2L, 1L, 2L, 2L,
2L, 2L, 2L, 1L, 2L, 1L, 1L, 2L, 2L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
1L, 2L, 1L, 1L, 1L, 1L, 2L, 2L, 2L, 1L, 2L, 1L, 2L, 2L, 1L, 2L,
1L, 2L, 1L, 2L, 1L, 2L, 2L, 2L, 1L, 1L, 2L, 2L, 1L, 1L, 2L, 1L,
1L, 1L, 2L, 2L, 1L, 2L, 2L, 2L, 1L, 2L, 1L, 1L, 1L, 1L, 2L, 2L,
2L, 1L, 2L, 2L, 1L, 1L, 2L, 1L, 1L, 2L, 2L, 2L, 2L, 1L, 1L, 1L,
1L, 1L, 1L, 1L, 2L, 1L, 1L, 2L, 2L, 1L, 2L, 2L, 2L, 2L, 2L, 2L,
2L, 2L, 1L, 2L, 1L, 2L, 1L, 1L, 2L, 2L, 2L, 1L, 1L, 1L, 1L, 1L,
2L, 2L, 2L, 2L, 1L, 2L, 1L, 2L, 1L, 2L, 1L, 2L, 2L, 1L, 1L, 2L,
2L, 2L, 2L), Intensity = c(0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L,
0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L,
0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L,
0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L,
0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L,
0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L,
0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L,
0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L,
0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L,
0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L,
0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L,
0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L,
0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L,
0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L,
0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L,
0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L,
0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L,
0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L,
0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L,
0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L,
0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L,
0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L,
0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L,
0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L,
0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L,
0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L,
0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L,
0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L,
0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L,
0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L,
0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L,
0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L,
0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L,
0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L,
0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L,
0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L,
0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L,
0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L,
0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L,
0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L,
0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L,
0L, 0L, 0L, 0L, 0L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 2L, 2L, 2L, 2L, 2L,
2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L,
2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 3L, 3L, 3L, 3L,
3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L,
3L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L,
4L, 4L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 6L, 6L,
6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 7L, 7L, 7L, 7L, 7L, 7L, 7L,
7L, 7L, 7L, 8L, 8L, 8L, 8L, 8L, 9L, 9L, 9L, 9L, 10L, 10L, 10L,
10L, 10L, 10L, 10L, 10L, 11L, 11L, 11L, 11L, 12L, 12L, 12L, 12L,
12L, 12L, 12L, 13L, 13L, 13L, 14L, 14L, 14L, 14L, 15L, 15L, 15L,
16L, 16L, 16L, 16L, 17L, 17L, 17L, 17L, 18L, 18L, 18L, 19L, 19L,
20L, 20L, 21L, 21L, 21L, 22L, 22L, 23L, 23L, 24L, 25L, 25L, 26L,
27L, 28L, 28L, 28L, 32L, 33L, 35L, 35L, 36L, 38L, 39L, 41L, 41L,
45L, 50L, 51L, 52L, 56L, 65L, 68L, 73L, 84L, 86L, 126L, 160L,
183L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 2L, 2L, 2L,
2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 3L, 3L, 3L,
3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 4L, 4L, 4L, 4L,
4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 5L, 5L, 5L, 5L, 5L, 5L, 5L,
5L, 5L, 6L, 6L, 6L, 7L, 7L, 7L, 8L, 8L, 8L, 8L, 8L, 8L, 8L, 8L,
9L, 9L, 9L, 10L, 10L, 11L, 11L, 12L, 12L, 12L, 12L, 13L, 14L,
14L, 14L, 15L, 17L, 19L, 20L, 20L, 22L, 26L, 26L, 27L, 28L, 30L,
30L, 30L, 31L, 31L, 35L, 39L, 40L, 43L, 43L, 44L, 45L, 45L, 49L,
52L, 56L, 56L, 58L, 67L, 67L, 71L, 81L, 186L, 210L, 223L, 1L,
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 2L, 2L, 2L, 2L, 2L, 2L,
2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L,
3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L,
4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 5L, 5L,
5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L,
7L, 7L, 7L, 8L, 8L, 8L, 8L, 8L, 8L, 8L, 8L, 9L, 9L, 9L, 10L,
10L, 10L, 10L, 10L, 11L, 13L, 13L, 13L, 14L, 14L, 14L, 16L, 17L,
17L, 18L, 18L, 18L, 19L, 20L, 20L, 30L, 34L, 36L, 40L, 42L, 45L,
46L, 46L, 49L, 50L, 55L, 75L, 84L, 89L, 90L, 104L, 125L, 128L,
257L)), class = "data.frame", row.names = c(1L, 2L, 3L, 4L, 5L,
6L, 7L, 8L, 9L, 10L, 11L, 12L, 13L, 14L, 15L, 16L, 17L, 18L,
19L, 20L, 21L, 22L, 23L, 24L, 25L, 26L, 27L, 28L, 29L, 30L, 31L,
32L, 33L, 34L, 35L, 36L, 37L, 38L, 39L, 40L, 41L, 42L, 43L, 44L,
45L, 46L, 47L, 48L, 49L, 50L, 51L, 52L, 53L, 54L, 55L, 56L, 57L,
58L, 59L, 60L, 61L, 62L, 63L, 64L, 65L, 66L, 67L, 68L, 69L, 70L,
71L, 72L, 73L, 74L, 75L, 76L, 77L, 78L, 79L, 80L, 81L, 82L, 83L,
84L, 85L, 86L, 87L, 88L, 89L, 90L, 91L, 92L, 93L, 94L, 95L, 96L,
97L, 98L, 99L, 100L, 101L, 102L, 103L, 104L, 105L, 106L, 107L,
108L, 109L, 110L, 111L, 112L, 113L, 114L, 115L, 116L, 117L, 118L,
119L, 120L, 121L, 122L, 123L, 124L, 125L, 126L, 127L, 128L, 129L,
130L, 131L, 132L, 133L, 134L, 135L, 136L, 137L, 138L, 139L, 140L,
141L, 142L, 143L, 144L, 145L, 146L, 147L, 148L, 149L, 150L, 151L,
152L, 153L, 154L, 155L, 156L, 157L, 158L, 159L, 160L, 161L, 162L,
163L, 164L, 165L, 166L, 167L, 168L, 169L, 170L, 171L, 172L, 173L,
174L, 175L, 176L, 177L, 178L, 179L, 180L, 181L, 182L, 183L, 184L,
185L, 186L, 187L, 188L, 189L, 190L, 191L, 192L, 193L, 194L, 195L,
196L, 197L, 198L, 199L, 200L, 201L, 202L, 203L, 204L, 205L, 206L,
207L, 208L, 209L, 210L, 211L, 212L, 213L, 214L, 215L, 216L, 217L,
218L, 219L, 220L, 221L, 222L, 223L, 224L, 225L, 226L, 227L, 228L,
229L, 230L, 231L, 232L, 233L, 234L, 235L, 236L, 237L, 238L, 239L,
240L, 241L, 242L, 243L, 244L, 245L, 246L, 247L, 248L, 249L, 250L,
251L, 252L, 253L, 254L, 255L, 256L, 257L, 258L, 259L, 260L, 261L,
262L, 263L, 264L, 265L, 266L, 267L, 268L, 269L, 270L, 271L, 272L,
273L, 274L, 275L, 276L, 277L, 278L, 279L, 280L, 281L, 282L, 283L,
284L, 285L, 286L, 287L, 288L, 289L, 290L, 291L, 292L, 293L, 294L,
295L, 296L, 297L, 298L, 299L, 300L, 301L, 302L, 303L, 304L, 305L,
306L, 307L, 308L, 309L, 310L, 311L, 312L, 313L, 314L, 315L, 316L,
317L, 318L, 319L, 320L, 321L, 322L, 323L, 324L, 325L, 326L, 327L,
328L, 329L, 330L, 331L, 332L, 333L, 334L, 335L, 336L, 337L, 338L,
339L, 340L, 341L, 342L, 343L, 344L, 345L, 346L, 347L, 348L, 349L,
350L, 351L, 352L, 353L, 354L, 355L, 356L, 357L, 358L, 359L, 360L,
361L, 362L, 363L, 364L, 365L, 366L, 367L, 368L, 369L, 370L, 371L,
372L, 373L, 374L, 375L, 376L, 377L, 378L, 379L, 380L, 381L, 382L,
383L, 384L, 385L, 386L, 387L, 388L, 389L, 390L, 391L, 392L, 393L,
394L, 395L, 396L, 397L, 398L, 399L, 400L, 401L, 402L, 403L, 404L,
405L, 406L, 407L, 408L, 409L, 410L, 411L, 412L, 413L, 414L, 415L,
416L, 417L, 418L, 419L, 420L, 421L, 422L, 423L, 424L, 425L, 426L,
427L, 428L, 429L, 430L, 431L, 432L, 433L, 434L, 435L, 436L, 437L,
438L, 439L, 440L, 441L, 442L, 443L, 444L, 445L, 446L, 447L, 448L,
449L, 450L, 451L, 452L, 453L, 454L, 455L, 456L, 457L, 458L, 459L,
460L, 461L, 462L, 463L, 464L, 465L, 466L, 467L, 468L, 469L, 470L,
471L, 472L, 473L, 474L, 475L, 476L, 477L, 478L, 479L, 480L, 481L,
482L, 483L, 484L, 485L, 486L, 487L, 488L, 489L, 490L, 491L, 492L,
493L, 494L, 495L, 496L, 497L, 498L, 499L, 500L, 501L, 502L, 503L,
504L, 505L, 506L, 507L, 508L, 509L, 510L, 511L, 512L, 513L, 514L,
515L, 516L, 517L, 518L, 519L, 520L, 521L, 522L, 523L, 524L, 525L,
526L, 527L, 528L, 529L, 530L, 531L, 532L, 533L, 534L, 535L, 536L,
537L, 538L, 539L, 540L, 541L, 542L, 543L, 544L, 545L, 546L, 547L,
548L, 549L, 550L, 551L, 552L, 553L, 554L, 555L, 556L, 557L, 558L,
559L, 560L, 561L, 562L, 563L, 564L, 565L, 566L, 567L, 568L, 569L,
570L, 571L, 572L, 573L, 574L, 575L, 576L, 577L, 578L, 579L, 580L,
581L, 582L, 583L, 584L, 585L, 586L, 587L, 588L, 589L, 590L, 591L,
592L, 593L, 594L, 595L, 596L, 597L, 598L, 599L, 600L, 601L, 602L,
603L, 604L, 605L, 606L, 607L, 608L, 609L, 610L, 611L, 612L, 613L,
614L, 615L, 616L, 617L, 618L, 619L, 620L, 621L, 622L, 623L, 624L,
625L, 626L, 627L, 628L, 629L, 630L, 631L, 632L, 633L, 634L, 635L,
636L, 637L, 638L, 639L, 640L, 641L, 642L, 643L, 644L, 645L, 646L,
647L, 648L, 649L, 650L, 651L, 652L, 653L, 654L, 655L, 656L, 657L,
658L, 659L, 660L, 661L, 662L, 663L, 664L, 665L, 666L, 667L, 668L,
669L, 670L, 671L, 672L, 673L, 674L, 675L, 676L, 677L, 678L, 679L,
680L, 681L, 682L, 683L, 684L, 685L, 686L, 687L, 688L, 689L, 690L,
691L, 692L, 693L, 694L, 695L, 696L, 697L, 698L, 699L, 700L, 701L,
702L, 703L, 704L, 705L, 706L, 707L, 708L, 709L, 710L, 711L, 712L,
713L, 714L, 715L, 716L, 717L, 718L, 719L, 720L, 721L, 722L, 723L,
724L, 725L, 726L, 727L, 728L, 729L, 730L, 731L, 732L, 733L, 734L,
735L, 736L, 737L, 738L, 739L, 740L, 741L, 742L, 743L, 744L, 745L,
746L, 747L, 748L, 749L, 750L, 751L, 752L, 753L, 754L, 755L, 756L,
757L, 758L, 759L, 760L, 761L, 762L, 763L, 764L, 765L, 766L, 767L,
768L, 769L, 770L, 771L, 772L, 773L, 774L, 775L, 776L, 777L, 778L,
779L, 780L, 781L, 782L, 783L, 784L, 785L, 786L, 787L, 788L, 789L,
790L, 791L, 792L, 793L, 794L, 795L, 796L, 797L, 798L, 799L, 800L,
801L, 802L, 803L, 804L, 805L, 806L, 807L, 808L, 809L, 810L, 811L,
812L, 813L, 814L, 815L, 816L, 817L, 818L, 819L, 820L, 821L, 822L,
823L, 824L, 825L, 826L, 827L, 828L, 829L, 830L, 831L, 832L, 833L,
834L, 835L, 836L, 837L, 838L, 839L, 840L, 841L, 842L, 843L, 844L,
845L, 846L, 847L, 848L, 849L, 850L, 851L, 852L, 853L, 854L, 855L,
856L, 857L, 858L, 859L, 860L, 861L, 862L, 863L, 864L, 865L, 866L,
867L, 868L, 869L, 870L, 871L, 872L, 873L, 874L, 875L, 876L, 877L,
878L, 879L, 880L, 881L, 882L, 883L, 884L, 885L, 886L, 944L, 945L,
946L, 947L, 948L, 949L, 950L, 951L, 952L, 953L, 954L, 955L, 956L,
957L, 958L, 959L, 960L, 961L, 962L, 963L, 964L, 965L, 966L, 967L,
968L, 969L, 970L, 971L, 972L, 973L, 974L, 975L, 976L, 977L, 978L,
979L, 980L, 981L, 982L, 983L, 984L, 985L, 986L, 987L, 988L, 989L,
990L, 991L, 992L, 993L, 994L, 995L, 996L, 997L, 998L, 999L, 1000L,
1001L, 1002L, 1003L, 1004L, 1005L, 1006L, 1007L, 1008L, 1009L,
1010L, 1011L, 1012L, 1013L, 1014L, 1015L, 1016L, 1017L, 1018L,
1019L, 1020L, 1021L, 1022L, 1023L, 1024L, 1025L, 1026L, 1027L,
1028L, 1029L, 1030L, 1031L, 1032L, 1033L, 1034L, 1035L, 1036L,
1037L, 1038L, 1039L, 1040L, 1041L, 1042L, 1043L, 1044L, 1045L,
1046L, 1047L, 1048L, 1049L, 1050L, 1051L, 1052L, 1053L, 1054L,
1055L, 1056L, 1057L, 1058L, 1059L, 1060L, 1061L, 1062L, 1063L,
1064L, 1065L, 1066L, 1067L, 1068L, 1069L, 1070L, 1071L, 1072L,
1073L, 1074L, 1075L, 1076L, 1077L, 1078L, 1079L, 1080L, 1081L,
1082L, 1083L, 1084L, 1085L, 1086L, 1087L, 1088L, 1089L, 1090L,
1091L, 1092L, 1093L, 1094L, 1095L, 1096L, 1097L, 1098L, 1099L,
1100L, 1101L, 1102L, 1103L, 1104L, 1105L, 1106L, 1107L, 1108L,
1109L, 1110L, 1111L, 1112L, 1113L, 1114L, 1115L, 1116L, 1117L,
1118L, 1119L, 1120L, 1121L, 1122L, 1123L, 1124L, 1125L, 1126L,
1127L, 1128L, 1129L, 1130L, 1131L, 1132L, 1133L, 1134L, 1135L,
1136L, 1137L, 1138L, 1139L, 1140L, 1141L, 1142L, 1143L, 1144L,
1145L, 1146L, 1147L, 1148L, 1149L, 1150L, 1151L, 1152L, 1153L,
1154L, 1155L, 1156L, 1157L, 1158L, 1159L, 1160L, 1161L, 1162L,
1163L, 1164L, 1165L, 1166L, 1167L, 1168L, 1169L, 1170L, 1171L,
1172L, 1173L, 1174L, 1175L, 1176L, 1177L, 1178L, 1179L, 1180L,
1181L, 1182L, 1183L, 1184L, 1185L, 1186L, 1187L, 1188L, 1189L,
1190L, 1191L, 1192L, 1193L, 1194L, 1195L, 1196L, 1197L, 1198L,
1199L, 1200L, 1201L, 1202L, 1203L, 1204L, 1205L, 1206L, 1207L,
1208L, 1209L, 1210L, 1211L, 1212L, 1213L, 1214L, 1215L, 1216L,
1217L, 1218L, 1219L, 1220L, 1221L, 1222L, 1223L, 1224L, 1225L,
1226L, 1227L, 1228L, 1229L, 1230L, 1231L, 1232L, 1233L, 1234L,
1235L, 1236L, 1237L, 1238L, 1239L, 1240L, 1241L, 1242L, 1243L,
1244L, 1245L, 1246L, 1247L, 1248L, 1249L, 1250L, 1251L, 1252L,
1253L, 1254L))
Then using ggplot2 package together with logarithmic transformation $ln(x + 1)$ you can draw violin-plot and show quantiles:
library(ggplot2)
ggplot(df, aes(x = factor(Sex), y = log(Intensity + 1))) +
geom_violin(draw_quantiles = c(.25, .5, .75, .95))
The result is: | Boxplot for data with a large number of zero values | You can use violin plots and logarithmic transformation (of course you should add some constant to avoid $log(0)$) to compare the distributions and their quantiles at different levels of some factor.
| Boxplot for data with a large number of zero values
You can use violin plots and logarithmic transformation (of course you should add some constant to avoid $log(0)$) to compare the distributions and their quantiles at different levels of some factor.
For the sake of illustration please see below zero-inflated data of the number of the cod parasite (A Beginner’s Guide to R, A.F. Zuur et al., 2009) in dependence of its sex:
df <- structure(list(Sex = c(0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L,
0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L,
0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 2L, 1L, 1L, 1L, 2L, 1L,
2L, 2L, 2L, 1L, 2L, 2L, 1L, 2L, 2L, 1L, 1L, 1L, 1L, 2L, 2L, 2L,
2L, 1L, 1L, 1L, 1L, 2L, 1L, 1L, 2L, 2L, 2L, 1L, 1L, 2L, 1L, 1L,
2L, 2L, 2L, 1L, 2L, 1L, 1L, 2L, 2L, 1L, 1L, 1L, 1L, 2L, 2L, 1L,
1L, 1L, 1L, 2L, 2L, 2L, 1L, 2L, 1L, 1L, 1L, 1L, 2L, 2L, 2L, 2L,
2L, 1L, 1L, 2L, 2L, 1L, 2L, 1L, 2L, 2L, 2L, 1L, 1L, 2L, 1L, 1L,
1L, 2L, 1L, 1L, 2L, 2L, 1L, 2L, 1L, 1L, 1L, 2L, 2L, 2L, 1L, 2L,
2L, 1L, 2L, 1L, 2L, 2L, 2L, 1L, 1L, 2L, 2L, 2L, 2L, 2L, 1L, 1L,
1L, 2L, 1L, 1L, 2L, 2L, 1L, 2L, 2L, 1L, 2L, 1L, 2L, 2L, 1L, 1L,
2L, 2L, 1L, 2L, 1L, 1L, 2L, 1L, 1L, 2L, 1L, 1L, 1L, 1L, 2L, 1L,
2L, 2L, 2L, 1L, 1L, 2L, 1L, 1L, 2L, 1L, 1L, 1L, 1L, 2L, 2L, 1L,
1L, 1L, 2L, 1L, 2L, 1L, 1L, 1L, 1L, 2L, 2L, 1L, 2L, 1L, 2L, 2L,
1L, 1L, 2L, 1L, 2L, 2L, 2L, 1L, 2L, 1L, 1L, 2L, 2L, 1L, 2L, 2L,
2L, 2L, 2L, 1L, 1L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 1L, 2L, 1L, 2L,
1L, 2L, 2L, 2L, 1L, 2L, 2L, 2L, 2L, 2L, 1L, 2L, 2L, 2L, 2L, 1L,
1L, 2L, 2L, 1L, 2L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 2L, 1L, 2L,
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 2L, 2L, 1L, 2L, 2L, 2L, 1L, 2L,
1L, 2L, 2L, 1L, 2L, 2L, 2L, 2L, 2L, 1L, 1L, 2L, 2L, 1L, 2L, 1L,
2L, 2L, 1L, 2L, 2L, 1L, 2L, 2L, 1L, 2L, 1L, 2L, 1L, 1L, 1L, 2L,
1L, 2L, 2L, 2L, 2L, 1L, 2L, 1L, 1L, 2L, 1L, 1L, 2L, 2L, 2L, 1L,
2L, 2L, 1L, 2L, 2L, 2L, 1L, 2L, 2L, 2L, 2L, 1L, 1L, 1L, 1L, 1L,
1L, 1L, 0L, 1L, 1L, 1L, 1L, 2L, 1L, 1L, 1L, 2L, 2L, 1L, 1L, 1L,
1L, 1L, 1L, 1L, 1L, 1L, 2L, 1L, 2L, 2L, 1L, 1L, 1L, 1L, 1L, 2L,
1L, 1L, 2L, 1L, 1L, 2L, 2L, 1L, 2L, 1L, 2L, 2L, 2L, 1L, 2L, 1L,
2L, 1L, 2L, 1L, 1L, 1L, 2L, 1L, 1L, 2L, 1L, 1L, 1L, 2L, 2L, 2L,
1L, 1L, 2L, 1L, 1L, 2L, 1L, 1L, 2L, 2L, 1L, 1L, 1L, 2L, 1L, 2L,
1L, 2L, 2L, 1L, 2L, 2L, 1L, 2L, 2L, 1L, 2L, 2L, 1L, 1L, 2L, 2L,
2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 1L, 1L, 1L, 2L,
1L, 1L, 1L, 1L, 2L, 1L, 1L, 1L, 2L, 2L, 1L, 1L, 2L, 2L, 1L, 2L,
1L, 2L, 1L, 2L, 2L, 2L, 1L, 1L, 2L, 2L, 1L, 1L, 1L, 2L, 2L, 1L,
2L, 2L, 2L, 1L, 2L, 1L, 2L, 1L, 2L, 1L, 2L, 1L, 2L, 2L, 1L, 1L,
1L, 2L, 1L, 1L, 1L, 1L, 2L, 2L, 2L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
2L, 1L, 1L, 2L, 2L, 2L, 1L, 2L, 1L, 2L, 2L, 2L, 2L, 2L, 2L, 2L,
2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 1L, 2L, 1L, 2L, 2L,
2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L,
2L, 1L, 1L, 2L, 2L, 2L, 2L, 1L, 2L, 2L, 2L, 1L, 2L, 1L, 2L, 2L,
1L, 2L, 2L, 2L, 1L, 1L, 2L, 1L, 1L, 1L, 1L, 1L, 2L, 2L, 1L, 2L,
1L, 1L, 1L, 1L, 2L, 2L, 2L, 1L, 1L, 1L, 2L, 1L, 1L, 1L, 2L, 1L,
1L, 1L, 1L, 1L, 1L, 2L, 2L, 1L, 1L, 2L, 1L, 1L, 2L, 1L, 1L, 1L,
1L, 2L, 2L, 1L, 0L, 0L, 0L, 0L, 2L, 1L, 1L, 1L, 2L, 1L, 1L, 2L,
1L, 1L, 1L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 1L, 2L,
1L, 2L, 2L, 2L, 1L, 1L, 1L, 2L, 2L, 1L, 0L, 0L, 1L, 2L, 1L, 2L,
2L, 1L, 1L, 1L, 1L, 2L, 2L, 2L, 1L, 1L, 1L, 2L, 1L, 2L, 2L, 2L,
2L, 1L, 2L, 1L, 1L, 2L, 2L, 1L, 2L, 2L, 2L, 0L, 0L, 1L, 1L, 2L,
2L, 2L, 2L, 1L, 1L, 1L, 2L, 1L, 1L, 1L, 2L, 2L, 1L, 2L, 1L, 1L,
0L, 2L, 2L, 2L, 1L, 2L, 1L, 2L, 1L, 2L, 2L, 1L, 2L, 2L, 1L, 2L,
2L, 0L, 0L, 0L, 1L, 1L, 1L, 1L, 2L, 2L, 2L, 1L, 2L, 1L, 1L, 1L,
1L, 1L, 1L, 1L, 1L, 1L, 1L, 2L, 0L, 1L, 1L, 2L, 1L, 1L, 1L, 1L,
1L, 1L, 2L, 2L, 2L, 2L, 2L, 2L, 1L, 1L, 1L, 0L, 1L, 1L, 2L, 1L,
2L, 2L, 1L, 0L, 1L, 1L, 1L, 0L, 1L, 2L, 2L, 1L, 2L, 1L, 2L, 2L,
1L, 2L, 1L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 1L, 2L, 1L, 1L, 2L, 2L,
2L, 1L, 1L, 1L, 1L, 1L, 2L, 2L, 1L, 2L, 1L, 2L, 1L, 2L, 0L, 0L,
2L, 2L, 1L, 1L, 1L, 2L, 1L, 1L, 0L, 2L, 1L, 0L, 0L, 1L, 1L, 0L,
2L, 0L, 2L, 0L, 1L, 0L, 0L, 2L, 2L, 1L, 0L, 0L, 1L, 1L, 1L, 1L,
1L, 1L, 1L, 2L, 2L, 1L, 2L, 1L, 1L, 2L, 1L, 1L, 2L, 1L, 1L, 1L,
2L, 2L, 2L, 2L, 2L, 2L, 1L, 2L, 2L, 2L, 2L, 1L, 2L, 1L, 2L, 2L,
2L, 1L, 1L, 2L, 1L, 1L, 1L, 1L, 2L, 2L, 2L, 2L, 1L, 1L, 1L, 1L,
2L, 2L, 1L, 1L, 2L, 1L, 1L, 2L, 2L, 2L, 1L, 2L, 2L, 1L, 1L, 2L,
1L, 1L, 1L, 1L, 1L, 2L, 2L, 1L, 2L, 1L, 1L, 1L, 2L, 2L, 2L, 1L,
2L, 1L, 2L, 1L, 1L, 2L, 1L, 2L, 2L, 1L, 1L, 1L, 2L, 1L, 1L, 1L,
2L, 2L, 2L, 2L, 1L, 2L, 1L, 1L, 2L, 1L, 2L, 2L, 1L, 2L, 2L, 2L,
1L, 2L, 1L, 1L, 2L, 1L, 2L, 1L, 2L, 2L, 1L, 2L, 1L, 1L, 1L, 1L,
2L, 2L, 2L, 2L, 1L, 2L, 2L, 2L, 2L, 1L, 1L, 2L, 1L, 2L, 2L, 1L,
1L, 2L, 2L, 1L, 1L, 1L, 2L, 1L, 1L, 2L, 2L, 1L, 1L, 2L, 1L, 1L,
1L, 2L, 2L, 2L, 1L, 1L, 2L, 1L, 2L, 2L, 1L, 2L, 2L, 1L, 2L, 2L,
2L, 2L, 2L, 1L, 2L, 1L, 1L, 2L, 2L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
1L, 2L, 1L, 1L, 1L, 1L, 2L, 2L, 2L, 1L, 2L, 1L, 2L, 2L, 1L, 2L,
1L, 2L, 1L, 2L, 1L, 2L, 2L, 2L, 1L, 1L, 2L, 2L, 1L, 1L, 2L, 1L,
1L, 1L, 2L, 2L, 1L, 2L, 2L, 2L, 1L, 2L, 1L, 1L, 1L, 1L, 2L, 2L,
2L, 1L, 2L, 2L, 1L, 1L, 2L, 1L, 1L, 2L, 2L, 2L, 2L, 1L, 1L, 1L,
1L, 1L, 1L, 1L, 2L, 1L, 1L, 2L, 2L, 1L, 2L, 2L, 2L, 2L, 2L, 2L,
2L, 2L, 1L, 2L, 1L, 2L, 1L, 1L, 2L, 2L, 2L, 1L, 1L, 1L, 1L, 1L,
2L, 2L, 2L, 2L, 1L, 2L, 1L, 2L, 1L, 2L, 1L, 2L, 2L, 1L, 1L, 2L,
2L, 2L, 2L), Intensity = c(0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L,
0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L,
0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L,
0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L,
0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L,
0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L,
0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L,
0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L,
0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L,
0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L,
0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L,
0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L,
0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L,
0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L,
0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L,
0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L,
0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L,
0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L,
0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L,
0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L,
0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L,
0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L,
0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L,
0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L,
0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L,
0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L,
0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L,
0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L,
0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L,
0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L,
0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L,
0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L,
0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L,
0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L,
0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L,
0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L,
0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L,
0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L,
0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L,
0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L,
0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L,
0L, 0L, 0L, 0L, 0L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 2L, 2L, 2L, 2L, 2L,
2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L,
2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 3L, 3L, 3L, 3L,
3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L,
3L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L,
4L, 4L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 6L, 6L,
6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 7L, 7L, 7L, 7L, 7L, 7L, 7L,
7L, 7L, 7L, 8L, 8L, 8L, 8L, 8L, 9L, 9L, 9L, 9L, 10L, 10L, 10L,
10L, 10L, 10L, 10L, 10L, 11L, 11L, 11L, 11L, 12L, 12L, 12L, 12L,
12L, 12L, 12L, 13L, 13L, 13L, 14L, 14L, 14L, 14L, 15L, 15L, 15L,
16L, 16L, 16L, 16L, 17L, 17L, 17L, 17L, 18L, 18L, 18L, 19L, 19L,
20L, 20L, 21L, 21L, 21L, 22L, 22L, 23L, 23L, 24L, 25L, 25L, 26L,
27L, 28L, 28L, 28L, 32L, 33L, 35L, 35L, 36L, 38L, 39L, 41L, 41L,
45L, 50L, 51L, 52L, 56L, 65L, 68L, 73L, 84L, 86L, 126L, 160L,
183L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 2L, 2L, 2L,
2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 3L, 3L, 3L,
3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 4L, 4L, 4L, 4L,
4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 5L, 5L, 5L, 5L, 5L, 5L, 5L,
5L, 5L, 6L, 6L, 6L, 7L, 7L, 7L, 8L, 8L, 8L, 8L, 8L, 8L, 8L, 8L,
9L, 9L, 9L, 10L, 10L, 11L, 11L, 12L, 12L, 12L, 12L, 13L, 14L,
14L, 14L, 15L, 17L, 19L, 20L, 20L, 22L, 26L, 26L, 27L, 28L, 30L,
30L, 30L, 31L, 31L, 35L, 39L, 40L, 43L, 43L, 44L, 45L, 45L, 49L,
52L, 56L, 56L, 58L, 67L, 67L, 71L, 81L, 186L, 210L, 223L, 1L,
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 2L, 2L, 2L, 2L, 2L, 2L,
2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L,
3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L,
4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 5L, 5L,
5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L,
7L, 7L, 7L, 8L, 8L, 8L, 8L, 8L, 8L, 8L, 8L, 9L, 9L, 9L, 10L,
10L, 10L, 10L, 10L, 11L, 13L, 13L, 13L, 14L, 14L, 14L, 16L, 17L,
17L, 18L, 18L, 18L, 19L, 20L, 20L, 30L, 34L, 36L, 40L, 42L, 45L,
46L, 46L, 49L, 50L, 55L, 75L, 84L, 89L, 90L, 104L, 125L, 128L,
257L)), class = "data.frame", row.names = c(1L, 2L, 3L, 4L, 5L,
6L, 7L, 8L, 9L, 10L, 11L, 12L, 13L, 14L, 15L, 16L, 17L, 18L,
19L, 20L, 21L, 22L, 23L, 24L, 25L, 26L, 27L, 28L, 29L, 30L, 31L,
32L, 33L, 34L, 35L, 36L, 37L, 38L, 39L, 40L, 41L, 42L, 43L, 44L,
45L, 46L, 47L, 48L, 49L, 50L, 51L, 52L, 53L, 54L, 55L, 56L, 57L,
58L, 59L, 60L, 61L, 62L, 63L, 64L, 65L, 66L, 67L, 68L, 69L, 70L,
71L, 72L, 73L, 74L, 75L, 76L, 77L, 78L, 79L, 80L, 81L, 82L, 83L,
84L, 85L, 86L, 87L, 88L, 89L, 90L, 91L, 92L, 93L, 94L, 95L, 96L,
97L, 98L, 99L, 100L, 101L, 102L, 103L, 104L, 105L, 106L, 107L,
108L, 109L, 110L, 111L, 112L, 113L, 114L, 115L, 116L, 117L, 118L,
119L, 120L, 121L, 122L, 123L, 124L, 125L, 126L, 127L, 128L, 129L,
130L, 131L, 132L, 133L, 134L, 135L, 136L, 137L, 138L, 139L, 140L,
141L, 142L, 143L, 144L, 145L, 146L, 147L, 148L, 149L, 150L, 151L,
152L, 153L, 154L, 155L, 156L, 157L, 158L, 159L, 160L, 161L, 162L,
163L, 164L, 165L, 166L, 167L, 168L, 169L, 170L, 171L, 172L, 173L,
174L, 175L, 176L, 177L, 178L, 179L, 180L, 181L, 182L, 183L, 184L,
185L, 186L, 187L, 188L, 189L, 190L, 191L, 192L, 193L, 194L, 195L,
196L, 197L, 198L, 199L, 200L, 201L, 202L, 203L, 204L, 205L, 206L,
207L, 208L, 209L, 210L, 211L, 212L, 213L, 214L, 215L, 216L, 217L,
218L, 219L, 220L, 221L, 222L, 223L, 224L, 225L, 226L, 227L, 228L,
229L, 230L, 231L, 232L, 233L, 234L, 235L, 236L, 237L, 238L, 239L,
240L, 241L, 242L, 243L, 244L, 245L, 246L, 247L, 248L, 249L, 250L,
251L, 252L, 253L, 254L, 255L, 256L, 257L, 258L, 259L, 260L, 261L,
262L, 263L, 264L, 265L, 266L, 267L, 268L, 269L, 270L, 271L, 272L,
273L, 274L, 275L, 276L, 277L, 278L, 279L, 280L, 281L, 282L, 283L,
284L, 285L, 286L, 287L, 288L, 289L, 290L, 291L, 292L, 293L, 294L,
295L, 296L, 297L, 298L, 299L, 300L, 301L, 302L, 303L, 304L, 305L,
306L, 307L, 308L, 309L, 310L, 311L, 312L, 313L, 314L, 315L, 316L,
317L, 318L, 319L, 320L, 321L, 322L, 323L, 324L, 325L, 326L, 327L,
328L, 329L, 330L, 331L, 332L, 333L, 334L, 335L, 336L, 337L, 338L,
339L, 340L, 341L, 342L, 343L, 344L, 345L, 346L, 347L, 348L, 349L,
350L, 351L, 352L, 353L, 354L, 355L, 356L, 357L, 358L, 359L, 360L,
361L, 362L, 363L, 364L, 365L, 366L, 367L, 368L, 369L, 370L, 371L,
372L, 373L, 374L, 375L, 376L, 377L, 378L, 379L, 380L, 381L, 382L,
383L, 384L, 385L, 386L, 387L, 388L, 389L, 390L, 391L, 392L, 393L,
394L, 395L, 396L, 397L, 398L, 399L, 400L, 401L, 402L, 403L, 404L,
405L, 406L, 407L, 408L, 409L, 410L, 411L, 412L, 413L, 414L, 415L,
416L, 417L, 418L, 419L, 420L, 421L, 422L, 423L, 424L, 425L, 426L,
427L, 428L, 429L, 430L, 431L, 432L, 433L, 434L, 435L, 436L, 437L,
438L, 439L, 440L, 441L, 442L, 443L, 444L, 445L, 446L, 447L, 448L,
449L, 450L, 451L, 452L, 453L, 454L, 455L, 456L, 457L, 458L, 459L,
460L, 461L, 462L, 463L, 464L, 465L, 466L, 467L, 468L, 469L, 470L,
471L, 472L, 473L, 474L, 475L, 476L, 477L, 478L, 479L, 480L, 481L,
482L, 483L, 484L, 485L, 486L, 487L, 488L, 489L, 490L, 491L, 492L,
493L, 494L, 495L, 496L, 497L, 498L, 499L, 500L, 501L, 502L, 503L,
504L, 505L, 506L, 507L, 508L, 509L, 510L, 511L, 512L, 513L, 514L,
515L, 516L, 517L, 518L, 519L, 520L, 521L, 522L, 523L, 524L, 525L,
526L, 527L, 528L, 529L, 530L, 531L, 532L, 533L, 534L, 535L, 536L,
537L, 538L, 539L, 540L, 541L, 542L, 543L, 544L, 545L, 546L, 547L,
548L, 549L, 550L, 551L, 552L, 553L, 554L, 555L, 556L, 557L, 558L,
559L, 560L, 561L, 562L, 563L, 564L, 565L, 566L, 567L, 568L, 569L,
570L, 571L, 572L, 573L, 574L, 575L, 576L, 577L, 578L, 579L, 580L,
581L, 582L, 583L, 584L, 585L, 586L, 587L, 588L, 589L, 590L, 591L,
592L, 593L, 594L, 595L, 596L, 597L, 598L, 599L, 600L, 601L, 602L,
603L, 604L, 605L, 606L, 607L, 608L, 609L, 610L, 611L, 612L, 613L,
614L, 615L, 616L, 617L, 618L, 619L, 620L, 621L, 622L, 623L, 624L,
625L, 626L, 627L, 628L, 629L, 630L, 631L, 632L, 633L, 634L, 635L,
636L, 637L, 638L, 639L, 640L, 641L, 642L, 643L, 644L, 645L, 646L,
647L, 648L, 649L, 650L, 651L, 652L, 653L, 654L, 655L, 656L, 657L,
658L, 659L, 660L, 661L, 662L, 663L, 664L, 665L, 666L, 667L, 668L,
669L, 670L, 671L, 672L, 673L, 674L, 675L, 676L, 677L, 678L, 679L,
680L, 681L, 682L, 683L, 684L, 685L, 686L, 687L, 688L, 689L, 690L,
691L, 692L, 693L, 694L, 695L, 696L, 697L, 698L, 699L, 700L, 701L,
702L, 703L, 704L, 705L, 706L, 707L, 708L, 709L, 710L, 711L, 712L,
713L, 714L, 715L, 716L, 717L, 718L, 719L, 720L, 721L, 722L, 723L,
724L, 725L, 726L, 727L, 728L, 729L, 730L, 731L, 732L, 733L, 734L,
735L, 736L, 737L, 738L, 739L, 740L, 741L, 742L, 743L, 744L, 745L,
746L, 747L, 748L, 749L, 750L, 751L, 752L, 753L, 754L, 755L, 756L,
757L, 758L, 759L, 760L, 761L, 762L, 763L, 764L, 765L, 766L, 767L,
768L, 769L, 770L, 771L, 772L, 773L, 774L, 775L, 776L, 777L, 778L,
779L, 780L, 781L, 782L, 783L, 784L, 785L, 786L, 787L, 788L, 789L,
790L, 791L, 792L, 793L, 794L, 795L, 796L, 797L, 798L, 799L, 800L,
801L, 802L, 803L, 804L, 805L, 806L, 807L, 808L, 809L, 810L, 811L,
812L, 813L, 814L, 815L, 816L, 817L, 818L, 819L, 820L, 821L, 822L,
823L, 824L, 825L, 826L, 827L, 828L, 829L, 830L, 831L, 832L, 833L,
834L, 835L, 836L, 837L, 838L, 839L, 840L, 841L, 842L, 843L, 844L,
845L, 846L, 847L, 848L, 849L, 850L, 851L, 852L, 853L, 854L, 855L,
856L, 857L, 858L, 859L, 860L, 861L, 862L, 863L, 864L, 865L, 866L,
867L, 868L, 869L, 870L, 871L, 872L, 873L, 874L, 875L, 876L, 877L,
878L, 879L, 880L, 881L, 882L, 883L, 884L, 885L, 886L, 944L, 945L,
946L, 947L, 948L, 949L, 950L, 951L, 952L, 953L, 954L, 955L, 956L,
957L, 958L, 959L, 960L, 961L, 962L, 963L, 964L, 965L, 966L, 967L,
968L, 969L, 970L, 971L, 972L, 973L, 974L, 975L, 976L, 977L, 978L,
979L, 980L, 981L, 982L, 983L, 984L, 985L, 986L, 987L, 988L, 989L,
990L, 991L, 992L, 993L, 994L, 995L, 996L, 997L, 998L, 999L, 1000L,
1001L, 1002L, 1003L, 1004L, 1005L, 1006L, 1007L, 1008L, 1009L,
1010L, 1011L, 1012L, 1013L, 1014L, 1015L, 1016L, 1017L, 1018L,
1019L, 1020L, 1021L, 1022L, 1023L, 1024L, 1025L, 1026L, 1027L,
1028L, 1029L, 1030L, 1031L, 1032L, 1033L, 1034L, 1035L, 1036L,
1037L, 1038L, 1039L, 1040L, 1041L, 1042L, 1043L, 1044L, 1045L,
1046L, 1047L, 1048L, 1049L, 1050L, 1051L, 1052L, 1053L, 1054L,
1055L, 1056L, 1057L, 1058L, 1059L, 1060L, 1061L, 1062L, 1063L,
1064L, 1065L, 1066L, 1067L, 1068L, 1069L, 1070L, 1071L, 1072L,
1073L, 1074L, 1075L, 1076L, 1077L, 1078L, 1079L, 1080L, 1081L,
1082L, 1083L, 1084L, 1085L, 1086L, 1087L, 1088L, 1089L, 1090L,
1091L, 1092L, 1093L, 1094L, 1095L, 1096L, 1097L, 1098L, 1099L,
1100L, 1101L, 1102L, 1103L, 1104L, 1105L, 1106L, 1107L, 1108L,
1109L, 1110L, 1111L, 1112L, 1113L, 1114L, 1115L, 1116L, 1117L,
1118L, 1119L, 1120L, 1121L, 1122L, 1123L, 1124L, 1125L, 1126L,
1127L, 1128L, 1129L, 1130L, 1131L, 1132L, 1133L, 1134L, 1135L,
1136L, 1137L, 1138L, 1139L, 1140L, 1141L, 1142L, 1143L, 1144L,
1145L, 1146L, 1147L, 1148L, 1149L, 1150L, 1151L, 1152L, 1153L,
1154L, 1155L, 1156L, 1157L, 1158L, 1159L, 1160L, 1161L, 1162L,
1163L, 1164L, 1165L, 1166L, 1167L, 1168L, 1169L, 1170L, 1171L,
1172L, 1173L, 1174L, 1175L, 1176L, 1177L, 1178L, 1179L, 1180L,
1181L, 1182L, 1183L, 1184L, 1185L, 1186L, 1187L, 1188L, 1189L,
1190L, 1191L, 1192L, 1193L, 1194L, 1195L, 1196L, 1197L, 1198L,
1199L, 1200L, 1201L, 1202L, 1203L, 1204L, 1205L, 1206L, 1207L,
1208L, 1209L, 1210L, 1211L, 1212L, 1213L, 1214L, 1215L, 1216L,
1217L, 1218L, 1219L, 1220L, 1221L, 1222L, 1223L, 1224L, 1225L,
1226L, 1227L, 1228L, 1229L, 1230L, 1231L, 1232L, 1233L, 1234L,
1235L, 1236L, 1237L, 1238L, 1239L, 1240L, 1241L, 1242L, 1243L,
1244L, 1245L, 1246L, 1247L, 1248L, 1249L, 1250L, 1251L, 1252L,
1253L, 1254L))
Then using ggplot2 package together with logarithmic transformation $ln(x + 1)$ you can draw violin-plot and show quantiles:
library(ggplot2)
ggplot(df, aes(x = factor(Sex), y = log(Intensity + 1))) +
geom_violin(draw_quantiles = c(.25, .5, .75, .95))
The result is: | Boxplot for data with a large number of zero values
You can use violin plots and logarithmic transformation (of course you should add some constant to avoid $log(0)$) to compare the distributions and their quantiles at different levels of some factor.
|
37,108 | How to determine appropriate lagged features for learning systems with states? | If we want to to look at lags over a long time in the past (or features derived from them like exponential moving averages or interactions between them) then there would be a large number of feature candidates. As you correctly mentioned a grid search would be expensive, even if you want to train a simple linear regression model. One approach that can be very helpful in this case would be to use a fast sub optimal feature selection method. For example you can use Greedy backward subset selection, Greedy backward/forward, or Lasso feature selection. This can be much faster and you can potentially look at much larger number of features. Based on my personal experience and also according to this paper if features are high correlated greedy backward/forward is outperforming Lasso:
http://papers.nips.cc/paper/3586-adaptive-forward-backward-greedy-algorithm-for-sparse-learning-with-linear-models.pdf
Another intuition that can be helpful in many time series is that as we look more into the past the exact time becomes less important. For example in your example, the impact of rain fall on the flow of water, the rain fall on today and yesterday will probably have different coefficients in your model. But the rain fall on 365 days ago and on 366 days ago will probably have the same impact on the flow today. This facilitates application of transforms / feature engineering techniques that aggregates the data based on time. For example you can have a grid of exponential moving averages (AR(1) systems or IIR(1) filters in signal processing terms) as new features to model long term memory, followed by a linear combination of lagged data (FIR filters) to model short term memory. Note that you don't have to include all the generated features in your model and it is a good idea to perform feature selection to select a few of AR(1) systems and lags. I used a scheme similar to what I described above to extract features from multiple time series as shown in the following diagram.
Another techniques that is commonly used is to perform an unsupervised feature extraction method on the time series data. For example you can use PCA and keep only the most dominant principal components, or you can use discrete (Cosine) Fourier transform and only keep the strongest components. There are other transforms like Haar wavelet that can be useful in certain domains to extract features from time series. | How to determine appropriate lagged features for learning systems with states? | If we want to to look at lags over a long time in the past (or features derived from them like exponential moving averages or interactions between them) then there would be a large number of feature c | How to determine appropriate lagged features for learning systems with states?
If we want to to look at lags over a long time in the past (or features derived from them like exponential moving averages or interactions between them) then there would be a large number of feature candidates. As you correctly mentioned a grid search would be expensive, even if you want to train a simple linear regression model. One approach that can be very helpful in this case would be to use a fast sub optimal feature selection method. For example you can use Greedy backward subset selection, Greedy backward/forward, or Lasso feature selection. This can be much faster and you can potentially look at much larger number of features. Based on my personal experience and also according to this paper if features are high correlated greedy backward/forward is outperforming Lasso:
http://papers.nips.cc/paper/3586-adaptive-forward-backward-greedy-algorithm-for-sparse-learning-with-linear-models.pdf
Another intuition that can be helpful in many time series is that as we look more into the past the exact time becomes less important. For example in your example, the impact of rain fall on the flow of water, the rain fall on today and yesterday will probably have different coefficients in your model. But the rain fall on 365 days ago and on 366 days ago will probably have the same impact on the flow today. This facilitates application of transforms / feature engineering techniques that aggregates the data based on time. For example you can have a grid of exponential moving averages (AR(1) systems or IIR(1) filters in signal processing terms) as new features to model long term memory, followed by a linear combination of lagged data (FIR filters) to model short term memory. Note that you don't have to include all the generated features in your model and it is a good idea to perform feature selection to select a few of AR(1) systems and lags. I used a scheme similar to what I described above to extract features from multiple time series as shown in the following diagram.
Another techniques that is commonly used is to perform an unsupervised feature extraction method on the time series data. For example you can use PCA and keep only the most dominant principal components, or you can use discrete (Cosine) Fourier transform and only keep the strongest components. There are other transforms like Haar wavelet that can be useful in certain domains to extract features from time series. | How to determine appropriate lagged features for learning systems with states?
If we want to to look at lags over a long time in the past (or features derived from them like exponential moving averages or interactions between them) then there would be a large number of feature c |
37,109 | How to determine appropriate lagged features for learning systems with states? | you could just create an instantaneous model, and you'd get OK
first-approximation results
Have you heard of Recurrent Neural Networks aka RNNs? The state parameter holds information about the past and can theoretically have infinite memory (though in practice that's not always the best configuration). Check out the link I provided—that chapter has some very helpful images for understanding how RNNs model sequences by "rolling up" past information.
For an example application, check out this video of two computers trained on sequences of speech data (clearly they have memory of past words and aren't just instantaneously generating a word at a time). | How to determine appropriate lagged features for learning systems with states? | you could just create an instantaneous model, and you'd get OK
first-approximation results
Have you heard of Recurrent Neural Networks aka RNNs? The state parameter holds information about the past | How to determine appropriate lagged features for learning systems with states?
you could just create an instantaneous model, and you'd get OK
first-approximation results
Have you heard of Recurrent Neural Networks aka RNNs? The state parameter holds information about the past and can theoretically have infinite memory (though in practice that's not always the best configuration). Check out the link I provided—that chapter has some very helpful images for understanding how RNNs model sequences by "rolling up" past information.
For an example application, check out this video of two computers trained on sequences of speech data (clearly they have memory of past words and aren't just instantaneously generating a word at a time). | How to determine appropriate lagged features for learning systems with states?
you could just create an instantaneous model, and you'd get OK
first-approximation results
Have you heard of Recurrent Neural Networks aka RNNs? The state parameter holds information about the past |
37,110 | How to determine appropriate lagged features for learning systems with states? | I tend to fall back on a pretty standard answer for this: what does your theory suggest? Should rain from a month ago actually impact streamflow? A year ago? A decade? 10 minutes? Surely there is some soil research (it's a thing, I have a family member that studied it!) that gives some hints about this.
If you're simply in need of the best possible prediction and you are not interested in why, then theory can at least give you a starting point for some test-and-trial (guess-and-pray) steps.
Other than that, time series analysis has some basic steps for choosing lag structures to use in, say, a VAR model. This answer might be a good place to start. | How to determine appropriate lagged features for learning systems with states? | I tend to fall back on a pretty standard answer for this: what does your theory suggest? Should rain from a month ago actually impact streamflow? A year ago? A decade? 10 minutes? Surely there is some | How to determine appropriate lagged features for learning systems with states?
I tend to fall back on a pretty standard answer for this: what does your theory suggest? Should rain from a month ago actually impact streamflow? A year ago? A decade? 10 minutes? Surely there is some soil research (it's a thing, I have a family member that studied it!) that gives some hints about this.
If you're simply in need of the best possible prediction and you are not interested in why, then theory can at least give you a starting point for some test-and-trial (guess-and-pray) steps.
Other than that, time series analysis has some basic steps for choosing lag structures to use in, say, a VAR model. This answer might be a good place to start. | How to determine appropriate lagged features for learning systems with states?
I tend to fall back on a pretty standard answer for this: what does your theory suggest? Should rain from a month ago actually impact streamflow? A year ago? A decade? 10 minutes? Surely there is some |
37,111 | Textbooks about reproducing kernel Hilbert space approach to machine learning? | The best and standard reference will be
Aronszajn, Nachman. "Theory of reproducing kernels." Transactions of
the American mathematical society 68.3 (1950): 337-404.
I am not sure how deep you know about functional analysis, different levels of functional analysis has great difference. So I will say another standard is:
Smola, Alex J., and Bernhard Schölkopf. Learning with kernels.
GMD-Forschungszentrum Informationstechnik, 1998.
I am also not sure about your general math background, more or less you may be interested in:
Lafferty, John, and Guy Lebanon. "Diffusion kernels on statistical
manifolds." Journal of Machine Learning Research 6.Jan (2005):
129-163. | Textbooks about reproducing kernel Hilbert space approach to machine learning? | The best and standard reference will be
Aronszajn, Nachman. "Theory of reproducing kernels." Transactions of
the American mathematical society 68.3 (1950): 337-404.
I am not sure how deep you kno | Textbooks about reproducing kernel Hilbert space approach to machine learning?
The best and standard reference will be
Aronszajn, Nachman. "Theory of reproducing kernels." Transactions of
the American mathematical society 68.3 (1950): 337-404.
I am not sure how deep you know about functional analysis, different levels of functional analysis has great difference. So I will say another standard is:
Smola, Alex J., and Bernhard Schölkopf. Learning with kernels.
GMD-Forschungszentrum Informationstechnik, 1998.
I am also not sure about your general math background, more or less you may be interested in:
Lafferty, John, and Guy Lebanon. "Diffusion kernels on statistical
manifolds." Journal of Machine Learning Research 6.Jan (2005):
129-163. | Textbooks about reproducing kernel Hilbert space approach to machine learning?
The best and standard reference will be
Aronszajn, Nachman. "Theory of reproducing kernels." Transactions of
the American mathematical society 68.3 (1950): 337-404.
I am not sure how deep you kno |
37,112 | Should we account for the intercept term when kernelizing algorithms? | Partial answer:
Focusing on SVMs for a while, I got to this reference (pointed by @DikranMarsupial in Bias term in support vector machine):
Poggio, T., Mukherjee, S., Rifkin, R., & Rakhlin, A. (2001). Verri, A.
b. In Proceedings of the Conference on Uncertainty in Geometric
Computations.
Excerpt:
This paper is devoted to answering the following questions: When
should b be used? Is there a choice of using or not using b? What does
the choice mean? Are the answers different for RNs (Regularization Networks) and SVMs? [...]
In their conclusion, they mention the use of a bias term is related to not privileging certain values for classification thresholds in SVMs. Also:
For infinite conditionally positive definite kernels the b term is de facto required allowing a natural interpretation of the optimizer.
For positive definite kernels the natural choice is without the b term, however it's possible to use one, actually leading to another kernel interpretation different of the one without it.
See that the minimizer is written including an explicit parameter b to be optimized. | Should we account for the intercept term when kernelizing algorithms? | Partial answer:
Focusing on SVMs for a while, I got to this reference (pointed by @DikranMarsupial in Bias term in support vector machine):
Poggio, T., Mukherjee, S., Rifkin, R., & Rakhlin, A. (2001) | Should we account for the intercept term when kernelizing algorithms?
Partial answer:
Focusing on SVMs for a while, I got to this reference (pointed by @DikranMarsupial in Bias term in support vector machine):
Poggio, T., Mukherjee, S., Rifkin, R., & Rakhlin, A. (2001). Verri, A.
b. In Proceedings of the Conference on Uncertainty in Geometric
Computations.
Excerpt:
This paper is devoted to answering the following questions: When
should b be used? Is there a choice of using or not using b? What does
the choice mean? Are the answers different for RNs (Regularization Networks) and SVMs? [...]
In their conclusion, they mention the use of a bias term is related to not privileging certain values for classification thresholds in SVMs. Also:
For infinite conditionally positive definite kernels the b term is de facto required allowing a natural interpretation of the optimizer.
For positive definite kernels the natural choice is without the b term, however it's possible to use one, actually leading to another kernel interpretation different of the one without it.
See that the minimizer is written including an explicit parameter b to be optimized. | Should we account for the intercept term when kernelizing algorithms?
Partial answer:
Focusing on SVMs for a while, I got to this reference (pointed by @DikranMarsupial in Bias term in support vector machine):
Poggio, T., Mukherjee, S., Rifkin, R., & Rakhlin, A. (2001) |
37,113 | Why is blocking necessary in experimental design if we already perform random assignment? | Well, if you have small number of experimental runs, then the random assignment could well make some variable poorly balanced between the experimental and control groups. By using blocking you avoid that.
Another idea with blocking is that it makes it possible to on purpose use inhomogeneous experimental material, because the blocking assures that it is balanced between the groups. That makes for a better basis for generalization from the experiments, as conclusion from experiment is valid for a greater range of conditions. | Why is blocking necessary in experimental design if we already perform random assignment? | Well, if you have small number of experimental runs, then the random assignment could well make some variable poorly balanced between the experimental and control groups. By using blocking you avoid | Why is blocking necessary in experimental design if we already perform random assignment?
Well, if you have small number of experimental runs, then the random assignment could well make some variable poorly balanced between the experimental and control groups. By using blocking you avoid that.
Another idea with blocking is that it makes it possible to on purpose use inhomogeneous experimental material, because the blocking assures that it is balanced between the groups. That makes for a better basis for generalization from the experiments, as conclusion from experiment is valid for a greater range of conditions. | Why is blocking necessary in experimental design if we already perform random assignment?
Well, if you have small number of experimental runs, then the random assignment could well make some variable poorly balanced between the experimental and control groups. By using blocking you avoid |
37,114 | Is it ok to decrease the size of a dataset to speedup hyperparameters search? | Depends. In your case, most probably yes
The hyper-parameters do not depend too strongly on the amount of data (as long as you have "enough") but on the complexity of the data (resp. its distribution). Reducing a dataset can mean to "change" the distribution of the data caused by statistical fluctuations.
On big datasets, you should be able to reduce the amount withouth real loss of the distribution shape. Try it! Use a classifier on the full dataset and one on the reduced. Are the metrics (Roc auc etc) the same? (maybe do that several times to get a good mean)
If they are, it should really not change the selection of the hyper-parameters.
Anyway, if you feel unsure whether the reduced dataset still has the same distribution, you may use it to get close to your best hyper-parameters and use the full distribution to find the best one in the end. | Is it ok to decrease the size of a dataset to speedup hyperparameters search? | Depends. In your case, most probably yes
The hyper-parameters do not depend too strongly on the amount of data (as long as you have "enough") but on the complexity of the data (resp. its distribution) | Is it ok to decrease the size of a dataset to speedup hyperparameters search?
Depends. In your case, most probably yes
The hyper-parameters do not depend too strongly on the amount of data (as long as you have "enough") but on the complexity of the data (resp. its distribution). Reducing a dataset can mean to "change" the distribution of the data caused by statistical fluctuations.
On big datasets, you should be able to reduce the amount withouth real loss of the distribution shape. Try it! Use a classifier on the full dataset and one on the reduced. Are the metrics (Roc auc etc) the same? (maybe do that several times to get a good mean)
If they are, it should really not change the selection of the hyper-parameters.
Anyway, if you feel unsure whether the reduced dataset still has the same distribution, you may use it to get close to your best hyper-parameters and use the full distribution to find the best one in the end. | Is it ok to decrease the size of a dataset to speedup hyperparameters search?
Depends. In your case, most probably yes
The hyper-parameters do not depend too strongly on the amount of data (as long as you have "enough") but on the complexity of the data (resp. its distribution) |
37,115 | Differences between linear and canonical discriminant analyses (LDA and CDA) | These are two names for the same thing.
Linear discriminant analysis (LDA) is called a lot of different names. I have seen
canonical discriminant analysis
canonical linear discriminant analysis
descriptive discriminant analysis (see What is "Descriptive Discriminant Analysis"?)
Fisher's discriminant analysis
and possibly some others. I suspect different names might be used in different applied fields. In machine learning, "linear discriminant analysis" is by far the most standard term and "LDA" is a standard abbreviation.
The reason for the term "canonical" is probably that LDA can be understood as a special case of canonical correlation analysis (CCA). Specifically, the "dimensionality reduction part" of LDA is equivalent to doing CCA between the data matrix $\mathbf X$ and the group indicator matrix $\mathbf G$. The indicator matrix $\mathbf G$ is a matrix with $n$ rows and $k$ columns with $G_{ij}=1$ if $i$-th data point belongs to class $j$ and zero otherwise. [Footnote: this $\mathbf G$ should not be centered.]
This fact is not at all obvious and has a proof, which this margin is too narrow to contain. | Differences between linear and canonical discriminant analyses (LDA and CDA) | These are two names for the same thing.
Linear discriminant analysis (LDA) is called a lot of different names. I have seen
canonical discriminant analysis
canonical linear discriminant analysis
descr | Differences between linear and canonical discriminant analyses (LDA and CDA)
These are two names for the same thing.
Linear discriminant analysis (LDA) is called a lot of different names. I have seen
canonical discriminant analysis
canonical linear discriminant analysis
descriptive discriminant analysis (see What is "Descriptive Discriminant Analysis"?)
Fisher's discriminant analysis
and possibly some others. I suspect different names might be used in different applied fields. In machine learning, "linear discriminant analysis" is by far the most standard term and "LDA" is a standard abbreviation.
The reason for the term "canonical" is probably that LDA can be understood as a special case of canonical correlation analysis (CCA). Specifically, the "dimensionality reduction part" of LDA is equivalent to doing CCA between the data matrix $\mathbf X$ and the group indicator matrix $\mathbf G$. The indicator matrix $\mathbf G$ is a matrix with $n$ rows and $k$ columns with $G_{ij}=1$ if $i$-th data point belongs to class $j$ and zero otherwise. [Footnote: this $\mathbf G$ should not be centered.]
This fact is not at all obvious and has a proof, which this margin is too narrow to contain. | Differences between linear and canonical discriminant analyses (LDA and CDA)
These are two names for the same thing.
Linear discriminant analysis (LDA) is called a lot of different names. I have seen
canonical discriminant analysis
canonical linear discriminant analysis
descr |
37,116 | How to express cells of a 2x2 table in terms of phi coefficient and marginal probabilities | We easily recognize every factor in the denominator of $\phi$, because $a+b=1-\mu_R$ and $a+c=1-\mu_C$. Let's therefore start with a tiny simplification to avoid writing lots of square roots:
$$\Delta=ad - bc = \phi \sqrt{\mu_R(1-\mu_R)\mu_C(1-\mu_C)}.$$
Let's find $d$:
$$\eqalign{d &= (1)d = (a+b+c+d)d = ad +bd +cd + d^2 \\
&= ad + (-bc + bc) + bd + cd + d^2 \\
&= (ad - bc) + (c+d)(b+d) \\&= \Delta + \mu_R\mu_C.}$$
Finding $a$, $b$, and $c$ proceeds similarly due to the symmetries of the problem: interchanging the columns swaps $a$ and $b$, $c$ and $d$, while changing $\mu_C$ to $1-\mu_C$ and negating $\Delta$, whence
$$c = -\Delta + \mu_R(1-\mu_C).$$
Interchanging the rows swaps $a$ and $c$, $b$ and $d$, while changing $\mu_R$ to $1-\mu_R$ and negating $\Delta$, whence
$$b = -\Delta + (1-\mu_R)\mu_C.$$
Swapping both rows and columns yields
$$a = \Delta + (1-\mu_R)(1-\mu_C).$$
Given these expressions for $a,b,c,d$, it is simple to check that $a+b+c+d=1, c+d=\mu_R,$ and $b+d=\mu_C$, and only a little bit harder to verify that $ad-bc=\Delta$. | How to express cells of a 2x2 table in terms of phi coefficient and marginal probabilities | We easily recognize every factor in the denominator of $\phi$, because $a+b=1-\mu_R$ and $a+c=1-\mu_C$. Let's therefore start with a tiny simplification to avoid writing lots of square roots:
$$\Delt | How to express cells of a 2x2 table in terms of phi coefficient and marginal probabilities
We easily recognize every factor in the denominator of $\phi$, because $a+b=1-\mu_R$ and $a+c=1-\mu_C$. Let's therefore start with a tiny simplification to avoid writing lots of square roots:
$$\Delta=ad - bc = \phi \sqrt{\mu_R(1-\mu_R)\mu_C(1-\mu_C)}.$$
Let's find $d$:
$$\eqalign{d &= (1)d = (a+b+c+d)d = ad +bd +cd + d^2 \\
&= ad + (-bc + bc) + bd + cd + d^2 \\
&= (ad - bc) + (c+d)(b+d) \\&= \Delta + \mu_R\mu_C.}$$
Finding $a$, $b$, and $c$ proceeds similarly due to the symmetries of the problem: interchanging the columns swaps $a$ and $b$, $c$ and $d$, while changing $\mu_C$ to $1-\mu_C$ and negating $\Delta$, whence
$$c = -\Delta + \mu_R(1-\mu_C).$$
Interchanging the rows swaps $a$ and $c$, $b$ and $d$, while changing $\mu_R$ to $1-\mu_R$ and negating $\Delta$, whence
$$b = -\Delta + (1-\mu_R)\mu_C.$$
Swapping both rows and columns yields
$$a = \Delta + (1-\mu_R)(1-\mu_C).$$
Given these expressions for $a,b,c,d$, it is simple to check that $a+b+c+d=1, c+d=\mu_R,$ and $b+d=\mu_C$, and only a little bit harder to verify that $ad-bc=\Delta$. | How to express cells of a 2x2 table in terms of phi coefficient and marginal probabilities
We easily recognize every factor in the denominator of $\phi$, because $a+b=1-\mu_R$ and $a+c=1-\mu_C$. Let's therefore start with a tiny simplification to avoid writing lots of square roots:
$$\Delt |
37,117 | Why are standard errors downward biased when considering weak instruments | See slides 8 and 9 of these notes. In a simplified setting,
$$y=\beta_{0}+\beta_{1}x + u$$
where $\text{Cov}(x,u) \ne 0$ but $z$ is a valid instrument for $x$, the estimated variance for $\hat{\beta_{1}}$ is the OLS estimated variance divided by the $R^2$ from the first-stage regression of $x$ on $z$. As long as $R^2 < 1$, the IV estimated variance will always be larger than the OLS estimated variance, hence the IV standard errors will also always be larger. If $z$ is a weak instrument measured by a low $R^2$, the IV standard errors will be much larger than the OLS standard errors, all else equal. | Why are standard errors downward biased when considering weak instruments | See slides 8 and 9 of these notes. In a simplified setting,
$$y=\beta_{0}+\beta_{1}x + u$$
where $\text{Cov}(x,u) \ne 0$ but $z$ is a valid instrument for $x$, the estimated variance for $\hat{\beta_{ | Why are standard errors downward biased when considering weak instruments
See slides 8 and 9 of these notes. In a simplified setting,
$$y=\beta_{0}+\beta_{1}x + u$$
where $\text{Cov}(x,u) \ne 0$ but $z$ is a valid instrument for $x$, the estimated variance for $\hat{\beta_{1}}$ is the OLS estimated variance divided by the $R^2$ from the first-stage regression of $x$ on $z$. As long as $R^2 < 1$, the IV estimated variance will always be larger than the OLS estimated variance, hence the IV standard errors will also always be larger. If $z$ is a weak instrument measured by a low $R^2$, the IV standard errors will be much larger than the OLS standard errors, all else equal. | Why are standard errors downward biased when considering weak instruments
See slides 8 and 9 of these notes. In a simplified setting,
$$y=\beta_{0}+\beta_{1}x + u$$
where $\text{Cov}(x,u) \ne 0$ but $z$ is a valid instrument for $x$, the estimated variance for $\hat{\beta_{ |
37,118 | outlier detection: area under precision recall curve | The problem is with your example that it is possible to have zero $tp$ and zero $fp$, therefore the precision $prec = tp/(tp+fp)$ becomes undefined because we divide by zero. Because of this the PR curve only contains points for one $x$-value, and therefore the area under the PR curve becomes zero for your example.
You can see this by plotting the PR curve:
[X,Y,T,PR] = perfcurve(label,score,1, 'xCrit', 'reca', 'yCrit', 'prec') % PR = 0
figure
scatter(X,Y)
xlabel('recall')
ylabel('precision')
So plotting a PR curve doesn't really work well when all your scores are the same.
To gain more insights between the difference of the PR curve and the ROC curve, compare these two prediction lists. We consider the case where we predict all zeros, and predict one 1, but it should be zero (score1). This one doesnt work very well, it predicts 0 everywhere, except for one object where it predicts 1 where it should be zero.
We consider another case, where we predict one 1 correctly, and the rest we classify as 0. Here we thus predict 1 one correctly, and the rest we classify as 0. We compare the area under the PR curve and the area under the ROC.
outlier = 1;
normal = 0;
% 99% normal data 1% outlier
label = normal*ones(1000,1);
label(1:10) = outlier;
%label = real( rand(1000,1) > 0.99 ); % 99% normal data 1% outlier
score1 = [zeros(999,1);1]; % predict everything as zero, and one mistake
score2 = [1;zeros(999,1)]; % predict everything as zero, and one 1 correct
[X,Y,T,AUC1] = perfcurve(label,score1,1)
% AUC1 = 0.5
[X,Y,T,AUC2] = perfcurve(label,score2,1)
% AUC2 = 0.55
[X,Y,T,PR1] = perfcurve(label,score1,1, 'xCrit', 'reca', 'yCrit', 'prec')
% PR1 = 0.005
[X,Y,T,PR2] = perfcurve(label,score2,1, 'xCrit', 'reca', 'yCrit', 'prec')
% PR2 = 0.4545
Observe that the AUC varies little between score1 and score2. However, the area under the PR curve is significantly different. It rewards score2 much more than score1. This indicates it is better suited to outlier detection: it rewards detecting the outlier much more than the AUC.
In case of outlier detection you would prefer score2 much more, since it predicts the 1 that you want to detect correctly, while score1 predicts a 1 for a zero and never catches any outliers.
In general, the AUC is more informative to give an idea how well your predictions work for varying priors. Thus the AUC characterizes how well the classifier works for varying number of ones and zeros.
The PR curves indicates more well how it performs for the current class imbalance considered. Therefore the PR curve is more interesting for you: it takes into account there are little 1's in your dataset than 0's. Because you are only interested in this case when you are interested in outlier detection, the PR curve is more informative.
While the AUC characterizes how your predictions would do if there are much more 1's as well.
For more information see also:
https://www.quora.com/What-is-Precision-Recall-PR-curve
ROC vs precision-and-recall curves
Finally, you might be interested in how to compute an ROC / PR curve, a detailed explanation is given here for ROC curves:
http://blogs.sas.com/content/iml/2011/07/29/computing-an-roc-curve-from-basic-principles.html | outlier detection: area under precision recall curve | The problem is with your example that it is possible to have zero $tp$ and zero $fp$, therefore the precision $prec = tp/(tp+fp)$ becomes undefined because we divide by zero. Because of this the PR cu | outlier detection: area under precision recall curve
The problem is with your example that it is possible to have zero $tp$ and zero $fp$, therefore the precision $prec = tp/(tp+fp)$ becomes undefined because we divide by zero. Because of this the PR curve only contains points for one $x$-value, and therefore the area under the PR curve becomes zero for your example.
You can see this by plotting the PR curve:
[X,Y,T,PR] = perfcurve(label,score,1, 'xCrit', 'reca', 'yCrit', 'prec') % PR = 0
figure
scatter(X,Y)
xlabel('recall')
ylabel('precision')
So plotting a PR curve doesn't really work well when all your scores are the same.
To gain more insights between the difference of the PR curve and the ROC curve, compare these two prediction lists. We consider the case where we predict all zeros, and predict one 1, but it should be zero (score1). This one doesnt work very well, it predicts 0 everywhere, except for one object where it predicts 1 where it should be zero.
We consider another case, where we predict one 1 correctly, and the rest we classify as 0. Here we thus predict 1 one correctly, and the rest we classify as 0. We compare the area under the PR curve and the area under the ROC.
outlier = 1;
normal = 0;
% 99% normal data 1% outlier
label = normal*ones(1000,1);
label(1:10) = outlier;
%label = real( rand(1000,1) > 0.99 ); % 99% normal data 1% outlier
score1 = [zeros(999,1);1]; % predict everything as zero, and one mistake
score2 = [1;zeros(999,1)]; % predict everything as zero, and one 1 correct
[X,Y,T,AUC1] = perfcurve(label,score1,1)
% AUC1 = 0.5
[X,Y,T,AUC2] = perfcurve(label,score2,1)
% AUC2 = 0.55
[X,Y,T,PR1] = perfcurve(label,score1,1, 'xCrit', 'reca', 'yCrit', 'prec')
% PR1 = 0.005
[X,Y,T,PR2] = perfcurve(label,score2,1, 'xCrit', 'reca', 'yCrit', 'prec')
% PR2 = 0.4545
Observe that the AUC varies little between score1 and score2. However, the area under the PR curve is significantly different. It rewards score2 much more than score1. This indicates it is better suited to outlier detection: it rewards detecting the outlier much more than the AUC.
In case of outlier detection you would prefer score2 much more, since it predicts the 1 that you want to detect correctly, while score1 predicts a 1 for a zero and never catches any outliers.
In general, the AUC is more informative to give an idea how well your predictions work for varying priors. Thus the AUC characterizes how well the classifier works for varying number of ones and zeros.
The PR curves indicates more well how it performs for the current class imbalance considered. Therefore the PR curve is more interesting for you: it takes into account there are little 1's in your dataset than 0's. Because you are only interested in this case when you are interested in outlier detection, the PR curve is more informative.
While the AUC characterizes how your predictions would do if there are much more 1's as well.
For more information see also:
https://www.quora.com/What-is-Precision-Recall-PR-curve
ROC vs precision-and-recall curves
Finally, you might be interested in how to compute an ROC / PR curve, a detailed explanation is given here for ROC curves:
http://blogs.sas.com/content/iml/2011/07/29/computing-an-roc-curve-from-basic-principles.html | outlier detection: area under precision recall curve
The problem is with your example that it is possible to have zero $tp$ and zero $fp$, therefore the precision $prec = tp/(tp+fp)$ becomes undefined because we divide by zero. Because of this the PR cu |
37,119 | Why the focus on variance reduction for $R^2$? | There is nothing inherently wrong with measuring goodness-of-fit in a regression model with other monotonic transforms of the coefficient of determination, and indeed, there are several natural transformations that have useful interpretations. Before getting to these, it is useful to note the desirable mathematical properties of the coefficient of determination, and how it arises. The best way to understand this is to look at linear regression from a geometric perspective, where we consider the response and explanatory variables as vectors in Euclidean space.
Geometric analysis of the linear regression: Using OLS estimation in linear regression, the response vector is projected onto the column-space of the design matrix, which yields a predicted response vector in that column-space, and a residual vector that is perpendicular to that column-space (i.e., in the null space of the design matrix). This gives the regression equation $(\mathbf{y} - \bar{\mathbf{y}}) = (\hat{\mathbf{y}} - \bar{\mathbf{y}}) + \mathbf{r}$ which decomposes the response deviation into a predicted deviation and a residual. Since the residual vector and the predicted response vector are orthogonal under OLS estimation, this gives you a triangle of vectors that obey Pythagoras theorem, giving the decomposition:
$$\underbrace{\|\mathbf{y} - \bar{\mathbf{y}}\|^2}_{SS_\text{Tot}}
= \underbrace{\|\hat{\mathbf{y}} - \bar{\mathbf{y}}\|^2}_{SS_\text{Reg}}
+ \underbrace{\|{\mathbf{y}} - \hat{\mathbf{y}}\|^2}_{SS_\text{Res}}.$$
Geometric explanations of linear regression commonly show the triangle of vectors in the above decomposition, and note the resulting decomposition of the squared-norms of these vectors (i.e., the sums-of-squares). One natural way to look at the goodness-of-fit of the linear regression model is to look at the shape of this triangular decomposition --- the smaller the residual vector (relative to the other vectors), the narrower the triangle and the better the fit of the model to the data.
Some useful measures of goodness-of-fit: There are several useful ways of looking at the goodness-of-fit, via the above decomposition of vectors (and the resulting decomposition of their squared-norms). Most of these involve using a measure that is some monotonic transformation of the coefficient of determination, and so they all measure the same thing, but in a different way. Here are some useful measures of the goodness-of-fit that are monotonic functions of the coefficient-of-determination:
Coefficient of determination: This statistic is defined as:$$R^2 \equiv 1 - \frac{SS_\text{Res}}{SS_\text{Tot}} = \frac{SS_\text{Reg}}{SS_\text{Tot}}.$$ As you point out, it measures the proportion of the variance that is "explained" by the explanatory variables. Geometrically, this statistic shows the proportionate size of the squared-norm of the predicted deviation, relative to the total deviation. The statistic is useful because it has a simple interpretation, and it has a simple geometric intuition.$$\text{ }$$
Regression vector angle: An associated measure of the goodness-of-fit is the angle $0 \leqslant \theta \leqslant \pi / 2$ between the response deviation vector and the residual deviation vector. Using standard trigonometric rules, this vector angle is obtained by the formula: $$\cos(\theta) = \frac{SS_\text{Reg}}{SS_\text{Tot}} = R^2.$$ Thus, it is easily seen that this vector angle is a monotonic transform of the coefficient-of-determination (a higher value for the coefficient-of-determination gives a smaller vector angle). This statistic is useful because it has a simple geometric interpretation --- a small vector angle means that the observed response deviation (from the mean) is close to the predicted response deviation (from the mean).$$\text{ }$$
F-statistic: Taking the number of data points and parameters as fixed, we can write the F-statistic for the goodness-of-fit of the regression in terms of the coefficient-of-determination:$$F = \frac{MS_\text{Reg}}{MS_\text{Res}} = \frac{n-m-1}{m} \cdot \frac{R^2}{1-R^2}.$$ Taking the number of data points and parameters as fixed, this statistic is a monotonic transform of the coefficient-of-determination. This statistic is useful because it has a well-known distribution under the null hypothesis that the true regression coefficients are all zero. It can therefore be used for hypothesis testing, to see if there is evidence of an association between the set of explanatory variables and the response.$$\text{ }$$
Explained standard deviation: Another useful measure of goodness-of-fit is the proportion of explained standard deviation, comparing the estimated standard deviation of the error terms and the response variables. This is given by: $$W \equiv 1 - \frac{\hat{\sigma}_\varepsilon}{\hat{\sigma}_Y} = 1 - \sqrt{{\frac{MS_\text{Res}}{MS_\text{Tot}}}} = 1 - \sqrt{\frac{n-1}{n-m-1} \cdot (1-R^2)}.$$ Taking the number of data points and parameters as fixed, this statistic is a monotonic transform of the coefficient-of-determination. It is similar to the statistic you propose to use, except that yours does not adjust properly for the degrees-of-freedom in the regression.
As you can see, there are several monotonic variations on the coefficient-of-determination that can be used as measures of goodness-of-fit. These have different interpretations that are all quite useful in certain contexts. The statistic you propose is somewhat similar to the explained standard deviation statistic above, but it fails to adjust properly for the degrees-of-freedom in the regression, so its interpretation would be a bit more difficult. Nevertheless, it is a monotonic function of the coefficient-of-determination, so it can be used as a measure of goodness-of-fit. | Why the focus on variance reduction for $R^2$? | There is nothing inherently wrong with measuring goodness-of-fit in a regression model with other monotonic transforms of the coefficient of determination, and indeed, there are several natural transf | Why the focus on variance reduction for $R^2$?
There is nothing inherently wrong with measuring goodness-of-fit in a regression model with other monotonic transforms of the coefficient of determination, and indeed, there are several natural transformations that have useful interpretations. Before getting to these, it is useful to note the desirable mathematical properties of the coefficient of determination, and how it arises. The best way to understand this is to look at linear regression from a geometric perspective, where we consider the response and explanatory variables as vectors in Euclidean space.
Geometric analysis of the linear regression: Using OLS estimation in linear regression, the response vector is projected onto the column-space of the design matrix, which yields a predicted response vector in that column-space, and a residual vector that is perpendicular to that column-space (i.e., in the null space of the design matrix). This gives the regression equation $(\mathbf{y} - \bar{\mathbf{y}}) = (\hat{\mathbf{y}} - \bar{\mathbf{y}}) + \mathbf{r}$ which decomposes the response deviation into a predicted deviation and a residual. Since the residual vector and the predicted response vector are orthogonal under OLS estimation, this gives you a triangle of vectors that obey Pythagoras theorem, giving the decomposition:
$$\underbrace{\|\mathbf{y} - \bar{\mathbf{y}}\|^2}_{SS_\text{Tot}}
= \underbrace{\|\hat{\mathbf{y}} - \bar{\mathbf{y}}\|^2}_{SS_\text{Reg}}
+ \underbrace{\|{\mathbf{y}} - \hat{\mathbf{y}}\|^2}_{SS_\text{Res}}.$$
Geometric explanations of linear regression commonly show the triangle of vectors in the above decomposition, and note the resulting decomposition of the squared-norms of these vectors (i.e., the sums-of-squares). One natural way to look at the goodness-of-fit of the linear regression model is to look at the shape of this triangular decomposition --- the smaller the residual vector (relative to the other vectors), the narrower the triangle and the better the fit of the model to the data.
Some useful measures of goodness-of-fit: There are several useful ways of looking at the goodness-of-fit, via the above decomposition of vectors (and the resulting decomposition of their squared-norms). Most of these involve using a measure that is some monotonic transformation of the coefficient of determination, and so they all measure the same thing, but in a different way. Here are some useful measures of the goodness-of-fit that are monotonic functions of the coefficient-of-determination:
Coefficient of determination: This statistic is defined as:$$R^2 \equiv 1 - \frac{SS_\text{Res}}{SS_\text{Tot}} = \frac{SS_\text{Reg}}{SS_\text{Tot}}.$$ As you point out, it measures the proportion of the variance that is "explained" by the explanatory variables. Geometrically, this statistic shows the proportionate size of the squared-norm of the predicted deviation, relative to the total deviation. The statistic is useful because it has a simple interpretation, and it has a simple geometric intuition.$$\text{ }$$
Regression vector angle: An associated measure of the goodness-of-fit is the angle $0 \leqslant \theta \leqslant \pi / 2$ between the response deviation vector and the residual deviation vector. Using standard trigonometric rules, this vector angle is obtained by the formula: $$\cos(\theta) = \frac{SS_\text{Reg}}{SS_\text{Tot}} = R^2.$$ Thus, it is easily seen that this vector angle is a monotonic transform of the coefficient-of-determination (a higher value for the coefficient-of-determination gives a smaller vector angle). This statistic is useful because it has a simple geometric interpretation --- a small vector angle means that the observed response deviation (from the mean) is close to the predicted response deviation (from the mean).$$\text{ }$$
F-statistic: Taking the number of data points and parameters as fixed, we can write the F-statistic for the goodness-of-fit of the regression in terms of the coefficient-of-determination:$$F = \frac{MS_\text{Reg}}{MS_\text{Res}} = \frac{n-m-1}{m} \cdot \frac{R^2}{1-R^2}.$$ Taking the number of data points and parameters as fixed, this statistic is a monotonic transform of the coefficient-of-determination. This statistic is useful because it has a well-known distribution under the null hypothesis that the true regression coefficients are all zero. It can therefore be used for hypothesis testing, to see if there is evidence of an association between the set of explanatory variables and the response.$$\text{ }$$
Explained standard deviation: Another useful measure of goodness-of-fit is the proportion of explained standard deviation, comparing the estimated standard deviation of the error terms and the response variables. This is given by: $$W \equiv 1 - \frac{\hat{\sigma}_\varepsilon}{\hat{\sigma}_Y} = 1 - \sqrt{{\frac{MS_\text{Res}}{MS_\text{Tot}}}} = 1 - \sqrt{\frac{n-1}{n-m-1} \cdot (1-R^2)}.$$ Taking the number of data points and parameters as fixed, this statistic is a monotonic transform of the coefficient-of-determination. It is similar to the statistic you propose to use, except that yours does not adjust properly for the degrees-of-freedom in the regression.
As you can see, there are several monotonic variations on the coefficient-of-determination that can be used as measures of goodness-of-fit. These have different interpretations that are all quite useful in certain contexts. The statistic you propose is somewhat similar to the explained standard deviation statistic above, but it fails to adjust properly for the degrees-of-freedom in the regression, so its interpretation would be a bit more difficult. Nevertheless, it is a monotonic function of the coefficient-of-determination, so it can be used as a measure of goodness-of-fit. | Why the focus on variance reduction for $R^2$?
There is nothing inherently wrong with measuring goodness-of-fit in a regression model with other monotonic transforms of the coefficient of determination, and indeed, there are several natural transf |
37,120 | Why the focus on variance reduction for $R^2$? | Particularly for a class for non-majors, it's probably fine. Most likely your students think of standard deviation whenever you mention variance, anyway.
It also makes sense to me. The goal of regression is to reduce the variability. Sure, the variability of human height is quite large, but when you account for age and gender, the distribution narrows, and you have a better idea of how tall a 30-year-old woman is ("around 5'5" ish") than how tall a human is in general.
So if you're reducing the variance of the conditional response distribution, you're also reducing the standard deviation of the response distribution. Where I am not clear is when it comes to quantifying that reduction, since the square root of an unbiased estimator of variance is a biased estimator of standard deviation.
Answering explicitly:
1) Variance is a natural way of thinking about the spread of data, since it's the second central moment of a distribution. There's also a good estimator that is unbiased for every distribution with a defined variance. Taking the square root of that (amazingly) results in a biased estimate of standard deviation.
2) If you're reducing the variance, you're also reducing the standard deviation. I'm unsure about the math of everything, since there's that nasty issue of unbiased variance becomes biased standard deviation, but that level of detail wouldn't make it into the class for non-majors. | Why the focus on variance reduction for $R^2$? | Particularly for a class for non-majors, it's probably fine. Most likely your students think of standard deviation whenever you mention variance, anyway.
It also makes sense to me. The goal of regress | Why the focus on variance reduction for $R^2$?
Particularly for a class for non-majors, it's probably fine. Most likely your students think of standard deviation whenever you mention variance, anyway.
It also makes sense to me. The goal of regression is to reduce the variability. Sure, the variability of human height is quite large, but when you account for age and gender, the distribution narrows, and you have a better idea of how tall a 30-year-old woman is ("around 5'5" ish") than how tall a human is in general.
So if you're reducing the variance of the conditional response distribution, you're also reducing the standard deviation of the response distribution. Where I am not clear is when it comes to quantifying that reduction, since the square root of an unbiased estimator of variance is a biased estimator of standard deviation.
Answering explicitly:
1) Variance is a natural way of thinking about the spread of data, since it's the second central moment of a distribution. There's also a good estimator that is unbiased for every distribution with a defined variance. Taking the square root of that (amazingly) results in a biased estimate of standard deviation.
2) If you're reducing the variance, you're also reducing the standard deviation. I'm unsure about the math of everything, since there's that nasty issue of unbiased variance becomes biased standard deviation, but that level of detail wouldn't make it into the class for non-majors. | Why the focus on variance reduction for $R^2$?
Particularly for a class for non-majors, it's probably fine. Most likely your students think of standard deviation whenever you mention variance, anyway.
It also makes sense to me. The goal of regress |
37,121 | Why the focus on variance reduction for $R^2$? | If $X_1,\ldots,X_n$ are independent random variables then
$$
\operatorname{var}(X_1+\cdots+X_n) = \operatorname{var}(X_1)+\cdots+\operatorname{var}(X_n).
$$
Other measures of dispersion, including standard deviation and mean absolute deviation, lack this property.
If follows that
\begin{align}
& \Big(\text{explained part of the variance} \Big) \\
& {} + \Big( \text{unexplained part of the variance} \Big) \\[6pt]
= {} & \Big( \text{total variance} \Big).
\end{align}
If not for that, would it make sense to speak of what percent of the dispersion is explained or unexplained? | Why the focus on variance reduction for $R^2$? | If $X_1,\ldots,X_n$ are independent random variables then
$$
\operatorname{var}(X_1+\cdots+X_n) = \operatorname{var}(X_1)+\cdots+\operatorname{var}(X_n).
$$
Other measures of dispersion, including sta | Why the focus on variance reduction for $R^2$?
If $X_1,\ldots,X_n$ are independent random variables then
$$
\operatorname{var}(X_1+\cdots+X_n) = \operatorname{var}(X_1)+\cdots+\operatorname{var}(X_n).
$$
Other measures of dispersion, including standard deviation and mean absolute deviation, lack this property.
If follows that
\begin{align}
& \Big(\text{explained part of the variance} \Big) \\
& {} + \Big( \text{unexplained part of the variance} \Big) \\[6pt]
= {} & \Big( \text{total variance} \Big).
\end{align}
If not for that, would it make sense to speak of what percent of the dispersion is explained or unexplained? | Why the focus on variance reduction for $R^2$?
If $X_1,\ldots,X_n$ are independent random variables then
$$
\operatorname{var}(X_1+\cdots+X_n) = \operatorname{var}(X_1)+\cdots+\operatorname{var}(X_n).
$$
Other measures of dispersion, including sta |
37,122 | If an inverse covariance matrix is sparse, what can I say about the covariance matrix? | As already commented by Yair there is no specific sparsity condition of the inverse covariance matrix that affects the actual covariance matrix or vice versa. Anything other than trivial sparsity matrix patterns (ie. diagonal) have no guarantee that they will reflected on both a particular matrix and its inverse. Even tridiagonal matrices can easily have non sparse inverses.
For particular cases where the sparsity of the matrix occurs in blocks you might be able to derive some results stemming from the Block matrix pseudoinverse algorithm which states that:
$\left[\begin{array}{cc} A & B \\C & D \end{array}\right]^{-1} =\begin{bmatrix}
(A - BD^{-1}C)^{-1} & -A^{-1}B(D - CA^{-1}B)^{-1} \\
-D^{-1}C(A - BD^{-1}C)^{-1} & (D - CA^{-1}B)^{-1}
\end{bmatrix}$
but that's probably about it (purely anecdotally, I have tried to impose sparsity patterns through the Cholesky decomposition of a PSD matrix but I failed in my trial-and-error foray). You might also want to consider looking into the Cuthill–McKee algorithm (CM) if you expect some adjacency feature to be reflected in the covariance matrix. The CM algorithm permutes a sparse matrix that has a symmetric sparsity pattern into a band matrix form with a small bandwidth, this might help preserve some sparsity towards the off-diagonal entries of the inverse matrix but that is not guaranteed. (Applying CM -if reasonable- can be very helpful for particular applications (eg. in 2D smoothing routines) and may significantly speed-up your computations.) | If an inverse covariance matrix is sparse, what can I say about the covariance matrix? | As already commented by Yair there is no specific sparsity condition of the inverse covariance matrix that affects the actual covariance matrix or vice versa. Anything other than trivial sparsity matr | If an inverse covariance matrix is sparse, what can I say about the covariance matrix?
As already commented by Yair there is no specific sparsity condition of the inverse covariance matrix that affects the actual covariance matrix or vice versa. Anything other than trivial sparsity matrix patterns (ie. diagonal) have no guarantee that they will reflected on both a particular matrix and its inverse. Even tridiagonal matrices can easily have non sparse inverses.
For particular cases where the sparsity of the matrix occurs in blocks you might be able to derive some results stemming from the Block matrix pseudoinverse algorithm which states that:
$\left[\begin{array}{cc} A & B \\C & D \end{array}\right]^{-1} =\begin{bmatrix}
(A - BD^{-1}C)^{-1} & -A^{-1}B(D - CA^{-1}B)^{-1} \\
-D^{-1}C(A - BD^{-1}C)^{-1} & (D - CA^{-1}B)^{-1}
\end{bmatrix}$
but that's probably about it (purely anecdotally, I have tried to impose sparsity patterns through the Cholesky decomposition of a PSD matrix but I failed in my trial-and-error foray). You might also want to consider looking into the Cuthill–McKee algorithm (CM) if you expect some adjacency feature to be reflected in the covariance matrix. The CM algorithm permutes a sparse matrix that has a symmetric sparsity pattern into a band matrix form with a small bandwidth, this might help preserve some sparsity towards the off-diagonal entries of the inverse matrix but that is not guaranteed. (Applying CM -if reasonable- can be very helpful for particular applications (eg. in 2D smoothing routines) and may significantly speed-up your computations.) | If an inverse covariance matrix is sparse, what can I say about the covariance matrix?
As already commented by Yair there is no specific sparsity condition of the inverse covariance matrix that affects the actual covariance matrix or vice versa. Anything other than trivial sparsity matr |
37,123 | "cumulative" vs "additive" | The cumulative error (also referred to as system error) - It's a single direction error. e.g, - If you are to measure 10 km run & your stopwatch is running 2 sec faster every minute. So at the end of the experiment to calculate error you will add 2 secs for each minute. In other words, it is a type of bias, with or without some superimposed random noise.
Additive errors - Random error terms which can go either way based on the scenario. Good example is residuals in a linear regression model. The residuals can be both negative or positive based on your observation (unlike 1st scenario).
Similar to an additive error, a multiplicative error can go both ways, but rather than consisting of random sequential additions / substitutions by an error term, it is the result of random multiplications / divisions by an error factor. Both the error term and the error factor are derived from a error-characterizing distribution (that is, typically a normal distribution centered around 0, or 1 respectively).
Hope this helps. | "cumulative" vs "additive" | The cumulative error (also referred to as system error) - It's a single direction error. e.g, - If you are to measure 10 km run & your stopwatch is running 2 sec faster every minute. So at the end of | "cumulative" vs "additive"
The cumulative error (also referred to as system error) - It's a single direction error. e.g, - If you are to measure 10 km run & your stopwatch is running 2 sec faster every minute. So at the end of the experiment to calculate error you will add 2 secs for each minute. In other words, it is a type of bias, with or without some superimposed random noise.
Additive errors - Random error terms which can go either way based on the scenario. Good example is residuals in a linear regression model. The residuals can be both negative or positive based on your observation (unlike 1st scenario).
Similar to an additive error, a multiplicative error can go both ways, but rather than consisting of random sequential additions / substitutions by an error term, it is the result of random multiplications / divisions by an error factor. Both the error term and the error factor are derived from a error-characterizing distribution (that is, typically a normal distribution centered around 0, or 1 respectively).
Hope this helps. | "cumulative" vs "additive"
The cumulative error (also referred to as system error) - It's a single direction error. e.g, - If you are to measure 10 km run & your stopwatch is running 2 sec faster every minute. So at the end of |
37,124 | "cumulative" vs "additive" | Interestingly, this is a problem that psychologists and sociologists come across when considering theories of identity. Sam being black, male and disabled are all part of his identity and these are obviously not mutually exclusive. However the effect of them when considered together is cumulative not additive. So to check if you are using the right term see if an aspect of the 'thing' (in this case Sam's multiple identities) can be removed. If not, the correct term to describe the combined effect is cumulative. Only when non-identity concepts are added to Sam's profile (such as him being temporarily ill, on holiday with no money) may the term additive be legitimately used, in place of cumulative. | "cumulative" vs "additive" | Interestingly, this is a problem that psychologists and sociologists come across when considering theories of identity. Sam being black, male and disabled are all part of his identity and these are ob | "cumulative" vs "additive"
Interestingly, this is a problem that psychologists and sociologists come across when considering theories of identity. Sam being black, male and disabled are all part of his identity and these are obviously not mutually exclusive. However the effect of them when considered together is cumulative not additive. So to check if you are using the right term see if an aspect of the 'thing' (in this case Sam's multiple identities) can be removed. If not, the correct term to describe the combined effect is cumulative. Only when non-identity concepts are added to Sam's profile (such as him being temporarily ill, on holiday with no money) may the term additive be legitimately used, in place of cumulative. | "cumulative" vs "additive"
Interestingly, this is a problem that psychologists and sociologists come across when considering theories of identity. Sam being black, male and disabled are all part of his identity and these are ob |
37,125 | Can intermediate rewards be used in reinforcement learning? | Is it common practice in RL to have only one reward function awarded when a task is fulfilled in the end?
This isn't quite the correct definition of a reward function. An MDP has a single reward function, $R(s,a,s'): S \times A \times S \mapsto \mathbb{R}$, where $S, A$ are the sets of states, actions in the problem. You'll sometimes see versions with fewer arguments, say $R(s,a)$ or $R(s)$.
$R$ returns rewards for every state transition. Many of them, or even all but one, can be zero. Or, other intermediate states can include positive or negative rewards. Both are possible, and dependent on the particular application.
This the definition you'll find at the start of most reinforcement learning papers, e.g. this one on reward shaping, the related study of how one can alter the reward function without affecting the optimal policy. | Can intermediate rewards be used in reinforcement learning? | Is it common practice in RL to have only one reward function awarded when a task is fulfilled in the end?
This isn't quite the correct definition of a reward function. An MDP has a single reward func | Can intermediate rewards be used in reinforcement learning?
Is it common practice in RL to have only one reward function awarded when a task is fulfilled in the end?
This isn't quite the correct definition of a reward function. An MDP has a single reward function, $R(s,a,s'): S \times A \times S \mapsto \mathbb{R}$, where $S, A$ are the sets of states, actions in the problem. You'll sometimes see versions with fewer arguments, say $R(s,a)$ or $R(s)$.
$R$ returns rewards for every state transition. Many of them, or even all but one, can be zero. Or, other intermediate states can include positive or negative rewards. Both are possible, and dependent on the particular application.
This the definition you'll find at the start of most reinforcement learning papers, e.g. this one on reward shaping, the related study of how one can alter the reward function without affecting the optimal policy. | Can intermediate rewards be used in reinforcement learning?
Is it common practice in RL to have only one reward function awarded when a task is fulfilled in the end?
This isn't quite the correct definition of a reward function. An MDP has a single reward func |
37,126 | Can intermediate rewards be used in reinforcement learning? | I think the short version to your question is yes, it appears to be common practice to only reward an agent for full completion of a task, but be careful with your wording, as Sean pointed out in his answer that a reward function is defined for all possible combinations of states, actions, and future states.
To add to Sean's answer, consider these snippets taken from Richard Sutton and Andrew Barto's intro book on Reinforcement Learning:
The reward signal is your way of communicating to the [agent] what you want it to achieve, not how you want it achieved (author emphasis).
For example, a chess-playing agent should be rewarded only for actually winning, not for achieving subgoals such as taking its opponents pieces or gaining control of the center.
Although it does appear to be the recommended approach in their book, I'm sure you can find others who disagree. | Can intermediate rewards be used in reinforcement learning? | I think the short version to your question is yes, it appears to be common practice to only reward an agent for full completion of a task, but be careful with your wording, as Sean pointed out in his | Can intermediate rewards be used in reinforcement learning?
I think the short version to your question is yes, it appears to be common practice to only reward an agent for full completion of a task, but be careful with your wording, as Sean pointed out in his answer that a reward function is defined for all possible combinations of states, actions, and future states.
To add to Sean's answer, consider these snippets taken from Richard Sutton and Andrew Barto's intro book on Reinforcement Learning:
The reward signal is your way of communicating to the [agent] what you want it to achieve, not how you want it achieved (author emphasis).
For example, a chess-playing agent should be rewarded only for actually winning, not for achieving subgoals such as taking its opponents pieces or gaining control of the center.
Although it does appear to be the recommended approach in their book, I'm sure you can find others who disagree. | Can intermediate rewards be used in reinforcement learning?
I think the short version to your question is yes, it appears to be common practice to only reward an agent for full completion of a task, but be careful with your wording, as Sean pointed out in his |
37,127 | Can intermediate rewards be used in reinforcement learning? | If you're interested in subtasks, you want to look at options. Aside from options, there is one reward function. | Can intermediate rewards be used in reinforcement learning? | If you're interested in subtasks, you want to look at options. Aside from options, there is one reward function. | Can intermediate rewards be used in reinforcement learning?
If you're interested in subtasks, you want to look at options. Aside from options, there is one reward function. | Can intermediate rewards be used in reinforcement learning?
If you're interested in subtasks, you want to look at options. Aside from options, there is one reward function. |
37,128 | Clustering and A/B testing | Absolutely, you can compare the different clusters, although it's important that you carefully consider what you infer from statistical significance. While it is indeed a very good indicator, by its very nature a threshold of $p<0.05$ will mean that $1/20$ tests will result in a false positive leaving many engineers and scientists to exclaim that an effect is present when it is possibly not. Also if the test returns $p=0.055$ would you immediately conclude that there is no relationship there?
This question touches on the problem of multiple comparisons where the more tests you apply the more likely you are to find something statistically significant. There are simple corrections such as bonferroni which essentially reduces the threshold to $p<0.05/n_{tests}$ although this must be used with caution as it is a rather aggressive correction.
So there is no harm in looking at your data from a number of ways to extract insight from it, in fact I would encourage it. The best advice I could give is to look at your data, plot it out, look at the distributions, how many data points do you have, are they normal or non-parametric or skewed. Get a real feeling of whats going on rather than just relying on statistical tests. If you have a hunch and the p-value looks in the right ball park, gather more data and see if this confirms your theory. | Clustering and A/B testing | Absolutely, you can compare the different clusters, although it's important that you carefully consider what you infer from statistical significance. While it is indeed a very good indicator, by its v | Clustering and A/B testing
Absolutely, you can compare the different clusters, although it's important that you carefully consider what you infer from statistical significance. While it is indeed a very good indicator, by its very nature a threshold of $p<0.05$ will mean that $1/20$ tests will result in a false positive leaving many engineers and scientists to exclaim that an effect is present when it is possibly not. Also if the test returns $p=0.055$ would you immediately conclude that there is no relationship there?
This question touches on the problem of multiple comparisons where the more tests you apply the more likely you are to find something statistically significant. There are simple corrections such as bonferroni which essentially reduces the threshold to $p<0.05/n_{tests}$ although this must be used with caution as it is a rather aggressive correction.
So there is no harm in looking at your data from a number of ways to extract insight from it, in fact I would encourage it. The best advice I could give is to look at your data, plot it out, look at the distributions, how many data points do you have, are they normal or non-parametric or skewed. Get a real feeling of whats going on rather than just relying on statistical tests. If you have a hunch and the p-value looks in the right ball park, gather more data and see if this confirms your theory. | Clustering and A/B testing
Absolutely, you can compare the different clusters, although it's important that you carefully consider what you infer from statistical significance. While it is indeed a very good indicator, by its v |
37,129 | how does multicollinearity affect feature importances in random forest classifier? | Yes, multicollinearity definitely can affect variable importances in random forest models. Intuitively, it can be difficult to rank the relative importance of different variables if they have the same or similar underlying effect, which is implied by multicollinearity. That is- if we can access the underlying effect by measuring more than one variable, it's not easy to say which is causing the effect, or if they are mutual symptoms of a third effect.
A discussion of this property of random forests (and of regression questions more generally) can be found in the following lecture notes, among other sources:
http://www-bcf.usc.edu/~shihs/shih_randomforests.pdf
One common way to adjust for this is in the variable selection stage- by selecting one of the multicollinear variables to keep while removing others. This comes, of course, with its own potential issues- by removing potentially partially unique effects. | how does multicollinearity affect feature importances in random forest classifier? | Yes, multicollinearity definitely can affect variable importances in random forest models. Intuitively, it can be difficult to rank the relative importance of different variables if they have the same | how does multicollinearity affect feature importances in random forest classifier?
Yes, multicollinearity definitely can affect variable importances in random forest models. Intuitively, it can be difficult to rank the relative importance of different variables if they have the same or similar underlying effect, which is implied by multicollinearity. That is- if we can access the underlying effect by measuring more than one variable, it's not easy to say which is causing the effect, or if they are mutual symptoms of a third effect.
A discussion of this property of random forests (and of regression questions more generally) can be found in the following lecture notes, among other sources:
http://www-bcf.usc.edu/~shihs/shih_randomforests.pdf
One common way to adjust for this is in the variable selection stage- by selecting one of the multicollinear variables to keep while removing others. This comes, of course, with its own potential issues- by removing potentially partially unique effects. | how does multicollinearity affect feature importances in random forest classifier?
Yes, multicollinearity definitely can affect variable importances in random forest models. Intuitively, it can be difficult to rank the relative importance of different variables if they have the same |
37,130 | Statistical differences between two hourly patterns | This is an old question, but has no accepted answer, so let me offer my own.
Here is some data that, while not being exactly like yours, is close enough for our purposes.
Because the data are non-linear, I think a GAM might work well here. I'll use the mgcv library to first fit a simple gam which uses a smooth for time and an additive effect for age group (here labeled g).
Model Code:
model = gam(y ~ s(t) + g, data = d)
Let's take a look at the predictions.
Model looks ok, maybe the tail ends could be problematic. Let's fit a smooth which varies by group
model = gam(y ~ s(t, by = g), data = d)
Let's take a look at predictions
Ehhh... maybe we needed that additive effect. Finally, let's fit a model which varies by group, but also has an additive effect
model = gam(y ~ s(t, by = g) + g, data = d)
I think that is the best fit we are going to get. I should add that since this data is technically cyclical, we should pass bs = 'cc' to use cyclic cubic regression. The model has a summary functionality which looks a lot like the lm summary, complete with hypothesis tests. The tests for the fixed effects are similar to a linear model, but the null hypothesis for the smooths is a bit more complicated. Gavin Simpson, who is like The GAM Guy so far as I am concerned, has an excellent run down of the gam summary table here. | Statistical differences between two hourly patterns | This is an old question, but has no accepted answer, so let me offer my own.
Here is some data that, while not being exactly like yours, is close enough for our purposes.
Because the data are non-lin | Statistical differences between two hourly patterns
This is an old question, but has no accepted answer, so let me offer my own.
Here is some data that, while not being exactly like yours, is close enough for our purposes.
Because the data are non-linear, I think a GAM might work well here. I'll use the mgcv library to first fit a simple gam which uses a smooth for time and an additive effect for age group (here labeled g).
Model Code:
model = gam(y ~ s(t) + g, data = d)
Let's take a look at the predictions.
Model looks ok, maybe the tail ends could be problematic. Let's fit a smooth which varies by group
model = gam(y ~ s(t, by = g), data = d)
Let's take a look at predictions
Ehhh... maybe we needed that additive effect. Finally, let's fit a model which varies by group, but also has an additive effect
model = gam(y ~ s(t, by = g) + g, data = d)
I think that is the best fit we are going to get. I should add that since this data is technically cyclical, we should pass bs = 'cc' to use cyclic cubic regression. The model has a summary functionality which looks a lot like the lm summary, complete with hypothesis tests. The tests for the fixed effects are similar to a linear model, but the null hypothesis for the smooths is a bit more complicated. Gavin Simpson, who is like The GAM Guy so far as I am concerned, has an excellent run down of the gam summary table here. | Statistical differences between two hourly patterns
This is an old question, but has no accepted answer, so let me offer my own.
Here is some data that, while not being exactly like yours, is close enough for our purposes.
Because the data are non-lin |
37,131 | Statistical differences between two hourly patterns | Why don't you split into few time bands of 2h duration, say 00:04, 04:06, etc. and for each band you apply a two-sample t-test for each band. You didn't mention how many patients for each group, but if they are only few a t-test should do the work. Then you will get a p-value and a confidence interval for each time band. You can reject the null hypothesis only if you can reject for all bands and use the largest p-value as p-value for the whole population. | Statistical differences between two hourly patterns | Why don't you split into few time bands of 2h duration, say 00:04, 04:06, etc. and for each band you apply a two-sample t-test for each band. You didn't mention how many patients for each group, but i | Statistical differences between two hourly patterns
Why don't you split into few time bands of 2h duration, say 00:04, 04:06, etc. and for each band you apply a two-sample t-test for each band. You didn't mention how many patients for each group, but if they are only few a t-test should do the work. Then you will get a p-value and a confidence interval for each time band. You can reject the null hypothesis only if you can reject for all bands and use the largest p-value as p-value for the whole population. | Statistical differences between two hourly patterns
Why don't you split into few time bands of 2h duration, say 00:04, 04:06, etc. and for each band you apply a two-sample t-test for each band. You didn't mention how many patients for each group, but i |
37,132 | How to impute a missing categorical predictor variable for a random forest model? | I think you need an unsupervised imputing method. That is one which do not use the target values for imputation. If you only have few prediction feature vectors, it may be difficult to uncover a data structure. Instead you could mix your predictions with already imputed training feature vectors and use this structure to impute once again. Notice this procedure may violate assumptions of independence, therefore wrap the entire procedure in an outer cross-validation to check for serious overfitting.
I just learned about missForest from a comment to this question. missForest seems to do the trick. I simulated your problem on the iris data. (without outer cross-validation)
rm(list=ls())
data("iris")
set.seed(1234)
n.train = 100
train.index = sample(nrow(iris),n.train)
feature.train = as.matrix(iris[ train.index,1:4])
feature.test = as.matrix(iris[-train.index,1:4])
#simulate 40 NAs in train
n.NAs = 40
NA.index = sample(length(feature.train),n.NAs)
NA.feature.train = feature.train; NA.feature.train[NA.index] = NA
#imputing 40 NAs unsupervised
library(missForest)
imp.feature.train = missForest(NA.feature.train)$ximp
#check how well imputation went, seems promsing for this data set
plot( feature.train[NA.index],xlab="true value",
imp.feature.train[NA.index],ylab="imp value",)
#simulate random NAs in feature test
feature.test[sample(length(feature.test),20)] = NA
#mix feature.test with imp.feature.train
nrow.test = nrow(feature.test)
mix.feature = rbind(feature.test,imp.feature.train)
imp.feature.test = missForest(mix.feature)$ximp[1:nrow.test,]
#train RF and predict
library(randomForest)
rf = randomForest(imp.feature.train,iris$Species[train.index])
pred.test = predict(rf,imp.feature.test)
table(pred.test, iris$Species[-train.index])
Printing...
-----------------
pred.test setosa versicolor virginica
setosa 12 0 0
versicolor 0 20 2
virginica 0 1 15 | How to impute a missing categorical predictor variable for a random forest model? | I think you need an unsupervised imputing method. That is one which do not use the target values for imputation. If you only have few prediction feature vectors, it may be difficult to uncover a data | How to impute a missing categorical predictor variable for a random forest model?
I think you need an unsupervised imputing method. That is one which do not use the target values for imputation. If you only have few prediction feature vectors, it may be difficult to uncover a data structure. Instead you could mix your predictions with already imputed training feature vectors and use this structure to impute once again. Notice this procedure may violate assumptions of independence, therefore wrap the entire procedure in an outer cross-validation to check for serious overfitting.
I just learned about missForest from a comment to this question. missForest seems to do the trick. I simulated your problem on the iris data. (without outer cross-validation)
rm(list=ls())
data("iris")
set.seed(1234)
n.train = 100
train.index = sample(nrow(iris),n.train)
feature.train = as.matrix(iris[ train.index,1:4])
feature.test = as.matrix(iris[-train.index,1:4])
#simulate 40 NAs in train
n.NAs = 40
NA.index = sample(length(feature.train),n.NAs)
NA.feature.train = feature.train; NA.feature.train[NA.index] = NA
#imputing 40 NAs unsupervised
library(missForest)
imp.feature.train = missForest(NA.feature.train)$ximp
#check how well imputation went, seems promsing for this data set
plot( feature.train[NA.index],xlab="true value",
imp.feature.train[NA.index],ylab="imp value",)
#simulate random NAs in feature test
feature.test[sample(length(feature.test),20)] = NA
#mix feature.test with imp.feature.train
nrow.test = nrow(feature.test)
mix.feature = rbind(feature.test,imp.feature.train)
imp.feature.test = missForest(mix.feature)$ximp[1:nrow.test,]
#train RF and predict
library(randomForest)
rf = randomForest(imp.feature.train,iris$Species[train.index])
pred.test = predict(rf,imp.feature.test)
table(pred.test, iris$Species[-train.index])
Printing...
-----------------
pred.test setosa versicolor virginica
setosa 12 0 0
versicolor 0 20 2
virginica 0 1 15 | How to impute a missing categorical predictor variable for a random forest model?
I think you need an unsupervised imputing method. That is one which do not use the target values for imputation. If you only have few prediction feature vectors, it may be difficult to uncover a data |
37,133 | Truncated trivariate normal - conditional expectation | By definition if $P(A)>0$
$$E(X|A)=\frac{E(X1_A)}{p(A)}$$
so
$$E(X_1|a<X_2<b)=\frac{E(X_1 1_{a<X_2<b})}{p(a<X_2<b)}
=\frac{\int_a^b \int x_1 f(x_1,x_2) dx_1 dx_2}{p(a<X_2<b)}$$
similarity define
$A=\{X_2\in (a,b)\}$ and $B=\{X_3\in (a,b)\}$
$$E(X_1|a<X_2<b,a<X_2<b)=E(X_1|AB)=
\frac{E(X_1 1_{AB})}{p(AB)}=\frac{E(X_1 1_{a<X_2<b} 1_{a<X_3<b})}{p(AB)}
=\frac{\int_a^b \int_a^b \int x_1 f(x_1,x_2,x_3) dx_1 dx_2 dx_3}{\int_a^b \int_a^b f(x_2,x_3) dx_2 dx_3}$$ | Truncated trivariate normal - conditional expectation | By definition if $P(A)>0$
$$E(X|A)=\frac{E(X1_A)}{p(A)}$$
so
$$E(X_1|a<X_2<b)=\frac{E(X_1 1_{a<X_2<b})}{p(a<X_2<b)}
=\frac{\int_a^b \int x_1 f(x_1,x_2) dx_1 dx_2}{p(a<X_2<b)}$$
similarity define
$A=\ | Truncated trivariate normal - conditional expectation
By definition if $P(A)>0$
$$E(X|A)=\frac{E(X1_A)}{p(A)}$$
so
$$E(X_1|a<X_2<b)=\frac{E(X_1 1_{a<X_2<b})}{p(a<X_2<b)}
=\frac{\int_a^b \int x_1 f(x_1,x_2) dx_1 dx_2}{p(a<X_2<b)}$$
similarity define
$A=\{X_2\in (a,b)\}$ and $B=\{X_3\in (a,b)\}$
$$E(X_1|a<X_2<b,a<X_2<b)=E(X_1|AB)=
\frac{E(X_1 1_{AB})}{p(AB)}=\frac{E(X_1 1_{a<X_2<b} 1_{a<X_3<b})}{p(AB)}
=\frac{\int_a^b \int_a^b \int x_1 f(x_1,x_2,x_3) dx_1 dx_2 dx_3}{\int_a^b \int_a^b f(x_2,x_3) dx_2 dx_3}$$ | Truncated trivariate normal - conditional expectation
By definition if $P(A)>0$
$$E(X|A)=\frac{E(X1_A)}{p(A)}$$
so
$$E(X_1|a<X_2<b)=\frac{E(X_1 1_{a<X_2<b})}{p(a<X_2<b)}
=\frac{\int_a^b \int x_1 f(x_1,x_2) dx_1 dx_2}{p(a<X_2<b)}$$
similarity define
$A=\ |
37,134 | Truncated trivariate normal - conditional expectation | Let's address the questions in turn.
The first one concerns the bivariate Normal distribution of $(X_1,X_2).$ This is determined by its mean $(\mu_1,\mu_2),$ the variances $\sigma_1\gt 0$ and $\sigma_2\gt 0,$ and the correlation coefficient $\rho = \rho_{12}.$ The theory of least-squares regression in the bivariate Normal setting teaches us that the distribution of $Z_1=(X_1-\mu_1)/\sigma_1$ conditional on $Z_2=(X_2-\mu_2)/\sigma_2$ is Normal with mean $\rho Z_2.$ Since $Z_2$ has a standard Normal distribution, we may directly compute
$$\begin{aligned}
E[X_1\mid a \le X_2 \le b] &= E[\mu_1+\sigma_1 Z_1\mid a \le \mu_2 + \sigma_2 Z_2 \le b]\\
&= \mu_1 + \sigma_1\,E[Z_1 \mid (a-\mu_2)/\sigma_2 \le Z_2 \le (b-\mu_2)/\sigma_2]\\
&= \mu_1 + \sigma_1 \,E[\rho Z_2 \mid (a-\mu_2)/\sigma_2 \le Z_2 \le (b-\mu_2)/\sigma_2]\\
&= \mu_1 + \sigma_1\rho \,E[Z_2 \mid (a-\mu_2)/\sigma_2 \le Z_2 \le (b-\mu_2)/\sigma_2].
\end{aligned}$$
Abbreviate things by setting
$$\alpha=(a-\mu_2)/\sigma_2\text{ and }\beta=(b-\mu_2)/\sigma_2$$
for the standardized interval endpoints. Letting $\phi$ be the standard Normal PDF and recalling that $\mathrm{d}\phi(z) = -z\,\phi(z)\mathrm{d}z,$ it is easy to compute this conditional expectation as
$$\begin{aligned}
E[Z_2 \mid \alpha\le Z_2 \le \beta] &= \frac{1}{\Phi(\beta)-\Phi(\alpha)}\int_\alpha^\beta z \phi(z)\,\mathrm{d}z \\
&= \frac{1}{\Phi(\beta)-\Phi(\alpha)}\int_\alpha^\beta -\mathrm{d}\phi(z) \\
&= \frac{\phi(\alpha)-\phi(\beta)}{\Phi(\beta)-\Phi(\alpha)}.
\end{aligned}$$
This result suggests we should tackle the trivariate problem by first making similar simplifications: that is, standardize the variables and perform linear regression. Generalize the preceding notation to include a third subscript for the third variable. As before,
$$\begin{aligned}
E[X_1\mid a_2 \le X_2 \le b_2,\, a_3 \le X_3 \le b_3] &= E[\mu_1+\sigma_1 Z_1\mid a_2 \le \mu_2 + \sigma_2 Z_2 \le b_2, \ldots]\\
&= \mu_1 + \sigma_1\,E[Z_1 \mid (a_2-\mu_2)/\sigma_2 \le Z_2 \le (b_2-\mu_2)/\sigma_2, \ldots].
\end{aligned}$$
(This handles the case where the value of $(X_2,X_3)$ is conditioned on a rectangle rather than a square; it's no more difficult to solve and the notation makes the pattern a little clearer.)
The regression of $Z_1$ on $(Z_2,Z_3)$ is found by finding coefficients $(\gamma_2,\gamma_3)$ that minimize $$E[(Z_1 - \gamma_2Z_2 - \gamma_3Z_3)^2] = 1 - 2\rho_{12}\gamma_2 - 2\rho_{13}\gamma_3 + 2\rho_{23}\gamma_2\gamma_3 + \gamma_2^2 + \gamma_3^2.$$ Assuming $(X_1,X_2,X_3)$ has a nondegenerate distribution, its unique critical point (where the gradient vanishes), which must be the global minimum, therefore occurs when
$$\pmatrix{\rho_{12}\\\rho_{13}} = \pmatrix{1 & \rho_{23} \\ \rho_{23} & 1}\pmatrix{\gamma_2\\\gamma_3}$$
with solution
$$\pmatrix{\gamma_2\\\gamma_3} = \frac{1}{1-\rho_{23}^2} \pmatrix{\rho_{12} - \rho_{23} \rho_{13} \\ \rho_{13} - \rho_{23}\rho_{12}}.$$
Thus $$E[Z_1 \mid (Z_2,Z_3)] = \gamma_2 E[Z_2 \mid (Z_2,Z_3)]+ \gamma_3 E[Z_3\mid (Z_2,Z_3)]$$ and we may proceed as before to find this via integration. Again, to simplify the notation, write
$$\alpha_i = (a_i - \mu_i)/\sigma_i,\ \beta_i = (b_i - \mu_i)/\sigma_i$$
for $i=2, 3,$ and define the standard bivariate Normal conditional expectation functions
$$\begin{aligned}
\Psi_i([a,b],\,[c,d]\mid \rho) &= E[Z_i\mid Z_2\in[a,b],\ Z_3\in[c,d]] \\
&= \frac{\iint_{[a,b]\times[c,d]} z_i\,\phi(z_2,z_3\mid \rho)\,\mathrm{d}z_2\mathrm{d}z_3}{\iint_{[a,b]\times[c,d]} \phi(z_2,z_3\mid \rho)\,\mathrm{d}z_2\mathrm{d}z_3}
\end{aligned}$$
where
$$\phi(z_2,z_3\mid \rho) = \frac{1}{2\pi(1-\rho^2)} \exp\left(-\frac{z_2^2-2\rho z_2z_3+z_3^2}{2(1-\rho^2)}\right)$$
is the standard bivariate Normal PDF (for variables with correlation $\rho$). Our result (at the top of this section) then is
$$\begin{aligned}
&E[X_1\mid a_2 \le X_2 \le b_2,\, a_3 \le X_3 \le b_3] \\
&= \mu_1 + \sigma_1\,E[Z_1 \mid (a_2-\mu_2)/\sigma_2 \le Z_2 \le (b_2-\mu_2)/\sigma_2, \ldots] \\
&= \mu_1 + \sigma_1 \left(\gamma_2 \Psi_2([\alpha_2,\beta_2],[\alpha_3,\beta_3]\mid\rho_{23}) + \gamma_3 \Psi_3([\alpha_2,\beta_2],[\alpha_3,\beta_3]\mid\rho_{23})\right).
\end{aligned}$$
The integrals in the definition of the $\Psi_i$ are over a rectangle within the domain of the bivariate Normal distribution of $(Z_2,Z_3).$ Unless $\rho_{23}=0$ (when $Z_2$ and $Z_3$ are independent) the formula for this is messy; unless you really need a formula for further analysis, numerical integration may be most appropriate. | Truncated trivariate normal - conditional expectation | Let's address the questions in turn.
The first one concerns the bivariate Normal distribution of $(X_1,X_2).$ This is determined by its mean $(\mu_1,\mu_2),$ the variances $\sigma_1\gt 0$ and $\sigma | Truncated trivariate normal - conditional expectation
Let's address the questions in turn.
The first one concerns the bivariate Normal distribution of $(X_1,X_2).$ This is determined by its mean $(\mu_1,\mu_2),$ the variances $\sigma_1\gt 0$ and $\sigma_2\gt 0,$ and the correlation coefficient $\rho = \rho_{12}.$ The theory of least-squares regression in the bivariate Normal setting teaches us that the distribution of $Z_1=(X_1-\mu_1)/\sigma_1$ conditional on $Z_2=(X_2-\mu_2)/\sigma_2$ is Normal with mean $\rho Z_2.$ Since $Z_2$ has a standard Normal distribution, we may directly compute
$$\begin{aligned}
E[X_1\mid a \le X_2 \le b] &= E[\mu_1+\sigma_1 Z_1\mid a \le \mu_2 + \sigma_2 Z_2 \le b]\\
&= \mu_1 + \sigma_1\,E[Z_1 \mid (a-\mu_2)/\sigma_2 \le Z_2 \le (b-\mu_2)/\sigma_2]\\
&= \mu_1 + \sigma_1 \,E[\rho Z_2 \mid (a-\mu_2)/\sigma_2 \le Z_2 \le (b-\mu_2)/\sigma_2]\\
&= \mu_1 + \sigma_1\rho \,E[Z_2 \mid (a-\mu_2)/\sigma_2 \le Z_2 \le (b-\mu_2)/\sigma_2].
\end{aligned}$$
Abbreviate things by setting
$$\alpha=(a-\mu_2)/\sigma_2\text{ and }\beta=(b-\mu_2)/\sigma_2$$
for the standardized interval endpoints. Letting $\phi$ be the standard Normal PDF and recalling that $\mathrm{d}\phi(z) = -z\,\phi(z)\mathrm{d}z,$ it is easy to compute this conditional expectation as
$$\begin{aligned}
E[Z_2 \mid \alpha\le Z_2 \le \beta] &= \frac{1}{\Phi(\beta)-\Phi(\alpha)}\int_\alpha^\beta z \phi(z)\,\mathrm{d}z \\
&= \frac{1}{\Phi(\beta)-\Phi(\alpha)}\int_\alpha^\beta -\mathrm{d}\phi(z) \\
&= \frac{\phi(\alpha)-\phi(\beta)}{\Phi(\beta)-\Phi(\alpha)}.
\end{aligned}$$
This result suggests we should tackle the trivariate problem by first making similar simplifications: that is, standardize the variables and perform linear regression. Generalize the preceding notation to include a third subscript for the third variable. As before,
$$\begin{aligned}
E[X_1\mid a_2 \le X_2 \le b_2,\, a_3 \le X_3 \le b_3] &= E[\mu_1+\sigma_1 Z_1\mid a_2 \le \mu_2 + \sigma_2 Z_2 \le b_2, \ldots]\\
&= \mu_1 + \sigma_1\,E[Z_1 \mid (a_2-\mu_2)/\sigma_2 \le Z_2 \le (b_2-\mu_2)/\sigma_2, \ldots].
\end{aligned}$$
(This handles the case where the value of $(X_2,X_3)$ is conditioned on a rectangle rather than a square; it's no more difficult to solve and the notation makes the pattern a little clearer.)
The regression of $Z_1$ on $(Z_2,Z_3)$ is found by finding coefficients $(\gamma_2,\gamma_3)$ that minimize $$E[(Z_1 - \gamma_2Z_2 - \gamma_3Z_3)^2] = 1 - 2\rho_{12}\gamma_2 - 2\rho_{13}\gamma_3 + 2\rho_{23}\gamma_2\gamma_3 + \gamma_2^2 + \gamma_3^2.$$ Assuming $(X_1,X_2,X_3)$ has a nondegenerate distribution, its unique critical point (where the gradient vanishes), which must be the global minimum, therefore occurs when
$$\pmatrix{\rho_{12}\\\rho_{13}} = \pmatrix{1 & \rho_{23} \\ \rho_{23} & 1}\pmatrix{\gamma_2\\\gamma_3}$$
with solution
$$\pmatrix{\gamma_2\\\gamma_3} = \frac{1}{1-\rho_{23}^2} \pmatrix{\rho_{12} - \rho_{23} \rho_{13} \\ \rho_{13} - \rho_{23}\rho_{12}}.$$
Thus $$E[Z_1 \mid (Z_2,Z_3)] = \gamma_2 E[Z_2 \mid (Z_2,Z_3)]+ \gamma_3 E[Z_3\mid (Z_2,Z_3)]$$ and we may proceed as before to find this via integration. Again, to simplify the notation, write
$$\alpha_i = (a_i - \mu_i)/\sigma_i,\ \beta_i = (b_i - \mu_i)/\sigma_i$$
for $i=2, 3,$ and define the standard bivariate Normal conditional expectation functions
$$\begin{aligned}
\Psi_i([a,b],\,[c,d]\mid \rho) &= E[Z_i\mid Z_2\in[a,b],\ Z_3\in[c,d]] \\
&= \frac{\iint_{[a,b]\times[c,d]} z_i\,\phi(z_2,z_3\mid \rho)\,\mathrm{d}z_2\mathrm{d}z_3}{\iint_{[a,b]\times[c,d]} \phi(z_2,z_3\mid \rho)\,\mathrm{d}z_2\mathrm{d}z_3}
\end{aligned}$$
where
$$\phi(z_2,z_3\mid \rho) = \frac{1}{2\pi(1-\rho^2)} \exp\left(-\frac{z_2^2-2\rho z_2z_3+z_3^2}{2(1-\rho^2)}\right)$$
is the standard bivariate Normal PDF (for variables with correlation $\rho$). Our result (at the top of this section) then is
$$\begin{aligned}
&E[X_1\mid a_2 \le X_2 \le b_2,\, a_3 \le X_3 \le b_3] \\
&= \mu_1 + \sigma_1\,E[Z_1 \mid (a_2-\mu_2)/\sigma_2 \le Z_2 \le (b_2-\mu_2)/\sigma_2, \ldots] \\
&= \mu_1 + \sigma_1 \left(\gamma_2 \Psi_2([\alpha_2,\beta_2],[\alpha_3,\beta_3]\mid\rho_{23}) + \gamma_3 \Psi_3([\alpha_2,\beta_2],[\alpha_3,\beta_3]\mid\rho_{23})\right).
\end{aligned}$$
The integrals in the definition of the $\Psi_i$ are over a rectangle within the domain of the bivariate Normal distribution of $(Z_2,Z_3).$ Unless $\rho_{23}=0$ (when $Z_2$ and $Z_3$ are independent) the formula for this is messy; unless you really need a formula for further analysis, numerical integration may be most appropriate. | Truncated trivariate normal - conditional expectation
Let's address the questions in turn.
The first one concerns the bivariate Normal distribution of $(X_1,X_2).$ This is determined by its mean $(\mu_1,\mu_2),$ the variances $\sigma_1\gt 0$ and $\sigma |
37,135 | Why do we want low autocorrelation for MCMC convergence? | There's two things going on here that both lead to wanting to low autocorrelation, but from slightly different angles.
First is that if you have some sort of sampler (i.e. Metropolis Hasting, Gibbs sampler, whatever), you would like to have very little autocorrelation in the samples. This can be explained very easily by thinking of the MCMC error: for the posterior mean, for example, the MCMC error will be lower if you have weakly correlated samples than if you have strongly correlated samples. That's the easy explanation, but it's worth thinking about more too. In general, it is easy to see that a sampler that produces weakly correlated samples is preferred over one that produces strongly correlated samples.
Second, which I think is more what you are getting, is using the empirical autocorrelation to determine what "burn-in" to remove. The reasoning behind this is that typically, we don't have great starting points; we often begin far from the mode. Including these starting points in a finite sample can add bias, as we are over representing these start points by beginning there and potentially slowly drifting toward the mode. Different samplers may "drift" faster than others. Once we get close to the mode, we should essentially bouncing around the mode at that point. But here in is the important note: when we are far from the mode, many samplers will have strong 'tug' back toward the mode, as moving toward the mode will likely greatly increase the posterior probability. However, when we are close to the mode, our sampler should be taking random jumps, with much less 'tug' toward the mode (because the samples are much closer). The stronger the tug, the higher the autocorrelation. Thus, if we observe that there is heavy autocorrelation early in our chain, which then levels off after awhile, this is indicative of being very far from the mode early on. | Why do we want low autocorrelation for MCMC convergence? | There's two things going on here that both lead to wanting to low autocorrelation, but from slightly different angles.
First is that if you have some sort of sampler (i.e. Metropolis Hasting, Gibbs s | Why do we want low autocorrelation for MCMC convergence?
There's two things going on here that both lead to wanting to low autocorrelation, but from slightly different angles.
First is that if you have some sort of sampler (i.e. Metropolis Hasting, Gibbs sampler, whatever), you would like to have very little autocorrelation in the samples. This can be explained very easily by thinking of the MCMC error: for the posterior mean, for example, the MCMC error will be lower if you have weakly correlated samples than if you have strongly correlated samples. That's the easy explanation, but it's worth thinking about more too. In general, it is easy to see that a sampler that produces weakly correlated samples is preferred over one that produces strongly correlated samples.
Second, which I think is more what you are getting, is using the empirical autocorrelation to determine what "burn-in" to remove. The reasoning behind this is that typically, we don't have great starting points; we often begin far from the mode. Including these starting points in a finite sample can add bias, as we are over representing these start points by beginning there and potentially slowly drifting toward the mode. Different samplers may "drift" faster than others. Once we get close to the mode, we should essentially bouncing around the mode at that point. But here in is the important note: when we are far from the mode, many samplers will have strong 'tug' back toward the mode, as moving toward the mode will likely greatly increase the posterior probability. However, when we are close to the mode, our sampler should be taking random jumps, with much less 'tug' toward the mode (because the samples are much closer). The stronger the tug, the higher the autocorrelation. Thus, if we observe that there is heavy autocorrelation early in our chain, which then levels off after awhile, this is indicative of being very far from the mode early on. | Why do we want low autocorrelation for MCMC convergence?
There's two things going on here that both lead to wanting to low autocorrelation, but from slightly different angles.
First is that if you have some sort of sampler (i.e. Metropolis Hasting, Gibbs s |
37,136 | Sampling distribution of sample trimmed (truncated) mean | No analytical formula is known for the expected minimum of $n$ normal variables when $n>5$.
Meanwhile, the trimmed mean in the background of the question has expectation $−1/(n−1)$ times the expectation of that minimum. So no analytical formula is known for the expected trimmed mean when $n>5$. This suggests that there is no nice analytical formula for the distribution of that trimmed mean either.
This was documented in a 1949 paper on "Some Low Moments of Order Statistics", where H.J. Godwin concluded: "the author has not succeeded in obtaining similar results with a higher number of variables -- it is possible that elementary functions no longer suffice then." If you search the literature of order statistics (perhaps guided H.A. David's textbook or the later editions with H.N. Nagaraja), I think you'll also see that no one's reported any new exact formulas for the minimum or maximum since then. | Sampling distribution of sample trimmed (truncated) mean | No analytical formula is known for the expected minimum of $n$ normal variables when $n>5$.
Meanwhile, the trimmed mean in the background of the question has expectation $−1/(n−1)$ times the expectati | Sampling distribution of sample trimmed (truncated) mean
No analytical formula is known for the expected minimum of $n$ normal variables when $n>5$.
Meanwhile, the trimmed mean in the background of the question has expectation $−1/(n−1)$ times the expectation of that minimum. So no analytical formula is known for the expected trimmed mean when $n>5$. This suggests that there is no nice analytical formula for the distribution of that trimmed mean either.
This was documented in a 1949 paper on "Some Low Moments of Order Statistics", where H.J. Godwin concluded: "the author has not succeeded in obtaining similar results with a higher number of variables -- it is possible that elementary functions no longer suffice then." If you search the literature of order statistics (perhaps guided H.A. David's textbook or the later editions with H.N. Nagaraja), I think you'll also see that no one's reported any new exact formulas for the minimum or maximum since then. | Sampling distribution of sample trimmed (truncated) mean
No analytical formula is known for the expected minimum of $n$ normal variables when $n>5$.
Meanwhile, the trimmed mean in the background of the question has expectation $−1/(n−1)$ times the expectati |
37,137 | Why is a lognormal distribution a good fit for server response times? | You might be interested in reading the paper
Vern Paxson. Empirically-Derived Analytic Models of
Wide-Area TCP Connections. IEEE/ACM Transactions on Networking, 1994.
which is available online here. From the abstract:
We analyze 3 million TCP connections that occurred during
15 wide-area traffic traces. The traces were gathered at five
“stub” networks and two internetwork gateways, providing a
diverse look at wide-area traffic. We derive analytic models
describing the random variables associated with telnet, nntp, smtp, and ftp connections.
and from the paper
For most connections the responder/duration ratio was well modeled by an exponential distribution, but “large” connections—those whose responder bytes were in the upper 10% of all connections—had a different distribution. For these, the ratio was fairly well modeled by a log-normal distribution.
Though, it is a bit dated already :-) | Why is a lognormal distribution a good fit for server response times? | You might be interested in reading the paper
Vern Paxson. Empirically-Derived Analytic Models of
Wide-Area TCP Connections. IEEE/ACM Transactions on Networking, 1994.
which is available online he | Why is a lognormal distribution a good fit for server response times?
You might be interested in reading the paper
Vern Paxson. Empirically-Derived Analytic Models of
Wide-Area TCP Connections. IEEE/ACM Transactions on Networking, 1994.
which is available online here. From the abstract:
We analyze 3 million TCP connections that occurred during
15 wide-area traffic traces. The traces were gathered at five
“stub” networks and two internetwork gateways, providing a
diverse look at wide-area traffic. We derive analytic models
describing the random variables associated with telnet, nntp, smtp, and ftp connections.
and from the paper
For most connections the responder/duration ratio was well modeled by an exponential distribution, but “large” connections—those whose responder bytes were in the upper 10% of all connections—had a different distribution. For these, the ratio was fairly well modeled by a log-normal distribution.
Though, it is a bit dated already :-) | Why is a lognormal distribution a good fit for server response times?
You might be interested in reading the paper
Vern Paxson. Empirically-Derived Analytic Models of
Wide-Area TCP Connections. IEEE/ACM Transactions on Networking, 1994.
which is available online he |
37,138 | Why is a lognormal distribution a good fit for server response times? | Say $X_1, \ldots X_n \overset{iid}{\sim} \text{something}$. You don't know the distribution but you don't need to. By the central limit theorem $\bar{X} \to \mathcal{N}$. Don't worry about the parameters. Then $\exp(\bar{X}) \to \text{lognormal}$. Last part: $Y_1 = \exp(\frac{\sum_i X_i}{n}) = \left[\exp(\sum_i X_i)\right] ^{1/n} = \left[\prod_i \exp X_i\right]^{1/n}$.
$Y_1$ is your first response time. I don't know anything about this stuff, but their justification for using this probably has something to do with this. Probably your response rate comes from an average of a gajillion unknown things coming from some unknown distribution. | Why is a lognormal distribution a good fit for server response times? | Say $X_1, \ldots X_n \overset{iid}{\sim} \text{something}$. You don't know the distribution but you don't need to. By the central limit theorem $\bar{X} \to \mathcal{N}$. Don't worry about the paramet | Why is a lognormal distribution a good fit for server response times?
Say $X_1, \ldots X_n \overset{iid}{\sim} \text{something}$. You don't know the distribution but you don't need to. By the central limit theorem $\bar{X} \to \mathcal{N}$. Don't worry about the parameters. Then $\exp(\bar{X}) \to \text{lognormal}$. Last part: $Y_1 = \exp(\frac{\sum_i X_i}{n}) = \left[\exp(\sum_i X_i)\right] ^{1/n} = \left[\prod_i \exp X_i\right]^{1/n}$.
$Y_1$ is your first response time. I don't know anything about this stuff, but their justification for using this probably has something to do with this. Probably your response rate comes from an average of a gajillion unknown things coming from some unknown distribution. | Why is a lognormal distribution a good fit for server response times?
Say $X_1, \ldots X_n \overset{iid}{\sim} \text{something}$. You don't know the distribution but you don't need to. By the central limit theorem $\bar{X} \to \mathcal{N}$. Don't worry about the paramet |
37,139 | MANOVA as protection against Type I errors | Requiring a significant MANOVA or ANOVA before conducting individual t-tests can help protect against Type I error, but is not generally sufficient to provide strong Type I error control. For example, if you only conduct the individual tests when the MANOVA is significant, that controls the familywise Type I error rate when the all null hypotheses are true (this is sometimes called "weak" control). But that doesn't necessarily protect you when one or more null hypotheses are false (unless there are only 2 DVs, in which case one null hypothesis being false would eliminate the problem of multiple comparisons). Similarly, if you only conduct the individual tests when the ANOVA is significant, that controls the familywise Type I error rate when all group means are equal, but not when one or more group means are different from the rest (unless there are only 3 groups in which case one group mean being different would eliminate the problem of multiple comparisons).
Therefore, the method you described does not reliably control Type I error. However, you can use a similar method if you apply a multiple comparisons adjustment (see references below).
References:
Frane. 2015. Power and Type I error control for univariate comparisons in multivariate two-group designs. Multivariate Behavioral Research, 50.
Hayter, 1986. The maximum familywise error rate of Fisher's least significant difference test. Journal of the American Statitical Association, 81. | MANOVA as protection against Type I errors | Requiring a significant MANOVA or ANOVA before conducting individual t-tests can help protect against Type I error, but is not generally sufficient to provide strong Type I error control. For example, | MANOVA as protection against Type I errors
Requiring a significant MANOVA or ANOVA before conducting individual t-tests can help protect against Type I error, but is not generally sufficient to provide strong Type I error control. For example, if you only conduct the individual tests when the MANOVA is significant, that controls the familywise Type I error rate when the all null hypotheses are true (this is sometimes called "weak" control). But that doesn't necessarily protect you when one or more null hypotheses are false (unless there are only 2 DVs, in which case one null hypothesis being false would eliminate the problem of multiple comparisons). Similarly, if you only conduct the individual tests when the ANOVA is significant, that controls the familywise Type I error rate when all group means are equal, but not when one or more group means are different from the rest (unless there are only 3 groups in which case one group mean being different would eliminate the problem of multiple comparisons).
Therefore, the method you described does not reliably control Type I error. However, you can use a similar method if you apply a multiple comparisons adjustment (see references below).
References:
Frane. 2015. Power and Type I error control for univariate comparisons in multivariate two-group designs. Multivariate Behavioral Research, 50.
Hayter, 1986. The maximum familywise error rate of Fisher's least significant difference test. Journal of the American Statitical Association, 81. | MANOVA as protection against Type I errors
Requiring a significant MANOVA or ANOVA before conducting individual t-tests can help protect against Type I error, but is not generally sufficient to provide strong Type I error control. For example, |
37,140 | Fair coin testing | If you didn't actually test the coin after the first set of tosses, or make the choice to toss the second set based on the first, then yes, you should be able to simply combine them into one large sample.
If your behavior was in any way contingent on what happened in the first set, then it affects the properties of the combined set when treated as one large sample, compared to what the properties would have been if it had actually been a large sample).
If you did test the coin after the first set, then the two tests will be dependent. (If you tested it but whatever the outcome it would have had no impact on anything in any way, you could continue to simply ignore it as if it had never happened. However, it may be better to report it as two tests, one of n=20 and a second of n=30 - there are various ways to combine independent tests after the fact ... but again, this would require that the second set not be contingent on the first.)
In response to an insightful question in comments:
It's not the proportion of heads that's at issue in my discussion (I can't bias the coin in this way). It's the test of it that's affected. If I assign significance to a particular set of outcomes, but I change the actions based on those outcomes, then I may change the proportion of times I'll make the various conclusions based on my experiment. whuber's comment on "best two out of three?" hints at this; it's not P(H) that is changed by saying "best two out of three" if tails comes up first, but the conclusion based on the experiment ("who wins the toss", in that case).
In the question's 20 tosses, say my original rule is "conclude the coin is biased toward heads if I see 15 or more heads, and conclude it's biased toward tails if I see 15 or more tails". About 2% of the time I'll call a fair coin biased toward heads and about 2% of the time I'll say it's biased toward tails.
Now consider the rule "conclude the coin is biased toward heads if I see 15 or more heads, otherwise, toss 30 more times and apply the rejection rule I would have applied as if I'd tossed 50 times to begin with", then I'm not longer as likely to say it's biased at all, nor as likely to say a fair coin is biased toward heads than to conclude it's biased toward tails | Fair coin testing | If you didn't actually test the coin after the first set of tosses, or make the choice to toss the second set based on the first, then yes, you should be able to simply combine them into one large sa | Fair coin testing
If you didn't actually test the coin after the first set of tosses, or make the choice to toss the second set based on the first, then yes, you should be able to simply combine them into one large sample.
If your behavior was in any way contingent on what happened in the first set, then it affects the properties of the combined set when treated as one large sample, compared to what the properties would have been if it had actually been a large sample).
If you did test the coin after the first set, then the two tests will be dependent. (If you tested it but whatever the outcome it would have had no impact on anything in any way, you could continue to simply ignore it as if it had never happened. However, it may be better to report it as two tests, one of n=20 and a second of n=30 - there are various ways to combine independent tests after the fact ... but again, this would require that the second set not be contingent on the first.)
In response to an insightful question in comments:
It's not the proportion of heads that's at issue in my discussion (I can't bias the coin in this way). It's the test of it that's affected. If I assign significance to a particular set of outcomes, but I change the actions based on those outcomes, then I may change the proportion of times I'll make the various conclusions based on my experiment. whuber's comment on "best two out of three?" hints at this; it's not P(H) that is changed by saying "best two out of three" if tails comes up first, but the conclusion based on the experiment ("who wins the toss", in that case).
In the question's 20 tosses, say my original rule is "conclude the coin is biased toward heads if I see 15 or more heads, and conclude it's biased toward tails if I see 15 or more tails". About 2% of the time I'll call a fair coin biased toward heads and about 2% of the time I'll say it's biased toward tails.
Now consider the rule "conclude the coin is biased toward heads if I see 15 or more heads, otherwise, toss 30 more times and apply the rejection rule I would have applied as if I'd tossed 50 times to begin with", then I'm not longer as likely to say it's biased at all, nor as likely to say a fair coin is biased toward heads than to conclude it's biased toward tails | Fair coin testing
If you didn't actually test the coin after the first set of tosses, or make the choice to toss the second set based on the first, then yes, you should be able to simply combine them into one large sa |
37,141 | Cramer's $\phi $ for three-way contingency tables | There really isn't a straightforward generalization to Cramer's V, in the same way that Pearson's $\phi$ isn't defined for $2 x 2 .... 2$ tables. This is because there are multiple null models to be selecting from, so a single collapsed relationship statistic is not meaningful.
As an example, say you have a large $\chi^2$ value in your association test. In a $2 x 2$ case this is simple, because the rescaling of the $\chi^2$ to a correlation is still meaningful: one unit of increase has a correlation of $\phi$ with the second variable. However, for a $2 x 2 x 2$ model, a large/significant $\chi^2$ could mean that there are many possible relationships present (V1 with V2, V1 with V3, V2 with V3, or V1 with V2 with V3). So a single number would not capture where this co-relationship is occurring, and hence a single correlation statistic would just be ambiguous. The same principle applies to Cramer's V, where higher dimensional tables are not easily collapsible to single number relationships.
Overall goodness of fit measures that are analogous to $R^2$ in linear regression are possible and several have been proposed (e.g., Pseudo R squared formula for GLMs), though these are not that easily done by hand as they rely on computing log-likelihood/deviation values. | Cramer's $\phi $ for three-way contingency tables | There really isn't a straightforward generalization to Cramer's V, in the same way that Pearson's $\phi$ isn't defined for $2 x 2 .... 2$ tables. This is because there are multiple null models to be s | Cramer's $\phi $ for three-way contingency tables
There really isn't a straightforward generalization to Cramer's V, in the same way that Pearson's $\phi$ isn't defined for $2 x 2 .... 2$ tables. This is because there are multiple null models to be selecting from, so a single collapsed relationship statistic is not meaningful.
As an example, say you have a large $\chi^2$ value in your association test. In a $2 x 2$ case this is simple, because the rescaling of the $\chi^2$ to a correlation is still meaningful: one unit of increase has a correlation of $\phi$ with the second variable. However, for a $2 x 2 x 2$ model, a large/significant $\chi^2$ could mean that there are many possible relationships present (V1 with V2, V1 with V3, V2 with V3, or V1 with V2 with V3). So a single number would not capture where this co-relationship is occurring, and hence a single correlation statistic would just be ambiguous. The same principle applies to Cramer's V, where higher dimensional tables are not easily collapsible to single number relationships.
Overall goodness of fit measures that are analogous to $R^2$ in linear regression are possible and several have been proposed (e.g., Pseudo R squared formula for GLMs), though these are not that easily done by hand as they rely on computing log-likelihood/deviation values. | Cramer's $\phi $ for three-way contingency tables
There really isn't a straightforward generalization to Cramer's V, in the same way that Pearson's $\phi$ isn't defined for $2 x 2 .... 2$ tables. This is because there are multiple null models to be s |
37,142 | Gibbs Sampler output: how many Markov chains? | This two-block Gibbs sampler is the only generic case when sub-chains remain Markov chains per se, because $(X_1^{(n)})$ is generated via the kernel
$$K(x_1,x_1^\prime)=\int f_2(x_2|x_1)f_1(x_1^\prime|x_2)\,\text{d}x_2$$
See our MCMC book for more details, but this is a case of interleaving property that also guarantees that the $X_1^{(n)}$'s are positively correlated with a correlation decreasing with the time difference and that Rao-Blackwellisation always reduce the variance of the resulting estimate.
Two Markov chains $(X^{(t)})$ and $(Y^{(t)})$ are said to be
conjugate to each other with the interleaving property (or interleaved) if
$X^{(t)}$ and $X^{(t+1)}$ are independent conditionally on
$Y^{(t)}$;
$Y^{(t-1)}$ and $Y^{(t)}$ are independent conditionally on
$X^{(t)}$; and
$(X^{(t)},Y^{(t-1)})$ and $(X^{(t)},Y^{(t)})$ are identically
distributed under stationarity. | Gibbs Sampler output: how many Markov chains? | This two-block Gibbs sampler is the only generic case when sub-chains remain Markov chains per se, because $(X_1^{(n)})$ is generated via the kernel
$$K(x_1,x_1^\prime)=\int f_2(x_2|x_1)f_1(x_1^\prime | Gibbs Sampler output: how many Markov chains?
This two-block Gibbs sampler is the only generic case when sub-chains remain Markov chains per se, because $(X_1^{(n)})$ is generated via the kernel
$$K(x_1,x_1^\prime)=\int f_2(x_2|x_1)f_1(x_1^\prime|x_2)\,\text{d}x_2$$
See our MCMC book for more details, but this is a case of interleaving property that also guarantees that the $X_1^{(n)}$'s are positively correlated with a correlation decreasing with the time difference and that Rao-Blackwellisation always reduce the variance of the resulting estimate.
Two Markov chains $(X^{(t)})$ and $(Y^{(t)})$ are said to be
conjugate to each other with the interleaving property (or interleaved) if
$X^{(t)}$ and $X^{(t+1)}$ are independent conditionally on
$Y^{(t)}$;
$Y^{(t-1)}$ and $Y^{(t)}$ are independent conditionally on
$X^{(t)}$; and
$(X^{(t)},Y^{(t-1)})$ and $(X^{(t)},Y^{(t)})$ are identically
distributed under stationarity. | Gibbs Sampler output: how many Markov chains?
This two-block Gibbs sampler is the only generic case when sub-chains remain Markov chains per se, because $(X_1^{(n)})$ is generated via the kernel
$$K(x_1,x_1^\prime)=\int f_2(x_2|x_1)f_1(x_1^\prime |
37,143 | Frequency jump detection | Since it seems that you have a time series here, I would recommend you to check my relevant answer for some ideas (time series clustering, entropy measures, anomaly detection) as well as links to further information. In addition, I would also consider the Fourier transformation approach.
UPDATE (based on discussion with the OP in comments below):
In regard to seeking analytical solutions to the problem, it seems to me that there exist several approaches: 1) apply CUSUM (or other) transformation to original data and then perform further analysis (detection); 2) use CUSUM to detect the abrupt changes; 3) use alternative algorithms.
Speaking about CUSUM transformations, it seems to be a topic of some debate - some researchers advise against it, warning about potential loss of inferential validity, while others disagree and still consider that approach useful. You may also find this paper relevant and useful.
Speaking about the selection of appropriate algorithms as well as theory behind the topic and corresponding methods, I highly recommend excellent comprehensive and freely available online book "Detection of Abrupt Changes: Theory and Application" by Basseville and Nikiforov.
In regard to the selection of software for implementing the abrupt change (anomaly) detection, I would recommend to explore several R packages that seem to offer required analytic functionality (in addition to visual) and support CUSUM and similar algorithms. In particular, take a look at the following packages: strucchange (see vignette / JSS paper), changepoint (see vignette), surveillance. The last one asks for special mentioning (considering insights of yours and of RegressForward's) as this package presents a framework and implements statistical methods for analysis of epidemic-like process phenomena (in various fields far beyond epidemiology). The project's home page and development are hosted at R-Forge, but the R package is available on CRAN. A vignette and related presentation slides are available. I hope that this update significantly improves my answer and is helpful. | Frequency jump detection | Since it seems that you have a time series here, I would recommend you to check my relevant answer for some ideas (time series clustering, entropy measures, anomaly detection) as well as links to furt | Frequency jump detection
Since it seems that you have a time series here, I would recommend you to check my relevant answer for some ideas (time series clustering, entropy measures, anomaly detection) as well as links to further information. In addition, I would also consider the Fourier transformation approach.
UPDATE (based on discussion with the OP in comments below):
In regard to seeking analytical solutions to the problem, it seems to me that there exist several approaches: 1) apply CUSUM (or other) transformation to original data and then perform further analysis (detection); 2) use CUSUM to detect the abrupt changes; 3) use alternative algorithms.
Speaking about CUSUM transformations, it seems to be a topic of some debate - some researchers advise against it, warning about potential loss of inferential validity, while others disagree and still consider that approach useful. You may also find this paper relevant and useful.
Speaking about the selection of appropriate algorithms as well as theory behind the topic and corresponding methods, I highly recommend excellent comprehensive and freely available online book "Detection of Abrupt Changes: Theory and Application" by Basseville and Nikiforov.
In regard to the selection of software for implementing the abrupt change (anomaly) detection, I would recommend to explore several R packages that seem to offer required analytic functionality (in addition to visual) and support CUSUM and similar algorithms. In particular, take a look at the following packages: strucchange (see vignette / JSS paper), changepoint (see vignette), surveillance. The last one asks for special mentioning (considering insights of yours and of RegressForward's) as this package presents a framework and implements statistical methods for analysis of epidemic-like process phenomena (in various fields far beyond epidemiology). The project's home page and development are hosted at R-Forge, but the R package is available on CRAN. A vignette and related presentation slides are available. I hope that this update significantly improves my answer and is helpful. | Frequency jump detection
Since it seems that you have a time series here, I would recommend you to check my relevant answer for some ideas (time series clustering, entropy measures, anomaly detection) as well as links to furt |
37,144 | Frequency jump detection | What an interesting data set. I imagine your specific type of data do not represent 500 independent events simply... co-occurring, then returning to 0 of these events occurring for years on end. Similar to disease outbreaks, there is (probably) a triggering event that changes the state of the world to one in which success is possible, then 500 successes occur, then we return to nothing happening again.
Would you consider hurdle models to estimate the probability of this "outbreak" occurring and the size of the "outbreak"? Hurdle models indicate that the natural state of the world is 0 events. But if some hurdle is passed, then the state of the world is one where the number of events is drawn from a different distribution (which does not include zero). They are very similar to zero-inflated models (where the second distribution still includes zero). However, they do not model jump discontinuities.
I think this matches your description of $h\sigma$, and given nothing else, it might be worth investigating further. | Frequency jump detection | What an interesting data set. I imagine your specific type of data do not represent 500 independent events simply... co-occurring, then returning to 0 of these events occurring for years on end. Simi | Frequency jump detection
What an interesting data set. I imagine your specific type of data do not represent 500 independent events simply... co-occurring, then returning to 0 of these events occurring for years on end. Similar to disease outbreaks, there is (probably) a triggering event that changes the state of the world to one in which success is possible, then 500 successes occur, then we return to nothing happening again.
Would you consider hurdle models to estimate the probability of this "outbreak" occurring and the size of the "outbreak"? Hurdle models indicate that the natural state of the world is 0 events. But if some hurdle is passed, then the state of the world is one where the number of events is drawn from a different distribution (which does not include zero). They are very similar to zero-inflated models (where the second distribution still includes zero). However, they do not model jump discontinuities.
I think this matches your description of $h\sigma$, and given nothing else, it might be worth investigating further. | Frequency jump detection
What an interesting data set. I imagine your specific type of data do not represent 500 independent events simply... co-occurring, then returning to 0 of these events occurring for years on end. Simi |
37,145 | Random Forest partial plot for a binary predictor | In general partial plots are the average of a series of hypothetical predictions.
For continuous variables, partialPlot selects a series of n.pt values along the variable of interest. It creates a test data set identical to the training data, and sequentially sets the variable of interest for all observations to a selected value. It then takes the average value of the predicted response for each test set and plots the results against the select value. For a binary categorical predictor, this process would result in only two values.
It is helpful to use partial plots in combination with variable dependence and interpret them together. The variable dependence figure is generated by plotting the forest predicted value against the variable of interest for each observation. | Random Forest partial plot for a binary predictor | In general partial plots are the average of a series of hypothetical predictions.
For continuous variables, partialPlot selects a series of n.pt values along the variable of interest. It creates a te | Random Forest partial plot for a binary predictor
In general partial plots are the average of a series of hypothetical predictions.
For continuous variables, partialPlot selects a series of n.pt values along the variable of interest. It creates a test data set identical to the training data, and sequentially sets the variable of interest for all observations to a selected value. It then takes the average value of the predicted response for each test set and plots the results against the select value. For a binary categorical predictor, this process would result in only two values.
It is helpful to use partial plots in combination with variable dependence and interpret them together. The variable dependence figure is generated by plotting the forest predicted value against the variable of interest for each observation. | Random Forest partial plot for a binary predictor
In general partial plots are the average of a series of hypothetical predictions.
For continuous variables, partialPlot selects a series of n.pt values along the variable of interest. It creates a te |
37,146 | When KL Divergence and KS test will show inconsistent results? | Set aside Kullback-Leibler divergence for a moment and consider the following: it's perfectly possible for the Kolmogorov-Smirnov p-value to be small and for the corresponding Kolomogorov-Smirnov distance to be small.
Specifically, that can easily happen with large sample sizes, where even small differences are still larger than we'd expect to see from random variation.
The same will naturally tend to happen when considering some other suitable measure of divergence and comparing it to the Kolmogorov-Smirnov p-value - it will quite naturally occur at large sample sizes.
[If you don't wish to confound the distinction between Kolmogorov-Smirnov distance and p-value with the difference in what the two things are looking at, it might be better to explore the differences in the two measures ($D_{KS}$ and $D_{KL}$) directly, but that's not what is being asked here.] | When KL Divergence and KS test will show inconsistent results? | Set aside Kullback-Leibler divergence for a moment and consider the following: it's perfectly possible for the Kolmogorov-Smirnov p-value to be small and for the corresponding Kolomogorov-Smirnov dist | When KL Divergence and KS test will show inconsistent results?
Set aside Kullback-Leibler divergence for a moment and consider the following: it's perfectly possible for the Kolmogorov-Smirnov p-value to be small and for the corresponding Kolomogorov-Smirnov distance to be small.
Specifically, that can easily happen with large sample sizes, where even small differences are still larger than we'd expect to see from random variation.
The same will naturally tend to happen when considering some other suitable measure of divergence and comparing it to the Kolmogorov-Smirnov p-value - it will quite naturally occur at large sample sizes.
[If you don't wish to confound the distinction between Kolmogorov-Smirnov distance and p-value with the difference in what the two things are looking at, it might be better to explore the differences in the two measures ($D_{KS}$ and $D_{KL}$) directly, but that's not what is being asked here.] | When KL Divergence and KS test will show inconsistent results?
Set aside Kullback-Leibler divergence for a moment and consider the following: it's perfectly possible for the Kolmogorov-Smirnov p-value to be small and for the corresponding Kolomogorov-Smirnov dist |
37,147 | Gibbs Sampler contradiction proof | \begin{align*}\mathbb{P}(X_{n+1} \in A_k | X_n \in A_k) &=\mathbb{E}[\mathbb{I}_{A_k}(X_{n+1}) | X_n \in A_k]\\
&= \mathbb{E}[\mathbb{E}[\mathbb{I}_{A_k}(X_{n+1}) | X_n \in A_k,Y_1,...,Y_{k-1}] | X_n \in A_k]\\
&= \mathbb{E}[\mathbb{P}(X_{n+1} \in A_k | X_n \in A_k,Y_1,...,Y_{k-1}) | X_n \in A_k]\\
&= \mathbb{E}[\mathbb{P}(X_{n+1} \in A_k | Y_1,...,Y_{k-1}) | X_n \in A_k]\end{align*} | Gibbs Sampler contradiction proof | \begin{align*}\mathbb{P}(X_{n+1} \in A_k | X_n \in A_k) &=\mathbb{E}[\mathbb{I}_{A_k}(X_{n+1}) | X_n \in A_k]\\
&= \mathbb{E}[\mathbb{E}[\mathbb{I}_{A_k}(X_{n+1}) | X_n \in A_k,Y_1,...,Y_{k-1}] | X_n | Gibbs Sampler contradiction proof
\begin{align*}\mathbb{P}(X_{n+1} \in A_k | X_n \in A_k) &=\mathbb{E}[\mathbb{I}_{A_k}(X_{n+1}) | X_n \in A_k]\\
&= \mathbb{E}[\mathbb{E}[\mathbb{I}_{A_k}(X_{n+1}) | X_n \in A_k,Y_1,...,Y_{k-1}] | X_n \in A_k]\\
&= \mathbb{E}[\mathbb{P}(X_{n+1} \in A_k | X_n \in A_k,Y_1,...,Y_{k-1}) | X_n \in A_k]\\
&= \mathbb{E}[\mathbb{P}(X_{n+1} \in A_k | Y_1,...,Y_{k-1}) | X_n \in A_k]\end{align*} | Gibbs Sampler contradiction proof
\begin{align*}\mathbb{P}(X_{n+1} \in A_k | X_n \in A_k) &=\mathbb{E}[\mathbb{I}_{A_k}(X_{n+1}) | X_n \in A_k]\\
&= \mathbb{E}[\mathbb{E}[\mathbb{I}_{A_k}(X_{n+1}) | X_n \in A_k,Y_1,...,Y_{k-1}] | X_n |
37,148 | Addressing "NOTE: Results may be misleading due to involvement in interactions" warning with Tukey post-hoc comparisons in lsmeans R package | My view is that the $F$ test of statistical significance of the interaction effect is less important than the subjective nature of the interaction, as evidenced by the plot. The plot tells me that it is reasonably sensible to compare the overall averages of Depression and Top, but it'd be silly to compare those averages with the overall average of Slope -- whether or not these comparisons are statistically significant. Basically, I'd say to avoid doing comparisons that don't make sense -- so my advice is do not ignore the warning note in this case. If the curve for Top were fairly parallel with the other two, that's when you could ignore it.
In general, I suggest looking at enough plots that you can tell what's going on, and then restrict your post-hoc testing to things that are sensible.
Since P is continuous, you're really fitting straight lines (they look curved because you chose unequally spaced points). You can compare the slopes of these lines:
R> lstrends(Dens.LMER, pairwise ~ Contour, var = "P")
$lstrends
Contour P.trend SE df lower.CL upper.CL
Depression -0.00681143 0.004901195 39.68 -0.01671957 0.003096714
Slope -0.03376293 0.010533875 41.88 -0.05502295 -0.012502911
Top -0.01306992 0.010499548 41.97 -0.03425936 0.008119525
Confidence level used: 0.95
$contrasts
contrast estimate SE df t.ratio p.value
Depression - Slope 0.026951501 0.01161827 42.00 2.320 0.0639
Depression - Top 0.006258486 0.01158716 41.81 0.540 0.8520
Slope - Top -0.020693015 0.01487290 41.99 -1.391 0.3545
P value adjustment: tukey method for a family of 3 tests
The comparison between the shallowest and largest slopes has an adjusted $P$ value of about $.06$. | Addressing "NOTE: Results may be misleading due to involvement in interactions" warning with Tukey p | My view is that the $F$ test of statistical significance of the interaction effect is less important than the subjective nature of the interaction, as evidenced by the plot. The plot tells me that it | Addressing "NOTE: Results may be misleading due to involvement in interactions" warning with Tukey post-hoc comparisons in lsmeans R package
My view is that the $F$ test of statistical significance of the interaction effect is less important than the subjective nature of the interaction, as evidenced by the plot. The plot tells me that it is reasonably sensible to compare the overall averages of Depression and Top, but it'd be silly to compare those averages with the overall average of Slope -- whether or not these comparisons are statistically significant. Basically, I'd say to avoid doing comparisons that don't make sense -- so my advice is do not ignore the warning note in this case. If the curve for Top were fairly parallel with the other two, that's when you could ignore it.
In general, I suggest looking at enough plots that you can tell what's going on, and then restrict your post-hoc testing to things that are sensible.
Since P is continuous, you're really fitting straight lines (they look curved because you chose unequally spaced points). You can compare the slopes of these lines:
R> lstrends(Dens.LMER, pairwise ~ Contour, var = "P")
$lstrends
Contour P.trend SE df lower.CL upper.CL
Depression -0.00681143 0.004901195 39.68 -0.01671957 0.003096714
Slope -0.03376293 0.010533875 41.88 -0.05502295 -0.012502911
Top -0.01306992 0.010499548 41.97 -0.03425936 0.008119525
Confidence level used: 0.95
$contrasts
contrast estimate SE df t.ratio p.value
Depression - Slope 0.026951501 0.01161827 42.00 2.320 0.0639
Depression - Top 0.006258486 0.01158716 41.81 0.540 0.8520
Slope - Top -0.020693015 0.01487290 41.99 -1.391 0.3545
P value adjustment: tukey method for a family of 3 tests
The comparison between the shallowest and largest slopes has an adjusted $P$ value of about $.06$. | Addressing "NOTE: Results may be misleading due to involvement in interactions" warning with Tukey p
My view is that the $F$ test of statistical significance of the interaction effect is less important than the subjective nature of the interaction, as evidenced by the plot. The plot tells me that it |
37,149 | How to get the variance of the residual variance in a simple linear regression model | With:
$\frac{\sum e_i^2}{\sigma ^2}\sim \chi^2_{n-2} $
and knowing that $var(\chi^2_{n-2}=2(n−2)$
I can get that $var[\frac{\sum e_i^2}{\sigma ^2}]=2(n−2)$ dividing for $(n−2)^2$ and multipliying for $\sigma^4$ I get $var[\frac{\sum e_i^2}{(n-2)}]=\frac{2\sigma^4}{n-2}=var[S^2_R]$. I applied that $a^2 \cdot Var(x)=Var[a \cdot x]$ | How to get the variance of the residual variance in a simple linear regression model | With:
$\frac{\sum e_i^2}{\sigma ^2}\sim \chi^2_{n-2} $
and knowing that $var(\chi^2_{n-2}=2(n−2)$
I can get that $var[\frac{\sum e_i^2}{\sigma ^2}]=2(n−2)$ dividing for $(n−2)^2$ and multipliying | How to get the variance of the residual variance in a simple linear regression model
With:
$\frac{\sum e_i^2}{\sigma ^2}\sim \chi^2_{n-2} $
and knowing that $var(\chi^2_{n-2}=2(n−2)$
I can get that $var[\frac{\sum e_i^2}{\sigma ^2}]=2(n−2)$ dividing for $(n−2)^2$ and multipliying for $\sigma^4$ I get $var[\frac{\sum e_i^2}{(n-2)}]=\frac{2\sigma^4}{n-2}=var[S^2_R]$. I applied that $a^2 \cdot Var(x)=Var[a \cdot x]$ | How to get the variance of the residual variance in a simple linear regression model
With:
$\frac{\sum e_i^2}{\sigma ^2}\sim \chi^2_{n-2} $
and knowing that $var(\chi^2_{n-2}=2(n−2)$
I can get that $var[\frac{\sum e_i^2}{\sigma ^2}]=2(n−2)$ dividing for $(n−2)^2$ and multipliying |
37,150 | Is $X_{(1)} + X_{(n)}$ a good estimator for $\theta$? | Since this is for self study, I've decided to make this intentionally terse. First, when $\theta = 1$, show that
$$
(X_{(1)}, X_{(n)} - X_{(1)},1 - X_{(n)}) \sim \operatorname{Dirichlet}(1, n-1, 1).
$$
More generally, you might show
$$
(X_{(1)}, X_{(2)} - X_{(1)}, \ldots, X_{(n)} - X_{(n-1)}, 1 - X_{(n)}) \sim \operatorname{Dirichlet(1, 1, \ldots, 1, 1).}
$$
Then, we have $$\hat \theta = -(1 - X_{(n)}) + X_{(1)} + 1.$$ Using the Dirichlet distribution given above, we have immediately that $$\operatorname{Var}(\hat \theta) = \frac{2}{(n+1)(n+2)}.$$ Hence, for arbitrary $\theta$, $$\operatorname{Var}(\hat \theta) = \frac{2\theta^2}{(n+1)(n+2)}$$
To assess whether this is "good" or not, compare it to the UMVUE $\tilde \theta = [(n+1)/n]X_{(n)}$. | Is $X_{(1)} + X_{(n)}$ a good estimator for $\theta$? | Since this is for self study, I've decided to make this intentionally terse. First, when $\theta = 1$, show that
$$
(X_{(1)}, X_{(n)} - X_{(1)},1 - X_{(n)}) \sim \operatorname{Dirichlet}(1, n-1, 1).
| Is $X_{(1)} + X_{(n)}$ a good estimator for $\theta$?
Since this is for self study, I've decided to make this intentionally terse. First, when $\theta = 1$, show that
$$
(X_{(1)}, X_{(n)} - X_{(1)},1 - X_{(n)}) \sim \operatorname{Dirichlet}(1, n-1, 1).
$$
More generally, you might show
$$
(X_{(1)}, X_{(2)} - X_{(1)}, \ldots, X_{(n)} - X_{(n-1)}, 1 - X_{(n)}) \sim \operatorname{Dirichlet(1, 1, \ldots, 1, 1).}
$$
Then, we have $$\hat \theta = -(1 - X_{(n)}) + X_{(1)} + 1.$$ Using the Dirichlet distribution given above, we have immediately that $$\operatorname{Var}(\hat \theta) = \frac{2}{(n+1)(n+2)}.$$ Hence, for arbitrary $\theta$, $$\operatorname{Var}(\hat \theta) = \frac{2\theta^2}{(n+1)(n+2)}$$
To assess whether this is "good" or not, compare it to the UMVUE $\tilde \theta = [(n+1)/n]X_{(n)}$. | Is $X_{(1)} + X_{(n)}$ a good estimator for $\theta$?
Since this is for self study, I've decided to make this intentionally terse. First, when $\theta = 1$, show that
$$
(X_{(1)}, X_{(n)} - X_{(1)},1 - X_{(n)}) \sim \operatorname{Dirichlet}(1, n-1, 1).
|
37,151 | Limits on conditional expectation with normal margins and specified (Pearson) correlation | I think there are no bounds. This conclusion relies on the following construction, which is simplest to describe for arbitrary continuous distributions. As we go along, conditions will be added until we are in the case of Normal marginals.
So, let $X$ be any continuous random variable with distribution function $F$. Given any half-open interval $(a,b]$ (which will eventually become very narrow), define
$$\psi: (a,b] \to (-\infty, c]$$
via
$$\psi(x) = F^{-1}(F(x) - F(a)).$$
This is monotonically increasing and evidently $c = \psi(b) = F^{-1}(F(b)-F(a))$. By construction,
$$\Pr(X \in (a,b]) = \Pr(\psi(X) \le c).$$
Extend $\psi$ to a one-to-one map $\Psi:\mathbb{R} \to \mathbb{R}$ via
$$\eqalign{
\Psi|_{(a,b]} &= \psi, \\ \Psi|_{(-\infty, c]} &= \psi^{-1}
}$$
and otherwise $\Psi(x) = x$. The distribution of $\Psi(X)$ is identical to that of $X$, but what it has done is to swap the values between the two intervals $(a,b]$ and $(-\infty, c]$.
Example of $\Psi$ for $(a,b]=(1.5, 1.75]$.
Let the Pearson correlation of $(X,Y)$ be $\rho \in (-1, 1)$. (Without loss of generality we may now suppose both $X$ and $Y$ have been standardized, because this will change neither $\rho$ nor the continuity of $X$). Let $x_q$ be any real number, as in the question, where the conditional expectation of $Y$ is to be evaluated. Choose $(a,b]$ for which $x_q \in (a,b]$ but make it so narrow that $\Pr(X \in (a,b])$ is tiny. Then the change from $\rho = \mathbb{E}(XY)$ to $\rho^\prime = \mathbb{E}(\Psi(X)Y)$ can be made arbitrarily small. (It takes a little work to show this; it comes down to the fact that the conditional expectation of $Y$ given $X\le c$ increases relatively slowly as $|b-a|$ decreases. If it didn't, $\rho$ would not be defined.) However, applying $\Psi$ changes $\mathbb{E}(Y|X=x_q)$ to
$$\mathbb{E}(Y|\Psi(X) = x_q) = \mathbb{E}(Y|X = \Psi(x_q)),$$
which is a conditional expectation for $Y$ at some value of $X$ less than or equal to $c$.
Contours of the PDF. Here $(a,b] = (1.5, 1.75]$. The original bivariate normal distribution was given a correlation of $0.85$, which reduced to approximately $0.5$--the target value--when probabilities in the two strips were swapped.
When $(X,Y)$ is a bivariate normal distribution, $c\to -\infty$ as $|b-a|\to 0$. Provided $\rho\ne 0$, the conditional expectation of $Y$ is pushed off to $-\infty$ for $\rho \gt 0$ and to $+\infty$ for $\rho \lt 0$. An analogous construction, swapping the interval $(a,b]$ with $[c, \infty)$, will push the conditional expectation of $Y$ infinitely far in the other direction. By adjusting the original value of $\rho$ slightly we may compensate for the infinitesimal change in $\rho$ that takes place, showing that no matter what the original value of $\rho$ may be, we can say nothing about the conditional expectation of $Y$ at any particular point $X=x_q$.
(The apparent exception $\rho=0$ can be handled by starting with, say, a bivariate distribution with Normal marginals whose support is confined to the lines $y=\pm x$.) | Limits on conditional expectation with normal margins and specified (Pearson) correlation | I think there are no bounds. This conclusion relies on the following construction, which is simplest to describe for arbitrary continuous distributions. As we go along, conditions will be added unti | Limits on conditional expectation with normal margins and specified (Pearson) correlation
I think there are no bounds. This conclusion relies on the following construction, which is simplest to describe for arbitrary continuous distributions. As we go along, conditions will be added until we are in the case of Normal marginals.
So, let $X$ be any continuous random variable with distribution function $F$. Given any half-open interval $(a,b]$ (which will eventually become very narrow), define
$$\psi: (a,b] \to (-\infty, c]$$
via
$$\psi(x) = F^{-1}(F(x) - F(a)).$$
This is monotonically increasing and evidently $c = \psi(b) = F^{-1}(F(b)-F(a))$. By construction,
$$\Pr(X \in (a,b]) = \Pr(\psi(X) \le c).$$
Extend $\psi$ to a one-to-one map $\Psi:\mathbb{R} \to \mathbb{R}$ via
$$\eqalign{
\Psi|_{(a,b]} &= \psi, \\ \Psi|_{(-\infty, c]} &= \psi^{-1}
}$$
and otherwise $\Psi(x) = x$. The distribution of $\Psi(X)$ is identical to that of $X$, but what it has done is to swap the values between the two intervals $(a,b]$ and $(-\infty, c]$.
Example of $\Psi$ for $(a,b]=(1.5, 1.75]$.
Let the Pearson correlation of $(X,Y)$ be $\rho \in (-1, 1)$. (Without loss of generality we may now suppose both $X$ and $Y$ have been standardized, because this will change neither $\rho$ nor the continuity of $X$). Let $x_q$ be any real number, as in the question, where the conditional expectation of $Y$ is to be evaluated. Choose $(a,b]$ for which $x_q \in (a,b]$ but make it so narrow that $\Pr(X \in (a,b])$ is tiny. Then the change from $\rho = \mathbb{E}(XY)$ to $\rho^\prime = \mathbb{E}(\Psi(X)Y)$ can be made arbitrarily small. (It takes a little work to show this; it comes down to the fact that the conditional expectation of $Y$ given $X\le c$ increases relatively slowly as $|b-a|$ decreases. If it didn't, $\rho$ would not be defined.) However, applying $\Psi$ changes $\mathbb{E}(Y|X=x_q)$ to
$$\mathbb{E}(Y|\Psi(X) = x_q) = \mathbb{E}(Y|X = \Psi(x_q)),$$
which is a conditional expectation for $Y$ at some value of $X$ less than or equal to $c$.
Contours of the PDF. Here $(a,b] = (1.5, 1.75]$. The original bivariate normal distribution was given a correlation of $0.85$, which reduced to approximately $0.5$--the target value--when probabilities in the two strips were swapped.
When $(X,Y)$ is a bivariate normal distribution, $c\to -\infty$ as $|b-a|\to 0$. Provided $\rho\ne 0$, the conditional expectation of $Y$ is pushed off to $-\infty$ for $\rho \gt 0$ and to $+\infty$ for $\rho \lt 0$. An analogous construction, swapping the interval $(a,b]$ with $[c, \infty)$, will push the conditional expectation of $Y$ infinitely far in the other direction. By adjusting the original value of $\rho$ slightly we may compensate for the infinitesimal change in $\rho$ that takes place, showing that no matter what the original value of $\rho$ may be, we can say nothing about the conditional expectation of $Y$ at any particular point $X=x_q$.
(The apparent exception $\rho=0$ can be handled by starting with, say, a bivariate distribution with Normal marginals whose support is confined to the lines $y=\pm x$.) | Limits on conditional expectation with normal margins and specified (Pearson) correlation
I think there are no bounds. This conclusion relies on the following construction, which is simplest to describe for arbitrary continuous distributions. As we go along, conditions will be added unti |
37,152 | Limits on conditional expectation with normal margins and specified (Pearson) correlation | If I understand your question correctly the answer depends on the "actual bivariate dependence relationship (the copula)" used.
Well there exist bounds on the value a copula can take right? So why not use the comonotonicity copula and countermonotonicity copula to establish the limits.
Source: Thorsten Schmidt - Coping with copulas | Limits on conditional expectation with normal margins and specified (Pearson) correlation | If I understand your question correctly the answer depends on the "actual bivariate dependence relationship (the copula)" used.
Well there exist bounds on the value a copula can take right? So why not | Limits on conditional expectation with normal margins and specified (Pearson) correlation
If I understand your question correctly the answer depends on the "actual bivariate dependence relationship (the copula)" used.
Well there exist bounds on the value a copula can take right? So why not use the comonotonicity copula and countermonotonicity copula to establish the limits.
Source: Thorsten Schmidt - Coping with copulas | Limits on conditional expectation with normal margins and specified (Pearson) correlation
If I understand your question correctly the answer depends on the "actual bivariate dependence relationship (the copula)" used.
Well there exist bounds on the value a copula can take right? So why not |
37,153 | How to efficiently compute Theil-Sen estimator? | According to wikipedia, it can be calculated exactly in O(n log(n)).
Wikipedia points to no less than six papers detailing different deterministic or randomized algorithms with $O(n\log n)$ performance, right in the section where they mention the existence of such algorithms (as well as mentioning an even faster one under particular circumstances).
Deterministic:
Cole, Richard; Salowe, Jeffrey S.; Steiger, W. L.; Szemerédi, Endre (1989), An optimal-time algorithm for slope selection, SIAM Journal on Computing 18 (4): 792–810, doi:10.1137/0218055, MR 1004799.
Katz, Matthew J.; Sharir, Micha (1993), Optimal slope selection via expanders, Information Processing Letters 47 (3): 115–122, doi:10.1016/0020-0190(93)90234-Z, MR 1237287.
Brönnimann, Hervé; Chazelle, Bernard (1998), Optimal slope selection via cuttings, Computational Geometry Theory and Applications 10 (1): 23–29, doi:10.1016/S0925-7721(97)00025-4, MR 1614381.
$\ $
Randomized:
Dillencourt, Michael B.; Mount, David M.; Netanyahu, Nathan S. (1992), A randomized algorithm for slope selection, International Journal of Computational Geometry & Applications 2 (1): 1–27, doi:10.1142/S0218195992000020, MR 1159839.
Matoušek, Jiří (1991), Randomized optimal algorithm for slope selection, Information Processing Letters 39 (4): 183–187, doi:10.1016/0020-0190(91)90177-J, MR 1130747.
Blunck, Henrik; Vahrenhold, Jan (2006), "In-place randomized slope selection", International Symposium on Algorithms and Complexity, Lecture Notes in Computer Science 3998, Berlin: Springer-Verlag, pp. 30–41, doi:10.1007/11758471_6, MR 2263136.
Which did you want? | How to efficiently compute Theil-Sen estimator? | According to wikipedia, it can be calculated exactly in O(n log(n)).
Wikipedia points to no less than six papers detailing different deterministic or randomized algorithms with $O(n\log n)$ performa | How to efficiently compute Theil-Sen estimator?
According to wikipedia, it can be calculated exactly in O(n log(n)).
Wikipedia points to no less than six papers detailing different deterministic or randomized algorithms with $O(n\log n)$ performance, right in the section where they mention the existence of such algorithms (as well as mentioning an even faster one under particular circumstances).
Deterministic:
Cole, Richard; Salowe, Jeffrey S.; Steiger, W. L.; Szemerédi, Endre (1989), An optimal-time algorithm for slope selection, SIAM Journal on Computing 18 (4): 792–810, doi:10.1137/0218055, MR 1004799.
Katz, Matthew J.; Sharir, Micha (1993), Optimal slope selection via expanders, Information Processing Letters 47 (3): 115–122, doi:10.1016/0020-0190(93)90234-Z, MR 1237287.
Brönnimann, Hervé; Chazelle, Bernard (1998), Optimal slope selection via cuttings, Computational Geometry Theory and Applications 10 (1): 23–29, doi:10.1016/S0925-7721(97)00025-4, MR 1614381.
$\ $
Randomized:
Dillencourt, Michael B.; Mount, David M.; Netanyahu, Nathan S. (1992), A randomized algorithm for slope selection, International Journal of Computational Geometry & Applications 2 (1): 1–27, doi:10.1142/S0218195992000020, MR 1159839.
Matoušek, Jiří (1991), Randomized optimal algorithm for slope selection, Information Processing Letters 39 (4): 183–187, doi:10.1016/0020-0190(91)90177-J, MR 1130747.
Blunck, Henrik; Vahrenhold, Jan (2006), "In-place randomized slope selection", International Symposium on Algorithms and Complexity, Lecture Notes in Computer Science 3998, Berlin: Springer-Verlag, pp. 30–41, doi:10.1007/11758471_6, MR 2263136.
Which did you want? | How to efficiently compute Theil-Sen estimator?
According to wikipedia, it can be calculated exactly in O(n log(n)).
Wikipedia points to no less than six papers detailing different deterministic or randomized algorithms with $O(n\log n)$ performa |
37,154 | How to efficiently compute Theil-Sen estimator? | The R-package robslopes contains a C++ implementation based on the algorithm by Dillencourt et. al (1992) and Matousek et. al (1998). See https://cran.r-project.org/web/packages/robslopes/index.html | How to efficiently compute Theil-Sen estimator? | The R-package robslopes contains a C++ implementation based on the algorithm by Dillencourt et. al (1992) and Matousek et. al (1998). See https://cran.r-project.org/web/packages/robslopes/index.html | How to efficiently compute Theil-Sen estimator?
The R-package robslopes contains a C++ implementation based on the algorithm by Dillencourt et. al (1992) and Matousek et. al (1998). See https://cran.r-project.org/web/packages/robslopes/index.html | How to efficiently compute Theil-Sen estimator?
The R-package robslopes contains a C++ implementation based on the algorithm by Dillencourt et. al (1992) and Matousek et. al (1998). See https://cran.r-project.org/web/packages/robslopes/index.html |
37,155 | How to determine moving window size? | I agree with whuber. You should have some methodology, for example bootstrapping and stability criterion (that is perturb your data a little bit and check that your estimates do not change too much), or better sharp theoretical results, to help you decide if you have enough samples to compute your estimates correctly.
Then, you should use the minimum amount of data that provides you strong guarantee (theoretical or empirical) on the relevance of your results, but no more as you will smooth the signal (or violate even more the stationary hypothesis).
As long as you stay with estimating mean, variance, and so on, you should be able to find theoretical results and guidelines. If you want to determine the minimum length of the window for a complex processing (say machine learning algorithms), you should go for an empirical study, cf. this study for an example on the clustering of correlated random variables. | How to determine moving window size? | I agree with whuber. You should have some methodology, for example bootstrapping and stability criterion (that is perturb your data a little bit and check that your estimates do not change too much), | How to determine moving window size?
I agree with whuber. You should have some methodology, for example bootstrapping and stability criterion (that is perturb your data a little bit and check that your estimates do not change too much), or better sharp theoretical results, to help you decide if you have enough samples to compute your estimates correctly.
Then, you should use the minimum amount of data that provides you strong guarantee (theoretical or empirical) on the relevance of your results, but no more as you will smooth the signal (or violate even more the stationary hypothesis).
As long as you stay with estimating mean, variance, and so on, you should be able to find theoretical results and guidelines. If you want to determine the minimum length of the window for a complex processing (say machine learning algorithms), you should go for an empirical study, cf. this study for an example on the clustering of correlated random variables. | How to determine moving window size?
I agree with whuber. You should have some methodology, for example bootstrapping and stability criterion (that is perturb your data a little bit and check that your estimates do not change too much), |
37,156 | How to determine moving window size? | Generally one picks the size of a sliding window that captures enough of information. Pick it too big, you will get more irrelevant information (loss of resolution). Pick too small, you will loose details.
You can see this following way. Suppose you have some real-valued function as a mixture of sinusoids with different periods. Picking a window size of length L will restrict you to a subset of functions that you will be able to extract. | How to determine moving window size? | Generally one picks the size of a sliding window that captures enough of information. Pick it too big, you will get more irrelevant information (loss of resolution). Pick too small, you will loose det | How to determine moving window size?
Generally one picks the size of a sliding window that captures enough of information. Pick it too big, you will get more irrelevant information (loss of resolution). Pick too small, you will loose details.
You can see this following way. Suppose you have some real-valued function as a mixture of sinusoids with different periods. Picking a window size of length L will restrict you to a subset of functions that you will be able to extract. | How to determine moving window size?
Generally one picks the size of a sliding window that captures enough of information. Pick it too big, you will get more irrelevant information (loss of resolution). Pick too small, you will loose det |
37,157 | How to determine moving window size? | I've done some thinking about this in a different context and came up with an approach that seemed reasonable intuitively, although I have a compsci rather than stats background.
The motivation for a smaller window size is increased sensitivity to changes in the underlying process from which you are sampling. I'll call this "predictive value".
Let's say they are both expressed in units of the predictive value or predictive error we expect due to the bias or variance respectively.
The motivation for a larger window size is decreased noise due to small sample size. This is the sample standard deviation:
standard_deviation(samples_in_window) / sqrt(size(samples_in_window))
On the predictive value side, this is the difference between the mean of all samples and the mean of samples within the window.
So, our task is to select the window size that maximizes predictive accuracy, which is the predictive value minus the predictive error.
This can be implemented quite efficiently with a little thought, and if so the window size could be re-computed every time we receive a new sample - allowing it to dynamically adapt the window size over time.
Note that this entire approach is nonparametric, so it doesn't just substitute one parameter, window size, for another parameter or parameters. | How to determine moving window size? | I've done some thinking about this in a different context and came up with an approach that seemed reasonable intuitively, although I have a compsci rather than stats background.
The motivation for a | How to determine moving window size?
I've done some thinking about this in a different context and came up with an approach that seemed reasonable intuitively, although I have a compsci rather than stats background.
The motivation for a smaller window size is increased sensitivity to changes in the underlying process from which you are sampling. I'll call this "predictive value".
Let's say they are both expressed in units of the predictive value or predictive error we expect due to the bias or variance respectively.
The motivation for a larger window size is decreased noise due to small sample size. This is the sample standard deviation:
standard_deviation(samples_in_window) / sqrt(size(samples_in_window))
On the predictive value side, this is the difference between the mean of all samples and the mean of samples within the window.
So, our task is to select the window size that maximizes predictive accuracy, which is the predictive value minus the predictive error.
This can be implemented quite efficiently with a little thought, and if so the window size could be re-computed every time we receive a new sample - allowing it to dynamically adapt the window size over time.
Note that this entire approach is nonparametric, so it doesn't just substitute one parameter, window size, for another parameter or parameters. | How to determine moving window size?
I've done some thinking about this in a different context and came up with an approach that seemed reasonable intuitively, although I have a compsci rather than stats background.
The motivation for a |
37,158 | Stationary function | Stationarity is a concept defined for stochastic processes. Since we look at the process as random function then we can extend the definition of stationarity to functions. I.e a stationary function is a realisation of stationary process. This extension is quite informal though.
Stationarity for a process means that the for a number of points $t_1,...,t_n$, $(X_{t_1},...,X_{t_n})\sim (X_{t_1+h},...,X_{t_n+h})$, where $\sim$ means equality in distribution. The question would be, what does this entail? For example take two points of the process which are close to each other $(X_t,X_{s})$. The relationship between these two points is expressed by their distribution function. Let us say the points are closely related, i.e. the correlation $corr(X_t,X_s)=0.9$. Then if we shift these points by any distance, due to stationarity their relationship remains the same, i.e. $corr(X_t,X_s)=corr(X_{t+h},X_{s+h})=0.9$. Informaly in this case we can say that $X_{s+h}$ would follow $X_{t+h}$ similar to the way $X_{s}$ follows $X_t$.
Now due the way stationarity is defined this holds for any number of points. So in some sense function should look similar at different locations. Note that this depends on the distributional properties of the process. White noise is a stationary process too and it does not look similar at different points in the usual common sense. | Stationary function | Stationarity is a concept defined for stochastic processes. Since we look at the process as random function then we can extend the definition of stationarity to functions. I.e a stationary function is | Stationary function
Stationarity is a concept defined for stochastic processes. Since we look at the process as random function then we can extend the definition of stationarity to functions. I.e a stationary function is a realisation of stationary process. This extension is quite informal though.
Stationarity for a process means that the for a number of points $t_1,...,t_n$, $(X_{t_1},...,X_{t_n})\sim (X_{t_1+h},...,X_{t_n+h})$, where $\sim$ means equality in distribution. The question would be, what does this entail? For example take two points of the process which are close to each other $(X_t,X_{s})$. The relationship between these two points is expressed by their distribution function. Let us say the points are closely related, i.e. the correlation $corr(X_t,X_s)=0.9$. Then if we shift these points by any distance, due to stationarity their relationship remains the same, i.e. $corr(X_t,X_s)=corr(X_{t+h},X_{s+h})=0.9$. Informaly in this case we can say that $X_{s+h}$ would follow $X_{t+h}$ similar to the way $X_{s}$ follows $X_t$.
Now due the way stationarity is defined this holds for any number of points. So in some sense function should look similar at different locations. Note that this depends on the distributional properties of the process. White noise is a stationary process too and it does not look similar at different points in the usual common sense. | Stationary function
Stationarity is a concept defined for stochastic processes. Since we look at the process as random function then we can extend the definition of stationarity to functions. I.e a stationary function is |
37,159 | Support vector regression versus kernel ridge regression | As expected: it depends on what you want. In terms of generalization performance, typically the performance differences are minor.
That said, minimizing the $l_1$-norm has the extremely attractive feature of yielding sparse solutions (the support vectors are a subset of the training set). When doing ridge regression, just like in least-squares SVM, all training instances become support vectors and you end up with a model the size of your training set. A large model requires a lot of memory (obviously) and is slower in prediction. | Support vector regression versus kernel ridge regression | As expected: it depends on what you want. In terms of generalization performance, typically the performance differences are minor.
That said, minimizing the $l_1$-norm has the extremely attractive fea | Support vector regression versus kernel ridge regression
As expected: it depends on what you want. In terms of generalization performance, typically the performance differences are minor.
That said, minimizing the $l_1$-norm has the extremely attractive feature of yielding sparse solutions (the support vectors are a subset of the training set). When doing ridge regression, just like in least-squares SVM, all training instances become support vectors and you end up with a model the size of your training set. A large model requires a lot of memory (obviously) and is slower in prediction. | Support vector regression versus kernel ridge regression
As expected: it depends on what you want. In terms of generalization performance, typically the performance differences are minor.
That said, minimizing the $l_1$-norm has the extremely attractive fea |
37,160 | K-means as a limit case of EM algorithm for Gaussian mixtures with covariances $\epsilon^2 I$ going to $0$ | Is it true that up to some constant and scalar multiplication:
$\lim_{\sigma \to 0} Q((\pi, \mu, \Sigma), (\pi, \mu, \Sigma)^{\text{old}}) = -J$?
This is not the case since – as you observed yourself – the limit diverges.
However, if we first transform $Q$ and then take the limit, we converge to the k-means objective.
For $\Sigma_k = \sigma^2 I$ and $\pi_k = 1/K$ we have
\begin{align}
Q
&= \sum_{n,k} \gamma_{nk} \left( \log \pi_k + \log N(x_n \mid \mu_k, \Sigma_k) \right) \\
&= N \log\frac{1}{K} - \frac{1}{\sigma^2} \sum_{n,k} \gamma_{nk} ||x_n - \mu_k||^2 - N \frac{D}{2} \log 2\pi\sigma^2.
\end{align}
Multiplying by $\sigma^2$ (which does not affect the EM algorithm, since $\sigma$ is not optimized but constant) and collecting all the constant terms in $C$, we see that
\begin{align}
Q &\propto - \sum_{n,k} \gamma_{nk} ||x_n - \mu_k||^2 + \sigma^2 C.
\end{align}
Note that maximizing this function with respect to $\mu$ for any $\gamma$ and $\sigma$ gives the same result as the objective function above, i.e., it is an equivalent formulation of the M-step. But taking the limit now yields $-J$.
As an aside, an in my view slightly more elegant formulation of EM is to use the objective function
\begin{align}
F(\mu, \gamma)
&= \sum_{n,k} \gamma_{nk} \log \pi_k N(x_n \mid \mu_k, \Sigma_k)/\gamma_{nk} \\
&\propto -\sum_{n,k} \sum_{n, k} \gamma_{nk} ||x_n - \mu_k||^2 - \sigma^2 \sum_{n,k} \gamma_{nk} \log \gamma_{nk} + \sigma^2 C.
\end{align}
Using this objective function, the EM algorithm amounts to alternating between optimizing $F$ with respect to $\mu$ (M-step) and $\gamma$ (E-step). Taking the limit we see that both the M-step and the E-step converge to the k-means algorithm.
See also an alternative view of EM. | K-means as a limit case of EM algorithm for Gaussian mixtures with covariances $\epsilon^2 I$ going | Is it true that up to some constant and scalar multiplication:
$\lim_{\sigma \to 0} Q((\pi, \mu, \Sigma), (\pi, \mu, \Sigma)^{\text{old}}) = -J$?
This is not the case since – as you observed yours | K-means as a limit case of EM algorithm for Gaussian mixtures with covariances $\epsilon^2 I$ going to $0$
Is it true that up to some constant and scalar multiplication:
$\lim_{\sigma \to 0} Q((\pi, \mu, \Sigma), (\pi, \mu, \Sigma)^{\text{old}}) = -J$?
This is not the case since – as you observed yourself – the limit diverges.
However, if we first transform $Q$ and then take the limit, we converge to the k-means objective.
For $\Sigma_k = \sigma^2 I$ and $\pi_k = 1/K$ we have
\begin{align}
Q
&= \sum_{n,k} \gamma_{nk} \left( \log \pi_k + \log N(x_n \mid \mu_k, \Sigma_k) \right) \\
&= N \log\frac{1}{K} - \frac{1}{\sigma^2} \sum_{n,k} \gamma_{nk} ||x_n - \mu_k||^2 - N \frac{D}{2} \log 2\pi\sigma^2.
\end{align}
Multiplying by $\sigma^2$ (which does not affect the EM algorithm, since $\sigma$ is not optimized but constant) and collecting all the constant terms in $C$, we see that
\begin{align}
Q &\propto - \sum_{n,k} \gamma_{nk} ||x_n - \mu_k||^2 + \sigma^2 C.
\end{align}
Note that maximizing this function with respect to $\mu$ for any $\gamma$ and $\sigma$ gives the same result as the objective function above, i.e., it is an equivalent formulation of the M-step. But taking the limit now yields $-J$.
As an aside, an in my view slightly more elegant formulation of EM is to use the objective function
\begin{align}
F(\mu, \gamma)
&= \sum_{n,k} \gamma_{nk} \log \pi_k N(x_n \mid \mu_k, \Sigma_k)/\gamma_{nk} \\
&\propto -\sum_{n,k} \sum_{n, k} \gamma_{nk} ||x_n - \mu_k||^2 - \sigma^2 \sum_{n,k} \gamma_{nk} \log \gamma_{nk} + \sigma^2 C.
\end{align}
Using this objective function, the EM algorithm amounts to alternating between optimizing $F$ with respect to $\mu$ (M-step) and $\gamma$ (E-step). Taking the limit we see that both the M-step and the E-step converge to the k-means algorithm.
See also an alternative view of EM. | K-means as a limit case of EM algorithm for Gaussian mixtures with covariances $\epsilon^2 I$ going
Is it true that up to some constant and scalar multiplication:
$\lim_{\sigma \to 0} Q((\pi, \mu, \Sigma), (\pi, \mu, \Sigma)^{\text{old}}) = -J$?
This is not the case since – as you observed yours |
37,161 | Truncated Gamma distribution parameter estimation | Maximum Likelihood Estimation (MLE) works remarkably well, even for fairly small datasets. For truncation at an upper limit of $U$ and lower limit of $L$, simply divide the Gamma likelihood of any data value $x$ by the total probability of the interval $[L,U]$ to obtain the likelihood for the truncated distribution.
Here are examples of datasets (shown as histograms), the underlying distributions that generated them (colored lines), and their MLEs (black lines) for a range of shape parameters "alpha" and scale parameters "sigma" that might be encountered when truncating to the interval $[0.05, 3]$. The agreement between the fits and distributions is excellent.
Details appear in the following R code.
#
# Log likelihood.
# `theta` is shape, log scale.
#
log.Lambda <- function(theta, x, limits) {
#
# Extract the parameters from the arguments.
#
alpha <- theta[1]
log.sigma <- theta[2]
sigma <- exp(log.sigma)
n <- length(x)
#
# Compute Gamma probabilities for the truncation limits. Keep them as logs
# for numerical accuracy and to avoid overflow.
#
p.lower <- pgamma(limits[1], alpha, scale=sigma, log.p=TRUE)
p.upper <- pgamma(limits[2], alpha, scale=sigma, log.p=TRUE)
#
# Compute the variable and constant portions of the log likelihood.
#
l <- (alpha-1) * log(x) - x/sigma
const <- alpha * log.sigma + lgamma(alpha) + p.lower + log(exp(p.upper - p.lower) - 1)
#
# Return the negative log likelihood.
#
return(-(sum(l) - n*const))
}
#
# Truncated Gamma distribution (for plotting).
#
dgammatrunc <- function(x, shape, scale, lower, upper) {
dgamma(x, shape, scale=scale) / diff(pgamma(c(lower,upper), shape, scale=scale))
}
#
# Test.
#
library(ggplot2)
library(data.table)
upper <- 3
lower <- 0.05
n <- 32 # Sample size
set.seed(17)
#
# Test for a range of shapes and scales.
#
parameters <- expand.grid(alpha=c(1/2, 2, 5), sigma=c(1/2, 6))
x0 <- seq(lower, upper, length.out=101) # Prediction points, for plotting
X <- apply(parameters, 1, function(theta) {
alpha <- theta[1]
sigma <- theta[2]
#
# Generate data.
#
q <- runif(n, pgamma(lower, alpha, scale=sigma), pgamma(upper, alpha, scale=sigma))
x <- qgamma(q, alpha, scale=sigma)
# hist(x, freq=FALSE)
#
# ML fitting.
#
theta.0 <- c(mean(x), 0)
fit <- nlm(log.Lambda, p=theta.0, x=x, limits=c(lower, upper))
beta.hat <- fit$estimate
alpha.hat <- beta.hat[1]
sigma.hat <- exp(beta.hat[2])
#
# Return the data and fits in a form convenient for plotting.
#
list(data.table(x=x, alpha=alpha, sigma=sigma),
data.table(x=x0, alpha=alpha, sigma=sigma,
y=dgammatrunc(x0, alpha, sigma, lower, upper),
y.hat=dgammatrunc(x0, alpha.hat, sigma.hat, lower, upper))
)
})
Y <- rbindlist(lapply(X, function(x) x[[2]])) # Data for the graphs
X <- rbindlist(lapply(X, function(x) x[[1]])) # The samples themselves
#
# Plot the results.
#
binwidth <- (upper - lower)/ceiling(n^(0.6))
ggplot(X, aes(x)) +
geom_histogram(binwidth=binwidth, aes(fill=ordered(alpha)), alpha=1/2,
color="Black", show.legend=FALSE) +
geom_path(aes(x, n*y*binwidth, color=ordered(alpha)), size=2, data=Y,
show.legend=FALSE) +
geom_path(aes(x, n*y.hat*binwidth), size=1.5, data=Y, show.legend=FALSE) +
facet_grid(sigma ~ alpha, scales="free_y", labeller = label_both) +
ggtitle(paste("MLEs for Samples of Size", n),
"Fitted Distributions Shown in Black") | Truncated Gamma distribution parameter estimation | Maximum Likelihood Estimation (MLE) works remarkably well, even for fairly small datasets. For truncation at an upper limit of $U$ and lower limit of $L$, simply divide the Gamma likelihood of any da | Truncated Gamma distribution parameter estimation
Maximum Likelihood Estimation (MLE) works remarkably well, even for fairly small datasets. For truncation at an upper limit of $U$ and lower limit of $L$, simply divide the Gamma likelihood of any data value $x$ by the total probability of the interval $[L,U]$ to obtain the likelihood for the truncated distribution.
Here are examples of datasets (shown as histograms), the underlying distributions that generated them (colored lines), and their MLEs (black lines) for a range of shape parameters "alpha" and scale parameters "sigma" that might be encountered when truncating to the interval $[0.05, 3]$. The agreement between the fits and distributions is excellent.
Details appear in the following R code.
#
# Log likelihood.
# `theta` is shape, log scale.
#
log.Lambda <- function(theta, x, limits) {
#
# Extract the parameters from the arguments.
#
alpha <- theta[1]
log.sigma <- theta[2]
sigma <- exp(log.sigma)
n <- length(x)
#
# Compute Gamma probabilities for the truncation limits. Keep them as logs
# for numerical accuracy and to avoid overflow.
#
p.lower <- pgamma(limits[1], alpha, scale=sigma, log.p=TRUE)
p.upper <- pgamma(limits[2], alpha, scale=sigma, log.p=TRUE)
#
# Compute the variable and constant portions of the log likelihood.
#
l <- (alpha-1) * log(x) - x/sigma
const <- alpha * log.sigma + lgamma(alpha) + p.lower + log(exp(p.upper - p.lower) - 1)
#
# Return the negative log likelihood.
#
return(-(sum(l) - n*const))
}
#
# Truncated Gamma distribution (for plotting).
#
dgammatrunc <- function(x, shape, scale, lower, upper) {
dgamma(x, shape, scale=scale) / diff(pgamma(c(lower,upper), shape, scale=scale))
}
#
# Test.
#
library(ggplot2)
library(data.table)
upper <- 3
lower <- 0.05
n <- 32 # Sample size
set.seed(17)
#
# Test for a range of shapes and scales.
#
parameters <- expand.grid(alpha=c(1/2, 2, 5), sigma=c(1/2, 6))
x0 <- seq(lower, upper, length.out=101) # Prediction points, for plotting
X <- apply(parameters, 1, function(theta) {
alpha <- theta[1]
sigma <- theta[2]
#
# Generate data.
#
q <- runif(n, pgamma(lower, alpha, scale=sigma), pgamma(upper, alpha, scale=sigma))
x <- qgamma(q, alpha, scale=sigma)
# hist(x, freq=FALSE)
#
# ML fitting.
#
theta.0 <- c(mean(x), 0)
fit <- nlm(log.Lambda, p=theta.0, x=x, limits=c(lower, upper))
beta.hat <- fit$estimate
alpha.hat <- beta.hat[1]
sigma.hat <- exp(beta.hat[2])
#
# Return the data and fits in a form convenient for plotting.
#
list(data.table(x=x, alpha=alpha, sigma=sigma),
data.table(x=x0, alpha=alpha, sigma=sigma,
y=dgammatrunc(x0, alpha, sigma, lower, upper),
y.hat=dgammatrunc(x0, alpha.hat, sigma.hat, lower, upper))
)
})
Y <- rbindlist(lapply(X, function(x) x[[2]])) # Data for the graphs
X <- rbindlist(lapply(X, function(x) x[[1]])) # The samples themselves
#
# Plot the results.
#
binwidth <- (upper - lower)/ceiling(n^(0.6))
ggplot(X, aes(x)) +
geom_histogram(binwidth=binwidth, aes(fill=ordered(alpha)), alpha=1/2,
color="Black", show.legend=FALSE) +
geom_path(aes(x, n*y*binwidth, color=ordered(alpha)), size=2, data=Y,
show.legend=FALSE) +
geom_path(aes(x, n*y.hat*binwidth), size=1.5, data=Y, show.legend=FALSE) +
facet_grid(sigma ~ alpha, scales="free_y", labeller = label_both) +
ggtitle(paste("MLEs for Samples of Size", n),
"Fitted Distributions Shown in Black") | Truncated Gamma distribution parameter estimation
Maximum Likelihood Estimation (MLE) works remarkably well, even for fairly small datasets. For truncation at an upper limit of $U$ and lower limit of $L$, simply divide the Gamma likelihood of any da |
37,162 | Truncated Gamma distribution parameter estimation | First it is more convenient to truncate gamma distribution, utilising the direct method of truncation
G(x) = (F(x,a,b) - F( zmin, a,b))/ (F(zmax,a,b) - F( zmin, a,b)). F are the gamma cumulative function and not (x-zmin).((b-zmin) to truncate in
zmin it is te left bound ary
zmax the right boundary
So, the transformation to number etc may be in a linear way
the truncated gamma distribution keeps its form, when we perform
g(x) x^k.
We could obtain another gamma function; and this is easier to manage
g(x)is the pdf gamma distribution (truncated)
Besides, with the truncated gamma we avoid the long tails that spoil the transformations
example the k Moment is b^k * GAMMA(a+k)/Gamma(a)/( F(a,zmax/b)-F(z, zmin/b)
it is very easy to manage | Truncated Gamma distribution parameter estimation | First it is more convenient to truncate gamma distribution, utilising the direct method of truncation
G(x) = (F(x,a,b) - F( zmin, a,b))/ (F(zmax,a,b) - F( zmin, a,b)). F are the gamma cumulative funct | Truncated Gamma distribution parameter estimation
First it is more convenient to truncate gamma distribution, utilising the direct method of truncation
G(x) = (F(x,a,b) - F( zmin, a,b))/ (F(zmax,a,b) - F( zmin, a,b)). F are the gamma cumulative function and not (x-zmin).((b-zmin) to truncate in
zmin it is te left bound ary
zmax the right boundary
So, the transformation to number etc may be in a linear way
the truncated gamma distribution keeps its form, when we perform
g(x) x^k.
We could obtain another gamma function; and this is easier to manage
g(x)is the pdf gamma distribution (truncated)
Besides, with the truncated gamma we avoid the long tails that spoil the transformations
example the k Moment is b^k * GAMMA(a+k)/Gamma(a)/( F(a,zmax/b)-F(z, zmin/b)
it is very easy to manage | Truncated Gamma distribution parameter estimation
First it is more convenient to truncate gamma distribution, utilising the direct method of truncation
G(x) = (F(x,a,b) - F( zmin, a,b))/ (F(zmax,a,b) - F( zmin, a,b)). F are the gamma cumulative funct |
37,163 | When to use zero-inflated poisson regression and negative binomial distribution | I suspect that your problem may be that the default behavior of predict.glm isn't what you think it is.
Specifically, predict used on a glm object will by default gives a response on the scale of the linear predictors, not the response.
This is quite clearly stated in the help (?predict.glm) but seems to trip people up very often (suggesting the default ought to be changed, perhaps; you might like to raise it on the relevant mailing list).
To get the values you want, try predict(model1,type="response") | When to use zero-inflated poisson regression and negative binomial distribution | I suspect that your problem may be that the default behavior of predict.glm isn't what you think it is.
Specifically, predict used on a glm object will by default gives a response on the scale of the | When to use zero-inflated poisson regression and negative binomial distribution
I suspect that your problem may be that the default behavior of predict.glm isn't what you think it is.
Specifically, predict used on a glm object will by default gives a response on the scale of the linear predictors, not the response.
This is quite clearly stated in the help (?predict.glm) but seems to trip people up very often (suggesting the default ought to be changed, perhaps; you might like to raise it on the relevant mailing list).
To get the values you want, try predict(model1,type="response") | When to use zero-inflated poisson regression and negative binomial distribution
I suspect that your problem may be that the default behavior of predict.glm isn't what you think it is.
Specifically, predict used on a glm object will by default gives a response on the scale of the |
37,164 | How to apply a Gaussian radial basis function kernel PCA to nonlinear data? | The first problem seems to be that the sign of gamma is wrong (it should be negative: $-15$, as in the definition of the kernel, not as in your code). Alternatively, use exp(-gamma * mat_sq_dists).
The second problem is that you clobber the eigenvectors with your invocation of zip's when you sort the list. The $i$-th eigenvector is eigvecs[:,i], not eigvecs[i,:], according to scipy.linalg.eigh (also: you should prefer eigh to eig because you have a symmetric real matrix).
Replace
< gamma = 15
> gamma = -15
and (to get ordered, real eigenvalues)
< eigvals, eigvecs = np.linalg.eig(K)
> eigvals, eigvecs = scipy.linalg.eigh(K)
and
< eigvals, eigvecs = zip(*sorted(zip(eigvals, eigvecs), reverse=True))
< X_pc1 = eigvecs[0]
> X_pc1 = eigvecs[:,99]
Finally, you can examine scikit-learn's own implementation here. | How to apply a Gaussian radial basis function kernel PCA to nonlinear data? | The first problem seems to be that the sign of gamma is wrong (it should be negative: $-15$, as in the definition of the kernel, not as in your code). Alternatively, use exp(-gamma * mat_sq_dists).
Th | How to apply a Gaussian radial basis function kernel PCA to nonlinear data?
The first problem seems to be that the sign of gamma is wrong (it should be negative: $-15$, as in the definition of the kernel, not as in your code). Alternatively, use exp(-gamma * mat_sq_dists).
The second problem is that you clobber the eigenvectors with your invocation of zip's when you sort the list. The $i$-th eigenvector is eigvecs[:,i], not eigvecs[i,:], according to scipy.linalg.eigh (also: you should prefer eigh to eig because you have a symmetric real matrix).
Replace
< gamma = 15
> gamma = -15
and (to get ordered, real eigenvalues)
< eigvals, eigvecs = np.linalg.eig(K)
> eigvals, eigvecs = scipy.linalg.eigh(K)
and
< eigvals, eigvecs = zip(*sorted(zip(eigvals, eigvecs), reverse=True))
< X_pc1 = eigvecs[0]
> X_pc1 = eigvecs[:,99]
Finally, you can examine scikit-learn's own implementation here. | How to apply a Gaussian radial basis function kernel PCA to nonlinear data?
The first problem seems to be that the sign of gamma is wrong (it should be negative: $-15$, as in the definition of the kernel, not as in your code). Alternatively, use exp(-gamma * mat_sq_dists).
Th |
37,165 | Good papers with reproducible analysis requiring only the basics | At the Universit of Goettingen they started a Wiki collecting various studies and their replications: http://replication.uni-goettingen.de/ | Good papers with reproducible analysis requiring only the basics | At the Universit of Goettingen they started a Wiki collecting various studies and their replications: http://replication.uni-goettingen.de/ | Good papers with reproducible analysis requiring only the basics
At the Universit of Goettingen they started a Wiki collecting various studies and their replications: http://replication.uni-goettingen.de/ | Good papers with reproducible analysis requiring only the basics
At the Universit of Goettingen they started a Wiki collecting various studies and their replications: http://replication.uni-goettingen.de/ |
37,166 | Is the population of blue-eyed Martians decreasing? | This answer describes three ways to handle the varying sample sizes appropriately: a Generalized Linear Model and two weighted Ordinary Least Squares regressions. In this case all three work well. In general, when some proportions are near $0$ or $1$, the GLM is better.
Because the sample sizes are so small compared to the populations (less than ten percent of them), to an excellent approximation the distribution of blue-eyed and non-blue-eyed results in a sample of size $n$ is Binomial (because the samples are random). The other Binomial parameter, $p$, is the true (but unknown) proportion of blue-eyed subjects in the population. Thus, the chance of observing $k$ blue-eyed people is
$$\binom{n}{k}p^k(1-p)^{n-k}.\tag{1}$$
Each decade we know $n$ and $k$--those are given by the data--but we don't know $p$. We may estimate it by assuming that the log odds corresponding to $p$ varies by year linearly (at least to a good approximation). This means we assume there are numbers $\beta_0$ and $\beta_1$ such that
$$\log(p) - \log(1-p) = \beta_0 + \beta_1 \times \text{Year}.$$
Equivalently,
$$p = \frac{1}{1 + e^{-\beta_0-\beta_1\text{Year}}};\ 1-p = \frac{ e^{-\beta_0-\beta_1\text{Year}}}{1 + e^{-\beta_0-\beta_1\text{Year}}}.$$
Plugging this into (1) gives the chance of observing $k$ out of $n$ during a given year $t$ as
$$\binom{n}{k} \frac{e^{-(\beta_0+\beta_1t)(n-k)}}{\left(1 + e^{-(\beta_0+\beta_1t)}\right)^n}.\tag{2}$$
Assuming the samples are independently obtained at years $t_1, t_2,$ etc and writing the corresponding sample sizes and counts of blue-eyed subjects as $n_i$ and $k_i$, the probability of the data is the product of the probabilities of the individual results. This product is (by definition) the likelihood of $(\beta_0, \beta_1)$. We may estimate these parameters as the values $(\hat\beta_0, \hat\beta_1)$ that maximize the likelihood; equivalently, they maximize the log likelihood
$$\Lambda(\beta_0,\beta_1) = \sum_t \log\left(\binom{n}{k} \frac{e^{-(\beta_0+\beta_1t)(n-k)}}{\left(1 + e^{-(\beta_0+\beta_1t)}\right)^n}\right)\tag{3}$$
obtained from $(2)$.
(This simplifies considerably, using rules of logarithms, which is one reason to express the time-proportion relationship in terms of log odds. When all proportions are between $0.2$ and $0.8$, approximately, there is little qualitative difference between using probabilities $p$ or their log odds: the fitted curve will be linear or close to linear, respectively.)
$(3)$ is a Binomial Generalized Linear Model. It must be fitted by numerically minimizing $\Lambda$. The glm procedure in R (shown at the end of this post) gives the solution
$$(\hat\beta_0, \hat\beta_1)_\text{GLM} = (31.498711, -0.0163568).$$
The data in this figure are plotted with disks whose areas are proportional to the sample sizes. The GLM fit is curvilinear. Shown for comparison, in gray, is the line we would get just by dumping the $(\text{Year},\text{Proportion})$ data shown in the question into an Ordinary Least Squares solver. Both fits are influenced by the greater proportions in earlier years, despite the small sample sizes then. However, the GLM fit does a better job of approximating the proportions in the largest samples obtained in 1970 and 1980. The dotted blue line is described below.
By adding a quadratic term we can test the goodness of fit. It significantly improves the GLM fit (although visually the difference is not great), providing evidence that this model does not describe the variation in results well. Looking at the plot indicates the result in 1990 was much lower than the model predicts.
An alternative, but comparable, approach is to estimate $p$ individually for each year $t_i$, perhaps as $k_i / n_i$ (although other estimators are possible). A linear regression of the log odds of these estimates against the year, weighted by the sample sizes $n_i$, or Weighted Least Squares regression, yields
$$(\hat\beta_0, \hat\beta_1)_\text{WLS} = (36.12744, -0.018706).$$
The standard errors of these estimates are $15.55$ and $0.00787$, respectively, indicating that the WLS estimates are not significantly different from the Binomial GLM. (The GLM's standard errors are considerably smaller, though: it "knows" these sample sizes are pretty large whereas the linear regression "knows" nothing about the sample sizes at all: it only has a sequence of ten separate observations.) Note that this alternative might not be available if $k_i=n_i$ or $k_i=0$, unless a different estimator of the probabilities is used (which doesn't produce values of $0$ or $1$).
Finally, we might simply perform a weighted least squares regression of the raw probability estimates $k/n$ against the year, inversely weighted by an estimate of sample variance. The variance of a Binomial$(n,p)$ variable $X$, re-expressed as a proportion $X/n$ is $p(1-p)/n$. That may be estimated from a sample as
$$p(1-p)n \approx \frac{k}{n}\frac{n-k}{n}/n = \frac{k(n-k)}{n^3}.$$
Its result appears in the figure as a dotted blue line. In this case it appears to compromise between the GLM and OLS fits.
The following R code performed the analyses and produced the figure.
year <- seq(1910, 2000, by=10)
total <- c(40, 200, 7, 3, 1, 14, 5000, 7000, 150, 500) * 10
blue <- c(250, 1000, 40, 14, 4, 52, 15400, 22000, 80, 800)
X <- data.frame(Year=year, Success=blue, Failure=total-blue,
Proportion=blue/total, Total=total)
#
# GLM
#
fit <- glm(cbind(Success, Failure) ~ Year, X, family="binomial")
summary(fit)
#
# WLS of the log odds (an alternative)
#
fit.WLS <- lm(log(Success/Failure) ~ Year, X, weights=Total)
summary(fit.WLS)
#
# Plot the results.
#
X.more <- data.frame(Year=1901:2010)
X.more$Prediction <- predict(fit, X.more, type="response")
plot(X$Year, X$Proportion, ylim=0:1,
type="p", pch=21, bg="Red", cex=sqrt(X$Total/2000),
xlab="Year", ylab="Proportion",
main="GLM and OLS Fits", sub="GLM: solid line; OLS: dotted line")
lines(X.more, lwd=2)
abline(lm(Proportion ~ Year, X),
lty=3, lwd=3, col="Gray") #The OLS fit
abline(lm(Proportion ~ Year, X, weights=Total^3/(Success*Failure)),
lty=3, lwd=3, col="Blue") #The weighted OLS fit to the proportions | Is the population of blue-eyed Martians decreasing? | This answer describes three ways to handle the varying sample sizes appropriately: a Generalized Linear Model and two weighted Ordinary Least Squares regressions. In this case all three work well. I | Is the population of blue-eyed Martians decreasing?
This answer describes three ways to handle the varying sample sizes appropriately: a Generalized Linear Model and two weighted Ordinary Least Squares regressions. In this case all three work well. In general, when some proportions are near $0$ or $1$, the GLM is better.
Because the sample sizes are so small compared to the populations (less than ten percent of them), to an excellent approximation the distribution of blue-eyed and non-blue-eyed results in a sample of size $n$ is Binomial (because the samples are random). The other Binomial parameter, $p$, is the true (but unknown) proportion of blue-eyed subjects in the population. Thus, the chance of observing $k$ blue-eyed people is
$$\binom{n}{k}p^k(1-p)^{n-k}.\tag{1}$$
Each decade we know $n$ and $k$--those are given by the data--but we don't know $p$. We may estimate it by assuming that the log odds corresponding to $p$ varies by year linearly (at least to a good approximation). This means we assume there are numbers $\beta_0$ and $\beta_1$ such that
$$\log(p) - \log(1-p) = \beta_0 + \beta_1 \times \text{Year}.$$
Equivalently,
$$p = \frac{1}{1 + e^{-\beta_0-\beta_1\text{Year}}};\ 1-p = \frac{ e^{-\beta_0-\beta_1\text{Year}}}{1 + e^{-\beta_0-\beta_1\text{Year}}}.$$
Plugging this into (1) gives the chance of observing $k$ out of $n$ during a given year $t$ as
$$\binom{n}{k} \frac{e^{-(\beta_0+\beta_1t)(n-k)}}{\left(1 + e^{-(\beta_0+\beta_1t)}\right)^n}.\tag{2}$$
Assuming the samples are independently obtained at years $t_1, t_2,$ etc and writing the corresponding sample sizes and counts of blue-eyed subjects as $n_i$ and $k_i$, the probability of the data is the product of the probabilities of the individual results. This product is (by definition) the likelihood of $(\beta_0, \beta_1)$. We may estimate these parameters as the values $(\hat\beta_0, \hat\beta_1)$ that maximize the likelihood; equivalently, they maximize the log likelihood
$$\Lambda(\beta_0,\beta_1) = \sum_t \log\left(\binom{n}{k} \frac{e^{-(\beta_0+\beta_1t)(n-k)}}{\left(1 + e^{-(\beta_0+\beta_1t)}\right)^n}\right)\tag{3}$$
obtained from $(2)$.
(This simplifies considerably, using rules of logarithms, which is one reason to express the time-proportion relationship in terms of log odds. When all proportions are between $0.2$ and $0.8$, approximately, there is little qualitative difference between using probabilities $p$ or their log odds: the fitted curve will be linear or close to linear, respectively.)
$(3)$ is a Binomial Generalized Linear Model. It must be fitted by numerically minimizing $\Lambda$. The glm procedure in R (shown at the end of this post) gives the solution
$$(\hat\beta_0, \hat\beta_1)_\text{GLM} = (31.498711, -0.0163568).$$
The data in this figure are plotted with disks whose areas are proportional to the sample sizes. The GLM fit is curvilinear. Shown for comparison, in gray, is the line we would get just by dumping the $(\text{Year},\text{Proportion})$ data shown in the question into an Ordinary Least Squares solver. Both fits are influenced by the greater proportions in earlier years, despite the small sample sizes then. However, the GLM fit does a better job of approximating the proportions in the largest samples obtained in 1970 and 1980. The dotted blue line is described below.
By adding a quadratic term we can test the goodness of fit. It significantly improves the GLM fit (although visually the difference is not great), providing evidence that this model does not describe the variation in results well. Looking at the plot indicates the result in 1990 was much lower than the model predicts.
An alternative, but comparable, approach is to estimate $p$ individually for each year $t_i$, perhaps as $k_i / n_i$ (although other estimators are possible). A linear regression of the log odds of these estimates against the year, weighted by the sample sizes $n_i$, or Weighted Least Squares regression, yields
$$(\hat\beta_0, \hat\beta_1)_\text{WLS} = (36.12744, -0.018706).$$
The standard errors of these estimates are $15.55$ and $0.00787$, respectively, indicating that the WLS estimates are not significantly different from the Binomial GLM. (The GLM's standard errors are considerably smaller, though: it "knows" these sample sizes are pretty large whereas the linear regression "knows" nothing about the sample sizes at all: it only has a sequence of ten separate observations.) Note that this alternative might not be available if $k_i=n_i$ or $k_i=0$, unless a different estimator of the probabilities is used (which doesn't produce values of $0$ or $1$).
Finally, we might simply perform a weighted least squares regression of the raw probability estimates $k/n$ against the year, inversely weighted by an estimate of sample variance. The variance of a Binomial$(n,p)$ variable $X$, re-expressed as a proportion $X/n$ is $p(1-p)/n$. That may be estimated from a sample as
$$p(1-p)n \approx \frac{k}{n}\frac{n-k}{n}/n = \frac{k(n-k)}{n^3}.$$
Its result appears in the figure as a dotted blue line. In this case it appears to compromise between the GLM and OLS fits.
The following R code performed the analyses and produced the figure.
year <- seq(1910, 2000, by=10)
total <- c(40, 200, 7, 3, 1, 14, 5000, 7000, 150, 500) * 10
blue <- c(250, 1000, 40, 14, 4, 52, 15400, 22000, 80, 800)
X <- data.frame(Year=year, Success=blue, Failure=total-blue,
Proportion=blue/total, Total=total)
#
# GLM
#
fit <- glm(cbind(Success, Failure) ~ Year, X, family="binomial")
summary(fit)
#
# WLS of the log odds (an alternative)
#
fit.WLS <- lm(log(Success/Failure) ~ Year, X, weights=Total)
summary(fit.WLS)
#
# Plot the results.
#
X.more <- data.frame(Year=1901:2010)
X.more$Prediction <- predict(fit, X.more, type="response")
plot(X$Year, X$Proportion, ylim=0:1,
type="p", pch=21, bg="Red", cex=sqrt(X$Total/2000),
xlab="Year", ylab="Proportion",
main="GLM and OLS Fits", sub="GLM: solid line; OLS: dotted line")
lines(X.more, lwd=2)
abline(lm(Proportion ~ Year, X),
lty=3, lwd=3, col="Gray") #The OLS fit
abline(lm(Proportion ~ Year, X, weights=Total^3/(Success*Failure)),
lty=3, lwd=3, col="Blue") #The weighted OLS fit to the proportions | Is the population of blue-eyed Martians decreasing?
This answer describes three ways to handle the varying sample sizes appropriately: a Generalized Linear Model and two weighted Ordinary Least Squares regressions. In this case all three work well. I |
37,167 | Follow-up question: When should you center your data & when should you standardize? | Suppose a model of the form
$$\mathbb{E}(Y) = f(\beta_0 + \beta_1 x_1 + \cdots + \beta_d x_d)$$
with parameters $(\beta_0, \beta_1, \ldots, \beta_d)$ is fit to data $((x_{i1}, x_{i2}, \ldots, x_{id}, y_i))$ by optimizing some measure of discrepancy between the $y_i$ and the corresponding $\mathrm{x}_i$, as is done (for instance) with least squares, generalized least squares, and maximum likelihood estimators for generalized linear models. Further suppose the optimum is unique. Write its value as $\hat{\beta} = (\hat{\beta}_0, \hat{\beta}_1, \ldots, \hat{\beta}_d)$. Then, for any nonzero constants $\sigma_1, \ldots, \sigma_d$ and any constants $\mu_1, \ldots, \mu_d$, it is immediate (by plugging in the values) that
$$\hat{\alpha}_0 = \hat{\beta}_0 - \hat{\beta}_1\mu_1/\sigma_1 - \cdots - \hat{\beta}_d\mu_d\sigma_d$$
and
$$(\hat{\alpha}_1, \ldots, \hat{\alpha}_d) = (\hat{\beta}_1/\sigma_1, \ldots, \hat{\beta}_d/\sigma_d)$$
is the unique optimum for the model
$$\mathbb{E}(Y) = f(\alpha_0 +\alpha_1 z_1 + \cdots + \alpha_d z_d)$$
with parameters $(\alpha_1, \ldots, \alpha_d)$ and new (affinely) transformed variables
$$z_i = \sigma_i x_i + \mu_i.$$
Even when the optimum is not unique, any optimum for the first model is still converted to some optimum for the second model. It just might not be the same optimum returned by a computer program. This can happen when the parameters are not identifiable, for instance.
When the constant term $\beta_0$ is not included in the model, it is no longer possible to carry out this reasoning unless all the $\mu_i=0$. Even then, the estimated coefficients $\hat{\beta}_i$ still transform contravariantly with respect to rescaling of the variables $x_i$. | Follow-up question: When should you center your data & when should you standardize? | Suppose a model of the form
$$\mathbb{E}(Y) = f(\beta_0 + \beta_1 x_1 + \cdots + \beta_d x_d)$$
with parameters $(\beta_0, \beta_1, \ldots, \beta_d)$ is fit to data $((x_{i1}, x_{i2}, \ldots, x_{id}, | Follow-up question: When should you center your data & when should you standardize?
Suppose a model of the form
$$\mathbb{E}(Y) = f(\beta_0 + \beta_1 x_1 + \cdots + \beta_d x_d)$$
with parameters $(\beta_0, \beta_1, \ldots, \beta_d)$ is fit to data $((x_{i1}, x_{i2}, \ldots, x_{id}, y_i))$ by optimizing some measure of discrepancy between the $y_i$ and the corresponding $\mathrm{x}_i$, as is done (for instance) with least squares, generalized least squares, and maximum likelihood estimators for generalized linear models. Further suppose the optimum is unique. Write its value as $\hat{\beta} = (\hat{\beta}_0, \hat{\beta}_1, \ldots, \hat{\beta}_d)$. Then, for any nonzero constants $\sigma_1, \ldots, \sigma_d$ and any constants $\mu_1, \ldots, \mu_d$, it is immediate (by plugging in the values) that
$$\hat{\alpha}_0 = \hat{\beta}_0 - \hat{\beta}_1\mu_1/\sigma_1 - \cdots - \hat{\beta}_d\mu_d\sigma_d$$
and
$$(\hat{\alpha}_1, \ldots, \hat{\alpha}_d) = (\hat{\beta}_1/\sigma_1, \ldots, \hat{\beta}_d/\sigma_d)$$
is the unique optimum for the model
$$\mathbb{E}(Y) = f(\alpha_0 +\alpha_1 z_1 + \cdots + \alpha_d z_d)$$
with parameters $(\alpha_1, \ldots, \alpha_d)$ and new (affinely) transformed variables
$$z_i = \sigma_i x_i + \mu_i.$$
Even when the optimum is not unique, any optimum for the first model is still converted to some optimum for the second model. It just might not be the same optimum returned by a computer program. This can happen when the parameters are not identifiable, for instance.
When the constant term $\beta_0$ is not included in the model, it is no longer possible to carry out this reasoning unless all the $\mu_i=0$. Even then, the estimated coefficients $\hat{\beta}_i$ still transform contravariantly with respect to rescaling of the variables $x_i$. | Follow-up question: When should you center your data & when should you standardize?
Suppose a model of the form
$$\mathbb{E}(Y) = f(\beta_0 + \beta_1 x_1 + \cdots + \beta_d x_d)$$
with parameters $(\beta_0, \beta_1, \ldots, \beta_d)$ is fit to data $((x_{i1}, x_{i2}, \ldots, x_{id}, |
37,168 | Multi-class classification via all pairwise classifications with LDA | This question is not restricted to LDA, but can be asked about any binary classifier that is used in a multi-class setting by making all pairwise comparisons. The question is how to combine all pairwise classifications into one final classification.
The simplest approach is as follows. Each of the $\frac{K(K-1)}{2}$ pairwise classifiers results in a "winning" class (among the two considered). Count the number of wins for each of the classes (with the upper bound $K-1$), and assign the observation to the class with most wins. Note that this simple "voting" approach works even if your classifier does not return a probability of belonging to each of the two classes, but simply reports pairwise decisions.
When each of the pairwise classifiers reports not only pairwise decisions, but also probability of belonging to each of the two classes, more sophisticated algorithms become possible. I cannot give an overview or an advice, but there is a massively popular 2004 paper (over 1k citations according to Google Scholar) that reviews exactly this question and offers some novel methods:
Wu, T. F., Lin, C. J., & Weng, R. C. (2004). Probability estimates for multi-class classification by pairwise coupling. The Journal of Machine Learning Research, 5, 975-1005.
I would guess, however, that in many real situations the simple voting method would already give reasonable results.
Update: In the NIPS version of the same paper the authors report performance of several methods, including the "voting" one, on several real datasets with number of classes ranging from 6 to 26, see Table 1. The voting method seems to be very competitive in each case. On some datasets it even seems to outperform all other, much more sophisticated, methods. | Multi-class classification via all pairwise classifications with LDA | This question is not restricted to LDA, but can be asked about any binary classifier that is used in a multi-class setting by making all pairwise comparisons. The question is how to combine all pairwi | Multi-class classification via all pairwise classifications with LDA
This question is not restricted to LDA, but can be asked about any binary classifier that is used in a multi-class setting by making all pairwise comparisons. The question is how to combine all pairwise classifications into one final classification.
The simplest approach is as follows. Each of the $\frac{K(K-1)}{2}$ pairwise classifiers results in a "winning" class (among the two considered). Count the number of wins for each of the classes (with the upper bound $K-1$), and assign the observation to the class with most wins. Note that this simple "voting" approach works even if your classifier does not return a probability of belonging to each of the two classes, but simply reports pairwise decisions.
When each of the pairwise classifiers reports not only pairwise decisions, but also probability of belonging to each of the two classes, more sophisticated algorithms become possible. I cannot give an overview or an advice, but there is a massively popular 2004 paper (over 1k citations according to Google Scholar) that reviews exactly this question and offers some novel methods:
Wu, T. F., Lin, C. J., & Weng, R. C. (2004). Probability estimates for multi-class classification by pairwise coupling. The Journal of Machine Learning Research, 5, 975-1005.
I would guess, however, that in many real situations the simple voting method would already give reasonable results.
Update: In the NIPS version of the same paper the authors report performance of several methods, including the "voting" one, on several real datasets with number of classes ranging from 6 to 26, see Table 1. The voting method seems to be very competitive in each case. On some datasets it even seems to outperform all other, much more sophisticated, methods. | Multi-class classification via all pairwise classifications with LDA
This question is not restricted to LDA, but can be asked about any binary classifier that is used in a multi-class setting by making all pairwise comparisons. The question is how to combine all pairwi |
37,169 | Proper Number of Clicks for Conversion Rate Testing | Paul. A conversion rate is defined as:
$\textrm{Conversion rate} = r =\frac{\textrm{Number of goal achievements}}{\textrm{Visits}} = \frac{s}{n}$.
Assuming that the number of goal achievements is basically the number of success $s$ out of the number of trials $v$ (rather than the number of events per unit time or space), then what you are trying to do with your conversion rate data is estimate the underlying but unknown probability of conversion $\kappa$. There is absolutely no need to make a normality assumption in estimating the rate or its uncertainty. Instead, you could use the Bayesian Beta-binomial model for estimating the probability distribution of an unknown proportion.
In the Beta-binomial model, your conversion rate data $v$ follows a binomial distribution with size $n$ and probability $\kappa$:
$s \sim \textrm{Bin}(n,\kappa)$
Of course, you don't know what $\kappa$ is, so you are going to use Bayes' theorem to estimate it by combining your prior beliefs about what the probability might be and your conversion rate data. It turns out that a very useful model for the distribution of your priors beliefs about the probability in this case is the Beta distribution with concentration parameters $\alpha$ and $\beta$.
$\kappa \sim \textrm{Beta}(\alpha, \beta)$
In the Beta distribution, the parameters $\alpha$ and $\beta$ represent your prior beliefs about the concentration of successes and failures. The greater one concentration parameter is relative to another, the greater your belief that the probability favors that event. Also, the greater the sum of the concentration parameters $\alpha + \beta$, the more prior information you have about the conversion rate (say, from previous experiments using the same landing page), and the more certain you are in the expected probability $\frac{\alpha}{\alpha + \beta}$.
There is a nifty mathematical result here. It turns out that the posterior distribution of the conversion probability $\kappa$ follows a Beta distribution with the concentration parameters being a simply modification of those in your prior. The posterior distribution of the conversion probability is:
$\textrm{Pr}(\kappa|s,n,\alpha,\beta) \sim \textrm{Beta}(\alpha + s, \beta + n - s)$
That is, you just add the counts in your data to the appropriate concentration parameter ($\alpha$ being the concentration of successes and $\beta$ that of failures), and voila!
But how should you set the values of $\alpha$ and $\beta$? If you have prior information about the conversion rate for that landing page, perhaps you could set the concentration parameters to be the counts of those prior experiments. But be careful: the bigger the prior sample size, the more new conversion data you will need to overwhelm your prior beliefs. Then again, you could set the parameters so that the prior expected value $\frac{\alpha}{\alpha + \beta}$ is equal to the conversion probability from your prior experiments, but choose the parameters also so that their sum is low, reflecting your lack of information about the present landing page, say, because this landing page is much different from your previous ones. How you set the prior depends on your circumstances and your beliefs and how strong those beliefs are.
Another option is to claim ignorance about what the value of $\kappa$ might be. In this case, you could set $\alpha = \beta = 1$, which is equivalent to a continuous uniform (i.e., flat) prior distribution. Some suggest that you should use the Jeffrey's prior distribution, wherein $\alpha = \beta = 1/2$ instead, which as a U-shape with modes at 0 and 1.
Regardless of what prior distribution you choose, now you can estimate the expected value of the conversion probability, which is:
$\textrm{E}(\kappa|s,n,\alpha,\beta) = \frac{\alpha + s}{\alpha + \beta + n}$
You could also estimate the posterior variance using the formula for the Beta distribution variance, or the posteiror median, or the posteiror kurtosis, or the posterior skewness, or what have you. You could use a computer program such as R to estimate the credible range for conversion rate given your data. For example, you could estimate the posterior 95% confidence interval by firing up R and running the following code (assuming that you've defined $\alpha$, $\beta$, $s$, and $n$ in your code previously):
post_CI <- qbeta(c(0.025, 0.975), alpha, beta)
You could also use simulations from the posterior distribution to compute any number of alternative credible intervals, such as the highest posterior density interval or lowest posterior loss interval. You should seriously look into highest posterior density interval because the Beta distribution can be quite skewed, causing the traditional quantile interval approach to allow values into the interval that have lower posterior probability than values that are not in the interval. Below is the code for computing the highest posterior density interval, assuming you've defined everything as before:
sims <- rbeta(1000000, alpha, beta)
require(coda) || install.packages("coda")
post_HDI <- HPDinterval(as.mcmc(sims), prob=0.95) | Proper Number of Clicks for Conversion Rate Testing | Paul. A conversion rate is defined as:
$\textrm{Conversion rate} = r =\frac{\textrm{Number of goal achievements}}{\textrm{Visits}} = \frac{s}{n}$.
Assuming that the number of goal achievements is basi | Proper Number of Clicks for Conversion Rate Testing
Paul. A conversion rate is defined as:
$\textrm{Conversion rate} = r =\frac{\textrm{Number of goal achievements}}{\textrm{Visits}} = \frac{s}{n}$.
Assuming that the number of goal achievements is basically the number of success $s$ out of the number of trials $v$ (rather than the number of events per unit time or space), then what you are trying to do with your conversion rate data is estimate the underlying but unknown probability of conversion $\kappa$. There is absolutely no need to make a normality assumption in estimating the rate or its uncertainty. Instead, you could use the Bayesian Beta-binomial model for estimating the probability distribution of an unknown proportion.
In the Beta-binomial model, your conversion rate data $v$ follows a binomial distribution with size $n$ and probability $\kappa$:
$s \sim \textrm{Bin}(n,\kappa)$
Of course, you don't know what $\kappa$ is, so you are going to use Bayes' theorem to estimate it by combining your prior beliefs about what the probability might be and your conversion rate data. It turns out that a very useful model for the distribution of your priors beliefs about the probability in this case is the Beta distribution with concentration parameters $\alpha$ and $\beta$.
$\kappa \sim \textrm{Beta}(\alpha, \beta)$
In the Beta distribution, the parameters $\alpha$ and $\beta$ represent your prior beliefs about the concentration of successes and failures. The greater one concentration parameter is relative to another, the greater your belief that the probability favors that event. Also, the greater the sum of the concentration parameters $\alpha + \beta$, the more prior information you have about the conversion rate (say, from previous experiments using the same landing page), and the more certain you are in the expected probability $\frac{\alpha}{\alpha + \beta}$.
There is a nifty mathematical result here. It turns out that the posterior distribution of the conversion probability $\kappa$ follows a Beta distribution with the concentration parameters being a simply modification of those in your prior. The posterior distribution of the conversion probability is:
$\textrm{Pr}(\kappa|s,n,\alpha,\beta) \sim \textrm{Beta}(\alpha + s, \beta + n - s)$
That is, you just add the counts in your data to the appropriate concentration parameter ($\alpha$ being the concentration of successes and $\beta$ that of failures), and voila!
But how should you set the values of $\alpha$ and $\beta$? If you have prior information about the conversion rate for that landing page, perhaps you could set the concentration parameters to be the counts of those prior experiments. But be careful: the bigger the prior sample size, the more new conversion data you will need to overwhelm your prior beliefs. Then again, you could set the parameters so that the prior expected value $\frac{\alpha}{\alpha + \beta}$ is equal to the conversion probability from your prior experiments, but choose the parameters also so that their sum is low, reflecting your lack of information about the present landing page, say, because this landing page is much different from your previous ones. How you set the prior depends on your circumstances and your beliefs and how strong those beliefs are.
Another option is to claim ignorance about what the value of $\kappa$ might be. In this case, you could set $\alpha = \beta = 1$, which is equivalent to a continuous uniform (i.e., flat) prior distribution. Some suggest that you should use the Jeffrey's prior distribution, wherein $\alpha = \beta = 1/2$ instead, which as a U-shape with modes at 0 and 1.
Regardless of what prior distribution you choose, now you can estimate the expected value of the conversion probability, which is:
$\textrm{E}(\kappa|s,n,\alpha,\beta) = \frac{\alpha + s}{\alpha + \beta + n}$
You could also estimate the posterior variance using the formula for the Beta distribution variance, or the posteiror median, or the posteiror kurtosis, or the posterior skewness, or what have you. You could use a computer program such as R to estimate the credible range for conversion rate given your data. For example, you could estimate the posterior 95% confidence interval by firing up R and running the following code (assuming that you've defined $\alpha$, $\beta$, $s$, and $n$ in your code previously):
post_CI <- qbeta(c(0.025, 0.975), alpha, beta)
You could also use simulations from the posterior distribution to compute any number of alternative credible intervals, such as the highest posterior density interval or lowest posterior loss interval. You should seriously look into highest posterior density interval because the Beta distribution can be quite skewed, causing the traditional quantile interval approach to allow values into the interval that have lower posterior probability than values that are not in the interval. Below is the code for computing the highest posterior density interval, assuming you've defined everything as before:
sims <- rbeta(1000000, alpha, beta)
require(coda) || install.packages("coda")
post_HDI <- HPDinterval(as.mcmc(sims), prob=0.95) | Proper Number of Clicks for Conversion Rate Testing
Paul. A conversion rate is defined as:
$\textrm{Conversion rate} = r =\frac{\textrm{Number of goal achievements}}{\textrm{Visits}} = \frac{s}{n}$.
Assuming that the number of goal achievements is basi |
37,170 | Ordinal Logistic Regression with a Different Link Function | I think we first have to ask whether it's necessary to use proportional odds logistic regression to approximate a cumulative relative risk, e.g. the relative risk of reporting a higher outcome. The probabilistic formulation of the proportional odds model relies on observing arbitrary bins of a latent logistic random variable. See my relevant question here. The elegance of this method is that the survival function (1-CDF) of a logistic RV is the inverse logit, e.g. $P(Z > z) = \exp(-z)/(1+\exp(-z))$.
If we are to assume a similar probabilistic derivation of a relative risk model, the desire is to find a latent random variable whose survival function is $P(Z > z) = \exp(-z)$. But that is just an exponential random variable, which is memoryless. Therefore, if we construct the matrix of thresholded outcome variables, $O_{ij} = \mathcal{I}(Y_{i} \ge j)$, (I believe) the cell frequencies are conditionally independent, and thus are amenable to modeling via a log-linear model which is just Poisson regression. This is reassuring because the interpretation of Poisson coefficients is as a relative rate. Modeling the interaction between the response variable as numeric outcome and the regression coefficients leads to the correct interpretation.
That is, fit the log-linear model:
$$\log (N_{ij} | Y_{i}, \mathbf{X}_{i,}) = \eta_0 I(Y_{i} = 0) + \ldots + \eta_j I(Y_i == j) + \vec{\beta} \mathbf{X}_{i,} + \vec{\gamma} \text{diag(Y)} \mathbf{X}_{i,}$$
Using the example from the MASS package: we see the desired effect that the relative risk is much smaller than the OR in all instances:
newData <- data.frame('oy'=oy, 'ny'=as.numeric(y), housing)
## trick: marginal frequencies are categorical but interactions are linear
## solution: use linear main effect and add indicators for remaining n-2 categories
## equivalent model specifications
fit <- glm(Freq ~ oy.2 + ny*(Infl + Type + Cont), data=newData, family=poisson)
effects <- grep('ny:', names(coef(fit)), value=T)
print(cbind(
coef(summary(fit))[effects, ],
coef(summary(house.plr))[gsub('ny:','', effects), ]
), digits=3)
Gives us:
Estimate Std. Error z value Pr(>|z|) Value Std. Error t value
ny:InflMedium 0.360 0.0664 5.41 6.23e-08 0.566 0.1047 5.41
ny:InflHigh 0.792 0.0811 9.77 1.50e-22 1.289 0.1272 10.14
ny:TypeApartment -0.299 0.0742 -4.03 5.55e-05 -0.572 0.1192 -4.80
ny:TypeAtrium -0.170 0.0977 -1.74 8.21e-02 -0.366 0.1552 -2.36
ny:TypeTerrace -0.673 0.0951 -7.07 1.51e-12 -1.091 0.1515 -7.20
ny:ContHigh 0.106 0.0578 1.84 6.62e-02 0.360 0.0955 3.77
Where the first 4 columns are inference from the log-linear model and the second 3 columns come from the proportional odds model.
This answers perhaps the most important question: how does one fit such a model. I think it can be used to explore the relative approximation(s) of ORs for rare events to the RRs. | Ordinal Logistic Regression with a Different Link Function | I think we first have to ask whether it's necessary to use proportional odds logistic regression to approximate a cumulative relative risk, e.g. the relative risk of reporting a higher outcome. The pr | Ordinal Logistic Regression with a Different Link Function
I think we first have to ask whether it's necessary to use proportional odds logistic regression to approximate a cumulative relative risk, e.g. the relative risk of reporting a higher outcome. The probabilistic formulation of the proportional odds model relies on observing arbitrary bins of a latent logistic random variable. See my relevant question here. The elegance of this method is that the survival function (1-CDF) of a logistic RV is the inverse logit, e.g. $P(Z > z) = \exp(-z)/(1+\exp(-z))$.
If we are to assume a similar probabilistic derivation of a relative risk model, the desire is to find a latent random variable whose survival function is $P(Z > z) = \exp(-z)$. But that is just an exponential random variable, which is memoryless. Therefore, if we construct the matrix of thresholded outcome variables, $O_{ij} = \mathcal{I}(Y_{i} \ge j)$, (I believe) the cell frequencies are conditionally independent, and thus are amenable to modeling via a log-linear model which is just Poisson regression. This is reassuring because the interpretation of Poisson coefficients is as a relative rate. Modeling the interaction between the response variable as numeric outcome and the regression coefficients leads to the correct interpretation.
That is, fit the log-linear model:
$$\log (N_{ij} | Y_{i}, \mathbf{X}_{i,}) = \eta_0 I(Y_{i} = 0) + \ldots + \eta_j I(Y_i == j) + \vec{\beta} \mathbf{X}_{i,} + \vec{\gamma} \text{diag(Y)} \mathbf{X}_{i,}$$
Using the example from the MASS package: we see the desired effect that the relative risk is much smaller than the OR in all instances:
newData <- data.frame('oy'=oy, 'ny'=as.numeric(y), housing)
## trick: marginal frequencies are categorical but interactions are linear
## solution: use linear main effect and add indicators for remaining n-2 categories
## equivalent model specifications
fit <- glm(Freq ~ oy.2 + ny*(Infl + Type + Cont), data=newData, family=poisson)
effects <- grep('ny:', names(coef(fit)), value=T)
print(cbind(
coef(summary(fit))[effects, ],
coef(summary(house.plr))[gsub('ny:','', effects), ]
), digits=3)
Gives us:
Estimate Std. Error z value Pr(>|z|) Value Std. Error t value
ny:InflMedium 0.360 0.0664 5.41 6.23e-08 0.566 0.1047 5.41
ny:InflHigh 0.792 0.0811 9.77 1.50e-22 1.289 0.1272 10.14
ny:TypeApartment -0.299 0.0742 -4.03 5.55e-05 -0.572 0.1192 -4.80
ny:TypeAtrium -0.170 0.0977 -1.74 8.21e-02 -0.366 0.1552 -2.36
ny:TypeTerrace -0.673 0.0951 -7.07 1.51e-12 -1.091 0.1515 -7.20
ny:ContHigh 0.106 0.0578 1.84 6.62e-02 0.360 0.0955 3.77
Where the first 4 columns are inference from the log-linear model and the second 3 columns come from the proportional odds model.
This answers perhaps the most important question: how does one fit such a model. I think it can be used to explore the relative approximation(s) of ORs for rare events to the RRs. | Ordinal Logistic Regression with a Different Link Function
I think we first have to ask whether it's necessary to use proportional odds logistic regression to approximate a cumulative relative risk, e.g. the relative risk of reporting a higher outcome. The pr |
37,171 | Ordinal Logistic Regression with a Different Link Function | Let's address your two questions separately:
Is the "rare outcome assumption" for an OR to approximate a relative risk still true in ordinal logistic regression?
Not really. You said yourself that your outcomes are evenly spread throughout the four categories, so no category is going to be particularly rare.
If so, is it possible to change the link function to directly estimate a relative risk, and is it still possible to use something like a poisson approximation with robust standard errors to deal with convergence issues in such a case?
You can, but there is a risk that when you use your model to make predictions, the predicted probability of being in a class might be more than 1.
The standard ordered logit model is formulated $$Y_i \sim categorical({\bf{p}}_i);logit({\bf{p}}_i) = X\beta$$
together with the proportional odds assumption. All we are doing is replacing the "logit" with "log", which still produces a valid model with a valid likelihood that produces valid estimates for $\beta$. When you apply these to real data though, it is possible that a component for $\bf{p}_i$ is more than one (and since this is outside the range of the proportional odds assumption, you can't use it to populate the remaining components).
This can't happen if you only use your model to predict on the data it was trained on, and is less likely if
you have a lot of training data
your training data covers all possible combinations of covariates (if they are categorical) or the full range of covariates (if they are numeric) | Ordinal Logistic Regression with a Different Link Function | Let's address your two questions separately:
Is the "rare outcome assumption" for an OR to approximate a relative risk still true in ordinal logistic regression?
Not really. You said yourself that you | Ordinal Logistic Regression with a Different Link Function
Let's address your two questions separately:
Is the "rare outcome assumption" for an OR to approximate a relative risk still true in ordinal logistic regression?
Not really. You said yourself that your outcomes are evenly spread throughout the four categories, so no category is going to be particularly rare.
If so, is it possible to change the link function to directly estimate a relative risk, and is it still possible to use something like a poisson approximation with robust standard errors to deal with convergence issues in such a case?
You can, but there is a risk that when you use your model to make predictions, the predicted probability of being in a class might be more than 1.
The standard ordered logit model is formulated $$Y_i \sim categorical({\bf{p}}_i);logit({\bf{p}}_i) = X\beta$$
together with the proportional odds assumption. All we are doing is replacing the "logit" with "log", which still produces a valid model with a valid likelihood that produces valid estimates for $\beta$. When you apply these to real data though, it is possible that a component for $\bf{p}_i$ is more than one (and since this is outside the range of the proportional odds assumption, you can't use it to populate the remaining components).
This can't happen if you only use your model to predict on the data it was trained on, and is less likely if
you have a lot of training data
your training data covers all possible combinations of covariates (if they are categorical) or the full range of covariates (if they are numeric) | Ordinal Logistic Regression with a Different Link Function
Let's address your two questions separately:
Is the "rare outcome assumption" for an OR to approximate a relative risk still true in ordinal logistic regression?
Not really. You said yourself that you |
37,172 | Does Box-Cox parameter estimation count towards parameters for AIC? | Write $p_\lambda(x)$ for the Box-Cox transformation of $x$ with parameter $\lambda$, $-\infty\lt\lambda\lt\infty$. The full model for data $(x_i,y_i)$ where the responses $(y_i)$ are viewed as a realization of a random vector $(Y_i)$ is described in the question as
$$\mathbb{E}(p_{\lambda_y}(Y_i)) = a + b\, p_{\lambda_x}(x_i).$$
That explicitly has four parameters ${a, b, p_{\lambda_y}, p_{\lambda_x}}$, all of which are identifiable provided there are at least three distinct values of $x_i$ and three distinct values of $y_i$. According to the answers to your preceding question, you count four parameters when none of the values are established independently of the data (and therefore are estimated from the data). If instead either (or both) $\lambda_x$ or $\lambda_y$ were established in some other way--for instance, if $\lambda_y$ were computed from a separate data set--then it would not be counted.
(Depending on distributional assumptions made about $p_{\lambda_y}(Y_i)$, there could be more parameters involved in fitting the model. Counting them is not affected by the Box-Cox transformations. The one-to-one property of the Box-Cox transformation indicates that any parameter that is identifiable in the absence of the transformation will remain identifiable when the transformation is applied.) | Does Box-Cox parameter estimation count towards parameters for AIC? | Write $p_\lambda(x)$ for the Box-Cox transformation of $x$ with parameter $\lambda$, $-\infty\lt\lambda\lt\infty$. The full model for data $(x_i,y_i)$ where the responses $(y_i)$ are viewed as a real | Does Box-Cox parameter estimation count towards parameters for AIC?
Write $p_\lambda(x)$ for the Box-Cox transformation of $x$ with parameter $\lambda$, $-\infty\lt\lambda\lt\infty$. The full model for data $(x_i,y_i)$ where the responses $(y_i)$ are viewed as a realization of a random vector $(Y_i)$ is described in the question as
$$\mathbb{E}(p_{\lambda_y}(Y_i)) = a + b\, p_{\lambda_x}(x_i).$$
That explicitly has four parameters ${a, b, p_{\lambda_y}, p_{\lambda_x}}$, all of which are identifiable provided there are at least three distinct values of $x_i$ and three distinct values of $y_i$. According to the answers to your preceding question, you count four parameters when none of the values are established independently of the data (and therefore are estimated from the data). If instead either (or both) $\lambda_x$ or $\lambda_y$ were established in some other way--for instance, if $\lambda_y$ were computed from a separate data set--then it would not be counted.
(Depending on distributional assumptions made about $p_{\lambda_y}(Y_i)$, there could be more parameters involved in fitting the model. Counting them is not affected by the Box-Cox transformations. The one-to-one property of the Box-Cox transformation indicates that any parameter that is identifiable in the absence of the transformation will remain identifiable when the transformation is applied.) | Does Box-Cox parameter estimation count towards parameters for AIC?
Write $p_\lambda(x)$ for the Box-Cox transformation of $x$ with parameter $\lambda$, $-\infty\lt\lambda\lt\infty$. The full model for data $(x_i,y_i)$ where the responses $(y_i)$ are viewed as a real |
37,173 | Does Box-Cox parameter estimation count towards parameters for AIC? | Why are you transforming the data?
What scale are you asking your questions on? If it isn't the transformed scale, then there is the issue of parameterization.
An example might help. Suppose some response $Y \sim \log N(\mu, \sigma)$, and you want to compare $Y$ across two independent populations. Suppose further that the question of interest is, "Are the means equal in these populations?" The obvious thing to do in this case is to analyze $\log y_{ij}$ and estimate $\mu_1 - \mu_2$.
That would not answer the question, though. $E\{Y_i\} = \exp (\mu_i+\sigma_i)$. What you need is a confidence interval on $\mu_1-\mu_2 + \sigma_1-\sigma_2$.
Now, if in fact you are interested in things on the transformed scale none of this applies. It happens: chemists and environmental scientists are interested in pH (to the point that they measure pH rather than $H^+$ concentrations.) | Does Box-Cox parameter estimation count towards parameters for AIC? | Why are you transforming the data?
What scale are you asking your questions on? If it isn't the transformed scale, then there is the issue of parameterization.
An example might help. Suppose some re | Does Box-Cox parameter estimation count towards parameters for AIC?
Why are you transforming the data?
What scale are you asking your questions on? If it isn't the transformed scale, then there is the issue of parameterization.
An example might help. Suppose some response $Y \sim \log N(\mu, \sigma)$, and you want to compare $Y$ across two independent populations. Suppose further that the question of interest is, "Are the means equal in these populations?" The obvious thing to do in this case is to analyze $\log y_{ij}$ and estimate $\mu_1 - \mu_2$.
That would not answer the question, though. $E\{Y_i\} = \exp (\mu_i+\sigma_i)$. What you need is a confidence interval on $\mu_1-\mu_2 + \sigma_1-\sigma_2$.
Now, if in fact you are interested in things on the transformed scale none of this applies. It happens: chemists and environmental scientists are interested in pH (to the point that they measure pH rather than $H^+$ concentrations.) | Does Box-Cox parameter estimation count towards parameters for AIC?
Why are you transforming the data?
What scale are you asking your questions on? If it isn't the transformed scale, then there is the issue of parameterization.
An example might help. Suppose some re |
37,174 | Internal validation via bootstrap: What ROC curve to present? | You are making the assumption that the ROC curve is informative and leads to good decisions. Neither is true. I have yet to see an ROC curve that provided useful insight. It also has a large ink:information ratio. The $c$-index (concordance probability) is a good measure of predictive discrimination. I would like it better were it not also the AUROC. There is no need to present an ROC curve.
Besides having low information yield, ROC curves invite analysts to seek cutpoints on predicted probabilities, which is a decision-making disaster. | Internal validation via bootstrap: What ROC curve to present? | You are making the assumption that the ROC curve is informative and leads to good decisions. Neither is true. I have yet to see an ROC curve that provided useful insight. It also has a large ink:in | Internal validation via bootstrap: What ROC curve to present?
You are making the assumption that the ROC curve is informative and leads to good decisions. Neither is true. I have yet to see an ROC curve that provided useful insight. It also has a large ink:information ratio. The $c$-index (concordance probability) is a good measure of predictive discrimination. I would like it better were it not also the AUROC. There is no need to present an ROC curve.
Besides having low information yield, ROC curves invite analysts to seek cutpoints on predicted probabilities, which is a decision-making disaster. | Internal validation via bootstrap: What ROC curve to present?
You are making the assumption that the ROC curve is informative and leads to good decisions. Neither is true. I have yet to see an ROC curve that provided useful insight. It also has a large ink:in |
37,175 | Internal validation via bootstrap: What ROC curve to present? | You raised a very good question that I was wondering for a long time. Perhaps it depends on your results to make a decision how to report. For most situations, authors would like to report a raw/apparent AUC (ie. step #1 in your question) despite over-optimism or not, and then report the bootstrap optimism corrected AUC (ie. step #5). see ref: http://journals.plos.org/plosone/article?id=10.1371/journal.pone.0125026
In some situations that AUC seems not to be over-optimistic, author would directly report corrected AUC.
As for AUC in step #3 (ii), it has rarely been reported and you'd better ignore it. | Internal validation via bootstrap: What ROC curve to present? | You raised a very good question that I was wondering for a long time. Perhaps it depends on your results to make a decision how to report. For most situations, authors would like to report a raw/appar | Internal validation via bootstrap: What ROC curve to present?
You raised a very good question that I was wondering for a long time. Perhaps it depends on your results to make a decision how to report. For most situations, authors would like to report a raw/apparent AUC (ie. step #1 in your question) despite over-optimism or not, and then report the bootstrap optimism corrected AUC (ie. step #5). see ref: http://journals.plos.org/plosone/article?id=10.1371/journal.pone.0125026
In some situations that AUC seems not to be over-optimistic, author would directly report corrected AUC.
As for AUC in step #3 (ii), it has rarely been reported and you'd better ignore it. | Internal validation via bootstrap: What ROC curve to present?
You raised a very good question that I was wondering for a long time. Perhaps it depends on your results to make a decision how to report. For most situations, authors would like to report a raw/appar |
37,176 | Internal validation via bootstrap: What ROC curve to present? | There are many details missing your question - however it appears to me that you are not talking about test set all. If you intend to demonstrate the generalizability of your model (which is primary use case for an ROC curve), you are expected to present the ROC derived from a test set, not validation or internal validation set. or an average ROC derived from multiple test sets. Hence it is important you find a way to generate test sets, and take it from there.
A good reference to learn ROC analysis (and how to create average ROC curves) is:
Fawcett, T. (2006). An introduction to ROC analysis. Pattern Recognition Letters, 27(8), 861–874.
http://www.sciencedirect.com/science/article/pii/S016786550500303X | Internal validation via bootstrap: What ROC curve to present? | There are many details missing your question - however it appears to me that you are not talking about test set all. If you intend to demonstrate the generalizability of your model (which is primary u | Internal validation via bootstrap: What ROC curve to present?
There are many details missing your question - however it appears to me that you are not talking about test set all. If you intend to demonstrate the generalizability of your model (which is primary use case for an ROC curve), you are expected to present the ROC derived from a test set, not validation or internal validation set. or an average ROC derived from multiple test sets. Hence it is important you find a way to generate test sets, and take it from there.
A good reference to learn ROC analysis (and how to create average ROC curves) is:
Fawcett, T. (2006). An introduction to ROC analysis. Pattern Recognition Letters, 27(8), 861–874.
http://www.sciencedirect.com/science/article/pii/S016786550500303X | Internal validation via bootstrap: What ROC curve to present?
There are many details missing your question - however it appears to me that you are not talking about test set all. If you intend to demonstrate the generalizability of your model (which is primary u |
37,177 | Rare event logistic regression bias correction | They define $\tau$ & $\bar{y}$ too: $\tau$ is the fraction of 1's in the population; $\bar{y}$ is the observed fraction of 1's in the sample (based on prior information).
You'd typically use prior correction when you've sampled based on the outcome; which I'd guess you haven't here. But if you have, then $\bar{y}=\frac{450}{90450}$ & you need to know or estimate $\tau$ in some other way.
Down-sampling, as described (quite correctly) in your last paragraph, can help if the full sample is too large for your computer's memory to hold or for its processor to deal with quickly, by sacrificing a little precision. But in this case you've fit the model on all the data already (I doubt it took very long).
[What you describe in your edit is what I called down-sampling, & you're applying the prior correction correctly. In medical statistics it's called a case–control design—see here. You might want to do it when you have the response but not yet the predictors, & there's an extra cost to measuring those. I don't know why you're calling it "bias correction for a rare event" though: it's a correction of the intercept for the deliberately introduced sampling bias. Section 5 of the paper deals with correcting the bias of maximum-likelihood estimates of log odds ratios & predicted probabilities.] | Rare event logistic regression bias correction | They define $\tau$ & $\bar{y}$ too: $\tau$ is the fraction of 1's in the population; $\bar{y}$ is the observed fraction of 1's in the sample (based on prior information).
You'd typically use prior co | Rare event logistic regression bias correction
They define $\tau$ & $\bar{y}$ too: $\tau$ is the fraction of 1's in the population; $\bar{y}$ is the observed fraction of 1's in the sample (based on prior information).
You'd typically use prior correction when you've sampled based on the outcome; which I'd guess you haven't here. But if you have, then $\bar{y}=\frac{450}{90450}$ & you need to know or estimate $\tau$ in some other way.
Down-sampling, as described (quite correctly) in your last paragraph, can help if the full sample is too large for your computer's memory to hold or for its processor to deal with quickly, by sacrificing a little precision. But in this case you've fit the model on all the data already (I doubt it took very long).
[What you describe in your edit is what I called down-sampling, & you're applying the prior correction correctly. In medical statistics it's called a case–control design—see here. You might want to do it when you have the response but not yet the predictors, & there's an extra cost to measuring those. I don't know why you're calling it "bias correction for a rare event" though: it's a correction of the intercept for the deliberately introduced sampling bias. Section 5 of the paper deals with correcting the bias of maximum-likelihood estimates of log odds ratios & predicted probabilities.] | Rare event logistic regression bias correction
They define $\tau$ & $\bar{y}$ too: $\tau$ is the fraction of 1's in the population; $\bar{y}$ is the observed fraction of 1's in the sample (based on prior information).
You'd typically use prior co |
37,178 | How to make the rare events corrections described in King and Zeng (2001)? | The logistf() function do not implement rare event logistic regression, that is done by the relogit() function in the Zelig package, on CRAN. You should test that one! | How to make the rare events corrections described in King and Zeng (2001)? | The logistf() function do not implement rare event logistic regression, that is done by the relogit() function in the Zelig package, on CRAN. You should test that one! | How to make the rare events corrections described in King and Zeng (2001)?
The logistf() function do not implement rare event logistic regression, that is done by the relogit() function in the Zelig package, on CRAN. You should test that one! | How to make the rare events corrections described in King and Zeng (2001)?
The logistf() function do not implement rare event logistic regression, that is done by the relogit() function in the Zelig package, on CRAN. You should test that one! |
37,179 | How to make the rare events corrections described in King and Zeng (2001)? | I realised that my comparisons of fitted and actual proportions in the first graph, top right-hand corner, are not the best way to assess model fit, since in the big data I can caclulate proportions for ABC categories, but with the model fit where all four variables are included, proportions are predicted for each ABCD category.
I fitted a new model on the subdata, where I removed D:
glm(R~A+B+C, family=binomial, data=subdata)
So that I can compare the predictions of this model fitted with the subdataset, and the true proportions in the big dataset, and assess wether my weighting does what I expect it to do.
The result is:
Predictions of the new model against proportions in the big dataset.
Now I think the answer is: yes, definitely.
Hence, this answered to my questions 1 (I properly understand King and Zheng (2001), at least the weighting method) and 3 (I can apply King and Zheng's (2001) weighting correction despite the fact that I have a value of $\tau$ and a value of $\bar{y}$ for each ABC category instead of global values).
The two other questions were:
Why is it so important to include A, B, and
C in the model to get a good fit and why their effect is significant.
Is it due as I suggested to the fact I deparse a lot from the half /
half proportions of 0 and 1 in my subset and differently in the
different ABC categories?
-> I think my expectation that including A+B+C in the model should have no effect because all ABC categories should contain approximately half of 0 and 1 observation would be true with a non-weighted linear model (actually, when you compare my two top left-hand corner graphics, there is not a lot of difference between them... but still, B and C have a significant effect in this non-weighted linear model.. I will consider this is because the departure from the 50/50), but not necessarily with a weighted linear model.
Is it an issue that my D variable is so unbalanced, and if it is, how
can I handle it? (Is "double weighting", i.e. weighting the weights,
possible?).
-> I think about using the Anova function of the 'car' library for a logistic regression (specifying 'test.statistic="LR"'). In that case, the function weights the cells directly to make type II SS, so I can keep the 'weight' option for the rare events correction. | How to make the rare events corrections described in King and Zeng (2001)? | I realised that my comparisons of fitted and actual proportions in the first graph, top right-hand corner, are not the best way to assess model fit, since in the big data I can caclulate proportions f | How to make the rare events corrections described in King and Zeng (2001)?
I realised that my comparisons of fitted and actual proportions in the first graph, top right-hand corner, are not the best way to assess model fit, since in the big data I can caclulate proportions for ABC categories, but with the model fit where all four variables are included, proportions are predicted for each ABCD category.
I fitted a new model on the subdata, where I removed D:
glm(R~A+B+C, family=binomial, data=subdata)
So that I can compare the predictions of this model fitted with the subdataset, and the true proportions in the big dataset, and assess wether my weighting does what I expect it to do.
The result is:
Predictions of the new model against proportions in the big dataset.
Now I think the answer is: yes, definitely.
Hence, this answered to my questions 1 (I properly understand King and Zheng (2001), at least the weighting method) and 3 (I can apply King and Zheng's (2001) weighting correction despite the fact that I have a value of $\tau$ and a value of $\bar{y}$ for each ABC category instead of global values).
The two other questions were:
Why is it so important to include A, B, and
C in the model to get a good fit and why their effect is significant.
Is it due as I suggested to the fact I deparse a lot from the half /
half proportions of 0 and 1 in my subset and differently in the
different ABC categories?
-> I think my expectation that including A+B+C in the model should have no effect because all ABC categories should contain approximately half of 0 and 1 observation would be true with a non-weighted linear model (actually, when you compare my two top left-hand corner graphics, there is not a lot of difference between them... but still, B and C have a significant effect in this non-weighted linear model.. I will consider this is because the departure from the 50/50), but not necessarily with a weighted linear model.
Is it an issue that my D variable is so unbalanced, and if it is, how
can I handle it? (Is "double weighting", i.e. weighting the weights,
possible?).
-> I think about using the Anova function of the 'car' library for a logistic regression (specifying 'test.statistic="LR"'). In that case, the function weights the cells directly to make type II SS, so I can keep the 'weight' option for the rare events correction. | How to make the rare events corrections described in King and Zeng (2001)?
I realised that my comparisons of fitted and actual proportions in the first graph, top right-hand corner, are not the best way to assess model fit, since in the big data I can caclulate proportions f |
37,180 | When/why does the central tendency of a resampling simulation markedly differ from the observed value? | Any nonlinear statistic (a non-linear combination of linear statistics such as sample means) has a small sample bias. Cohen's $d$ is obviously no exception: it is essentially
$$
d=\frac{m_1 - m_2}{\sqrt{m_3-m_4^2}}
$$
which is fairly non-linear, at least as far as the terms in the denominator go.
Each of the moments can be considered an unbiased estimator of what it's supposed to estimate:
$$
\begin{array}{ll}
m_1 & = \frac1{n_1} \sum_{i\in\mbox{group }1} y_i , \\
m_2 & = \frac1{n_2} \sum_{i\in\mbox{group }2} y_i , \\
m_3 & = \frac1{n_1+n_2} \sum_{i} y_i^2 , \\
m_4 & = \frac1{n_1+n_2} \sum_{i} y_i , \\
\end{array}
$$
However, by Jensen's inequality there is no way on Earth you get an unbiased estimator of the population quantity out of a nonlinear combination. Thus ${\mathbb{E}}[ d]\neq$ population $d$ in finite samples, although the bias is typically of the order of $O(1/n)$. Wikipedia article on effect sizes mentions the small sample biases in discussion of Hedges' $g$.
I imagine that Cohen's $d$ has a limited range (in the extreme case, if there is no variability within groups, then $d$ must equal $\pm 2$, right?), hence its sampling distribution must be skewed, which contributes to the finite sample biases (some function of the skewness of the sampling distribution is typically the multiplier in front of $1/n$ that I mentioned above). The closer you are to the limits of the allowed range, the more pronounced the skewness is.
What bootstrap does, rather miraculously considering that it is such a simple method, is it gets you the ability to estimate this finite sample bias through comparison of the bootstrap mean and the estimate from the original sample. (Keep in mind though that unless you make special adjustments to how the bootstrap sampling is set up, the former will be subject to Monte Carlo variability.) I provided more detailed and more technical explanations in another bootstrap question which may be worth reading anyway.
Now if there's a positive bias, i.e., the estimate based on the original sample is biased upward relative to the population $d$, then the bootstrap will mock that and produce estimates that are, on average, even higher than the sample estimate. It is not actually as bad as it sounds, as then you can quantify the bias and subtract it from the original estimate. If the original estimate of a quantity was $\hat\theta_n$, and the mean bootstrap of the bootstrap replicates is $\bar\theta^*_n$, then the bias estimate is $\hat b_n=\bar\theta^*_n-\hat\theta_n$, and a bias-corrected estimate is $\hat\theta_n - \hat b_n=2\hat\theta_n - \bar\theta^*_n$. | When/why does the central tendency of a resampling simulation markedly differ from the observed valu | Any nonlinear statistic (a non-linear combination of linear statistics such as sample means) has a small sample bias. Cohen's $d$ is obviously no exception: it is essentially
$$
d=\frac{m_1 - m_2}{\sq | When/why does the central tendency of a resampling simulation markedly differ from the observed value?
Any nonlinear statistic (a non-linear combination of linear statistics such as sample means) has a small sample bias. Cohen's $d$ is obviously no exception: it is essentially
$$
d=\frac{m_1 - m_2}{\sqrt{m_3-m_4^2}}
$$
which is fairly non-linear, at least as far as the terms in the denominator go.
Each of the moments can be considered an unbiased estimator of what it's supposed to estimate:
$$
\begin{array}{ll}
m_1 & = \frac1{n_1} \sum_{i\in\mbox{group }1} y_i , \\
m_2 & = \frac1{n_2} \sum_{i\in\mbox{group }2} y_i , \\
m_3 & = \frac1{n_1+n_2} \sum_{i} y_i^2 , \\
m_4 & = \frac1{n_1+n_2} \sum_{i} y_i , \\
\end{array}
$$
However, by Jensen's inequality there is no way on Earth you get an unbiased estimator of the population quantity out of a nonlinear combination. Thus ${\mathbb{E}}[ d]\neq$ population $d$ in finite samples, although the bias is typically of the order of $O(1/n)$. Wikipedia article on effect sizes mentions the small sample biases in discussion of Hedges' $g$.
I imagine that Cohen's $d$ has a limited range (in the extreme case, if there is no variability within groups, then $d$ must equal $\pm 2$, right?), hence its sampling distribution must be skewed, which contributes to the finite sample biases (some function of the skewness of the sampling distribution is typically the multiplier in front of $1/n$ that I mentioned above). The closer you are to the limits of the allowed range, the more pronounced the skewness is.
What bootstrap does, rather miraculously considering that it is such a simple method, is it gets you the ability to estimate this finite sample bias through comparison of the bootstrap mean and the estimate from the original sample. (Keep in mind though that unless you make special adjustments to how the bootstrap sampling is set up, the former will be subject to Monte Carlo variability.) I provided more detailed and more technical explanations in another bootstrap question which may be worth reading anyway.
Now if there's a positive bias, i.e., the estimate based on the original sample is biased upward relative to the population $d$, then the bootstrap will mock that and produce estimates that are, on average, even higher than the sample estimate. It is not actually as bad as it sounds, as then you can quantify the bias and subtract it from the original estimate. If the original estimate of a quantity was $\hat\theta_n$, and the mean bootstrap of the bootstrap replicates is $\bar\theta^*_n$, then the bias estimate is $\hat b_n=\bar\theta^*_n-\hat\theta_n$, and a bias-corrected estimate is $\hat\theta_n - \hat b_n=2\hat\theta_n - \bar\theta^*_n$. | When/why does the central tendency of a resampling simulation markedly differ from the observed valu
Any nonlinear statistic (a non-linear combination of linear statistics such as sample means) has a small sample bias. Cohen's $d$ is obviously no exception: it is essentially
$$
d=\frac{m_1 - m_2}{\sq |
37,181 | p-value and the base rate fallacy | The positive predictive value (PPV; the probability that a drug actually working, given that we rejected the null hypothesis that it had no effect—i.e. the probability that we made a true rejection) is sensitive to the base rate of cancer drugs that actually work.
Consider the $2\times2$ table below, where testing positive or negative corresponds to rejecting or not rejecting H$_{0}$, and the truth being positive or negative means that H$_{0}$ is false or true, respectively. Each quadrant contains the counts of the four possibilities under these conditions: the number of true positive tests, number of true negative tests, number of false positive tests, and number of false negative tests. The margins sum the rows and columns, and the sum of row margins equals the sum of column margins equals the total number of tests.
PPV is the number of true positives over the total testing positive. If you imagine that the area in each quadrant of the table is proportional to the number in each quadrant, and further, imagine that the vertical line down the center of the $2 \times2$ table represents the base rate (e.g. prevalence), then the table above shows half of tests of cancer drugs truly rejecting H$_{0}$. If the base rate is lowered (that vertical line shifts left), you can see that true positives shrink relative to false positives and therefore the PPV gets smaller (i.e. just because you rejected the null hypothesis for a drug means that you still probably made a false rejection).
By contrast, the $p$ value is the probability of observing your data, if in fact the null hypothesis is true. In the table, the null hypothesis being true is the left column, and $\alpha$ (your willingness to reject the null when the null is true) is the number of false negatives over the total truly negative (or one minus the specificity of the test).
So, if the null hypothesis is true, and the base rate is low, the $p$ value being small enough to reject, even if it is very small, means that you are probably seeing a false positive.
Suggested further reading
Altman, D. G. and Bland, J. M. (1994). Diagnostic tests 2: predictive values. British Medical Journal, 309:102.
Altman, D. G. and Bland, J. M. (1994). Diagnostic tests 1: sensitivity and specificity. British Medical Journal, 308:1552.
Ioannidis, J. P. A. (2005). Why most published research findings are false. PLoS Medicine, 2(8):0696–0701. | p-value and the base rate fallacy | The positive predictive value (PPV; the probability that a drug actually working, given that we rejected the null hypothesis that it had no effect—i.e. the probability that we made a true rejection) i | p-value and the base rate fallacy
The positive predictive value (PPV; the probability that a drug actually working, given that we rejected the null hypothesis that it had no effect—i.e. the probability that we made a true rejection) is sensitive to the base rate of cancer drugs that actually work.
Consider the $2\times2$ table below, where testing positive or negative corresponds to rejecting or not rejecting H$_{0}$, and the truth being positive or negative means that H$_{0}$ is false or true, respectively. Each quadrant contains the counts of the four possibilities under these conditions: the number of true positive tests, number of true negative tests, number of false positive tests, and number of false negative tests. The margins sum the rows and columns, and the sum of row margins equals the sum of column margins equals the total number of tests.
PPV is the number of true positives over the total testing positive. If you imagine that the area in each quadrant of the table is proportional to the number in each quadrant, and further, imagine that the vertical line down the center of the $2 \times2$ table represents the base rate (e.g. prevalence), then the table above shows half of tests of cancer drugs truly rejecting H$_{0}$. If the base rate is lowered (that vertical line shifts left), you can see that true positives shrink relative to false positives and therefore the PPV gets smaller (i.e. just because you rejected the null hypothesis for a drug means that you still probably made a false rejection).
By contrast, the $p$ value is the probability of observing your data, if in fact the null hypothesis is true. In the table, the null hypothesis being true is the left column, and $\alpha$ (your willingness to reject the null when the null is true) is the number of false negatives over the total truly negative (or one minus the specificity of the test).
So, if the null hypothesis is true, and the base rate is low, the $p$ value being small enough to reject, even if it is very small, means that you are probably seeing a false positive.
Suggested further reading
Altman, D. G. and Bland, J. M. (1994). Diagnostic tests 2: predictive values. British Medical Journal, 309:102.
Altman, D. G. and Bland, J. M. (1994). Diagnostic tests 1: sensitivity and specificity. British Medical Journal, 308:1552.
Ioannidis, J. P. A. (2005). Why most published research findings are false. PLoS Medicine, 2(8):0696–0701. | p-value and the base rate fallacy
The positive predictive value (PPV; the probability that a drug actually working, given that we rejected the null hypothesis that it had no effect—i.e. the probability that we made a true rejection) i |
37,182 | How to perform hypothesis testing for comparing different classifiers | In general layman's terms (and not just for this problem),
Null Hypothesis $H_0$: no change or difference (i.e. the classifiers have the same performance, however you define it)
Alternative Hypothesis: there is some sort of difference in performance
For your classifier performance comparison problem, I recommend reading Chapter 6 of Japkowicz & Shah, which goes into detail on how to use significance testing to assess the performance of different classifiers. (Other chapters give more background on classifier comparison - sounds like they might interest you too.)
In your case,
to compare 2 classifiers (on a single domain) you may use a matched-pairs t-test where $t=\frac{\bar{d}}{\bar{\sigma}_d / \sqrt{n}}$, where $\bar{d} = \bar{\text{pm}}(f_1) - \bar{\text{pm}}(f_2)$ is the difference of the means of your performance measures (whatever you choose to use) based on applying the two classifiers $f_1$ and $f_2$, $n$ is the number of trials and $\bar{\sigma}_d$ is the sample standard deviation of the mean difference
to compare multiple classifiers (on a single domain) you may use one-way ANOVA (i.e. an F-test) to check whether there is any difference among multiple means (though it cannot tell which are actually different) and then follow up with post-hoc tests, such as Tukey's Honest Significant Difference test to identify which pairs of classifiers exhibit significant differences.
The book goes into far more detail, so I do recommend reading that chapter.
And in terms of baselines, the tests I've mentioned don't distinguish between a baseline and a non-baseline. This is a good thing, as it gives you flexibility to decide which comparisons you should give more importance to in your analysis. The number of tests you actually do determines whether you should rely on 1. or 2. above. | How to perform hypothesis testing for comparing different classifiers | In general layman's terms (and not just for this problem),
Null Hypothesis $H_0$: no change or difference (i.e. the classifiers have the same performance, however you define it)
Alternative Hypothesi | How to perform hypothesis testing for comparing different classifiers
In general layman's terms (and not just for this problem),
Null Hypothesis $H_0$: no change or difference (i.e. the classifiers have the same performance, however you define it)
Alternative Hypothesis: there is some sort of difference in performance
For your classifier performance comparison problem, I recommend reading Chapter 6 of Japkowicz & Shah, which goes into detail on how to use significance testing to assess the performance of different classifiers. (Other chapters give more background on classifier comparison - sounds like they might interest you too.)
In your case,
to compare 2 classifiers (on a single domain) you may use a matched-pairs t-test where $t=\frac{\bar{d}}{\bar{\sigma}_d / \sqrt{n}}$, where $\bar{d} = \bar{\text{pm}}(f_1) - \bar{\text{pm}}(f_2)$ is the difference of the means of your performance measures (whatever you choose to use) based on applying the two classifiers $f_1$ and $f_2$, $n$ is the number of trials and $\bar{\sigma}_d$ is the sample standard deviation of the mean difference
to compare multiple classifiers (on a single domain) you may use one-way ANOVA (i.e. an F-test) to check whether there is any difference among multiple means (though it cannot tell which are actually different) and then follow up with post-hoc tests, such as Tukey's Honest Significant Difference test to identify which pairs of classifiers exhibit significant differences.
The book goes into far more detail, so I do recommend reading that chapter.
And in terms of baselines, the tests I've mentioned don't distinguish between a baseline and a non-baseline. This is a good thing, as it gives you flexibility to decide which comparisons you should give more importance to in your analysis. The number of tests you actually do determines whether you should rely on 1. or 2. above. | How to perform hypothesis testing for comparing different classifiers
In general layman's terms (and not just for this problem),
Null Hypothesis $H_0$: no change or difference (i.e. the classifiers have the same performance, however you define it)
Alternative Hypothesi |
37,183 | How to perform hypothesis testing for comparing different classifiers | One-way ANOVA followed by post hoc tests using Tukey-Kramer method for multiple comparison analysis is one possible approach.
As a result various plots are generated where in each graph, the mean of the classifier performance measure and an interval (95% confidence interval) are clearly represented. Two means are significantly different if their intervals are disjoint, and are not significantly different if their intervals overlap.
In the reference, I have included a research article from our group, where we statistically compare the outputs from different classifiers, and take out the best one.
Reference:
M.L. McHugh, Multiple comparison analysis testing in ANOVA, Biochemia
medica 21 (2011) 203–209. http://www.ncbi.nlm.nih.gov/pubmed/22420233
R. Prashanth, S Dutta Roy, PK Mandal, S Ghosh, High-Accuracy Detection of Early Parkinson's Disease through Multimodal Features and Machine Learning, 90 (2016) 13–21. http://www.sciencedirect.com/science/article/pii/S1386505616300326 | How to perform hypothesis testing for comparing different classifiers | One-way ANOVA followed by post hoc tests using Tukey-Kramer method for multiple comparison analysis is one possible approach.
As a result various plots are generated where in each graph, the mean of t | How to perform hypothesis testing for comparing different classifiers
One-way ANOVA followed by post hoc tests using Tukey-Kramer method for multiple comparison analysis is one possible approach.
As a result various plots are generated where in each graph, the mean of the classifier performance measure and an interval (95% confidence interval) are clearly represented. Two means are significantly different if their intervals are disjoint, and are not significantly different if their intervals overlap.
In the reference, I have included a research article from our group, where we statistically compare the outputs from different classifiers, and take out the best one.
Reference:
M.L. McHugh, Multiple comparison analysis testing in ANOVA, Biochemia
medica 21 (2011) 203–209. http://www.ncbi.nlm.nih.gov/pubmed/22420233
R. Prashanth, S Dutta Roy, PK Mandal, S Ghosh, High-Accuracy Detection of Early Parkinson's Disease through Multimodal Features and Machine Learning, 90 (2016) 13–21. http://www.sciencedirect.com/science/article/pii/S1386505616300326 | How to perform hypothesis testing for comparing different classifiers
One-way ANOVA followed by post hoc tests using Tukey-Kramer method for multiple comparison analysis is one possible approach.
As a result various plots are generated where in each graph, the mean of t |
37,184 | How to perform hypothesis testing for comparing different classifiers | I would not do an ANOVA because your experimental design corresponds to a one way within subjects (the algorithms are tested on identical test-set folds). Such an ANOVA has a sphericity assumption which you cannot assume is met by your data.
But this is not a problem anyway. What you really need are those post-hoc tests. They tell you much more than a simple ANOVA ever could. You can perform them without the ANOVA. | How to perform hypothesis testing for comparing different classifiers | I would not do an ANOVA because your experimental design corresponds to a one way within subjects (the algorithms are tested on identical test-set folds). Such an ANOVA has a sphericity assumption whi | How to perform hypothesis testing for comparing different classifiers
I would not do an ANOVA because your experimental design corresponds to a one way within subjects (the algorithms are tested on identical test-set folds). Such an ANOVA has a sphericity assumption which you cannot assume is met by your data.
But this is not a problem anyway. What you really need are those post-hoc tests. They tell you much more than a simple ANOVA ever could. You can perform them without the ANOVA. | How to perform hypothesis testing for comparing different classifiers
I would not do an ANOVA because your experimental design corresponds to a one way within subjects (the algorithms are tested on identical test-set folds). Such an ANOVA has a sphericity assumption whi |
37,185 | How do I implement a deep autoencoder? | Basically, you want to use layer-wise approach to train your deep autoencoder. You want to train one layer at a time, and then eventually do fine-tuning on all the layers.
You can follow this stanford UFLDL tutorial. It is a great tutorial for deep learning (have stacked autoencoder; not built from RBM. But it should be enough to give you some ideas).
Tutorial: http://ufldl.stanford.edu/wiki/index.php/UFLDL_Tutorial
You can use this github as reference:
https://github.com/johnny5550822/Ho-UFLDL-tutorial | How do I implement a deep autoencoder? | Basically, you want to use layer-wise approach to train your deep autoencoder. You want to train one layer at a time, and then eventually do fine-tuning on all the layers.
You can follow this stanfor | How do I implement a deep autoencoder?
Basically, you want to use layer-wise approach to train your deep autoencoder. You want to train one layer at a time, and then eventually do fine-tuning on all the layers.
You can follow this stanford UFLDL tutorial. It is a great tutorial for deep learning (have stacked autoencoder; not built from RBM. But it should be enough to give you some ideas).
Tutorial: http://ufldl.stanford.edu/wiki/index.php/UFLDL_Tutorial
You can use this github as reference:
https://github.com/johnny5550822/Ho-UFLDL-tutorial | How do I implement a deep autoencoder?
Basically, you want to use layer-wise approach to train your deep autoencoder. You want to train one layer at a time, and then eventually do fine-tuning on all the layers.
You can follow this stanfor |
37,186 | Why it is better to use the cumulative distribution to compute distances? | We all know the equation for the PDF of a Gaussian distribution, right?
$$
f_X(x\vert\mu,\sigma^2) = \dfrac{1}{\sqrt{2\pi\sigma^2}}\exp\bigg[{-\dfrac{1}{2}\bigg(\dfrac{x-\mu}{\sigma}\bigg)^2}\bigg]
$$
However, this also is a valid equation for the PDF of a Gaussian distribution.
$$
g_X(x\vert\mu,\sigma^2) = \begin{cases}
\dfrac{1}{\sqrt{2\pi\sigma^2}}\exp\bigg[{-\dfrac{1}{2}\bigg(\dfrac{x-\mu}{\sigma}\bigg)^2}\bigg], & x\ne 0 \\
0, & x = 0
\end{cases}
\
$$
The two differ at just that one point, $x=0$, meaning that their integrals are equal. These represent the same distribution.
The integral is the CDF.
Further, not every CDF has a corresponding PDF. The math winds up being a bit exotic, but it is possible to construct such a CDF. A standard example is the Cantor distribution.
(As mentioned in the comments, there is a sense in which "almost all" CDFs behave this way and lack corresponding PDF.)
So for a random variable $X$, the CDF is defined uniquely and always, while the PDF is defined ambiguously if it is defined at all! This makes the CDF the natural place to operate. Imagine trying to do a test like Kolmogorov-Smirnov (KS) on my $f_X(x)$ and $g_X(x)$. For $\mu=0$ and $\sigma^2 = 0$, $f$ and $g$ would differ by a vertical distance of $0.399$ at $x=0$, which sounds like a lot, even though they correspond to the same distribution. | Why it is better to use the cumulative distribution to compute distances? | We all know the equation for the PDF of a Gaussian distribution, right?
$$
f_X(x\vert\mu,\sigma^2) = \dfrac{1}{\sqrt{2\pi\sigma^2}}\exp\bigg[{-\dfrac{1}{2}\bigg(\dfrac{x-\mu}{\sigma}\bigg)^2}\bigg]
$$ | Why it is better to use the cumulative distribution to compute distances?
We all know the equation for the PDF of a Gaussian distribution, right?
$$
f_X(x\vert\mu,\sigma^2) = \dfrac{1}{\sqrt{2\pi\sigma^2}}\exp\bigg[{-\dfrac{1}{2}\bigg(\dfrac{x-\mu}{\sigma}\bigg)^2}\bigg]
$$
However, this also is a valid equation for the PDF of a Gaussian distribution.
$$
g_X(x\vert\mu,\sigma^2) = \begin{cases}
\dfrac{1}{\sqrt{2\pi\sigma^2}}\exp\bigg[{-\dfrac{1}{2}\bigg(\dfrac{x-\mu}{\sigma}\bigg)^2}\bigg], & x\ne 0 \\
0, & x = 0
\end{cases}
\
$$
The two differ at just that one point, $x=0$, meaning that their integrals are equal. These represent the same distribution.
The integral is the CDF.
Further, not every CDF has a corresponding PDF. The math winds up being a bit exotic, but it is possible to construct such a CDF. A standard example is the Cantor distribution.
(As mentioned in the comments, there is a sense in which "almost all" CDFs behave this way and lack corresponding PDF.)
So for a random variable $X$, the CDF is defined uniquely and always, while the PDF is defined ambiguously if it is defined at all! This makes the CDF the natural place to operate. Imagine trying to do a test like Kolmogorov-Smirnov (KS) on my $f_X(x)$ and $g_X(x)$. For $\mu=0$ and $\sigma^2 = 0$, $f$ and $g$ would differ by a vertical distance of $0.399$ at $x=0$, which sounds like a lot, even though they correspond to the same distribution. | Why it is better to use the cumulative distribution to compute distances?
We all know the equation for the PDF of a Gaussian distribution, right?
$$
f_X(x\vert\mu,\sigma^2) = \dfrac{1}{\sqrt{2\pi\sigma^2}}\exp\bigg[{-\dfrac{1}{2}\bigg(\dfrac{x-\mu}{\sigma}\bigg)^2}\bigg]
$$ |
37,187 | Why it is better to use the cumulative distribution to compute distances? | Others have already pointed out that a PDF can be modified arbitrarily on a set of probability measure zero, and this still gives a valid PDF for the random variable. That is true, but it is somewhat of an artificial answer to your question. In such cases, for almost all random variables we deal with in practice, there is still a "natural" PDF (e.g., the continuous one) which is the one we usually use. These could in theory be compared as a means of looking at the "distance" between random variables, so your question is a reasonable one.
So, let's restrict attention to cases where we are comparing random variables that have a continuous PDF, and let's take the continuous PDF as the "natural" version used for the comparison. Even with this restriction, it is still possible to create a "spike" in a PDF which can be arbitrarily large without having a substantial effect on the CDF. To see this, consider a random variable $X$ and suppose we form the mixture random variable:
$$Y \equiv IG + (1-I)X
\quad \quad \quad \quad \quad
G \sim \text{N}(x_0, \epsilon^2)
\quad \quad \quad \quad \quad
I\sim \text{Bern}(\epsilon).$$
The effect of using this mixture distribution when $\epsilon$ is small is that the distribution of $Y$ looks roughly proportionate to the distribution of $X$, except that it has a continuous "spike" concentrated around the value $x_0$. Taking $\epsilon \rightarrow 0$ there is convergence in probability $Y \rightarrow X$ and convergence in the corresponding distributions (i.e., $F_Y \rightarrow F_X$). However, when we take this limit the "spike" in the PDF of $Y$ gets arbitrarily large, so the distance between the PDFs at the point $x_0$ diverges to infinity.
So, in terms of distance between $X$ and $Y$, if $\epsilon$ is small, what do you do here? Intuitively, the random variables are very close to each other (as $\epsilon \rightarrow 0$ they converge) so the "distance" should be small. However, if we are judging things from the PDFs, we see that there is a point where these PDFs are growing apart infinitely, so perhaps this means that the "distance" ought to be large?
This example indicates that if you are using the PDFs to determine the "distance" between random variables, you are going to have to find a way to resolve this type of case. If you think there is little distance between these random variables then the distance measure constructed on the PDFs should reflect this, which would mean the distance remains small even if the PDFS grow apart infinitely at a point (or indeed, at any countable number of points). I will leave it to you to think about how you might construct such a measure. | Why it is better to use the cumulative distribution to compute distances? | Others have already pointed out that a PDF can be modified arbitrarily on a set of probability measure zero, and this still gives a valid PDF for the random variable. That is true, but it is somewhat | Why it is better to use the cumulative distribution to compute distances?
Others have already pointed out that a PDF can be modified arbitrarily on a set of probability measure zero, and this still gives a valid PDF for the random variable. That is true, but it is somewhat of an artificial answer to your question. In such cases, for almost all random variables we deal with in practice, there is still a "natural" PDF (e.g., the continuous one) which is the one we usually use. These could in theory be compared as a means of looking at the "distance" between random variables, so your question is a reasonable one.
So, let's restrict attention to cases where we are comparing random variables that have a continuous PDF, and let's take the continuous PDF as the "natural" version used for the comparison. Even with this restriction, it is still possible to create a "spike" in a PDF which can be arbitrarily large without having a substantial effect on the CDF. To see this, consider a random variable $X$ and suppose we form the mixture random variable:
$$Y \equiv IG + (1-I)X
\quad \quad \quad \quad \quad
G \sim \text{N}(x_0, \epsilon^2)
\quad \quad \quad \quad \quad
I\sim \text{Bern}(\epsilon).$$
The effect of using this mixture distribution when $\epsilon$ is small is that the distribution of $Y$ looks roughly proportionate to the distribution of $X$, except that it has a continuous "spike" concentrated around the value $x_0$. Taking $\epsilon \rightarrow 0$ there is convergence in probability $Y \rightarrow X$ and convergence in the corresponding distributions (i.e., $F_Y \rightarrow F_X$). However, when we take this limit the "spike" in the PDF of $Y$ gets arbitrarily large, so the distance between the PDFs at the point $x_0$ diverges to infinity.
So, in terms of distance between $X$ and $Y$, if $\epsilon$ is small, what do you do here? Intuitively, the random variables are very close to each other (as $\epsilon \rightarrow 0$ they converge) so the "distance" should be small. However, if we are judging things from the PDFs, we see that there is a point where these PDFs are growing apart infinitely, so perhaps this means that the "distance" ought to be large?
This example indicates that if you are using the PDFs to determine the "distance" between random variables, you are going to have to find a way to resolve this type of case. If you think there is little distance between these random variables then the distance measure constructed on the PDFs should reflect this, which would mean the distance remains small even if the PDFS grow apart infinitely at a point (or indeed, at any countable number of points). I will leave it to you to think about how you might construct such a measure. | Why it is better to use the cumulative distribution to compute distances?
Others have already pointed out that a PDF can be modified arbitrarily on a set of probability measure zero, and this still gives a valid PDF for the random variable. That is true, but it is somewhat |
37,188 | Conditioning on independent random variables | Given the information in the question, we have a sample of $n$ i.i.d normals (which also means that their joint distribution is also normal), each following $N(\mu, \sigma^2)$. Therefore $\bar X \sim N(\mu, \sigma^2/n)$.
One can easily calculate that $\operatorname{Cov}(X_1, \bar X) = \sigma^2/n$. So their correlation coefficient is $\rho = 1/\sqrt{n}$. Then, since their joint distribution is bi-variate normal, the conditional expected value of $X_1\mid \bar X$ is
$$E(X_1\mid \bar X) = \mu + \rho \frac{\sigma}{\sigma/\sqrt n}(\bar X - \mu)= \bar X$$.
...as should be expected
Now the reason I mentioned in the comments a 2nd-order Taylor expansion, is the completely arbitrary nature of $u(\cdot)$, which does not really permit us to do anything much. But with the Taylor expansion around the sample mean, we have (write $M$ for $\{\bar X, S^2\}$)
$$E(u(X_1)\mid M)\approx E\Big(u(\bar{X})+u^{\prime} (\bar{X}) (X_1-\bar{X})+\frac 12u^{\prime \prime} (\bar X)(X_1-\bar{X})^2\mid M\Big)$$
Since when we condition a function of a random variable on the random variable, we have $E(u(Y)\mid Y) = u(Y)$, $E(Y \mid Y) = Y$, $E(ZY\mid Y) = YE(Z\mid Y)$ in our case this implies
$$E(u(X_1)\mid M) \approx u(\bar{X})+u^{\prime} (\bar{X}) (E(X_1\mid M)-E(\bar{X}\mid M))+\frac 12u^{\prime \prime}(\bar X)E\Big[(X_1-\bar{X})^2\mid M\Big]$$
and using the previous results, the second term is zero, and so we obtain
$$E(u(X_1)\mid M) \approx u(\bar{X})+\frac 12u^{\prime \prime}(\bar X)E\Big[(X_1-\bar{X})^2\mid M\Big]$$
But
$$E\Big[(X_1-\bar{X})^2\mid M\Big] = \text{Var}(X_1\mid M) = S^2$$ so
$$E(u(X_1)\mid M) \approx u(\bar{X})+\frac 12u^{\prime \prime}(\bar X)S^2 \qquad [1]$$
Of course, one should deal also with the Remainder (the expected value of it). The "Peano form" of the Remainder is the most convenient here, meaning that we need to consider
$$E[R_2(X_1;\bar X) \mid M]=E\left[h_2(X_1)\cdot \left(X_1-\bar X\right)^2 \mid M\right] \qquad [2]$$
where $h_2()$ is some function with the property that $h_2(X_1) \rightarrow 0$ as $X_1 \rightarrow \bar X$.
Then, take the full Taylor expansion of $h_2()$ around $\bar X$ using again the peano form to write this Remainder too:
$$h_2(X_1) = h_2(\bar X) + h_2'(\bar X)(X_1-\bar X) + g_1(X_1)\cdot (X_1-\bar X)$$
$h_2(\bar X) = 0$. Insert the rest into eq. $[2]$ to obtain:
$$E[R_2(X_1;\bar X) \mid M]=E\left[\Big(h_2'(\bar X)+ g_1(X_1)\Big)\cdot\left(X_1-\bar X\right)^3 \mid M\right]$$
$$=h_2'(\bar X)E\left[\left(X_1-\bar X\right)^3 \mid M\right] + E\left[g_1(X_1)\cdot\left(X_1-\bar X\right)^3 \mid M\right]$$
The conditional on $M$ distribution of $X_1$ will also be normal, and has mean $\bar X$ as we have seen. So the third central moment, being odd, will be zero. Then the 1st term in the above expression is zero and we are left with
$$E[R_2(X_1;\bar X) \mid M]= E\left[g_1(X_1)\cdot\left(X_1-\bar X\right)^3 \mid M\right] \qquad [3]$$
which I would say, will be a rather small amount, since $g_1$ belongs to the Remainder of the Remainder.
Note that if we can say that $u'''(X_1)$ is bounded above and below in a neighborhood of $\bar X$ and belongs to the interval, say $[a, A]$ then the expected value of the Remainder is sandwiched to zero, because we have
$$a\frac {(X_1-\bar X)^3}{3!} \le R_2(X_1;\bar X) \le A\frac {(X_1-\bar X)^3}{3!}$$
$$\Rightarrow E\left (a\frac {(X_1-\bar X)^3}{3!} \mid M\right) \le E[R_2(X_1;\bar X) \mid M] \le E\left (a\frac {(X_1-\bar X)^3}{3!} \mid M\right)$$
$$\Rightarrow 0 \le E[R_2(X_1;\bar X) \mid M] \le 0 \Rightarrow E[R_2(X_1;\bar X) \mid M]=0$$
If we cannot say anything about $u()$ then we are left with the approximation $[1]$ and the approximation error $[3]$. | Conditioning on independent random variables | Given the information in the question, we have a sample of $n$ i.i.d normals (which also means that their joint distribution is also normal), each following $N(\mu, \sigma^2)$. Therefore $\bar X \sim | Conditioning on independent random variables
Given the information in the question, we have a sample of $n$ i.i.d normals (which also means that their joint distribution is also normal), each following $N(\mu, \sigma^2)$. Therefore $\bar X \sim N(\mu, \sigma^2/n)$.
One can easily calculate that $\operatorname{Cov}(X_1, \bar X) = \sigma^2/n$. So their correlation coefficient is $\rho = 1/\sqrt{n}$. Then, since their joint distribution is bi-variate normal, the conditional expected value of $X_1\mid \bar X$ is
$$E(X_1\mid \bar X) = \mu + \rho \frac{\sigma}{\sigma/\sqrt n}(\bar X - \mu)= \bar X$$.
...as should be expected
Now the reason I mentioned in the comments a 2nd-order Taylor expansion, is the completely arbitrary nature of $u(\cdot)$, which does not really permit us to do anything much. But with the Taylor expansion around the sample mean, we have (write $M$ for $\{\bar X, S^2\}$)
$$E(u(X_1)\mid M)\approx E\Big(u(\bar{X})+u^{\prime} (\bar{X}) (X_1-\bar{X})+\frac 12u^{\prime \prime} (\bar X)(X_1-\bar{X})^2\mid M\Big)$$
Since when we condition a function of a random variable on the random variable, we have $E(u(Y)\mid Y) = u(Y)$, $E(Y \mid Y) = Y$, $E(ZY\mid Y) = YE(Z\mid Y)$ in our case this implies
$$E(u(X_1)\mid M) \approx u(\bar{X})+u^{\prime} (\bar{X}) (E(X_1\mid M)-E(\bar{X}\mid M))+\frac 12u^{\prime \prime}(\bar X)E\Big[(X_1-\bar{X})^2\mid M\Big]$$
and using the previous results, the second term is zero, and so we obtain
$$E(u(X_1)\mid M) \approx u(\bar{X})+\frac 12u^{\prime \prime}(\bar X)E\Big[(X_1-\bar{X})^2\mid M\Big]$$
But
$$E\Big[(X_1-\bar{X})^2\mid M\Big] = \text{Var}(X_1\mid M) = S^2$$ so
$$E(u(X_1)\mid M) \approx u(\bar{X})+\frac 12u^{\prime \prime}(\bar X)S^2 \qquad [1]$$
Of course, one should deal also with the Remainder (the expected value of it). The "Peano form" of the Remainder is the most convenient here, meaning that we need to consider
$$E[R_2(X_1;\bar X) \mid M]=E\left[h_2(X_1)\cdot \left(X_1-\bar X\right)^2 \mid M\right] \qquad [2]$$
where $h_2()$ is some function with the property that $h_2(X_1) \rightarrow 0$ as $X_1 \rightarrow \bar X$.
Then, take the full Taylor expansion of $h_2()$ around $\bar X$ using again the peano form to write this Remainder too:
$$h_2(X_1) = h_2(\bar X) + h_2'(\bar X)(X_1-\bar X) + g_1(X_1)\cdot (X_1-\bar X)$$
$h_2(\bar X) = 0$. Insert the rest into eq. $[2]$ to obtain:
$$E[R_2(X_1;\bar X) \mid M]=E\left[\Big(h_2'(\bar X)+ g_1(X_1)\Big)\cdot\left(X_1-\bar X\right)^3 \mid M\right]$$
$$=h_2'(\bar X)E\left[\left(X_1-\bar X\right)^3 \mid M\right] + E\left[g_1(X_1)\cdot\left(X_1-\bar X\right)^3 \mid M\right]$$
The conditional on $M$ distribution of $X_1$ will also be normal, and has mean $\bar X$ as we have seen. So the third central moment, being odd, will be zero. Then the 1st term in the above expression is zero and we are left with
$$E[R_2(X_1;\bar X) \mid M]= E\left[g_1(X_1)\cdot\left(X_1-\bar X\right)^3 \mid M\right] \qquad [3]$$
which I would say, will be a rather small amount, since $g_1$ belongs to the Remainder of the Remainder.
Note that if we can say that $u'''(X_1)$ is bounded above and below in a neighborhood of $\bar X$ and belongs to the interval, say $[a, A]$ then the expected value of the Remainder is sandwiched to zero, because we have
$$a\frac {(X_1-\bar X)^3}{3!} \le R_2(X_1;\bar X) \le A\frac {(X_1-\bar X)^3}{3!}$$
$$\Rightarrow E\left (a\frac {(X_1-\bar X)^3}{3!} \mid M\right) \le E[R_2(X_1;\bar X) \mid M] \le E\left (a\frac {(X_1-\bar X)^3}{3!} \mid M\right)$$
$$\Rightarrow 0 \le E[R_2(X_1;\bar X) \mid M] \le 0 \Rightarrow E[R_2(X_1;\bar X) \mid M]=0$$
If we cannot say anything about $u()$ then we are left with the approximation $[1]$ and the approximation error $[3]$. | Conditioning on independent random variables
Given the information in the question, we have a sample of $n$ i.i.d normals (which also means that their joint distribution is also normal), each following $N(\mu, \sigma^2)$. Therefore $\bar X \sim |
37,189 | derivation of predictive distribution of Gaussian Process | See for example Murphyin page 110-111 Chapter 4.3 Inference in jointly Gaussian distributions. What you are looking for in Theorem 4.3.1, which uses the Matrix Inversion Lemma to compute the posterior conditional probabilities. Replacing $x_1$ with $u_{*}$ and $x_2$ with $u$, $\Sigma_{11}$ with $K_{x^*}$, $\Sigma_{22}$ with $K_{x}$, etc. you get the desired result. (Since we condition w.r.t. $u$-$x_2$) Again the proof is straightforward if you use the matrix inversion Lemma. | derivation of predictive distribution of Gaussian Process | See for example Murphyin page 110-111 Chapter 4.3 Inference in jointly Gaussian distributions. What you are looking for in Theorem 4.3.1, which uses the Matrix Inversion Lemma to compute the posterior | derivation of predictive distribution of Gaussian Process
See for example Murphyin page 110-111 Chapter 4.3 Inference in jointly Gaussian distributions. What you are looking for in Theorem 4.3.1, which uses the Matrix Inversion Lemma to compute the posterior conditional probabilities. Replacing $x_1$ with $u_{*}$ and $x_2$ with $u$, $\Sigma_{11}$ with $K_{x^*}$, $\Sigma_{22}$ with $K_{x}$, etc. you get the desired result. (Since we condition w.r.t. $u$-$x_2$) Again the proof is straightforward if you use the matrix inversion Lemma. | derivation of predictive distribution of Gaussian Process
See for example Murphyin page 110-111 Chapter 4.3 Inference in jointly Gaussian distributions. What you are looking for in Theorem 4.3.1, which uses the Matrix Inversion Lemma to compute the posterior |
37,190 | How to design experiments for Market Research (with a twist)? | One approach to your problem is using a stratified sample. One purpose of stratification is making sure certain domains (groups) of the population are represented in the sample, which otherwise would be represented too sparsely for valid inference, e.g. due to small selection probability.
For example, if "Native Americans" is an important group in terms of your estimates from the 'likeability model', but their selection probability is very small, a simple random sample (SRS) of size $n=50$ might contain no or only very few units of this type. If you then include Nat. Am. as an indicator variable in the model, the estimates will perhaps be extremely unreliable (large standard errors), or the parameters cannot be estimated at all. The goal of a stratified sample is to avoid this.
Stratification means selecting units with a higher probability than they would have in a SRS. In estimating your logistic/polynomial regression, you will be able to use stratification weights (design weights) to adjust for the higher selection probability. A weight is then commonly defined as $$w_i=\frac{\pi_s}{\pi_{pop}},$$ where $\pi_s$ is the selection probability into the stratified sample, and $\pi_{pop}$ is the selection probability when using a SRS.
The problem in your particular application is that you probably cannot stratify for all characteristics you mention, given the small sample size (say $n=50$). In stratification, you usually need to cross all characteristics and sample from all cells of the resulting contingency table. The number of cells quickly grows with the number of characteristics and categories of each characteristic, and at one point of complexity, it is not possible anymore to fill all cells sufficiently given a fixed $n=50$.
My advice therefore is to look at your characteristics and make a selection as follows. First, make a list of all characteristics that you want to have in the final model, because you assume that they will have predictive power for 'likeability' or they identify groups that are important in the 'bidding process'. Second, from these characteristics, distinguish between those that imply a high and low selection probability during sampling. A low selection probability is one that will probably give you too few observations in one of the categories given a SRS sample of size $n$.
For example, 'gender' usually will be a well-represented variable with 50/50 probability in the pop., so even if $n=50$ you will have 'sufficient' men and women, but Nat. Am. might not be a variable of this type, but still important for your model. A power analysis might provide further guidance if needed, but it depends on the particular model and might be very complex for polytomous regression.
The characteristics with too low selection probability are the candidates for stratification, whereas the variables with high enough / balanced selection probability across their categories can be ignored in sampling design. Now that you have identified the crucial strata for your population and model, you can build the sampling design strategy on them (i.e. randomly sample from all relevant strata to fill all 'cells').
I hope that when doing this you will end up with few enough strata to go ahead with a sample of size $n=50$. | How to design experiments for Market Research (with a twist)? | One approach to your problem is using a stratified sample. One purpose of stratification is making sure certain domains (groups) of the population are represented in the sample, which otherwise would | How to design experiments for Market Research (with a twist)?
One approach to your problem is using a stratified sample. One purpose of stratification is making sure certain domains (groups) of the population are represented in the sample, which otherwise would be represented too sparsely for valid inference, e.g. due to small selection probability.
For example, if "Native Americans" is an important group in terms of your estimates from the 'likeability model', but their selection probability is very small, a simple random sample (SRS) of size $n=50$ might contain no or only very few units of this type. If you then include Nat. Am. as an indicator variable in the model, the estimates will perhaps be extremely unreliable (large standard errors), or the parameters cannot be estimated at all. The goal of a stratified sample is to avoid this.
Stratification means selecting units with a higher probability than they would have in a SRS. In estimating your logistic/polynomial regression, you will be able to use stratification weights (design weights) to adjust for the higher selection probability. A weight is then commonly defined as $$w_i=\frac{\pi_s}{\pi_{pop}},$$ where $\pi_s$ is the selection probability into the stratified sample, and $\pi_{pop}$ is the selection probability when using a SRS.
The problem in your particular application is that you probably cannot stratify for all characteristics you mention, given the small sample size (say $n=50$). In stratification, you usually need to cross all characteristics and sample from all cells of the resulting contingency table. The number of cells quickly grows with the number of characteristics and categories of each characteristic, and at one point of complexity, it is not possible anymore to fill all cells sufficiently given a fixed $n=50$.
My advice therefore is to look at your characteristics and make a selection as follows. First, make a list of all characteristics that you want to have in the final model, because you assume that they will have predictive power for 'likeability' or they identify groups that are important in the 'bidding process'. Second, from these characteristics, distinguish between those that imply a high and low selection probability during sampling. A low selection probability is one that will probably give you too few observations in one of the categories given a SRS sample of size $n$.
For example, 'gender' usually will be a well-represented variable with 50/50 probability in the pop., so even if $n=50$ you will have 'sufficient' men and women, but Nat. Am. might not be a variable of this type, but still important for your model. A power analysis might provide further guidance if needed, but it depends on the particular model and might be very complex for polytomous regression.
The characteristics with too low selection probability are the candidates for stratification, whereas the variables with high enough / balanced selection probability across their categories can be ignored in sampling design. Now that you have identified the crucial strata for your population and model, you can build the sampling design strategy on them (i.e. randomly sample from all relevant strata to fill all 'cells').
I hope that when doing this you will end up with few enough strata to go ahead with a sample of size $n=50$. | How to design experiments for Market Research (with a twist)?
One approach to your problem is using a stratified sample. One purpose of stratification is making sure certain domains (groups) of the population are represented in the sample, which otherwise would |
37,191 | Can I use Wilcoxon Signed-Rank Test to test pairs of data in a time series? | One major concern is whether there's serial dependence in the differences, due to the observations being over time. The test assumes independence and if that doesn't hold, it could be badly affected. [The rest of my answer is predicated on independence being sufficiently close to true that the null distribution of the test statistic is not badly affected.]
If you want to test the null hypothesis that the pairs of measurements have the same distribution against the alternative that they don't, the Wilcoxon signed rank test will be suitable (there are some other pairs of hypotheses that would fit with the test).
If you want to specifically test for an alternative of a difference in means, the test will be sensitive to that difference (under a null of identical distributions), but the location-shift estimate it gives is not a shift in means (it's the Hodges-Lehmann estimate, the median of pairwise differences; if you like it's the median shift). If your alternative is explicitly a shift alternative, the Hodges-Lehmann estimate will be a reasonable estimator for the population mean of the pairwise shifts.
(In short, if I understand your description, then yes, it looks like a signed rank test would be suitable, but to make your inference about the means you have to make additional assumptions.)
If your interest is particularly in the mean of the differences, I'd suggest looking at a permutation test; with a reasonably efficient implementation, your sample is small enough to cover all possible permutations. | Can I use Wilcoxon Signed-Rank Test to test pairs of data in a time series? | One major concern is whether there's serial dependence in the differences, due to the observations being over time. The test assumes independence and if that doesn't hold, it could be badly affected. | Can I use Wilcoxon Signed-Rank Test to test pairs of data in a time series?
One major concern is whether there's serial dependence in the differences, due to the observations being over time. The test assumes independence and if that doesn't hold, it could be badly affected. [The rest of my answer is predicated on independence being sufficiently close to true that the null distribution of the test statistic is not badly affected.]
If you want to test the null hypothesis that the pairs of measurements have the same distribution against the alternative that they don't, the Wilcoxon signed rank test will be suitable (there are some other pairs of hypotheses that would fit with the test).
If you want to specifically test for an alternative of a difference in means, the test will be sensitive to that difference (under a null of identical distributions), but the location-shift estimate it gives is not a shift in means (it's the Hodges-Lehmann estimate, the median of pairwise differences; if you like it's the median shift). If your alternative is explicitly a shift alternative, the Hodges-Lehmann estimate will be a reasonable estimator for the population mean of the pairwise shifts.
(In short, if I understand your description, then yes, it looks like a signed rank test would be suitable, but to make your inference about the means you have to make additional assumptions.)
If your interest is particularly in the mean of the differences, I'd suggest looking at a permutation test; with a reasonably efficient implementation, your sample is small enough to cover all possible permutations. | Can I use Wilcoxon Signed-Rank Test to test pairs of data in a time series?
One major concern is whether there's serial dependence in the differences, due to the observations being over time. The test assumes independence and if that doesn't hold, it could be badly affected. |
37,192 | Can I use Wilcoxon Signed-Rank Test to test pairs of data in a time series? | I have also been wondering about this. It turns out that this question has cropped up a few times in the recent past:
Is Wilcoxon Signed-Rank Test the right test to use?
Can I use wilcoxon signed rank test for time series data
@Glen_b makes the point that autocorrelation in the data (e.g. the tendency for readings close in time to be close in value) breaks the central assumption of the Wilcoxon Signed-Rank Test that the pairs are independent in your data.
Put another way, if your 100 paired readings are highly correlated over time (as is often the case), then you are not testing 100 independent pairs. Your effective sample size is much smaller. If observation A >> observation B at time 1, the same is likely to be true at time 2, time 3 and so on... depending on the level of autocorrelation in the data.
Now Wilcoxon comes along and sees 100 independent samples that all have the property A >> B. Bingo! A differs from B with dramatically high statistical significance. But in reality, if you were to run the test again you might find that $A \approx B$ at time 1 and this propagates forwards in time as before. Wilcoxon now says that A and B have the same distribution.
So, having laboured this point, I now admit that I have no real idea how to deal with it! A recent study gives a modification to the test to deal with clustered data. For example a left eye - right eye (before and after) test. But our problem only has one 'cluster' - a single time series - so I don't think this will help. | Can I use Wilcoxon Signed-Rank Test to test pairs of data in a time series? | I have also been wondering about this. It turns out that this question has cropped up a few times in the recent past:
Is Wilcoxon Signed-Rank Test the right test to use?
Can I use wilcoxon signed ra | Can I use Wilcoxon Signed-Rank Test to test pairs of data in a time series?
I have also been wondering about this. It turns out that this question has cropped up a few times in the recent past:
Is Wilcoxon Signed-Rank Test the right test to use?
Can I use wilcoxon signed rank test for time series data
@Glen_b makes the point that autocorrelation in the data (e.g. the tendency for readings close in time to be close in value) breaks the central assumption of the Wilcoxon Signed-Rank Test that the pairs are independent in your data.
Put another way, if your 100 paired readings are highly correlated over time (as is often the case), then you are not testing 100 independent pairs. Your effective sample size is much smaller. If observation A >> observation B at time 1, the same is likely to be true at time 2, time 3 and so on... depending on the level of autocorrelation in the data.
Now Wilcoxon comes along and sees 100 independent samples that all have the property A >> B. Bingo! A differs from B with dramatically high statistical significance. But in reality, if you were to run the test again you might find that $A \approx B$ at time 1 and this propagates forwards in time as before. Wilcoxon now says that A and B have the same distribution.
So, having laboured this point, I now admit that I have no real idea how to deal with it! A recent study gives a modification to the test to deal with clustered data. For example a left eye - right eye (before and after) test. But our problem only has one 'cluster' - a single time series - so I don't think this will help. | Can I use Wilcoxon Signed-Rank Test to test pairs of data in a time series?
I have also been wondering about this. It turns out that this question has cropped up a few times in the recent past:
Is Wilcoxon Signed-Rank Test the right test to use?
Can I use wilcoxon signed ra |
37,193 | What method is simulating pvalues from re sampling from the data | It seems to me that Ellis could be referring to as many as three distinct ideas here. First he says something about creating "simulated data generated by a model under the null hypothesis of no relation." I would call this a form of parametric bootstrapping. Then he says that this would be "probably based on resampling the times between each event (eg between each yawn) to create a new set of time stamps for hypothetical null model events." Which, let's just be clear here, to do this is not to "create simulated data." We are instead, if I understand correctly, resampling from our actually observed data. This latter procedure is either a permutation test or nonparametric bootstrapping, depending on how the resampling takes place.
I guess I should say a few more words about parametric bootstrapping, permutation tests, and nonparametric bootstrapping.
Usually parametric bootstrapping is done by simulating based on the actually estimated model, and not based on a hypothetical model that is just like the estimated model except the null hypothesis is assumed true, as Ellis seems to suggest at first. By "simulate data" I mean something like as an example: my model states that my data come from two groups, each with a normal distribution, with means $\mu_1$ and $\mu_2$, respectively, and standard deviation $\sigma$, so I will generate many sets of data that satisfy this and use the distribution of test statistics computed from each of these simulated datasets as my sampling distribution. Note, I am creating this data using something like rnorm() in R, not directly using my observed data. Now, one could certainly do this procedure and get a sort of sampling distribution under the null hypothesis of, say, no difference in group means--we would just assume $\mu_1=\mu_2$ in all the simulated datasets, contrary to what we actually observed--and in this way we get a bootstrapped p-value (rather than a bootstrapped confidence interval, which is what the former/traditional method affords you). Again, I would just call this a way of obtaining a p-value via parametric bootstrapping.
A permutation test, on the other hand, involves shuffling your observed data over and over in a way that would be consistent with the null hypothesis. So for example, if the null hypothesis implies that group assignment makes no difference in terms of the group means, you can randomly shuffle the group labels among all your observations many many times and see what mean differences you would get for all possible ways of shuffling in this way. And then you would see where within the distribution of test statistics computed from these shuffled datasets does your actual observed statistic lie. Note that there is a finite (but usually large) number of ways that you can shuffle your actually observed data.
Finally, nonparametric bootstrapping is very similar to the permutation test, but we resample the observed data with replacement to try to get closer to an infinite "population" of values that our data might have been drawn from. There are many, many more ways to resample from your data with replacement than there are to shuffle your data (although it is technically finite in practice as well). Again, similar to parametric bootstrapping, this is usually done not under the null hypothesis, but under the model implied by the observed data, yielding confidence intervals around the observed test statistics, not p-values. But one could certainly imagine doing this under the null hypothesis like Ellis suggests and obtaining p-values in this way. As an example of nonparametric bootstrapping here (in the traditional fashion, i.e., not under the null hypothesis) using the same difference-in-group-means example I used in the parametric bootstrapping paragraph, to do this we would resample with replacement the observations within each group many times but not mixing observations between groups (unlike in the permutation test), and build up the sampling distribution of group mean differences that we get this way. | What method is simulating pvalues from re sampling from the data | It seems to me that Ellis could be referring to as many as three distinct ideas here. First he says something about creating "simulated data generated by a model under the null hypothesis of no relati | What method is simulating pvalues from re sampling from the data
It seems to me that Ellis could be referring to as many as three distinct ideas here. First he says something about creating "simulated data generated by a model under the null hypothesis of no relation." I would call this a form of parametric bootstrapping. Then he says that this would be "probably based on resampling the times between each event (eg between each yawn) to create a new set of time stamps for hypothetical null model events." Which, let's just be clear here, to do this is not to "create simulated data." We are instead, if I understand correctly, resampling from our actually observed data. This latter procedure is either a permutation test or nonparametric bootstrapping, depending on how the resampling takes place.
I guess I should say a few more words about parametric bootstrapping, permutation tests, and nonparametric bootstrapping.
Usually parametric bootstrapping is done by simulating based on the actually estimated model, and not based on a hypothetical model that is just like the estimated model except the null hypothesis is assumed true, as Ellis seems to suggest at first. By "simulate data" I mean something like as an example: my model states that my data come from two groups, each with a normal distribution, with means $\mu_1$ and $\mu_2$, respectively, and standard deviation $\sigma$, so I will generate many sets of data that satisfy this and use the distribution of test statistics computed from each of these simulated datasets as my sampling distribution. Note, I am creating this data using something like rnorm() in R, not directly using my observed data. Now, one could certainly do this procedure and get a sort of sampling distribution under the null hypothesis of, say, no difference in group means--we would just assume $\mu_1=\mu_2$ in all the simulated datasets, contrary to what we actually observed--and in this way we get a bootstrapped p-value (rather than a bootstrapped confidence interval, which is what the former/traditional method affords you). Again, I would just call this a way of obtaining a p-value via parametric bootstrapping.
A permutation test, on the other hand, involves shuffling your observed data over and over in a way that would be consistent with the null hypothesis. So for example, if the null hypothesis implies that group assignment makes no difference in terms of the group means, you can randomly shuffle the group labels among all your observations many many times and see what mean differences you would get for all possible ways of shuffling in this way. And then you would see where within the distribution of test statistics computed from these shuffled datasets does your actual observed statistic lie. Note that there is a finite (but usually large) number of ways that you can shuffle your actually observed data.
Finally, nonparametric bootstrapping is very similar to the permutation test, but we resample the observed data with replacement to try to get closer to an infinite "population" of values that our data might have been drawn from. There are many, many more ways to resample from your data with replacement than there are to shuffle your data (although it is technically finite in practice as well). Again, similar to parametric bootstrapping, this is usually done not under the null hypothesis, but under the model implied by the observed data, yielding confidence intervals around the observed test statistics, not p-values. But one could certainly imagine doing this under the null hypothesis like Ellis suggests and obtaining p-values in this way. As an example of nonparametric bootstrapping here (in the traditional fashion, i.e., not under the null hypothesis) using the same difference-in-group-means example I used in the parametric bootstrapping paragraph, to do this we would resample with replacement the observations within each group many times but not mixing observations between groups (unlike in the permutation test), and build up the sampling distribution of group mean differences that we get this way. | What method is simulating pvalues from re sampling from the data
It seems to me that Ellis could be referring to as many as three distinct ideas here. First he says something about creating "simulated data generated by a model under the null hypothesis of no relati |
37,194 | Specify a Zero-inflated (Hurdle) Gamma Model in JAGS/BUGS | I figured out the answer, with help from Martyn Plummer. My code uses the inverse link for the gamma model (and no inverse of the predictors). Also, this code requires the 'glm' module for JAGS.
model{
# For the ones trick
C <- 10000
# for every observation
for(i in 1:N){
# define the logistic regression model, where w is the probability of occurance.
# use the logistic transformation exp(z)/(1 + exp(z)), where z is a linear function
logit(w[i]) <- zeta[i]
zeta[i] <- gamma0 + gamma1*MPD[i] + gamma2*MTD[i] + gamma3*int[i] + gamma4*MPD[i]*int[i] + gamma5*MTD[i]*int[i]
# define the gamma regression model for the mean. use the log link the ensure positive, non-zero mu
mu[i] <- pow(eta[i], -1)
eta[i] <- beta0 + beta1*MPD[i] + beta2*MTD[i] + beta3*int[i] + beta4*MPD[i]*int[i] + beta5*MTD[i]*int[i]
# redefine the mu and sd of the continuous part into the shape and scale parameters
shape[i] <- pow(mu[i], 2) / pow(sd, 2)
rate[i] <- mu[i] / pow(sd, 2)
# for readability, define the log-likelihood of the gamma here
logGamma[i] <- log(dgamma(y[i], shape[i], rate[i]))
# define the total likelihood, where the likelihood is (1 - w) if y < 0.0001 (z = 0) or
# the likelihood is w * gammalik if y >= 0.0001 (z = 1). So if z = 1, then the first bit must be
# 0 and the second bit 1. Use 1 - z, which is 0 if y > 0.0001 and 1 if y < 0.0001
logLik[i] <- (1 - z[i]) * log(1 - w[i]) + z[i] * ( log(w[i]) + logGamma[i] )
Lik[i] <- exp(logLik[i])
# Use the ones trick
p[i] <- Lik[i] / C
ones[i] ~ dbern(p[i])
}
# PRIORS
beta0 ~ dnorm(0, 0.0001)
beta1 ~ dnorm(0, 0.0001)
beta2 ~ dnorm(0, 0.0001)
beta3 ~ dnorm(0, 0.0001)
beta4 ~ dnorm(0, 0.0001)
beta5 ~ dnorm(0, 0.0001)
gamma0 ~ dnorm(0, 0.0001)
gamma1 ~ dnorm(0, 0.0001)
gamma2 ~ dnorm(0, 0.0001)
gamma3 ~ dnorm(0, 0.0001)
gamma4 ~ dnorm(0, 0.0001)
gamma5 ~ dnorm(0, 0.0001)
sd ~ dgamma(2, 2)
} | Specify a Zero-inflated (Hurdle) Gamma Model in JAGS/BUGS | I figured out the answer, with help from Martyn Plummer. My code uses the inverse link for the gamma model (and no inverse of the predictors). Also, this code requires the 'glm' module for JAGS.
model | Specify a Zero-inflated (Hurdle) Gamma Model in JAGS/BUGS
I figured out the answer, with help from Martyn Plummer. My code uses the inverse link for the gamma model (and no inverse of the predictors). Also, this code requires the 'glm' module for JAGS.
model{
# For the ones trick
C <- 10000
# for every observation
for(i in 1:N){
# define the logistic regression model, where w is the probability of occurance.
# use the logistic transformation exp(z)/(1 + exp(z)), where z is a linear function
logit(w[i]) <- zeta[i]
zeta[i] <- gamma0 + gamma1*MPD[i] + gamma2*MTD[i] + gamma3*int[i] + gamma4*MPD[i]*int[i] + gamma5*MTD[i]*int[i]
# define the gamma regression model for the mean. use the log link the ensure positive, non-zero mu
mu[i] <- pow(eta[i], -1)
eta[i] <- beta0 + beta1*MPD[i] + beta2*MTD[i] + beta3*int[i] + beta4*MPD[i]*int[i] + beta5*MTD[i]*int[i]
# redefine the mu and sd of the continuous part into the shape and scale parameters
shape[i] <- pow(mu[i], 2) / pow(sd, 2)
rate[i] <- mu[i] / pow(sd, 2)
# for readability, define the log-likelihood of the gamma here
logGamma[i] <- log(dgamma(y[i], shape[i], rate[i]))
# define the total likelihood, where the likelihood is (1 - w) if y < 0.0001 (z = 0) or
# the likelihood is w * gammalik if y >= 0.0001 (z = 1). So if z = 1, then the first bit must be
# 0 and the second bit 1. Use 1 - z, which is 0 if y > 0.0001 and 1 if y < 0.0001
logLik[i] <- (1 - z[i]) * log(1 - w[i]) + z[i] * ( log(w[i]) + logGamma[i] )
Lik[i] <- exp(logLik[i])
# Use the ones trick
p[i] <- Lik[i] / C
ones[i] ~ dbern(p[i])
}
# PRIORS
beta0 ~ dnorm(0, 0.0001)
beta1 ~ dnorm(0, 0.0001)
beta2 ~ dnorm(0, 0.0001)
beta3 ~ dnorm(0, 0.0001)
beta4 ~ dnorm(0, 0.0001)
beta5 ~ dnorm(0, 0.0001)
gamma0 ~ dnorm(0, 0.0001)
gamma1 ~ dnorm(0, 0.0001)
gamma2 ~ dnorm(0, 0.0001)
gamma3 ~ dnorm(0, 0.0001)
gamma4 ~ dnorm(0, 0.0001)
gamma5 ~ dnorm(0, 0.0001)
sd ~ dgamma(2, 2)
} | Specify a Zero-inflated (Hurdle) Gamma Model in JAGS/BUGS
I figured out the answer, with help from Martyn Plummer. My code uses the inverse link for the gamma model (and no inverse of the predictors). Also, this code requires the 'glm' module for JAGS.
model |
37,195 | G-test statistic and KL divergence | People use inconsistent language with the KL divergence. Sometimes "the divergence of $Q$ from $P$" means $KL(P \| Q)$; sometimes it means $KL(Q \| P)$.
$KL(\text{true} \| \text{approximation})$ indeed has a nice information-theoretic interpretation as the inefficiency due to encoding the true distribution with a code built based on the approximation.
But that doesn't mean that $KL(\text{approximation} \| \text{true})$ doesn't ever come up; it does all the time. An information-theoretic interpretation is how efficiently you can represent the data itself, with respect to a code based on the expected distribution. In fact, this is closely related to the likelihood of the data under the expected distribution:
\begin{align*}
D_{KL}(P \| Q)
&= \underbrace{\sum_i P(i) \ln P(i)}_{-\text{entropy[P]}} - \underbrace{\sum_i P(i) \ln Q(i) }_{\text{expected log-likelihood of data under $Q$}}
\end{align*} | G-test statistic and KL divergence | People use inconsistent language with the KL divergence. Sometimes "the divergence of $Q$ from $P$" means $KL(P \| Q)$; sometimes it means $KL(Q \| P)$.
$KL(\text{true} \| \text{approximation})$ indee | G-test statistic and KL divergence
People use inconsistent language with the KL divergence. Sometimes "the divergence of $Q$ from $P$" means $KL(P \| Q)$; sometimes it means $KL(Q \| P)$.
$KL(\text{true} \| \text{approximation})$ indeed has a nice information-theoretic interpretation as the inefficiency due to encoding the true distribution with a code built based on the approximation.
But that doesn't mean that $KL(\text{approximation} \| \text{true})$ doesn't ever come up; it does all the time. An information-theoretic interpretation is how efficiently you can represent the data itself, with respect to a code based on the expected distribution. In fact, this is closely related to the likelihood of the data under the expected distribution:
\begin{align*}
D_{KL}(P \| Q)
&= \underbrace{\sum_i P(i) \ln P(i)}_{-\text{entropy[P]}} - \underbrace{\sum_i P(i) \ln Q(i) }_{\text{expected log-likelihood of data under $Q$}}
\end{align*} | G-test statistic and KL divergence
People use inconsistent language with the KL divergence. Sometimes "the divergence of $Q$ from $P$" means $KL(P \| Q)$; sometimes it means $KL(Q \| P)$.
$KL(\text{true} \| \text{approximation})$ indee |
37,196 | A Bayesian perspective on omitted-variable bias (and other covariate-selection bias problems) | In general, Bayesian estimation is not very concerned with unbiasedness of estimators since the model is always misspecified. There definitely exist proofs about conditions for unbiased estimation in Bayesian frameworks. I just don't think practitioners care very much about that and try to avoid using fitting procedures that would be susceptible to this kind of thing at all.
And sometimes doing tricky things just to get an "unbiased" estimator can come at the expense of other exploitable problem structure (e.g. when pooling is used to get an unbiased estimator, you are trading usable category-level variance in exchange for guarantees of unbiasedness under implausible assumptions. Whether that is a useful trade-off or not should be considered at the level of specific applied inference problems, rather than as a generic thing to do with any model. Here is a post by Andrew Gelman about that.)
For the problem at hand, I believe Bayesian practitioners look more generally at model fit assessment and model misspecification. It's more about whether you are missing an appreciable or significant effect size for the omitted variable, and less about whether the omission has sprayed effect size onto other variables.
One way to address this is to perform posterior predictive checks on your model. If you do this with a procedure like continuous model expansion (section 5.2 of this paper), then the posterior predictive checks should give you evidence about the best model specification (or better yet, the best distribution over some set of model specifications), rather than forcing you to make an unnatural choice like "The model with Variable Z is 'better' than the model without Variable Z" (which are almost always misunderstood or misinterpreted later by readers). | A Bayesian perspective on omitted-variable bias (and other covariate-selection bias problems) | In general, Bayesian estimation is not very concerned with unbiasedness of estimators since the model is always misspecified. There definitely exist proofs about conditions for unbiased estimation in | A Bayesian perspective on omitted-variable bias (and other covariate-selection bias problems)
In general, Bayesian estimation is not very concerned with unbiasedness of estimators since the model is always misspecified. There definitely exist proofs about conditions for unbiased estimation in Bayesian frameworks. I just don't think practitioners care very much about that and try to avoid using fitting procedures that would be susceptible to this kind of thing at all.
And sometimes doing tricky things just to get an "unbiased" estimator can come at the expense of other exploitable problem structure (e.g. when pooling is used to get an unbiased estimator, you are trading usable category-level variance in exchange for guarantees of unbiasedness under implausible assumptions. Whether that is a useful trade-off or not should be considered at the level of specific applied inference problems, rather than as a generic thing to do with any model. Here is a post by Andrew Gelman about that.)
For the problem at hand, I believe Bayesian practitioners look more generally at model fit assessment and model misspecification. It's more about whether you are missing an appreciable or significant effect size for the omitted variable, and less about whether the omission has sprayed effect size onto other variables.
One way to address this is to perform posterior predictive checks on your model. If you do this with a procedure like continuous model expansion (section 5.2 of this paper), then the posterior predictive checks should give you evidence about the best model specification (or better yet, the best distribution over some set of model specifications), rather than forcing you to make an unnatural choice like "The model with Variable Z is 'better' than the model without Variable Z" (which are almost always misunderstood or misinterpreted later by readers). | A Bayesian perspective on omitted-variable bias (and other covariate-selection bias problems)
In general, Bayesian estimation is not very concerned with unbiasedness of estimators since the model is always misspecified. There definitely exist proofs about conditions for unbiased estimation in |
37,197 | A Bayesian perspective on omitted-variable bias (and other covariate-selection bias problems) | It's not properly true that Bayesian models are always misspecified!
Try by yourself... You will realize that even with a wrong prior you can find conditions for having an unbiased posterior estimator. | A Bayesian perspective on omitted-variable bias (and other covariate-selection bias problems) | It's not properly true that Bayesian models are always misspecified!
Try by yourself... You will realize that even with a wrong prior you can find conditions for having an unbiased posterior estimator | A Bayesian perspective on omitted-variable bias (and other covariate-selection bias problems)
It's not properly true that Bayesian models are always misspecified!
Try by yourself... You will realize that even with a wrong prior you can find conditions for having an unbiased posterior estimator. | A Bayesian perspective on omitted-variable bias (and other covariate-selection bias problems)
It's not properly true that Bayesian models are always misspecified!
Try by yourself... You will realize that even with a wrong prior you can find conditions for having an unbiased posterior estimator |
37,198 | How to select cut-point for making classifications table for logistic regression? | Setting these cut points should really be done in the context of some descicion making process. I'll give you an example that you might be able to generalize to your context.
Let's say I build a model that estimates the probability a person has event Y occur in the future, given their score on X today. I then estimate P(Y|X) in a new population, for whom Y hasn't occured yet. I can then set a cuttoff point in the predicted probability that says which people are at "high risk" of Y. Lacking any other information or context, this is completely arbitrary and not useful.
Now let's say I want to save money, and people that have Y occur cost me some of it. I have an intervention that prevents Y from occuring some of the time, but this intervention also costs me money.
Now I have a decision to make...and that is where the cuttoff I choose might have meaning. If X is very expensive, weighed against a very cheap and effective intervention, I might set my cuttoff very low, even intervening in people that would never have had the outcome occur anyway. Conversely, if X is cheap, and/or the intervention is expensive or doesn't work well, I might set the cut-off very high (or in the extreme do nothing at all). Basically you can define an equation that relates all of these things, and choose the cut-off that saves the most money.
It's also helpful to do this because you start to see how hard it is! Your estimate of P(Y|X) has uncertainty...and so do all your other parameters - how much does Y cost; how effective is the intervention; how much does the intervention cost? And perish the thought you want to optimize something harder to measure than money, like happiness. This is when you will really see how useful your model is, or isn't. | How to select cut-point for making classifications table for logistic regression? | Setting these cut points should really be done in the context of some descicion making process. I'll give you an example that you might be able to generalize to your context.
Let's say I build a mode | How to select cut-point for making classifications table for logistic regression?
Setting these cut points should really be done in the context of some descicion making process. I'll give you an example that you might be able to generalize to your context.
Let's say I build a model that estimates the probability a person has event Y occur in the future, given their score on X today. I then estimate P(Y|X) in a new population, for whom Y hasn't occured yet. I can then set a cuttoff point in the predicted probability that says which people are at "high risk" of Y. Lacking any other information or context, this is completely arbitrary and not useful.
Now let's say I want to save money, and people that have Y occur cost me some of it. I have an intervention that prevents Y from occuring some of the time, but this intervention also costs me money.
Now I have a decision to make...and that is where the cuttoff I choose might have meaning. If X is very expensive, weighed against a very cheap and effective intervention, I might set my cuttoff very low, even intervening in people that would never have had the outcome occur anyway. Conversely, if X is cheap, and/or the intervention is expensive or doesn't work well, I might set the cut-off very high (or in the extreme do nothing at all). Basically you can define an equation that relates all of these things, and choose the cut-off that saves the most money.
It's also helpful to do this because you start to see how hard it is! Your estimate of P(Y|X) has uncertainty...and so do all your other parameters - how much does Y cost; how effective is the intervention; how much does the intervention cost? And perish the thought you want to optimize something harder to measure than money, like happiness. This is when you will really see how useful your model is, or isn't. | How to select cut-point for making classifications table for logistic regression?
Setting these cut points should really be done in the context of some descicion making process. I'll give you an example that you might be able to generalize to your context.
Let's say I build a mode |
37,199 | How to select cut-point for making classifications table for logistic regression? | For example there is a R package ROCR which contains many valuable functions to evaluate a decision concerning cutt-off points. It might very well be that there is a range of values which are optimal in certain sense.
Also you can build decision based on cost function / loss function. For example consider False Positives and False Negatives and give them explicit values. Then for all cuttoff points from 0..1 can be evaluated. | How to select cut-point for making classifications table for logistic regression? | For example there is a R package ROCR which contains many valuable functions to evaluate a decision concerning cutt-off points. It might very well be that there is a range of values which are optimal | How to select cut-point for making classifications table for logistic regression?
For example there is a R package ROCR which contains many valuable functions to evaluate a decision concerning cutt-off points. It might very well be that there is a range of values which are optimal in certain sense.
Also you can build decision based on cost function / loss function. For example consider False Positives and False Negatives and give them explicit values. Then for all cuttoff points from 0..1 can be evaluated. | How to select cut-point for making classifications table for logistic regression?
For example there is a R package ROCR which contains many valuable functions to evaluate a decision concerning cutt-off points. It might very well be that there is a range of values which are optimal |
37,200 | How do I show that $(\hat{\beta_1}-\beta_1)$ and $ \bar{u}$ are uncorrelated, i.e. that $E[(\hat{\beta_1}-\beta_1) \bar{u}] = 0$? | Strategy
It can be illuminating to move back and forth among three points of view: the statistical one (viewing $x_i$ and $y_i$ as data), a geometrical one (where least squares solutions are just projections in suitable Euclidean spaces), and an algebraic one (manipulating symbols representing matrices or linear transformations). Doing this not only streamlines the ideas, but also exposes the assumptions needed to make the result true, which otherwise might be buried in all the summations.
Notation and assumptions
So: let $y = X\beta + u$ where $y$ is an $n$-vector, $X$ is an $n$ by $p+1$ "design matrix" whose first column is all ones, $\beta$ is a $p+1$-vector of true coefficients, and $u$ are iid random variables with zero expectation and common variance $\sigma^2$. (Let's continue, as in the question, to begin the coefficient vector's indexes with $0$, writing ${\beta} = ({\beta_0}, {\beta_1}, \ldots, {\beta_p})$.) This generalizes the question, for which $X$ has just two columns: its second column is the vector $(x_1, x_2, \ldots, x_n)'$.
Basic properties of OLS regression
The regression estimate $\hat{\beta}$ is a $p+1$-vector obtained by applying a linear transformation $\mathbb{P}$ to $y$. As the solution to the regression, it projects the exact values $X\beta$ onto the true values $\beta$: $$\mathbb{P}\left(X\beta\right) = \beta.$$ Finally--and this is the crux of the matter before us--it is obvious statistically (thinking of these values as data)--that the projection of $y = (1, 1, \ldots, 1)'$ has the unique solution $\hat{\beta} = (1, 0, 0, \ldots, 0)$: $$\mathbb{P}1_n' = (1, 0, 0, \ldots, 0),$$ because when all the responses $y_i$ are equal to $1$, the intercept $\beta_0 = 1$ and all the other coefficients must vanish. That's all we need to know. (Having a formula for $\mathbb{P}$ in terms of $X$ is unimportant (and distracting).)
Easy preliminaries
Begin with some straightforward algebraic manipulation of the original expression:
$$\eqalign{
(\hat{\beta}-\beta)\bar{u} &= (\mathbb{P}y-\beta)\bar{u} \\
&= (\mathbb{P}(X\beta+u)-\beta)\bar{u} \\
&= \mathbb{P}(X\beta+u)\bar{u} - \beta\bar{u} \\
&= (\mathbb{P}X\beta)\bar{u} + \mathbb{P}u\bar{u} - \beta\bar{u} \\
&= \beta\bar{u} + \mathbb{P}u\bar{u} - \beta\bar{u}\\
&= \mathbb{P}(u\bar{u}).
}
$$
This almost mindless sequence of steps--each leads naturally to the next by simple algebraic rules--is motivated by the desire to (a) express the random variation purely in terms of $u$, whence it all derives, and (b) introduce $\mathbb{P}$ so that we can exploit its properties.
Computing the expectation
Taking the expectation can no longer be put off, but because $\mathbb{P}$ is a linear operator, it will be applied to the expectation of $u\bar{u}$. We could employ some formal matrix operations to work out this expectation, but there's an easier way. Recalling that the $u_i$ are iid, it is immediate that all the coefficients in $\mathbb{E}[u\bar{u}]$ must be the same. Since they are the same, each one equals their average. This can be obtained by averaging the coefficients of $u$, multiplying by $\bar{u}$, and taking the expectation. But that's just a recipe for finding $$\mathbb{E}[\bar{u}\bar{u}] = \text{Var}[\bar{u}] = \sigma^2/n.$$ It follows that $\mathbb{E}[u\bar{u}]$ is a vector of $n$ values, all of which equal $\sigma^2/n$. Using our previous vector shorthand we may write $$\mathbb{E}[(\hat{\beta}-\beta)\bar{u} ] = \mathbb{E}[\mathbb{P}(u\bar{u})] = \mathbb{PE}[u\bar{u}]=\mathbb{P}1_n'\sigma^2/n=(\sigma^2/n, 0, 0, \ldots, 0).$$
Conclusion
This says that the estimated coefficients $\hat{\beta_i}$ and the mean error $\hat{u}$ are uncorrelated for $i=1, 2, \ldots, p$, but not so for $\hat{\beta_0}$ (the intercept).
It is instructive to review the steps and consider which assumptions were essential and which elements of the regression apparatus simply did not appear in the demonstration. We should expect any proof, no matter how elementary or sophisticated, will need to use the same (or stronger) assumptions and will need, in some guise or another, to include calculations of $\mathbb{P}1_n'$ and $\mathbb{E}[u\bar{u}]$. | How do I show that $(\hat{\beta_1}-\beta_1)$ and $ \bar{u}$ are uncorrelated, i.e. that $E[(\hat{\be | Strategy
It can be illuminating to move back and forth among three points of view: the statistical one (viewing $x_i$ and $y_i$ as data), a geometrical one (where least squares solutions are just proj | How do I show that $(\hat{\beta_1}-\beta_1)$ and $ \bar{u}$ are uncorrelated, i.e. that $E[(\hat{\beta_1}-\beta_1) \bar{u}] = 0$?
Strategy
It can be illuminating to move back and forth among three points of view: the statistical one (viewing $x_i$ and $y_i$ as data), a geometrical one (where least squares solutions are just projections in suitable Euclidean spaces), and an algebraic one (manipulating symbols representing matrices or linear transformations). Doing this not only streamlines the ideas, but also exposes the assumptions needed to make the result true, which otherwise might be buried in all the summations.
Notation and assumptions
So: let $y = X\beta + u$ where $y$ is an $n$-vector, $X$ is an $n$ by $p+1$ "design matrix" whose first column is all ones, $\beta$ is a $p+1$-vector of true coefficients, and $u$ are iid random variables with zero expectation and common variance $\sigma^2$. (Let's continue, as in the question, to begin the coefficient vector's indexes with $0$, writing ${\beta} = ({\beta_0}, {\beta_1}, \ldots, {\beta_p})$.) This generalizes the question, for which $X$ has just two columns: its second column is the vector $(x_1, x_2, \ldots, x_n)'$.
Basic properties of OLS regression
The regression estimate $\hat{\beta}$ is a $p+1$-vector obtained by applying a linear transformation $\mathbb{P}$ to $y$. As the solution to the regression, it projects the exact values $X\beta$ onto the true values $\beta$: $$\mathbb{P}\left(X\beta\right) = \beta.$$ Finally--and this is the crux of the matter before us--it is obvious statistically (thinking of these values as data)--that the projection of $y = (1, 1, \ldots, 1)'$ has the unique solution $\hat{\beta} = (1, 0, 0, \ldots, 0)$: $$\mathbb{P}1_n' = (1, 0, 0, \ldots, 0),$$ because when all the responses $y_i$ are equal to $1$, the intercept $\beta_0 = 1$ and all the other coefficients must vanish. That's all we need to know. (Having a formula for $\mathbb{P}$ in terms of $X$ is unimportant (and distracting).)
Easy preliminaries
Begin with some straightforward algebraic manipulation of the original expression:
$$\eqalign{
(\hat{\beta}-\beta)\bar{u} &= (\mathbb{P}y-\beta)\bar{u} \\
&= (\mathbb{P}(X\beta+u)-\beta)\bar{u} \\
&= \mathbb{P}(X\beta+u)\bar{u} - \beta\bar{u} \\
&= (\mathbb{P}X\beta)\bar{u} + \mathbb{P}u\bar{u} - \beta\bar{u} \\
&= \beta\bar{u} + \mathbb{P}u\bar{u} - \beta\bar{u}\\
&= \mathbb{P}(u\bar{u}).
}
$$
This almost mindless sequence of steps--each leads naturally to the next by simple algebraic rules--is motivated by the desire to (a) express the random variation purely in terms of $u$, whence it all derives, and (b) introduce $\mathbb{P}$ so that we can exploit its properties.
Computing the expectation
Taking the expectation can no longer be put off, but because $\mathbb{P}$ is a linear operator, it will be applied to the expectation of $u\bar{u}$. We could employ some formal matrix operations to work out this expectation, but there's an easier way. Recalling that the $u_i$ are iid, it is immediate that all the coefficients in $\mathbb{E}[u\bar{u}]$ must be the same. Since they are the same, each one equals their average. This can be obtained by averaging the coefficients of $u$, multiplying by $\bar{u}$, and taking the expectation. But that's just a recipe for finding $$\mathbb{E}[\bar{u}\bar{u}] = \text{Var}[\bar{u}] = \sigma^2/n.$$ It follows that $\mathbb{E}[u\bar{u}]$ is a vector of $n$ values, all of which equal $\sigma^2/n$. Using our previous vector shorthand we may write $$\mathbb{E}[(\hat{\beta}-\beta)\bar{u} ] = \mathbb{E}[\mathbb{P}(u\bar{u})] = \mathbb{PE}[u\bar{u}]=\mathbb{P}1_n'\sigma^2/n=(\sigma^2/n, 0, 0, \ldots, 0).$$
Conclusion
This says that the estimated coefficients $\hat{\beta_i}$ and the mean error $\hat{u}$ are uncorrelated for $i=1, 2, \ldots, p$, but not so for $\hat{\beta_0}$ (the intercept).
It is instructive to review the steps and consider which assumptions were essential and which elements of the regression apparatus simply did not appear in the demonstration. We should expect any proof, no matter how elementary or sophisticated, will need to use the same (or stronger) assumptions and will need, in some guise or another, to include calculations of $\mathbb{P}1_n'$ and $\mathbb{E}[u\bar{u}]$. | How do I show that $(\hat{\beta_1}-\beta_1)$ and $ \bar{u}$ are uncorrelated, i.e. that $E[(\hat{\be
Strategy
It can be illuminating to move back and forth among three points of view: the statistical one (viewing $x_i$ and $y_i$ as data), a geometrical one (where least squares solutions are just proj |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.