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 |
|---|---|---|---|---|---|---|
38,801 | How to build an "equilibrated histogram"? | To follow up on @mbq's suggestion, here's the code to do that with R:
require(Hmisc)
x <- c(-2.153, -1.732, -1.699, -1.559, -1.355
, -1.306, -1.151, -1.129, -0.636, 0.4085
, 0.5408, 0.5731, 0.5842, 0.6206, 0.8175
, 0.8274, 0.8710, 1.3214, 1.5552, 2.2342
)
eqBins <- cut2(x, g = 4)
#what are the bins and how many in each?
> as.data.frame(table(eqBins))
eqBins Freq
1 [-2.153,-1.306) 5
2 [-1.306, 0.541) 5
3 [ 0.541, 0.827) 5
4 [ 0.827, 2.234] 5 | How to build an "equilibrated histogram"? | To follow up on @mbq's suggestion, here's the code to do that with R:
require(Hmisc)
x <- c(-2.153, -1.732, -1.699, -1.559, -1.355
, -1.306, -1.151, -1.129, -0.636, 0.4085
, 0.5408, 0.5731, 0.5842, 0 | How to build an "equilibrated histogram"?
To follow up on @mbq's suggestion, here's the code to do that with R:
require(Hmisc)
x <- c(-2.153, -1.732, -1.699, -1.559, -1.355
, -1.306, -1.151, -1.129, -0.636, 0.4085
, 0.5408, 0.5731, 0.5842, 0.6206, 0.8175
, 0.8274, 0.8710, 1.3214, 1.5552, 2.2342
)
eqBins <- cut2(x, g = 4)
#what are the bins and how many in each?
> as.data.frame(table(eqBins))
eqBins Freq
1 [-2.153,-1.306) 5
2 [-1.306, 0.541) 5
3 [ 0.541, 0.827) 5
4 [ 0.827, 2.234] 5 | How to build an "equilibrated histogram"?
To follow up on @mbq's suggestion, here's the code to do that with R:
require(Hmisc)
x <- c(-2.153, -1.732, -1.699, -1.559, -1.355
, -1.306, -1.151, -1.129, -0.636, 0.4085
, 0.5408, 0.5731, 0.5842, 0 |
38,802 | How to build an "equilibrated histogram"? | You are looking for quantiles; in R there is a function quantile that will calculate them for you; Hmisc R package provides cut2 function which explicitly calculates such "equilibrated bins". | How to build an "equilibrated histogram"? | You are looking for quantiles; in R there is a function quantile that will calculate them for you; Hmisc R package provides cut2 function which explicitly calculates such "equilibrated bins". | How to build an "equilibrated histogram"?
You are looking for quantiles; in R there is a function quantile that will calculate them for you; Hmisc R package provides cut2 function which explicitly calculates such "equilibrated bins". | How to build an "equilibrated histogram"?
You are looking for quantiles; in R there is a function quantile that will calculate them for you; Hmisc R package provides cut2 function which explicitly calculates such "equilibrated bins". |
38,803 | How to build an "equilibrated histogram"? | There's a histogram here, with R code that does approximately equal counts using the quantile function.
There's also the histogram function in the lattice package that comes with R. Compare:
library("lattice")
histogram(islands^(1/4)) # equal width
histogram(islands^(1/4),breaks=NULL,equal.widths=FALSE) # approx. equal area | How to build an "equilibrated histogram"? | There's a histogram here, with R code that does approximately equal counts using the quantile function.
There's also the histogram function in the lattice package that comes with R. Compare:
library(" | How to build an "equilibrated histogram"?
There's a histogram here, with R code that does approximately equal counts using the quantile function.
There's also the histogram function in the lattice package that comes with R. Compare:
library("lattice")
histogram(islands^(1/4)) # equal width
histogram(islands^(1/4),breaks=NULL,equal.widths=FALSE) # approx. equal area | How to build an "equilibrated histogram"?
There's a histogram here, with R code that does approximately equal counts using the quantile function.
There's also the histogram function in the lattice package that comes with R. Compare:
library(" |
38,804 | Using weighted regression to obtain fit lines for which I only have summary data | Weight each mean by the number of points that went into computing it. You can later use the estimated standard deviations to test the hypothesis of homoscedasticity that this approach assumes. If the Ns are as small as in your example then this test probably wouldn't have much power unless the SDs vary greatly. | Using weighted regression to obtain fit lines for which I only have summary data | Weight each mean by the number of points that went into computing it. You can later use the estimated standard deviations to test the hypothesis of homoscedasticity that this approach assumes. If the | Using weighted regression to obtain fit lines for which I only have summary data
Weight each mean by the number of points that went into computing it. You can later use the estimated standard deviations to test the hypothesis of homoscedasticity that this approach assumes. If the Ns are as small as in your example then this test probably wouldn't have much power unless the SDs vary greatly. | Using weighted regression to obtain fit lines for which I only have summary data
Weight each mean by the number of points that went into computing it. You can later use the estimated standard deviations to test the hypothesis of homoscedasticity that this approach assumes. If the |
38,805 | Using weighted regression to obtain fit lines for which I only have summary data | This is Analysis of Variance.
After all, consider one of the $y$'s, with standard deviation $s$, and let its predicted value (which depends on the corresponding $x$) be $f$. The original aim is to vary $f$ (within constraints depending on the model; often $f$ is required to be a linear function of $x$) to minimize the sum of squared residuals. Suppose we had the original dataset available. Let the values summarized by a particular $y$ be $y_1, y_2, \ldots, y_k$, so that $y$ is their mean and $s$ is their standard deviation. Their contribution to the sum of squares of residuals equals
$$\sum_{i=1}^k{\left( y_i - f \right)^2} = k \left(y - f \right)^2 + k' s^2 \text{.}$$
(I have written $k'$ because its value depends on how you compute your standard deviations: it is $k$ for one convention and $k-1$ for another.) Because the last term does not depend on $f$, it does not affect the minimization: we can neglect it.
The other term on the right hand side shows that you want to perform a weighted least squares calculation with weights equal to the counts $k$ (the "N_Y" column of the data). Equivalently, you can create a synthetic dataset by making $N_Y$ copies of each datum $(X,Y)$ and performing ordinary least squares regression.
Note that this analysis presumes nothing about the form of the prediction function: it can include any explanatory variables you like and have any form, even nonlinear ones.
Note also that the weighting does not depend on the standard deviations. This is because implicitly we have assumed that the variance of the y's is constant, so that all of the differences among the observed standard deviations are attributed to random fluctuations. This hypothesis can be tested in the usual ways (e.g., with F-tests). For the example data it holds up: those standard deviations do not vary significantly.
Edit
I see, in retrospect, that this answer merely reiterates @onestop's pithy response. I'm leaving it up because it demonstrates why @onestop is correct. | Using weighted regression to obtain fit lines for which I only have summary data | This is Analysis of Variance.
After all, consider one of the $y$'s, with standard deviation $s$, and let its predicted value (which depends on the corresponding $x$) be $f$. The original aim is to va | Using weighted regression to obtain fit lines for which I only have summary data
This is Analysis of Variance.
After all, consider one of the $y$'s, with standard deviation $s$, and let its predicted value (which depends on the corresponding $x$) be $f$. The original aim is to vary $f$ (within constraints depending on the model; often $f$ is required to be a linear function of $x$) to minimize the sum of squared residuals. Suppose we had the original dataset available. Let the values summarized by a particular $y$ be $y_1, y_2, \ldots, y_k$, so that $y$ is their mean and $s$ is their standard deviation. Their contribution to the sum of squares of residuals equals
$$\sum_{i=1}^k{\left( y_i - f \right)^2} = k \left(y - f \right)^2 + k' s^2 \text{.}$$
(I have written $k'$ because its value depends on how you compute your standard deviations: it is $k$ for one convention and $k-1$ for another.) Because the last term does not depend on $f$, it does not affect the minimization: we can neglect it.
The other term on the right hand side shows that you want to perform a weighted least squares calculation with weights equal to the counts $k$ (the "N_Y" column of the data). Equivalently, you can create a synthetic dataset by making $N_Y$ copies of each datum $(X,Y)$ and performing ordinary least squares regression.
Note that this analysis presumes nothing about the form of the prediction function: it can include any explanatory variables you like and have any form, even nonlinear ones.
Note also that the weighting does not depend on the standard deviations. This is because implicitly we have assumed that the variance of the y's is constant, so that all of the differences among the observed standard deviations are attributed to random fluctuations. This hypothesis can be tested in the usual ways (e.g., with F-tests). For the example data it holds up: those standard deviations do not vary significantly.
Edit
I see, in retrospect, that this answer merely reiterates @onestop's pithy response. I'm leaving it up because it demonstrates why @onestop is correct. | Using weighted regression to obtain fit lines for which I only have summary data
This is Analysis of Variance.
After all, consider one of the $y$'s, with standard deviation $s$, and let its predicted value (which depends on the corresponding $x$) be $f$. The original aim is to va |
38,806 | Using weighted regression to obtain fit lines for which I only have summary data | Let the disaggregrate model be:
$Y_{ia} = X_a \beta + \epsilon_i$
where
$\epsilon_i \sim N(0,\sigma^2)$
Your aggregate model is given by:
$Y_a = \frac{\sum_i(Y_{ia})}{n_a}$
where,
$n_a$ is the number of observations you have corresponding to the $a$ index.
Therefore, it follows that:
$Y_a = X_a \beta + \epsilon_a$
where
$\epsilon_a \sim N(0, \frac{\sigma^2}{n_a} )$ and
$a=1, 2, ... A$
Therefore, the OLS estimate would be given by minimizing:
$\sum_a(Y_a - X_a \beta)^2$
Which yields the usual solution. So, I do not think there is any difference as far as the estimate for the slope parameters are concerned.
Edit 1
Here is a small simulation in R which illustrates the above idea (apologies for the flaky code as I am using questions such as the above to learn R).
set.seed(1);
n <- c(4,2,8);
x <- c(1,2,3);
data <- matrix(0,14,2)
mean_data <- matrix(0,3,2)
index <- 1;
for (i in 1 : 3)
{
for(obs in 1:n[i])
{
data[index,1] <- x[i];
data[index,2] <- x[i]*8 + 1.5*rnorm(1);
mean_data[i,1] = x[i];
mean_data[i,2] = mean_data[i,2] + data[index,2];
index = index + 1;
}
mean_data[i,2] = mean_data[i,2] / n[i];
}
beta <- lm(mean_data[,2] ~ mean_data[,1]);
The above code yields the output when you type beta:
Call:
lm(formula = mean_data[, 2] ~ mean_data[, 1])
Coefficients:
(Intercept) mean_data[, 1]
-0.03455 7.99326
Edit 2
However, OLS is not efficient as error variances are not equal. Thus, using MLE ideas, we need to minimize:
$\sum_a{n_a (Y_a - X_a \beta)^2}$
In other words, we want to minimize:
$\sum_a{(\sqrt{n_a} Y_a - \sqrt{n_a} X_a \beta)^2}$
Thus, the MLE can be written as follows:
Let $W$ be a diagonal matrix with the $\sqrt{n_a}$ along the diagonal. Thus, the MLE estimate can be written as:
$(X' X)^{-1} X' Y$
where,
$Y = W [Y_1,Y_2,...Y_A]'$ and
$X = W [X_1,X_2,...X_A]'$
Another way to think about this is:
Consider the variance of $Y$. The transformation given above for $Y$ ensures that the variance of the individual values of $Y$ are identical thus satisfying the conditions of the Gauss-Markov theorem that OLS is BLUE. | Using weighted regression to obtain fit lines for which I only have summary data | Let the disaggregrate model be:
$Y_{ia} = X_a \beta + \epsilon_i$
where
$\epsilon_i \sim N(0,\sigma^2)$
Your aggregate model is given by:
$Y_a = \frac{\sum_i(Y_{ia})}{n_a}$
where,
$n_a$ is the number | Using weighted regression to obtain fit lines for which I only have summary data
Let the disaggregrate model be:
$Y_{ia} = X_a \beta + \epsilon_i$
where
$\epsilon_i \sim N(0,\sigma^2)$
Your aggregate model is given by:
$Y_a = \frac{\sum_i(Y_{ia})}{n_a}$
where,
$n_a$ is the number of observations you have corresponding to the $a$ index.
Therefore, it follows that:
$Y_a = X_a \beta + \epsilon_a$
where
$\epsilon_a \sim N(0, \frac{\sigma^2}{n_a} )$ and
$a=1, 2, ... A$
Therefore, the OLS estimate would be given by minimizing:
$\sum_a(Y_a - X_a \beta)^2$
Which yields the usual solution. So, I do not think there is any difference as far as the estimate for the slope parameters are concerned.
Edit 1
Here is a small simulation in R which illustrates the above idea (apologies for the flaky code as I am using questions such as the above to learn R).
set.seed(1);
n <- c(4,2,8);
x <- c(1,2,3);
data <- matrix(0,14,2)
mean_data <- matrix(0,3,2)
index <- 1;
for (i in 1 : 3)
{
for(obs in 1:n[i])
{
data[index,1] <- x[i];
data[index,2] <- x[i]*8 + 1.5*rnorm(1);
mean_data[i,1] = x[i];
mean_data[i,2] = mean_data[i,2] + data[index,2];
index = index + 1;
}
mean_data[i,2] = mean_data[i,2] / n[i];
}
beta <- lm(mean_data[,2] ~ mean_data[,1]);
The above code yields the output when you type beta:
Call:
lm(formula = mean_data[, 2] ~ mean_data[, 1])
Coefficients:
(Intercept) mean_data[, 1]
-0.03455 7.99326
Edit 2
However, OLS is not efficient as error variances are not equal. Thus, using MLE ideas, we need to minimize:
$\sum_a{n_a (Y_a - X_a \beta)^2}$
In other words, we want to minimize:
$\sum_a{(\sqrt{n_a} Y_a - \sqrt{n_a} X_a \beta)^2}$
Thus, the MLE can be written as follows:
Let $W$ be a diagonal matrix with the $\sqrt{n_a}$ along the diagonal. Thus, the MLE estimate can be written as:
$(X' X)^{-1} X' Y$
where,
$Y = W [Y_1,Y_2,...Y_A]'$ and
$X = W [X_1,X_2,...X_A]'$
Another way to think about this is:
Consider the variance of $Y$. The transformation given above for $Y$ ensures that the variance of the individual values of $Y$ are identical thus satisfying the conditions of the Gauss-Markov theorem that OLS is BLUE. | Using weighted regression to obtain fit lines for which I only have summary data
Let the disaggregrate model be:
$Y_{ia} = X_a \beta + \epsilon_i$
where
$\epsilon_i \sim N(0,\sigma^2)$
Your aggregate model is given by:
$Y_a = \frac{\sum_i(Y_{ia})}{n_a}$
where,
$n_a$ is the number |
38,807 | Using weighted regression to obtain fit lines for which I only have summary data | I think I would calculate normalized variables (z=(x-mean(x))/(sd(x)), and run the regression. Or you could work out a way to generate samples in a bootstrap. I'm not shure if this would be the textbook solution, but intuitively it should work. | Using weighted regression to obtain fit lines for which I only have summary data | I think I would calculate normalized variables (z=(x-mean(x))/(sd(x)), and run the regression. Or you could work out a way to generate samples in a bootstrap. I'm not shure if this would be the textbo | Using weighted regression to obtain fit lines for which I only have summary data
I think I would calculate normalized variables (z=(x-mean(x))/(sd(x)), and run the regression. Or you could work out a way to generate samples in a bootstrap. I'm not shure if this would be the textbook solution, but intuitively it should work. | Using weighted regression to obtain fit lines for which I only have summary data
I think I would calculate normalized variables (z=(x-mean(x))/(sd(x)), and run the regression. Or you could work out a way to generate samples in a bootstrap. I'm not shure if this would be the textbo |
38,808 | Does the concordance correlation coefficient make linearity or monotone assumptions? | The concordance correlation can be thought of as a measure of agreement. The question is: do two variables $x$ and $y$ (say) have identical values? If so, the concordance correlation will be 1. The question makes no sense unless the variables have the same units of measurement or more generally are recorded in the same way.
You can calculate a concordance correlation for any variables you like, but the answer will be of no use unless your question is about agreement. You could have a deterministic relation $y = \sin x$, but concordance between $y$ and $x$ will be a meaningless number, if only because concordance correlation does not adjust for different units.
For an informal introduction to this area, see
Cox, N.J. 2006. Assessing agreement of measurements and predictions in geomorphology. Geomorphology 76: 332-346. http://www.sciencedirect.com/science/article/pii/S0169555X05003740
Here "in geomorphology" indicates the field of the examples, not a restriction of statistical scope. | Does the concordance correlation coefficient make linearity or monotone assumptions? | The concordance correlation can be thought of as a measure of agreement. The question is: do two variables $x$ and $y$ (say) have identical values? If so, the concordance correlation will be 1. The qu | Does the concordance correlation coefficient make linearity or monotone assumptions?
The concordance correlation can be thought of as a measure of agreement. The question is: do two variables $x$ and $y$ (say) have identical values? If so, the concordance correlation will be 1. The question makes no sense unless the variables have the same units of measurement or more generally are recorded in the same way.
You can calculate a concordance correlation for any variables you like, but the answer will be of no use unless your question is about agreement. You could have a deterministic relation $y = \sin x$, but concordance between $y$ and $x$ will be a meaningless number, if only because concordance correlation does not adjust for different units.
For an informal introduction to this area, see
Cox, N.J. 2006. Assessing agreement of measurements and predictions in geomorphology. Geomorphology 76: 332-346. http://www.sciencedirect.com/science/article/pii/S0169555X05003740
Here "in geomorphology" indicates the field of the examples, not a restriction of statistical scope. | Does the concordance correlation coefficient make linearity or monotone assumptions?
The concordance correlation can be thought of as a measure of agreement. The question is: do two variables $x$ and $y$ (say) have identical values? If so, the concordance correlation will be 1. The qu |
38,809 | Does the concordance correlation coefficient make linearity or monotone assumptions? | This statistic measures a kind of correlation between two sets of data. Its calculation requires no assumptions about what their scatterplot looks like (if that's what you mean by "tendency"). | Does the concordance correlation coefficient make linearity or monotone assumptions? | This statistic measures a kind of correlation between two sets of data. Its calculation requires no assumptions about what their scatterplot looks like (if that's what you mean by "tendency"). | Does the concordance correlation coefficient make linearity or monotone assumptions?
This statistic measures a kind of correlation between two sets of data. Its calculation requires no assumptions about what their scatterplot looks like (if that's what you mean by "tendency"). | Does the concordance correlation coefficient make linearity or monotone assumptions?
This statistic measures a kind of correlation between two sets of data. Its calculation requires no assumptions about what their scatterplot looks like (if that's what you mean by "tendency"). |
38,810 | Does the concordance correlation coefficient make linearity or monotone assumptions? | If your data are a sample of pairs $(x_i,y_i)$ independently and identically distributed (according to some bivariate distribution); then the sample CCC is an estimate of the population CCC defined as
$$ \rho_c = \frac{2\sigma_{xy}}{\sigma_x^2+\sigma_y^2+(\mu_x-\mu_y)^2}$$ which:
equals $0$ when the covariance $\sigma_{xy}$ of the assumed bivariate distribution is $0$;
equals $1$ when $x_i=y_i$ almost surely. | Does the concordance correlation coefficient make linearity or monotone assumptions? | If your data are a sample of pairs $(x_i,y_i)$ independently and identically distributed (according to some bivariate distribution); then the sample CCC is an estimate of the population CCC defined as | Does the concordance correlation coefficient make linearity or monotone assumptions?
If your data are a sample of pairs $(x_i,y_i)$ independently and identically distributed (according to some bivariate distribution); then the sample CCC is an estimate of the population CCC defined as
$$ \rho_c = \frac{2\sigma_{xy}}{\sigma_x^2+\sigma_y^2+(\mu_x-\mu_y)^2}$$ which:
equals $0$ when the covariance $\sigma_{xy}$ of the assumed bivariate distribution is $0$;
equals $1$ when $x_i=y_i$ almost surely. | Does the concordance correlation coefficient make linearity or monotone assumptions?
If your data are a sample of pairs $(x_i,y_i)$ independently and identically distributed (according to some bivariate distribution); then the sample CCC is an estimate of the population CCC defined as |
38,811 | Why must a product of symmetric random variables be symmetric? | To say that a random variable $W$ "has a symmetric distribution around zero" is saying that $W$ and $-W$ have the same distribution.
Let $X$ be another random variable and set $Y=WX.$ By the rules of algebra, $-Y = -WX = (-W)X$ must have the same distribution as $WX$ provided $W$ and $X$ are independent. Therefore $Y$ is symmetric around zero.
To see why independence is a necessary assumption, let $(W,X)$ take on the values $(-1,0),$ $(-1,1),$ $(1,0),$ and $(1,1)$ with probabilities $1/3,1/6,1/6,$ and $1/3,$ respectively. Because $W$ has equal chance of being $\pm 1,$ it is symmetric around zero. ($X$ is symmetric about $1/2.$) But $Y=WX$ takes on the value $0$ with probability $1/3+1/6,$ the value $-1$ with probability $1/6,$ and the value $1$ with probability $1/3,$ and therefore is not symmetric at all.
$$\begin{array}{crrr}
& \Pr & W & X & Y \\
\hline
& \frac{1}{3} & -1 & 0 & 0\\
& \frac{1}{6} & -1 & 1 & -1\\
& \frac{1}{6} & 1 & 0 & 0\\
& \frac{1}{3} & 1 & 1 & 1
\end{array}$$ | Why must a product of symmetric random variables be symmetric? | To say that a random variable $W$ "has a symmetric distribution around zero" is saying that $W$ and $-W$ have the same distribution.
Let $X$ be another random variable and set $Y=WX.$ By the rules of | Why must a product of symmetric random variables be symmetric?
To say that a random variable $W$ "has a symmetric distribution around zero" is saying that $W$ and $-W$ have the same distribution.
Let $X$ be another random variable and set $Y=WX.$ By the rules of algebra, $-Y = -WX = (-W)X$ must have the same distribution as $WX$ provided $W$ and $X$ are independent. Therefore $Y$ is symmetric around zero.
To see why independence is a necessary assumption, let $(W,X)$ take on the values $(-1,0),$ $(-1,1),$ $(1,0),$ and $(1,1)$ with probabilities $1/3,1/6,1/6,$ and $1/3,$ respectively. Because $W$ has equal chance of being $\pm 1,$ it is symmetric around zero. ($X$ is symmetric about $1/2.$) But $Y=WX$ takes on the value $0$ with probability $1/3+1/6,$ the value $-1$ with probability $1/6,$ and the value $1$ with probability $1/3,$ and therefore is not symmetric at all.
$$\begin{array}{crrr}
& \Pr & W & X & Y \\
\hline
& \frac{1}{3} & -1 & 0 & 0\\
& \frac{1}{6} & -1 & 1 & -1\\
& \frac{1}{6} & 1 & 0 & 0\\
& \frac{1}{3} & 1 & 1 & 1
\end{array}$$ | Why must a product of symmetric random variables be symmetric?
To say that a random variable $W$ "has a symmetric distribution around zero" is saying that $W$ and $-W$ have the same distribution.
Let $X$ be another random variable and set $Y=WX.$ By the rules of |
38,812 | Why does R say 'cannot compute exact p-values with ties' when I can do it with pen and paper? | The wilcox.test from the standard stats library is limited to cases without ties because it uses an algorithm from the function pwilcox that assumes that there are no ties.
This algorithm is not your pen and paper solution which would become computation intensive for larger sample sizes.
The algorithm in pwilcox is not computing all possibilities, and instead it has a function that counts the number of possibilities for the tail. E.g. if the statistic $U$ which has the range $0$ to $n_1n_2$, had a value close to $0$, say $U = 4$ then we only compute the number of permutation that result in $U = 1$, $U = 2$, $U = 3$ and $U = 4$. The computations are done with iterations. This is faster than making all potential permutations and compute the statistic for each of those permutations.
The documentation of the wilcox.test function mentions that there are functions in other packages that can compute the exact test for the cases with ties.
'wilcox_test' in package coin for exact, asymptotic and Monte Carlo conditional p-values, including in the presence of ties.
The c-code of the algorithm behind the wilcox.test can be viewed on GitHub here: https://github.com/SurajGupta/r-source/blob/master/src/nmath/wilcox.c
An interesting related article might be (although I haven't read it myself because it is behind a paywall):
Bergmann, Reinhard, John Ludbrook, and Will PJM Spooren. "Different outcomes of the Wilcoxon—Mann—Whitney test from different statistics packages." The American Statistician 54.1 (2000): 72-77. | Why does R say 'cannot compute exact p-values with ties' when I can do it with pen and paper? | The wilcox.test from the standard stats library is limited to cases without ties because it uses an algorithm from the function pwilcox that assumes that there are no ties.
This algorithm is not your | Why does R say 'cannot compute exact p-values with ties' when I can do it with pen and paper?
The wilcox.test from the standard stats library is limited to cases without ties because it uses an algorithm from the function pwilcox that assumes that there are no ties.
This algorithm is not your pen and paper solution which would become computation intensive for larger sample sizes.
The algorithm in pwilcox is not computing all possibilities, and instead it has a function that counts the number of possibilities for the tail. E.g. if the statistic $U$ which has the range $0$ to $n_1n_2$, had a value close to $0$, say $U = 4$ then we only compute the number of permutation that result in $U = 1$, $U = 2$, $U = 3$ and $U = 4$. The computations are done with iterations. This is faster than making all potential permutations and compute the statistic for each of those permutations.
The documentation of the wilcox.test function mentions that there are functions in other packages that can compute the exact test for the cases with ties.
'wilcox_test' in package coin for exact, asymptotic and Monte Carlo conditional p-values, including in the presence of ties.
The c-code of the algorithm behind the wilcox.test can be viewed on GitHub here: https://github.com/SurajGupta/r-source/blob/master/src/nmath/wilcox.c
An interesting related article might be (although I haven't read it myself because it is behind a paywall):
Bergmann, Reinhard, John Ludbrook, and Will PJM Spooren. "Different outcomes of the Wilcoxon—Mann—Whitney test from different statistics packages." The American Statistician 54.1 (2000): 72-77. | Why does R say 'cannot compute exact p-values with ties' when I can do it with pen and paper?
The wilcox.test from the standard stats library is limited to cases without ties because it uses an algorithm from the function pwilcox that assumes that there are no ties.
This algorithm is not your |
38,813 | How can I generate random observations from a concrete copula? | Copulas are usually defined via the joint cdf of the Uniform components,
$$ C(u_1,u_2,\dots,u_d)=\mathbb P[U_1\leq u_1,U_2\leq u_2,\dots,U_d\leq u_d]$$
Unfortunately, a value $C(u_1,u_2,\dots,u_d)$ computed from a random realisation from $C$ is not a Uniform variate as in the univariate case.
In the bivariate case, simulation of $(U_1,U_2)$ could proceed by the conditional method:
generating $U_1\sim\mathcal U(0,1)$ [since the marginal is Uniform]
generating $U_2$ conditional on $U_1$
The second step will depend on the format of $C(u_1,u_2)$:
The conditional cdf of $U_2$ is given by$$F(u_2|u_1)=\frac{\partial C}{\partial u_1}(u_1,u_2)\Big/\frac{\partial C}{\partial u_1}(u_1,\infty)$$and the inverse cdf method can be used if inverting the above $F$ in $u_2$ is easily done
The conditional pdf of $U_2$ is given by$$f(u_2|u_1)\propto\frac{\partial^2 C}{\partial u_1\partial u_2}(u_1,u_2)$$and standard simulation techniques apply when this function is available.
Historically, Devroye (1986, Chapter XI) has two entire sections XI.3.2. and XI.3.3 on the topic (even though he does not use the term copula despite them being introduced in 1959 by A, Sklar, in response to a query of M. Fréchet). These sections contain many examples (as for instance the Table on page 585) but no generic simulation method. | How can I generate random observations from a concrete copula? | Copulas are usually defined via the joint cdf of the Uniform components,
$$ C(u_1,u_2,\dots,u_d)=\mathbb P[U_1\leq u_1,U_2\leq u_2,\dots,U_d\leq u_d]$$
Unfortunately, a value $C(u_1,u_2,\dots,u_d)$ co | How can I generate random observations from a concrete copula?
Copulas are usually defined via the joint cdf of the Uniform components,
$$ C(u_1,u_2,\dots,u_d)=\mathbb P[U_1\leq u_1,U_2\leq u_2,\dots,U_d\leq u_d]$$
Unfortunately, a value $C(u_1,u_2,\dots,u_d)$ computed from a random realisation from $C$ is not a Uniform variate as in the univariate case.
In the bivariate case, simulation of $(U_1,U_2)$ could proceed by the conditional method:
generating $U_1\sim\mathcal U(0,1)$ [since the marginal is Uniform]
generating $U_2$ conditional on $U_1$
The second step will depend on the format of $C(u_1,u_2)$:
The conditional cdf of $U_2$ is given by$$F(u_2|u_1)=\frac{\partial C}{\partial u_1}(u_1,u_2)\Big/\frac{\partial C}{\partial u_1}(u_1,\infty)$$and the inverse cdf method can be used if inverting the above $F$ in $u_2$ is easily done
The conditional pdf of $U_2$ is given by$$f(u_2|u_1)\propto\frac{\partial^2 C}{\partial u_1\partial u_2}(u_1,u_2)$$and standard simulation techniques apply when this function is available.
Historically, Devroye (1986, Chapter XI) has two entire sections XI.3.2. and XI.3.3 on the topic (even though he does not use the term copula despite them being introduced in 1959 by A, Sklar, in response to a query of M. Fréchet). These sections contain many examples (as for instance the Table on page 585) but no generic simulation method. | How can I generate random observations from a concrete copula?
Copulas are usually defined via the joint cdf of the Uniform components,
$$ C(u_1,u_2,\dots,u_d)=\mathbb P[U_1\leq u_1,U_2\leq u_2,\dots,U_d\leq u_d]$$
Unfortunately, a value $C(u_1,u_2,\dots,u_d)$ co |
38,814 | How can I generate random observations from a concrete copula? | A recipe for how to generate random observations depends on the level of detail. If you can generate from the copula, then you get points on $[0,1]\times [0,1]$. Then you transform the $X$ coordinate into $X$ and the $Y$ coordinate into $Y$ by using their respective inverse CDFs. | How can I generate random observations from a concrete copula? | A recipe for how to generate random observations depends on the level of detail. If you can generate from the copula, then you get points on $[0,1]\times [0,1]$. Then you transform the $X$ coordinate | How can I generate random observations from a concrete copula?
A recipe for how to generate random observations depends on the level of detail. If you can generate from the copula, then you get points on $[0,1]\times [0,1]$. Then you transform the $X$ coordinate into $X$ and the $Y$ coordinate into $Y$ by using their respective inverse CDFs. | How can I generate random observations from a concrete copula?
A recipe for how to generate random observations depends on the level of detail. If you can generate from the copula, then you get points on $[0,1]\times [0,1]$. Then you transform the $X$ coordinate |
38,815 | What is the reasoning behind expecting residuals in OLS regression to be normally distributed? | That author is writing nonsense. Just because errors are random doesn't mean that if you have a lot of them they will be normally distributed. It is absolutely not the case that OLS requires normally distributed residuals; its objective is "Least Squares", and minimizing the sum of squared deviations from the estimated values in no way requires any particular distribution for the residuals. See, for example, Regression when the OLS residuals are not normally distributed , and some of the associated questions linked to in comments.
It is true that if the underlying errors follow a Normal distribution, and are independent and identically distributed, then the OLS estimator is also the maximum likelihood estimator. But that in no way justifies the author's statement quoted in the original post.
Edit: For more, read @Glen_b's comment below. | What is the reasoning behind expecting residuals in OLS regression to be normally distributed? | That author is writing nonsense. Just because errors are random doesn't mean that if you have a lot of them they will be normally distributed. It is absolutely not the case that OLS requires normall | What is the reasoning behind expecting residuals in OLS regression to be normally distributed?
That author is writing nonsense. Just because errors are random doesn't mean that if you have a lot of them they will be normally distributed. It is absolutely not the case that OLS requires normally distributed residuals; its objective is "Least Squares", and minimizing the sum of squared deviations from the estimated values in no way requires any particular distribution for the residuals. See, for example, Regression when the OLS residuals are not normally distributed , and some of the associated questions linked to in comments.
It is true that if the underlying errors follow a Normal distribution, and are independent and identically distributed, then the OLS estimator is also the maximum likelihood estimator. But that in no way justifies the author's statement quoted in the original post.
Edit: For more, read @Glen_b's comment below. | What is the reasoning behind expecting residuals in OLS regression to be normally distributed?
That author is writing nonsense. Just because errors are random doesn't mean that if you have a lot of them they will be normally distributed. It is absolutely not the case that OLS requires normall |
38,816 | Posterior distribution is impossible depending on which prior hyperparameters are used? | Let's work through the steps. To begin with we have
\begin{equation}
p(\delta|\beta)\,p(\beta|\alpha)\,p(\alpha) ,
\end{equation}
where
\begin{align}
p(\delta|\beta) &= \textsf{Bernoulli}(\delta|\beta) \\
p(\beta|\alpha) &= \textsf{Beta}(\beta|a_\alpha,b_\alpha) \\
p(\alpha) &= \textsf{Bernoulli}(\alpha|\rho) .
\end{align}
Note that instead of indexing the parameter $\beta$ with $\alpha$ as in the question, I have indexed the hyperparameters $(a_\alpha,b_\alpha)$ of the beta distribution with $\alpha$.
Then
\begin{equation}
p(\delta|\alpha) = \int p(\delta|\beta)\,p(\beta|\alpha)\,d\beta = \textsf{Bernoulli}\Big(\delta\,\big|\,\frac{a_\alpha}{a_\alpha+b_\alpha}\Big) .
\end{equation}
Consequently,
\begin{equation}
p(\alpha|\delta) = \frac{p(\delta|\alpha)\,p(\alpha)}{p(\delta)} ,
%= \textsf{Bernoulli} \Big(\delta\,\big|\,\frac{a_\alpha}{a_\alpha+b_\alpha}\Big)\,\textsf{Bernoulli}(\alpha|\rho)
\end{equation}
where
\begin{equation}
p(\delta) = \sum_{\alpha\in\{0,1\}} p(\delta|\alpha)\,p(\alpha) .
\end{equation}
Dividing by $p(\delta)$ guarantees the probabilities for $\alpha$ sum to one without any special restrictions on the hyperparameters.
Here is some additional detail:
\begin{equation}
p(\delta|\alpha)\,p(\alpha) = \left(\frac{a_\alpha}{a_\alpha+b_\alpha}\right)^\delta \left(\frac{b_\alpha}{a_\alpha+b_\alpha}\right)^{1-\delta} \rho^\alpha\,(1-\rho)^{1-\alpha} .
\end{equation} | Posterior distribution is impossible depending on which prior hyperparameters are used? | Let's work through the steps. To begin with we have
\begin{equation}
p(\delta|\beta)\,p(\beta|\alpha)\,p(\alpha) ,
\end{equation}
where
\begin{align}
p(\delta|\beta) &= \textsf{Bernoulli}(\delta|\beta | Posterior distribution is impossible depending on which prior hyperparameters are used?
Let's work through the steps. To begin with we have
\begin{equation}
p(\delta|\beta)\,p(\beta|\alpha)\,p(\alpha) ,
\end{equation}
where
\begin{align}
p(\delta|\beta) &= \textsf{Bernoulli}(\delta|\beta) \\
p(\beta|\alpha) &= \textsf{Beta}(\beta|a_\alpha,b_\alpha) \\
p(\alpha) &= \textsf{Bernoulli}(\alpha|\rho) .
\end{align}
Note that instead of indexing the parameter $\beta$ with $\alpha$ as in the question, I have indexed the hyperparameters $(a_\alpha,b_\alpha)$ of the beta distribution with $\alpha$.
Then
\begin{equation}
p(\delta|\alpha) = \int p(\delta|\beta)\,p(\beta|\alpha)\,d\beta = \textsf{Bernoulli}\Big(\delta\,\big|\,\frac{a_\alpha}{a_\alpha+b_\alpha}\Big) .
\end{equation}
Consequently,
\begin{equation}
p(\alpha|\delta) = \frac{p(\delta|\alpha)\,p(\alpha)}{p(\delta)} ,
%= \textsf{Bernoulli} \Big(\delta\,\big|\,\frac{a_\alpha}{a_\alpha+b_\alpha}\Big)\,\textsf{Bernoulli}(\alpha|\rho)
\end{equation}
where
\begin{equation}
p(\delta) = \sum_{\alpha\in\{0,1\}} p(\delta|\alpha)\,p(\alpha) .
\end{equation}
Dividing by $p(\delta)$ guarantees the probabilities for $\alpha$ sum to one without any special restrictions on the hyperparameters.
Here is some additional detail:
\begin{equation}
p(\delta|\alpha)\,p(\alpha) = \left(\frac{a_\alpha}{a_\alpha+b_\alpha}\right)^\delta \left(\frac{b_\alpha}{a_\alpha+b_\alpha}\right)^{1-\delta} \rho^\alpha\,(1-\rho)^{1-\alpha} .
\end{equation} | Posterior distribution is impossible depending on which prior hyperparameters are used?
Let's work through the steps. To begin with we have
\begin{equation}
p(\delta|\beta)\,p(\beta|\alpha)\,p(\alpha) ,
\end{equation}
where
\begin{align}
p(\delta|\beta) &= \textsf{Bernoulli}(\delta|\beta |
38,817 | Posterior distribution is impossible depending on which prior hyperparameters are used? | The distribution you are describing is a mixture of Bernoulli distributions with the likelihood function
$$
p(\delta|\rho,\beta_0,\beta_1) = \rho \, \beta_0^{\delta} (1-\beta_0)^{1-\delta} + (1 - \rho) \, \beta_1^{\delta} (1-\beta_1)^{1-\delta}
$$
It does not have a closed-form solution, you need to use an optimization algorithm like E-M for maximum a posteriori solution, MCMC for Monte Carlo approximation of the posterior, or other approach. | Posterior distribution is impossible depending on which prior hyperparameters are used? | The distribution you are describing is a mixture of Bernoulli distributions with the likelihood function
$$
p(\delta|\rho,\beta_0,\beta_1) = \rho \, \beta_0^{\delta} (1-\beta_0)^{1-\delta} + (1 - \rho | Posterior distribution is impossible depending on which prior hyperparameters are used?
The distribution you are describing is a mixture of Bernoulli distributions with the likelihood function
$$
p(\delta|\rho,\beta_0,\beta_1) = \rho \, \beta_0^{\delta} (1-\beta_0)^{1-\delta} + (1 - \rho) \, \beta_1^{\delta} (1-\beta_1)^{1-\delta}
$$
It does not have a closed-form solution, you need to use an optimization algorithm like E-M for maximum a posteriori solution, MCMC for Monte Carlo approximation of the posterior, or other approach. | Posterior distribution is impossible depending on which prior hyperparameters are used?
The distribution you are describing is a mixture of Bernoulli distributions with the likelihood function
$$
p(\delta|\rho,\beta_0,\beta_1) = \rho \, \beta_0^{\delta} (1-\beta_0)^{1-\delta} + (1 - \rho |
38,818 | Does $Cov(X,Y)<0$ and $Cov(X,Z)>0$ imply $Cov(Y,Z)<0$? | If the correlations between the three variables are $a$, $b$ and $c$, the eigenvalues of the correlation matrix satisfies
$$
\left|\begin{matrix}
1-\lambda & a & c \\
a & 1-\lambda & b \\
c & b & 1-\lambda
\end{matrix}\right|=0
$$
which after some algebra simplifies to
$$
(1-\lambda)^3 - (1-\lambda)(a^2+b^2+c^2)+2abc=0.
$$
For given values of $a$ and $b$, the correlation matrix is positive semi-definite when $c$ lies in a closed interval. At the endpoints of this interval, one of the eigenvalues are zero implying that
$$
1-a^2-b^2-c^2+2abc=0.
$$
Solving this quadratic equation for $c$, we find that the endpoints of the interval of possible values of $c$ (plotted below) for given values of $a$ and $b$ are
$$
ab\pm \sqrt{(a^2-1)(b^2-1)}.
$$
If $a$ and $b$ are of opposite sign, the whole interval for $c$ thus contains only negative values if
$$
ab+\sqrt{(a^2-1)(b^2-1)}<0.
$$
Moving $ab$ to the right hands side and squaring both sides yields
$$
(a^2-1)(b^2-1)<a^2b^2
$$
which simplifies to the condition
$$
1<a^2+b^2.
\newcommand{corr}{\operatorname{corr}}
$$
Thus, to summarise, if $a=\corr(X,Y)$ and $b=\corr(X,Z)$ are of opposite signs and $(a,b)$ lies outside the unit circle, then $c=\corr(Y,Z)$ is necessarily negative. | Does $Cov(X,Y)<0$ and $Cov(X,Z)>0$ imply $Cov(Y,Z)<0$? | If the correlations between the three variables are $a$, $b$ and $c$, the eigenvalues of the correlation matrix satisfies
$$
\left|\begin{matrix}
1-\lambda & a & c \\
a & 1-\lambda & b \\
c & b & 1-\l | Does $Cov(X,Y)<0$ and $Cov(X,Z)>0$ imply $Cov(Y,Z)<0$?
If the correlations between the three variables are $a$, $b$ and $c$, the eigenvalues of the correlation matrix satisfies
$$
\left|\begin{matrix}
1-\lambda & a & c \\
a & 1-\lambda & b \\
c & b & 1-\lambda
\end{matrix}\right|=0
$$
which after some algebra simplifies to
$$
(1-\lambda)^3 - (1-\lambda)(a^2+b^2+c^2)+2abc=0.
$$
For given values of $a$ and $b$, the correlation matrix is positive semi-definite when $c$ lies in a closed interval. At the endpoints of this interval, one of the eigenvalues are zero implying that
$$
1-a^2-b^2-c^2+2abc=0.
$$
Solving this quadratic equation for $c$, we find that the endpoints of the interval of possible values of $c$ (plotted below) for given values of $a$ and $b$ are
$$
ab\pm \sqrt{(a^2-1)(b^2-1)}.
$$
If $a$ and $b$ are of opposite sign, the whole interval for $c$ thus contains only negative values if
$$
ab+\sqrt{(a^2-1)(b^2-1)}<0.
$$
Moving $ab$ to the right hands side and squaring both sides yields
$$
(a^2-1)(b^2-1)<a^2b^2
$$
which simplifies to the condition
$$
1<a^2+b^2.
\newcommand{corr}{\operatorname{corr}}
$$
Thus, to summarise, if $a=\corr(X,Y)$ and $b=\corr(X,Z)$ are of opposite signs and $(a,b)$ lies outside the unit circle, then $c=\corr(Y,Z)$ is necessarily negative. | Does $Cov(X,Y)<0$ and $Cov(X,Z)>0$ imply $Cov(Y,Z)<0$?
If the correlations between the three variables are $a$, $b$ and $c$, the eigenvalues of the correlation matrix satisfies
$$
\left|\begin{matrix}
1-\lambda & a & c \\
a & 1-\lambda & b \\
c & b & 1-\l |
38,819 | Does $Cov(X,Y)<0$ and $Cov(X,Z)>0$ imply $Cov(Y,Z)<0$? | No (to the title question). Any positive semi-definite matrix is also a covariance matrix. So, if there exists a $\rho$ that the following matrix is PSD, then you've a contradiction:
$$\Sigma=\begin{bmatrix}1&-\rho&\rho\\-\rho &1&\rho\\\rho&\rho&1\end{bmatrix}$$
This occurs for $\rho=0.1$ for example. The conditions on when it implies are correctly laid out in Jarle’s answer. | Does $Cov(X,Y)<0$ and $Cov(X,Z)>0$ imply $Cov(Y,Z)<0$? | No (to the title question). Any positive semi-definite matrix is also a covariance matrix. So, if there exists a $\rho$ that the following matrix is PSD, then you've a contradiction:
$$\Sigma=\begin{b | Does $Cov(X,Y)<0$ and $Cov(X,Z)>0$ imply $Cov(Y,Z)<0$?
No (to the title question). Any positive semi-definite matrix is also a covariance matrix. So, if there exists a $\rho$ that the following matrix is PSD, then you've a contradiction:
$$\Sigma=\begin{bmatrix}1&-\rho&\rho\\-\rho &1&\rho\\\rho&\rho&1\end{bmatrix}$$
This occurs for $\rho=0.1$ for example. The conditions on when it implies are correctly laid out in Jarle’s answer. | Does $Cov(X,Y)<0$ and $Cov(X,Z)>0$ imply $Cov(Y,Z)<0$?
No (to the title question). Any positive semi-definite matrix is also a covariance matrix. So, if there exists a $\rho$ that the following matrix is PSD, then you've a contradiction:
$$\Sigma=\begin{b |
38,820 | Is it possible to take the mean of a time series when it is not stationary? | I think you are operating under some faulty assumptions here. Regardless of stationarity, it is always possible to compute the sample mean of a set of data, and if you only want to know this sample mean then there is no inference problem to begin with. Stationarity of the time-series only becomes an issue when you want to use the sample mean or other statistics to help you make inferences about some broader unknown aspect of the series (e.g., its long-term mean, trend, etc.). In this latter case, non-stationarity causes difficulties with the inference, but if you just want to know the sample mean over the observation period then there is no inference problem at all.
(Also, your notation for the sample mean is unusual here. The sample mean here would be denoted as $\bar{x}_T = \tfrac{1}{T} \sum_{i=1}^T x_i$. We only use the notation $\hat{\mu}$ when we are using the sample mean as an estimator of a parameter $\mu$, which is apparently not what you want to do.) | Is it possible to take the mean of a time series when it is not stationary? | I think you are operating under some faulty assumptions here. Regardless of stationarity, it is always possible to compute the sample mean of a set of data, and if you only want to know this sample m | Is it possible to take the mean of a time series when it is not stationary?
I think you are operating under some faulty assumptions here. Regardless of stationarity, it is always possible to compute the sample mean of a set of data, and if you only want to know this sample mean then there is no inference problem to begin with. Stationarity of the time-series only becomes an issue when you want to use the sample mean or other statistics to help you make inferences about some broader unknown aspect of the series (e.g., its long-term mean, trend, etc.). In this latter case, non-stationarity causes difficulties with the inference, but if you just want to know the sample mean over the observation period then there is no inference problem at all.
(Also, your notation for the sample mean is unusual here. The sample mean here would be denoted as $\bar{x}_T = \tfrac{1}{T} \sum_{i=1}^T x_i$. We only use the notation $\hat{\mu}$ when we are using the sample mean as an estimator of a parameter $\mu$, which is apparently not what you want to do.) | Is it possible to take the mean of a time series when it is not stationary?
I think you are operating under some faulty assumptions here. Regardless of stationarity, it is always possible to compute the sample mean of a set of data, and if you only want to know this sample m |
38,821 | Do you do linear regression in logistic regression? | The simplest way of likening logistic regression to standard linear regression is using the latent variable interpretation. The logistic regression model can be described by considering the observable responses:
$$Y_i = \mathbb{I}(Y_i^* > 0),$$
based on the unobservable latent variables:
$$Y_i^* = \beta_0 + \beta_1 x_{i,1} + \cdots + \beta_m x_{i,m} + \varepsilon_i
\quad \quad \quad \varepsilon_1, ... \varepsilon_n \sim \text{IID Logistic}(0, s).$$
As you can see, in this model form the latent response variable follows a linear regression model with an error term that has a logistic distribution. We observe whether the latent response variable is above zero or not, but we do not observe its actual value. For estimation purposes, this manifests in a substantial difference in estimating the coefficients in the model. We do not estimate using OLS estimation, so this is not "just like multiple linear regression". Nevertheless, we do indeed get estimated coefficients and this does get us an estimated function for the conditional probability of the response outcome, so there are certainly similarities. | Do you do linear regression in logistic regression? | The simplest way of likening logistic regression to standard linear regression is using the latent variable interpretation. The logistic regression model can be described by considering the observabl | Do you do linear regression in logistic regression?
The simplest way of likening logistic regression to standard linear regression is using the latent variable interpretation. The logistic regression model can be described by considering the observable responses:
$$Y_i = \mathbb{I}(Y_i^* > 0),$$
based on the unobservable latent variables:
$$Y_i^* = \beta_0 + \beta_1 x_{i,1} + \cdots + \beta_m x_{i,m} + \varepsilon_i
\quad \quad \quad \varepsilon_1, ... \varepsilon_n \sim \text{IID Logistic}(0, s).$$
As you can see, in this model form the latent response variable follows a linear regression model with an error term that has a logistic distribution. We observe whether the latent response variable is above zero or not, but we do not observe its actual value. For estimation purposes, this manifests in a substantial difference in estimating the coefficients in the model. We do not estimate using OLS estimation, so this is not "just like multiple linear regression". Nevertheless, we do indeed get estimated coefficients and this does get us an estimated function for the conditional probability of the response outcome, so there are certainly similarities. | Do you do linear regression in logistic regression?
The simplest way of likening logistic regression to standard linear regression is using the latent variable interpretation. The logistic regression model can be described by considering the observabl |
38,822 | Do you do linear regression in logistic regression? | No, it is not done like this. Quoting my other answer
Logistic regression can be described as a linear combination
$$ \eta = \beta_0 + \beta_1 X_1 + ... + \beta_k X_k $$
that is passed through the link function $g$:
$$ g(E(Y)) = \eta $$
where the link function is a logit function
$$ E(Y|X,\beta) = p = \text{logit}^{-1}( \eta ) $$
As you can see, the linear predictor $\eta = \mathbf{X}\boldsymbol{\beta}$ is not equal to the conditional mean of $y$, but you need to transform it first using the inverse of the logit link function $g^{-1}(\eta)$. If you just ran the linear regression, you would be ignoring the fact that the transformation of the linear predictor happens.
You can easily verify this yourself, run linear and logistic regression on the same data. If using linear regression would be enough, you should get the same regression parameters. As you can see from the example below, that's not the case.
> lm(vs~mpg+cyl, data=mtcars)
Call:
lm(formula = vs ~ mpg + cyl, data = mtcars)
Coefficients:
(Intercept) mpg cyl
2.164638 -0.008217 -0.252454
> glm(vs~mpg+cyl, family=binomial, data=mtcars)
Call: glm(formula = vs ~ mpg + cyl, family = binomial, data = mtcars)
Coefficients:
(Intercept) mpg cyl
15.9714 -0.1633 -2.1482
Degrees of Freedom: 31 Total (i.e. Null); 29 Residual
Null Deviance: 43.86
Residual Deviance: 17.49 AIC: 23.49
Logistic regression is fitted by using an optimization algorithm that maximizes the likelihood function. The likelihood function is defined in terms of Bernoulli distribution:
$$
L(\boldsymbol{\beta}|y;\mathbf{X}) = \prod_i\, g^{-1}(\mathbf{X}_i\boldsymbol{\beta})^{y_i} \, (1 - g^{-1}(\mathbf{X}_i\boldsymbol{\beta}))^{1-y_i}
$$
Commonly IRLS algorithm is used for finding the maximum of this function, but you probably could ignore this fact and live a happy life without that knowledge. | Do you do linear regression in logistic regression? | No, it is not done like this. Quoting my other answer
Logistic regression can be described as a linear combination
$$ \eta = \beta_0 + \beta_1 X_1 + ... + \beta_k X_k $$
that is passed through the li | Do you do linear regression in logistic regression?
No, it is not done like this. Quoting my other answer
Logistic regression can be described as a linear combination
$$ \eta = \beta_0 + \beta_1 X_1 + ... + \beta_k X_k $$
that is passed through the link function $g$:
$$ g(E(Y)) = \eta $$
where the link function is a logit function
$$ E(Y|X,\beta) = p = \text{logit}^{-1}( \eta ) $$
As you can see, the linear predictor $\eta = \mathbf{X}\boldsymbol{\beta}$ is not equal to the conditional mean of $y$, but you need to transform it first using the inverse of the logit link function $g^{-1}(\eta)$. If you just ran the linear regression, you would be ignoring the fact that the transformation of the linear predictor happens.
You can easily verify this yourself, run linear and logistic regression on the same data. If using linear regression would be enough, you should get the same regression parameters. As you can see from the example below, that's not the case.
> lm(vs~mpg+cyl, data=mtcars)
Call:
lm(formula = vs ~ mpg + cyl, data = mtcars)
Coefficients:
(Intercept) mpg cyl
2.164638 -0.008217 -0.252454
> glm(vs~mpg+cyl, family=binomial, data=mtcars)
Call: glm(formula = vs ~ mpg + cyl, family = binomial, data = mtcars)
Coefficients:
(Intercept) mpg cyl
15.9714 -0.1633 -2.1482
Degrees of Freedom: 31 Total (i.e. Null); 29 Residual
Null Deviance: 43.86
Residual Deviance: 17.49 AIC: 23.49
Logistic regression is fitted by using an optimization algorithm that maximizes the likelihood function. The likelihood function is defined in terms of Bernoulli distribution:
$$
L(\boldsymbol{\beta}|y;\mathbf{X}) = \prod_i\, g^{-1}(\mathbf{X}_i\boldsymbol{\beta})^{y_i} \, (1 - g^{-1}(\mathbf{X}_i\boldsymbol{\beta}))^{1-y_i}
$$
Commonly IRLS algorithm is used for finding the maximum of this function, but you probably could ignore this fact and live a happy life without that knowledge. | Do you do linear regression in logistic regression?
No, it is not done like this. Quoting my other answer
Logistic regression can be described as a linear combination
$$ \eta = \beta_0 + \beta_1 X_1 + ... + \beta_k X_k $$
that is passed through the li |
38,823 | Find a Confidence Interval for Data from a Uniform Distribution on $(\theta-.5,\theta+.5).$ | Definitely not the most efficient approach (doesn't condition on the sufficient statistic), but the mean is unbiased for $\theta$. And the variance of a single observation from the above distribution is 1/12. So, by the CLT:
$$ \sqrt{n} \left( \bar{X} - \theta \right) \rightarrow_d \mathcal{N}\left(0, 1/12 \right)$$
Which means that a $1-\alpha$ confidence interval for $\theta$ can be given by
$$\left(\bar{X}+(12n)^{-.5}\mathcal{Z}_{\alpha/2}, \bar{X}+(12n)^{-.5} \mathcal{Z}_{1-\alpha/2} \right)$$ | Find a Confidence Interval for Data from a Uniform Distribution on $(\theta-.5,\theta+.5).$ | Definitely not the most efficient approach (doesn't condition on the sufficient statistic), but the mean is unbiased for $\theta$. And the variance of a single observation from the above distribution | Find a Confidence Interval for Data from a Uniform Distribution on $(\theta-.5,\theta+.5).$
Definitely not the most efficient approach (doesn't condition on the sufficient statistic), but the mean is unbiased for $\theta$. And the variance of a single observation from the above distribution is 1/12. So, by the CLT:
$$ \sqrt{n} \left( \bar{X} - \theta \right) \rightarrow_d \mathcal{N}\left(0, 1/12 \right)$$
Which means that a $1-\alpha$ confidence interval for $\theta$ can be given by
$$\left(\bar{X}+(12n)^{-.5}\mathcal{Z}_{\alpha/2}, \bar{X}+(12n)^{-.5} \mathcal{Z}_{1-\alpha/2} \right)$$ | Find a Confidence Interval for Data from a Uniform Distribution on $(\theta-.5,\theta+.5).$
Definitely not the most efficient approach (doesn't condition on the sufficient statistic), but the mean is unbiased for $\theta$. And the variance of a single observation from the above distribution |
38,824 | Find a Confidence Interval for Data from a Uniform Distribution on $(\theta-.5,\theta+.5).$ | Frequentist interval via pivotal quantity: An improvement over the interval suggested by @AdamO but still suboptimal solution can be obtained using almost exactly the same method as the one I give here so I omit the details of the following derivation. The pdf of
$$
Z=\frac{X_{(1)}+X_{(n)}}2-\theta,
$$
is
$$
f(z)=n(1-2|z|)^{n-1}
$$
for $-1/2 \le z \le 1/2$.
Since the distribution of $Z$ doesn't depend on $\theta$, $Z$ is a pivotal quantity.
This pdf is symmetric and the upper $\alpha/2$-quantile of $Z$ is $\frac{1-\alpha^{1/n}}2$. Thus
$$
P\left(-\frac{1-\alpha^{1/n}}2<\frac{X_{(1)}+X_{(n)}}2-\theta<\frac{1-\alpha^{1/n}}2\right)=1-\alpha.
$$
Inverting the double inequality, we find that
$$
\frac{X_{(1)}+X_{(n)}}2 \pm \frac{1-\alpha^{1/n}}2 \tag{1}
$$
is a $1-\alpha$ confidence interval for $\theta$. The midrange $(X_{(1)}+X_{(n)})/2$ is not a sufficient statistics for $\theta$, however.
Whittinghill and Hogg: As pointed out by @COOLSerdash, by inverting a likelihood ratio statistic these authors derive the interval
$$\left(x_{(n)}-\frac{(1-\alpha)^{1/n}}2,x_{(1)}+\frac{(1-\alpha)^{1/n}}2\right)\tag{2}$$
which is a function of the sufficient statistic $(X_{(1)},X_{(2)})$ for $\theta$. However, simulations (see below) suggest that this interval is also suboptimal.
A Bayesian credible interval: An alternative is to represent our prior ignorance about $\theta$ by a uniform improper prior $\pi(\theta)=1$. The posterior density of $\theta$ is then
$$
\pi(\theta|\mathbf{x})\propto \prod_{i=1}^n I_{(\theta-\frac12,\theta+\frac12)}(x_i)=I_{(x_{(n)}-\frac12,x_{(1)}+\frac12)}(\theta),
$$
that is, conditional on the observations, $\theta$ is uniformly distributed on the interval from $(x_{(n)}-\frac12,x_{(1)}+\frac12)$. A $1-\alpha$ credible interval for $\theta$ is therefore
$$
\left(x_{(n)}-\frac12 + \frac{\alpha}2L, x_{(1)}+\frac12 - \frac{\alpha}2L\right) \tag{3}
$$
where $L=1-(x_{(n)}-x_{(1)})$. Interestingly, judged by frequentist criteria, based on the following simulation, this interval appear to have the exact nominal coverage but is considerably shorter on average than both (1) and (2):
ci.normal <- function(x, alpha) {
n <- length(x)
mean(x) + c(-1,1)*(12*n)^(-.5)*qnorm(alpha/2, lower.tail = FALSE)
}
ci.pivot <- function(x, alpha=.05) {
n <- length(x)
(min(x)+max(x))/2 + c(-1,1)*(1 - alpha^(1/n))/2
}
ci.wh <- function(x, alpha) {
n <- length(x)
c <- (1-alpha)^(1/n)/2
c(max(x)-c, min(x)+c)
}
ci.bayes <- function(x, alpha=.05) {
L <- 1 - (max(x)-min(x))
c(max(x) - .5 + L*alpha/2, min(x) + .5 - L*alpha/2)
}
coverage <- function(fn, theta=0, nsim=100000, n, alpha=0.05) {
hits <- 0
ci.lengths <- numeric(nsim)
for (i in 1:nsim) {
x <- runif(n, theta-.5, theta+.5)
ci <- fn(x,alpha)
ci.lengths[i] <- ci[2] - ci[1]
if (ci[1] < theta & ci[2] > theta)
hits <- hits + 1
}
list(coverage = hits/nsim, meanlength = mean(ci.lengths))
}
> coverage(ci.normal, n=5)
$coverage
[1] 0.95315
$meanlength
[1] 0.5060605
> coverage(ci.pivot, n=5)
$coverage
[1] 0.95004
$meanlength
[1] 0.4507197
> coverage(ci.wh, n=5)
$coverage
[1] 0.94968
$meanlength
[1] 0.3226174
> coverage(ci.bayes, n=5)
$coverage
[1] 0.94991
$meanlength
[1] 0.3169024 | Find a Confidence Interval for Data from a Uniform Distribution on $(\theta-.5,\theta+.5).$ | Frequentist interval via pivotal quantity: An improvement over the interval suggested by @AdamO but still suboptimal solution can be obtained using almost exactly the same method as the one I give her | Find a Confidence Interval for Data from a Uniform Distribution on $(\theta-.5,\theta+.5).$
Frequentist interval via pivotal quantity: An improvement over the interval suggested by @AdamO but still suboptimal solution can be obtained using almost exactly the same method as the one I give here so I omit the details of the following derivation. The pdf of
$$
Z=\frac{X_{(1)}+X_{(n)}}2-\theta,
$$
is
$$
f(z)=n(1-2|z|)^{n-1}
$$
for $-1/2 \le z \le 1/2$.
Since the distribution of $Z$ doesn't depend on $\theta$, $Z$ is a pivotal quantity.
This pdf is symmetric and the upper $\alpha/2$-quantile of $Z$ is $\frac{1-\alpha^{1/n}}2$. Thus
$$
P\left(-\frac{1-\alpha^{1/n}}2<\frac{X_{(1)}+X_{(n)}}2-\theta<\frac{1-\alpha^{1/n}}2\right)=1-\alpha.
$$
Inverting the double inequality, we find that
$$
\frac{X_{(1)}+X_{(n)}}2 \pm \frac{1-\alpha^{1/n}}2 \tag{1}
$$
is a $1-\alpha$ confidence interval for $\theta$. The midrange $(X_{(1)}+X_{(n)})/2$ is not a sufficient statistics for $\theta$, however.
Whittinghill and Hogg: As pointed out by @COOLSerdash, by inverting a likelihood ratio statistic these authors derive the interval
$$\left(x_{(n)}-\frac{(1-\alpha)^{1/n}}2,x_{(1)}+\frac{(1-\alpha)^{1/n}}2\right)\tag{2}$$
which is a function of the sufficient statistic $(X_{(1)},X_{(2)})$ for $\theta$. However, simulations (see below) suggest that this interval is also suboptimal.
A Bayesian credible interval: An alternative is to represent our prior ignorance about $\theta$ by a uniform improper prior $\pi(\theta)=1$. The posterior density of $\theta$ is then
$$
\pi(\theta|\mathbf{x})\propto \prod_{i=1}^n I_{(\theta-\frac12,\theta+\frac12)}(x_i)=I_{(x_{(n)}-\frac12,x_{(1)}+\frac12)}(\theta),
$$
that is, conditional on the observations, $\theta$ is uniformly distributed on the interval from $(x_{(n)}-\frac12,x_{(1)}+\frac12)$. A $1-\alpha$ credible interval for $\theta$ is therefore
$$
\left(x_{(n)}-\frac12 + \frac{\alpha}2L, x_{(1)}+\frac12 - \frac{\alpha}2L\right) \tag{3}
$$
where $L=1-(x_{(n)}-x_{(1)})$. Interestingly, judged by frequentist criteria, based on the following simulation, this interval appear to have the exact nominal coverage but is considerably shorter on average than both (1) and (2):
ci.normal <- function(x, alpha) {
n <- length(x)
mean(x) + c(-1,1)*(12*n)^(-.5)*qnorm(alpha/2, lower.tail = FALSE)
}
ci.pivot <- function(x, alpha=.05) {
n <- length(x)
(min(x)+max(x))/2 + c(-1,1)*(1 - alpha^(1/n))/2
}
ci.wh <- function(x, alpha) {
n <- length(x)
c <- (1-alpha)^(1/n)/2
c(max(x)-c, min(x)+c)
}
ci.bayes <- function(x, alpha=.05) {
L <- 1 - (max(x)-min(x))
c(max(x) - .5 + L*alpha/2, min(x) + .5 - L*alpha/2)
}
coverage <- function(fn, theta=0, nsim=100000, n, alpha=0.05) {
hits <- 0
ci.lengths <- numeric(nsim)
for (i in 1:nsim) {
x <- runif(n, theta-.5, theta+.5)
ci <- fn(x,alpha)
ci.lengths[i] <- ci[2] - ci[1]
if (ci[1] < theta & ci[2] > theta)
hits <- hits + 1
}
list(coverage = hits/nsim, meanlength = mean(ci.lengths))
}
> coverage(ci.normal, n=5)
$coverage
[1] 0.95315
$meanlength
[1] 0.5060605
> coverage(ci.pivot, n=5)
$coverage
[1] 0.95004
$meanlength
[1] 0.4507197
> coverage(ci.wh, n=5)
$coverage
[1] 0.94968
$meanlength
[1] 0.3226174
> coverage(ci.bayes, n=5)
$coverage
[1] 0.94991
$meanlength
[1] 0.3169024 | Find a Confidence Interval for Data from a Uniform Distribution on $(\theta-.5,\theta+.5).$
Frequentist interval via pivotal quantity: An improvement over the interval suggested by @AdamO but still suboptimal solution can be obtained using almost exactly the same method as the one I give her |
38,825 | Find a Confidence Interval for Data from a Uniform Distribution on $(\theta-.5,\theta+.5).$ | I too will avoid analytic derivations of distributions
of $\max(X_i)$ and $\min(X_i)$ because I guess that is
the main point of this assignment. [Also see this page.]
However, results from a simulation for the case $n = 20, \theta = 10,$ based on
the sample midrange, are shown below.
set.seed(2021)
n=20
mr = replicate(10^6, mean(range(runif(n, 9.5, 10.5))))
CI = quantile(mr, c(.025,.975)); CI
2.5% 97.5%
9.930509 10.069571
hdr = "Simulated Distributions of Midrange"
hist(mr, prob=T, br=50, col="skyblue2", main=hdr)
abline(v = CI, col="red", lwd=2, lty="dashed") | Find a Confidence Interval for Data from a Uniform Distribution on $(\theta-.5,\theta+.5).$ | I too will avoid analytic derivations of distributions
of $\max(X_i)$ and $\min(X_i)$ because I guess that is
the main point of this assignment. [Also see this page.]
However, results from a simulati | Find a Confidence Interval for Data from a Uniform Distribution on $(\theta-.5,\theta+.5).$
I too will avoid analytic derivations of distributions
of $\max(X_i)$ and $\min(X_i)$ because I guess that is
the main point of this assignment. [Also see this page.]
However, results from a simulation for the case $n = 20, \theta = 10,$ based on
the sample midrange, are shown below.
set.seed(2021)
n=20
mr = replicate(10^6, mean(range(runif(n, 9.5, 10.5))))
CI = quantile(mr, c(.025,.975)); CI
2.5% 97.5%
9.930509 10.069571
hdr = "Simulated Distributions of Midrange"
hist(mr, prob=T, br=50, col="skyblue2", main=hdr)
abline(v = CI, col="red", lwd=2, lty="dashed") | Find a Confidence Interval for Data from a Uniform Distribution on $(\theta-.5,\theta+.5).$
I too will avoid analytic derivations of distributions
of $\max(X_i)$ and $\min(X_i)$ because I guess that is
the main point of this assignment. [Also see this page.]
However, results from a simulati |
38,826 | Why is AIC or BIC commonly used in model selections for time series forecasting? | What alternatives do we have in model selection for prediction?
The main ones are cross validation and information criteria.
Why are the latter attractive in the time series setting?
Information criteria are less computationally intensive. You only need to fit the model once to calculate an information criterion. This is in contrast to most applications of cross validation. Computational efficience is extra desirable in the time series setting as many basic time series models (ARMA, GARCH and the like) tend to be rather computationally demanding (more so than, say, linear regression).
Information criteria are also more effective in utilizing the data, as the model is estimated on the entire sample rather than just a training subset. The latter is important in small data sets* and especially in time series settings. In small data sets, we do not want to leave out too much data for testing, as then there is very little data left for training/estimation. We have leave-one-out cross validation (LOOCV) which leaves out only a single observation at a time in training/estimation, and it works well in a cross-sectional setting. However, it is often inapplicable in the time series setting due to the mutual dependence of the observations. Other types of validation that are applicable are much more data-costly. For more details, see "AIC versus cross validation in time series: the small sample case".
*Information criteria have an asymptotic justification, so their use is not unproblematic in small samples. Nevetherless, a more efficient use of the data is more desirable than a less efficient use. By using the entire sample for estimation you are closer to asymptotics than by using, say, 2/3 of the sample. | Why is AIC or BIC commonly used in model selections for time series forecasting? | What alternatives do we have in model selection for prediction?
The main ones are cross validation and information criteria.
Why are the latter attractive in the time series setting?
Information cr | Why is AIC or BIC commonly used in model selections for time series forecasting?
What alternatives do we have in model selection for prediction?
The main ones are cross validation and information criteria.
Why are the latter attractive in the time series setting?
Information criteria are less computationally intensive. You only need to fit the model once to calculate an information criterion. This is in contrast to most applications of cross validation. Computational efficience is extra desirable in the time series setting as many basic time series models (ARMA, GARCH and the like) tend to be rather computationally demanding (more so than, say, linear regression).
Information criteria are also more effective in utilizing the data, as the model is estimated on the entire sample rather than just a training subset. The latter is important in small data sets* and especially in time series settings. In small data sets, we do not want to leave out too much data for testing, as then there is very little data left for training/estimation. We have leave-one-out cross validation (LOOCV) which leaves out only a single observation at a time in training/estimation, and it works well in a cross-sectional setting. However, it is often inapplicable in the time series setting due to the mutual dependence of the observations. Other types of validation that are applicable are much more data-costly. For more details, see "AIC versus cross validation in time series: the small sample case".
*Information criteria have an asymptotic justification, so their use is not unproblematic in small samples. Nevetherless, a more efficient use of the data is more desirable than a less efficient use. By using the entire sample for estimation you are closer to asymptotics than by using, say, 2/3 of the sample. | Why is AIC or BIC commonly used in model selections for time series forecasting?
What alternatives do we have in model selection for prediction?
The main ones are cross validation and information criteria.
Why are the latter attractive in the time series setting?
Information cr |
38,827 | Why is AIC or BIC commonly used in model selections for time series forecasting? | First off, as Richard Hardy comments, information criteria do not assume we have the true model. Quite to the contrary. For instance, AIC estimates the Kullback-Leibler distance between the proposed model and the true data generating process (up to an offset), and picking the model with minimal AIC amounts to choosing the one with the smallest distance to the true DGP. See Burnham & Anderson (2002, Model selection and multi-model inference: a practical information-theoretic approach) or Burnham & Anderson (2004, Sociological Methods & Research) for an accessible treatment. They also go into the justification for BIC.
Information criteria break down with overparameterized models, but that's not really a problem of the ICs. Instead, it's that every overparameterized model that is not regularized breaks down, and that "normal" ICs don't work with regularized models. (I believe there are IC variants that apply to regularized models, but am not an expert in this.)
ICs are used in forecasting model selection because of the above argument about distances to true DGPs. A related argument is that the AIC asymptotically estimates a monotone function of the prediction error (section 4.3.1 in Lütkepohl, 2005, New Introduction to Multiple Time Series Analysis, who also goes into other model selection criteria). Also, ICs are not the only tool used: some people prefer using holdout sets, but that means you need more data. | Why is AIC or BIC commonly used in model selections for time series forecasting? | First off, as Richard Hardy comments, information criteria do not assume we have the true model. Quite to the contrary. For instance, AIC estimates the Kullback-Leibler distance between the proposed m | Why is AIC or BIC commonly used in model selections for time series forecasting?
First off, as Richard Hardy comments, information criteria do not assume we have the true model. Quite to the contrary. For instance, AIC estimates the Kullback-Leibler distance between the proposed model and the true data generating process (up to an offset), and picking the model with minimal AIC amounts to choosing the one with the smallest distance to the true DGP. See Burnham & Anderson (2002, Model selection and multi-model inference: a practical information-theoretic approach) or Burnham & Anderson (2004, Sociological Methods & Research) for an accessible treatment. They also go into the justification for BIC.
Information criteria break down with overparameterized models, but that's not really a problem of the ICs. Instead, it's that every overparameterized model that is not regularized breaks down, and that "normal" ICs don't work with regularized models. (I believe there are IC variants that apply to regularized models, but am not an expert in this.)
ICs are used in forecasting model selection because of the above argument about distances to true DGPs. A related argument is that the AIC asymptotically estimates a monotone function of the prediction error (section 4.3.1 in Lütkepohl, 2005, New Introduction to Multiple Time Series Analysis, who also goes into other model selection criteria). Also, ICs are not the only tool used: some people prefer using holdout sets, but that means you need more data. | Why is AIC or BIC commonly used in model selections for time series forecasting?
First off, as Richard Hardy comments, information criteria do not assume we have the true model. Quite to the contrary. For instance, AIC estimates the Kullback-Leibler distance between the proposed m |
38,828 | Why is AIC or BIC commonly used in model selections for time series forecasting? | First of all, sorry this was supposed to be a comment as opposed to an answer. The question has already been answered well. I just wanted to add that even though ICs aim at minimizing the distance to the true DGP, they might not always be able to do so. True DGP is unknown and there is no best way to identify the model closest to it. However, you can aid the ICs with autocorrelation and partial autocorrelation functions. Just by looking at these plots will give you an idea of how your model should look like in terms of lags. This will narrow down your pool of candidate models and you can then select the one with lower IC. In my understanding ICs look at how the models fit the distribution of the data but do not incorporate how the data is distributed over time. Incorporating auto-/partial autocorrelation plots helps to bridge the gap.
Would love to be corrected if I am wrong. | Why is AIC or BIC commonly used in model selections for time series forecasting? | First of all, sorry this was supposed to be a comment as opposed to an answer. The question has already been answered well. I just wanted to add that even though ICs aim at minimizing the distance to | Why is AIC or BIC commonly used in model selections for time series forecasting?
First of all, sorry this was supposed to be a comment as opposed to an answer. The question has already been answered well. I just wanted to add that even though ICs aim at minimizing the distance to the true DGP, they might not always be able to do so. True DGP is unknown and there is no best way to identify the model closest to it. However, you can aid the ICs with autocorrelation and partial autocorrelation functions. Just by looking at these plots will give you an idea of how your model should look like in terms of lags. This will narrow down your pool of candidate models and you can then select the one with lower IC. In my understanding ICs look at how the models fit the distribution of the data but do not incorporate how the data is distributed over time. Incorporating auto-/partial autocorrelation plots helps to bridge the gap.
Would love to be corrected if I am wrong. | Why is AIC or BIC commonly used in model selections for time series forecasting?
First of all, sorry this was supposed to be a comment as opposed to an answer. The question has already been answered well. I just wanted to add that even though ICs aim at minimizing the distance to |
38,829 | Intuition for why likelihood function sometimes *is* a PDF | The purpose of this answer is to show that the situation is so rich and complicated that it's unlikely there exists any simple characterization of such distributional families.
I will first show, by construction, that there are many such families and they are flexible and varied. Then I will show that even this construction doesn't cover the gamut of possibilities. In this process, though, we might improve our intuition about what it means for the likelihood of a single real parameter to be a density function.
When $\theta$ can range over all the real numbers and is a location parameter -- that is, when the distribution functions are all of the form $f(x-\theta)$ for some density $f$ -- it is easy to see that integrating over the parameter $\theta$ gives the constant value $1.$
Let's play with this a little. What if, for instance, we were to take two distinct densities $f_1$ and $f_2$ and let $\theta$ play the role of a location parameter for each one of them, but in two different ways? For instance, form the family of functions
$$f(x,\theta) = a_1f_1(x-2\theta) + a_2f_2(x-\theta/2)$$
where the $a_i$ are to be determined. By simple substitutions $x=y+\theta$ and $x=y+\theta/2,$ compute that
$$\begin{aligned}
\int_{\mathbb{R}}f(x,\theta)\,\mathrm{d}x &= \int_{\mathbb{R}}a_1f_1(x-2\theta)\,\mathrm{d}x + \int_{\mathbb{R}}a_2f_2(x-\theta/2)\,\mathrm{d}x\\
&= a_1\int_{\mathbb{R}}f_1(y)\,\mathrm{d}y + a_2\int_{\mathbb{R}}f_2(y)\,\mathrm{d}y\\
&= a_1+a_2.
\end{aligned}$$
Thus, provided $a_1+a_2 = 1$ and $f(x,\theta)\ge 0$ for all $x,$ $x\to f(x,\theta)$ is a probability density. When we integrate over the parameter $\theta$ we obtain, using the same methods of substituting $\theta=(y+x)/2$ and $\theta=2(y+x),$
$$\begin{aligned}
\int_{\mathbb{R}}f(x,\theta)\,\mathrm{d}\theta &= \int_{\mathbb{R}}a_1f_1(x-2\theta)\,\mathrm{d}\theta + \int_{\mathbb{R}}a_2f_2(x-\theta/2)\,\mathrm{d}\theta \\
&= \frac{1}{2}a_1\int_{\mathbb{R}}f_1(y)\,\mathrm{d}y + 2a_2\int_{\mathbb{R}}f_2(y)\,\mathrm{d}y\\
&= \frac{1}{2}a_1+2a_2.
\end{aligned}$$
By setting $a_1=2/3$ and $a_2=1/3$ we can make this result unity for all $x$ as well as guaranteeing $f$ has no negative values, thereby satisfying the conditions of the problem. With some care we can also make this family of distributions identifiable in the sense that each $\theta$ determines a unique distribution, as I will show by example. However, $\theta$ is not a location parameter.
An example illustrates why not. Let $f_2$ be the Uniform$[0,1]$ density and $f_1$ be a Normal density with variance $1/3$ and mean $0.$ Here are some plots of $f$ for various values of $\theta:$
As $\theta$ increases (from left to right), the rectangular part of the density (the Uniform component) marches slowly rightward while the curved part of the density (the Normal component) marches rightward four times faster. The resulting distributions are all obviously different. Effectively, $\theta$ does determine a "location" of sorts, but it also determines the shape of the distribution. That's why it's not a location parameter.
This construction can be vastly generalized to create rich, flexible families of distributions having all the properties in the question but (in general) not being location families. For completeness, I will give the details before proceeding with the main question.
Let $f:\mathbb{R}\times\mathbb{R}\to[0,\infty)$ be any integrable family of distribution functions; that is, for all numbers $\lambda$
$$\int_{\mathbb{R}}f(x,\lambda)\,\mathrm{d}x = 1.$$
Consider any distribution function $G$ supported on the nonnegative real numbers and use it to form the family $\mathcal G$ of functions $g:\mathbb{R}\times\mathbb{R}\to[0,\infty)$ via
$$g(x,\theta) = \int_0^\infty f\left(x - \frac{\theta}{\lambda}\right)\,\mathrm{d}G(\lambda).$$
For each $\theta$ this gives a density function because obviously $g(x,\theta)\ge 0$ and
$$\begin{aligned}
\int_\mathbb{R}g(x,\theta)\,\mathrm{d}x &= \int_\mathbb{R}\int_0^\infty f\left(x - \frac{\theta}{\lambda}\right)\,\mathrm{d}G(\lambda)\,\mathrm{d}x\\
&= \int_0^\infty \int_\mathbb{R}f\left(x - \frac{\theta}{\lambda}\right)\,\mathrm{d}x\,\mathrm{d}G(\lambda)\\
&= \int_0^\infty (1)\,\mathrm{d}G(\lambda)\\
&= 1.
\end{aligned}$$
Integrating instead over $\theta$ using the substitution $\theta=y\lambda$ yields
$$\begin{aligned}
\int_\mathbb{R}g(x,\theta)\,\mathrm{d}\theta&= \int_\mathbb{R}\int_0^\infty f\left(x - \frac{\theta}{\lambda}\right)\,\mathrm{d}G(\lambda)\,\mathrm{d}\theta\\
&= \int_0^\infty \int_\mathbb{R}f\left(x - \frac{\theta}{\lambda}\right)\,\mathrm{d}\theta\,\mathrm{d}G(\lambda)\\
&= \int_0^\infty \int_\mathbb{R}f\left(x - \frac{y\lambda}{\lambda}\right)\,\mathrm{d}\left(y\lambda\right)\,\mathrm{d}G(\lambda)\\
&= \int_0^\infty \int_\mathbb{R}f\left(x - y\right)\,\mathrm{d}y\,\lambda\,\mathrm{d}G(\lambda)\\
&= \int_0^\infty\lambda\,\mathrm{d}G(\lambda).
\end{aligned}$$
If we further stipulate that the expectation of $G$ is unity, this shows that the family $\mathcal G$ satisfies the conditions of the question. However, except in special cases, $\theta$ is not a location parameter.
Let's consider the natural follow-up question: when the likelihood is a PDF in the sense of the question, can we always represent the family as a mixture in the foregoing sense?
Unfortunately the answer is no. As a counterexample, consider the family of distribution functions given by
$$f(x,\theta) = 2\left(\left\{\theta\right\} + \left(x - \lfloor \theta \rfloor\right) - 2 \left\{\theta\right\}\left(x - \lfloor \theta \rfloor\right)\right)$$
where $\lfloor \theta \rfloor$ is the greatest integer less than or equal to $\theta$ and $\left\{\theta\right\} = \theta - \lfloor \theta \rfloor$ is the fractional part of $\theta$ (lying in the interval $[0,1)$).
This strange looking function describes distributions defined on intervals $[n,n+1)$ (where $n = \lfloor \theta \rfloor$) that vary according to the fractional part of $\theta.$ Here are some of their densities:
Here is a plot of $f:$
Now if this family had a location parameter $\mu = \mu(\theta),$ we would be able to express each $f(x,\theta)$ as a fixed function of $x-\mu(\theta).$ Its level sets (contours) would therefore be unions of lines of the form $x-\mu=\text{constant};$ that is, of lines with 45 degree slopes. Geometrically, this means we can stretch and compress this image purely in the vertical ($\theta$) direction until its bright patches--where the density is nonzero--become a slanted band with parallel linear contours.
No matter how we might re-express the parameter $\theta$ (in a continuous fashion), obviously there's no way it can change this checkered pattern into such an image. | Intuition for why likelihood function sometimes *is* a PDF | The purpose of this answer is to show that the situation is so rich and complicated that it's unlikely there exists any simple characterization of such distributional families.
I will first show, by c | Intuition for why likelihood function sometimes *is* a PDF
The purpose of this answer is to show that the situation is so rich and complicated that it's unlikely there exists any simple characterization of such distributional families.
I will first show, by construction, that there are many such families and they are flexible and varied. Then I will show that even this construction doesn't cover the gamut of possibilities. In this process, though, we might improve our intuition about what it means for the likelihood of a single real parameter to be a density function.
When $\theta$ can range over all the real numbers and is a location parameter -- that is, when the distribution functions are all of the form $f(x-\theta)$ for some density $f$ -- it is easy to see that integrating over the parameter $\theta$ gives the constant value $1.$
Let's play with this a little. What if, for instance, we were to take two distinct densities $f_1$ and $f_2$ and let $\theta$ play the role of a location parameter for each one of them, but in two different ways? For instance, form the family of functions
$$f(x,\theta) = a_1f_1(x-2\theta) + a_2f_2(x-\theta/2)$$
where the $a_i$ are to be determined. By simple substitutions $x=y+\theta$ and $x=y+\theta/2,$ compute that
$$\begin{aligned}
\int_{\mathbb{R}}f(x,\theta)\,\mathrm{d}x &= \int_{\mathbb{R}}a_1f_1(x-2\theta)\,\mathrm{d}x + \int_{\mathbb{R}}a_2f_2(x-\theta/2)\,\mathrm{d}x\\
&= a_1\int_{\mathbb{R}}f_1(y)\,\mathrm{d}y + a_2\int_{\mathbb{R}}f_2(y)\,\mathrm{d}y\\
&= a_1+a_2.
\end{aligned}$$
Thus, provided $a_1+a_2 = 1$ and $f(x,\theta)\ge 0$ for all $x,$ $x\to f(x,\theta)$ is a probability density. When we integrate over the parameter $\theta$ we obtain, using the same methods of substituting $\theta=(y+x)/2$ and $\theta=2(y+x),$
$$\begin{aligned}
\int_{\mathbb{R}}f(x,\theta)\,\mathrm{d}\theta &= \int_{\mathbb{R}}a_1f_1(x-2\theta)\,\mathrm{d}\theta + \int_{\mathbb{R}}a_2f_2(x-\theta/2)\,\mathrm{d}\theta \\
&= \frac{1}{2}a_1\int_{\mathbb{R}}f_1(y)\,\mathrm{d}y + 2a_2\int_{\mathbb{R}}f_2(y)\,\mathrm{d}y\\
&= \frac{1}{2}a_1+2a_2.
\end{aligned}$$
By setting $a_1=2/3$ and $a_2=1/3$ we can make this result unity for all $x$ as well as guaranteeing $f$ has no negative values, thereby satisfying the conditions of the problem. With some care we can also make this family of distributions identifiable in the sense that each $\theta$ determines a unique distribution, as I will show by example. However, $\theta$ is not a location parameter.
An example illustrates why not. Let $f_2$ be the Uniform$[0,1]$ density and $f_1$ be a Normal density with variance $1/3$ and mean $0.$ Here are some plots of $f$ for various values of $\theta:$
As $\theta$ increases (from left to right), the rectangular part of the density (the Uniform component) marches slowly rightward while the curved part of the density (the Normal component) marches rightward four times faster. The resulting distributions are all obviously different. Effectively, $\theta$ does determine a "location" of sorts, but it also determines the shape of the distribution. That's why it's not a location parameter.
This construction can be vastly generalized to create rich, flexible families of distributions having all the properties in the question but (in general) not being location families. For completeness, I will give the details before proceeding with the main question.
Let $f:\mathbb{R}\times\mathbb{R}\to[0,\infty)$ be any integrable family of distribution functions; that is, for all numbers $\lambda$
$$\int_{\mathbb{R}}f(x,\lambda)\,\mathrm{d}x = 1.$$
Consider any distribution function $G$ supported on the nonnegative real numbers and use it to form the family $\mathcal G$ of functions $g:\mathbb{R}\times\mathbb{R}\to[0,\infty)$ via
$$g(x,\theta) = \int_0^\infty f\left(x - \frac{\theta}{\lambda}\right)\,\mathrm{d}G(\lambda).$$
For each $\theta$ this gives a density function because obviously $g(x,\theta)\ge 0$ and
$$\begin{aligned}
\int_\mathbb{R}g(x,\theta)\,\mathrm{d}x &= \int_\mathbb{R}\int_0^\infty f\left(x - \frac{\theta}{\lambda}\right)\,\mathrm{d}G(\lambda)\,\mathrm{d}x\\
&= \int_0^\infty \int_\mathbb{R}f\left(x - \frac{\theta}{\lambda}\right)\,\mathrm{d}x\,\mathrm{d}G(\lambda)\\
&= \int_0^\infty (1)\,\mathrm{d}G(\lambda)\\
&= 1.
\end{aligned}$$
Integrating instead over $\theta$ using the substitution $\theta=y\lambda$ yields
$$\begin{aligned}
\int_\mathbb{R}g(x,\theta)\,\mathrm{d}\theta&= \int_\mathbb{R}\int_0^\infty f\left(x - \frac{\theta}{\lambda}\right)\,\mathrm{d}G(\lambda)\,\mathrm{d}\theta\\
&= \int_0^\infty \int_\mathbb{R}f\left(x - \frac{\theta}{\lambda}\right)\,\mathrm{d}\theta\,\mathrm{d}G(\lambda)\\
&= \int_0^\infty \int_\mathbb{R}f\left(x - \frac{y\lambda}{\lambda}\right)\,\mathrm{d}\left(y\lambda\right)\,\mathrm{d}G(\lambda)\\
&= \int_0^\infty \int_\mathbb{R}f\left(x - y\right)\,\mathrm{d}y\,\lambda\,\mathrm{d}G(\lambda)\\
&= \int_0^\infty\lambda\,\mathrm{d}G(\lambda).
\end{aligned}$$
If we further stipulate that the expectation of $G$ is unity, this shows that the family $\mathcal G$ satisfies the conditions of the question. However, except in special cases, $\theta$ is not a location parameter.
Let's consider the natural follow-up question: when the likelihood is a PDF in the sense of the question, can we always represent the family as a mixture in the foregoing sense?
Unfortunately the answer is no. As a counterexample, consider the family of distribution functions given by
$$f(x,\theta) = 2\left(\left\{\theta\right\} + \left(x - \lfloor \theta \rfloor\right) - 2 \left\{\theta\right\}\left(x - \lfloor \theta \rfloor\right)\right)$$
where $\lfloor \theta \rfloor$ is the greatest integer less than or equal to $\theta$ and $\left\{\theta\right\} = \theta - \lfloor \theta \rfloor$ is the fractional part of $\theta$ (lying in the interval $[0,1)$).
This strange looking function describes distributions defined on intervals $[n,n+1)$ (where $n = \lfloor \theta \rfloor$) that vary according to the fractional part of $\theta.$ Here are some of their densities:
Here is a plot of $f:$
Now if this family had a location parameter $\mu = \mu(\theta),$ we would be able to express each $f(x,\theta)$ as a fixed function of $x-\mu(\theta).$ Its level sets (contours) would therefore be unions of lines of the form $x-\mu=\text{constant};$ that is, of lines with 45 degree slopes. Geometrically, this means we can stretch and compress this image purely in the vertical ($\theta$) direction until its bright patches--where the density is nonzero--become a slanted band with parallel linear contours.
No matter how we might re-express the parameter $\theta$ (in a continuous fashion), obviously there's no way it can change this checkered pattern into such an image. | Intuition for why likelihood function sometimes *is* a PDF
The purpose of this answer is to show that the situation is so rich and complicated that it's unlikely there exists any simple characterization of such distributional families.
I will first show, by c |
38,830 | Intuition for why likelihood function sometimes *is* a PDF | There is a similar question here:
What is the reason that a likelihood function is not a pdf?
Hopefully, that can be of help. In particular see whuber's comment regarding Fishers 1922 article:
Integrating to unity is beside the point. Fisher, in a 1922 paper On the Mathematical Foundations of Theoretical Statistics, observed that indeed usually the likelihood L(θ) can be "normalized" to integrate to unity upon multiplying by a suitable function p(θ) so that ∫L(θ)p(θ)dθ=1. What he objected to is the arbitrariness: there are many p that work. "...the word probability is wrongly used in such a connection: probability is a ratio of frequencies, and about the frequencies of such values we can know nothing whatever."
It seems that this indicates that there would exist an arbitrary number of likelihood functions that post normalization would be integratable to 1.
Then the distinction would seem to lie in the fact that a likelihood function is a measure of goodness of fit. Thus, if we look at a graph of a likelihood function a point is the likelihood of a parameter $\theta$ for a given observed outcome.
In the image above: is the likelihood function of $p_(H)^2$ the probability of a coin landing heads up (without prior knowledge) given we have observed HH. Where $P_H$ is $\theta$ the true probability of the coin landing heads. -https://en.wikipedia.org/wiki/Likelihood_function
In the case of a PDF any "any given sample (or point) in the sample space (the set of possible values taken by the random variable) can be interpreted as providing a relative likelihood that the value of the random variable would equal that sample."- https://en.wikipedia.org/wiki/Probability_density_function
Where, as I see it, the sample would have fixed parameters.
to summarize, a likelihood function gives probability of a parameter for an observed outcome. Where as pdf gives likelihood that a random variable belongs to the sample.
Hopefully someone that knows more can chime in and answer your question directly | Intuition for why likelihood function sometimes *is* a PDF | There is a similar question here:
What is the reason that a likelihood function is not a pdf?
Hopefully, that can be of help. In particular see whuber's comment regarding Fishers 1922 article:
Integr | Intuition for why likelihood function sometimes *is* a PDF
There is a similar question here:
What is the reason that a likelihood function is not a pdf?
Hopefully, that can be of help. In particular see whuber's comment regarding Fishers 1922 article:
Integrating to unity is beside the point. Fisher, in a 1922 paper On the Mathematical Foundations of Theoretical Statistics, observed that indeed usually the likelihood L(θ) can be "normalized" to integrate to unity upon multiplying by a suitable function p(θ) so that ∫L(θ)p(θ)dθ=1. What he objected to is the arbitrariness: there are many p that work. "...the word probability is wrongly used in such a connection: probability is a ratio of frequencies, and about the frequencies of such values we can know nothing whatever."
It seems that this indicates that there would exist an arbitrary number of likelihood functions that post normalization would be integratable to 1.
Then the distinction would seem to lie in the fact that a likelihood function is a measure of goodness of fit. Thus, if we look at a graph of a likelihood function a point is the likelihood of a parameter $\theta$ for a given observed outcome.
In the image above: is the likelihood function of $p_(H)^2$ the probability of a coin landing heads up (without prior knowledge) given we have observed HH. Where $P_H$ is $\theta$ the true probability of the coin landing heads. -https://en.wikipedia.org/wiki/Likelihood_function
In the case of a PDF any "any given sample (or point) in the sample space (the set of possible values taken by the random variable) can be interpreted as providing a relative likelihood that the value of the random variable would equal that sample."- https://en.wikipedia.org/wiki/Probability_density_function
Where, as I see it, the sample would have fixed parameters.
to summarize, a likelihood function gives probability of a parameter for an observed outcome. Where as pdf gives likelihood that a random variable belongs to the sample.
Hopefully someone that knows more can chime in and answer your question directly | Intuition for why likelihood function sometimes *is* a PDF
There is a similar question here:
What is the reason that a likelihood function is not a pdf?
Hopefully, that can be of help. In particular see whuber's comment regarding Fishers 1922 article:
Integr |
38,831 | Intuition for why likelihood function sometimes *is* a PDF | The mean of a normal distribution is a location parameter. In general, if $\theta$ is a location parameter, then:
$$\int_{\theta \in \mathbb{R}}g_{\theta}(x_0)\:d\theta = \int_{x \in \mathbb{R}}g_o(x_0 - x)\:dx = \int_{x \in \mathbb{R}}g_o(x)\:dx = 1$$
where $g_0$ is the pdf when $\theta = 0$. | Intuition for why likelihood function sometimes *is* a PDF | The mean of a normal distribution is a location parameter. In general, if $\theta$ is a location parameter, then:
$$\int_{\theta \in \mathbb{R}}g_{\theta}(x_0)\:d\theta = \int_{x \in \mathbb{R}}g_o(x_ | Intuition for why likelihood function sometimes *is* a PDF
The mean of a normal distribution is a location parameter. In general, if $\theta$ is a location parameter, then:
$$\int_{\theta \in \mathbb{R}}g_{\theta}(x_0)\:d\theta = \int_{x \in \mathbb{R}}g_o(x_0 - x)\:dx = \int_{x \in \mathbb{R}}g_o(x)\:dx = 1$$
where $g_0$ is the pdf when $\theta = 0$. | Intuition for why likelihood function sometimes *is* a PDF
The mean of a normal distribution is a location parameter. In general, if $\theta$ is a location parameter, then:
$$\int_{\theta \in \mathbb{R}}g_{\theta}(x_0)\:d\theta = \int_{x \in \mathbb{R}}g_o(x_ |
38,832 | Intuition for why likelihood function sometimes *is* a PDF | The likelihood is not a PDF
Is there an intuitive explanation for the fact that this particular likelihood function is a PDF?
This is a loaded question. It is based on a wrong premise. The likelihood function is not a PDF.
The condition $\int_{\theta \in \mathbb{R}} f(\theta) d\theta= 1$ is a necessary condition for some function $f(\theta)$ to be a PDF but it is not a sufficient condition for the function to be a PDF.
For some function to be a PDF it must also have a probability interpretation. The likelihood function does not have this interpretation (not by itselve). Yes, the likelihood is the probability density of observing $x$, but as a function of $\theta$ it looses the interpretation of a probability density or mass function. The likelihood function is 'a function of probability densities' but it is not a probability density itselve.
A probability density is a function $f$ such that the integral over some differential measure $\theta$ on a set of events $\Omega$ gives a measure of the joint probability for those events in the set $P(\Omega) = \int_\omega f d\theta$
The quantity $\int_a^b f_X(x|\theta) dx$ is a probability (namely the frequency of events $a \leq x \leq b$)
But the quantity $\int_a^b \mathcal{L}(\theta|x) d\theta$ is not a probability. It has no probabilistic meaning.
Analogous example in physics: You may have a mass density that is a function of both space and temperature. The mass density as a function of temperature should not be interpreted as the density expressing the amount of mass per amount of temperature.
Likelihood's that sum up to 1
A likelihood can sum to 1 but if this is the case then this is a coincidence. This is not a special property for some cases. For any case you have a likelihood function that sums to 1.
Likelihood functions are defined as being proportional to the probability density or mass of $x$ as function of $\theta$ $$\mathcal{L}(\theta|x) = c \cdot f_X(x|\theta)$$ where $c$ can be any constant and there is always* some $c$ such that you can make the likelihood function integrate to 1.
*Possibly there might be some pathological case where there is some observation $x$ with infinite density such that $\int_{\theta \in \mathbb{R}} f(x|\theta) d\theta$ is infinite.
The likelihood function can be mathematically equivalent to a probability
The likelihood function (when properly normalized) coincides with the formula for a probability density if the prior distribution is uniform. In this case the likelihood function and the posterior probability density are equal. In this case you might say that the likelihood function has a probabilistic interpretation (Although it is just that the formula for the likelihood coincides with the formula for the posterior pdf; The concept of likelihood does not turn into a probability)
The likelihood function sometimes coincides with the fiducial distribution or confidence distribution. The fiducial density is similar to the likelihood but based on the CDF.
$$\begin{array}{rrcl}
\text{Likelihood: } & \mathcal{L}(\theta|x) &\propto& f_X(x|\theta)\\
\text{Fiducial distribution: } & \mathcal{F}(\theta|x) &= & F_X(x|\theta)
\end{array}$$
In this case it can also be considered to coincide with a probabilistic interpretation. (But it is not a probability in the typical sense. Similar to the confidence interval it does not relate to the probability for the parameter conditional on the observation) | Intuition for why likelihood function sometimes *is* a PDF | The likelihood is not a PDF
Is there an intuitive explanation for the fact that this particular likelihood function is a PDF?
This is a loaded question. It is based on a wrong premise. The likelihoo | Intuition for why likelihood function sometimes *is* a PDF
The likelihood is not a PDF
Is there an intuitive explanation for the fact that this particular likelihood function is a PDF?
This is a loaded question. It is based on a wrong premise. The likelihood function is not a PDF.
The condition $\int_{\theta \in \mathbb{R}} f(\theta) d\theta= 1$ is a necessary condition for some function $f(\theta)$ to be a PDF but it is not a sufficient condition for the function to be a PDF.
For some function to be a PDF it must also have a probability interpretation. The likelihood function does not have this interpretation (not by itselve). Yes, the likelihood is the probability density of observing $x$, but as a function of $\theta$ it looses the interpretation of a probability density or mass function. The likelihood function is 'a function of probability densities' but it is not a probability density itselve.
A probability density is a function $f$ such that the integral over some differential measure $\theta$ on a set of events $\Omega$ gives a measure of the joint probability for those events in the set $P(\Omega) = \int_\omega f d\theta$
The quantity $\int_a^b f_X(x|\theta) dx$ is a probability (namely the frequency of events $a \leq x \leq b$)
But the quantity $\int_a^b \mathcal{L}(\theta|x) d\theta$ is not a probability. It has no probabilistic meaning.
Analogous example in physics: You may have a mass density that is a function of both space and temperature. The mass density as a function of temperature should not be interpreted as the density expressing the amount of mass per amount of temperature.
Likelihood's that sum up to 1
A likelihood can sum to 1 but if this is the case then this is a coincidence. This is not a special property for some cases. For any case you have a likelihood function that sums to 1.
Likelihood functions are defined as being proportional to the probability density or mass of $x$ as function of $\theta$ $$\mathcal{L}(\theta|x) = c \cdot f_X(x|\theta)$$ where $c$ can be any constant and there is always* some $c$ such that you can make the likelihood function integrate to 1.
*Possibly there might be some pathological case where there is some observation $x$ with infinite density such that $\int_{\theta \in \mathbb{R}} f(x|\theta) d\theta$ is infinite.
The likelihood function can be mathematically equivalent to a probability
The likelihood function (when properly normalized) coincides with the formula for a probability density if the prior distribution is uniform. In this case the likelihood function and the posterior probability density are equal. In this case you might say that the likelihood function has a probabilistic interpretation (Although it is just that the formula for the likelihood coincides with the formula for the posterior pdf; The concept of likelihood does not turn into a probability)
The likelihood function sometimes coincides with the fiducial distribution or confidence distribution. The fiducial density is similar to the likelihood but based on the CDF.
$$\begin{array}{rrcl}
\text{Likelihood: } & \mathcal{L}(\theta|x) &\propto& f_X(x|\theta)\\
\text{Fiducial distribution: } & \mathcal{F}(\theta|x) &= & F_X(x|\theta)
\end{array}$$
In this case it can also be considered to coincide with a probabilistic interpretation. (But it is not a probability in the typical sense. Similar to the confidence interval it does not relate to the probability for the parameter conditional on the observation) | Intuition for why likelihood function sometimes *is* a PDF
The likelihood is not a PDF
Is there an intuitive explanation for the fact that this particular likelihood function is a PDF?
This is a loaded question. It is based on a wrong premise. The likelihoo |
38,833 | Intuition for why likelihood function sometimes *is* a PDF | To quote from Ronald Fisher himself (and intersecting with the answer by NicoFish as well as the answer by WHuber to the earlier question):
when defining the likelihood function (as a function of the parameter $\theta$), Fisher (in his 1912 undergraduate memoir) warns against integrating it w.r.t. the parameter: “the integration with respect to [the mean parameter] $m$ is illegitimate and has no definite meaning with respect to inverse probability. [The likelihood is] a relative probability only, suitable to compare point with point, but incapable of being interpreted as a probability distribution over a region, or of giving any estimate of absolute probability.” And again in 1922: “[the likelihood] is not a differential element, and is incapable of being integrated: it is assigned to a particular point of the range of variation, not to a particular element of it”.
He introduced the very term “likelihood” especially to avoid the confusion with a probability density and to separate it and himself from Bayesian analysis: “I perceive that the word probability is wrongly used in such a connection: probability is a ratio of frequencies, and about the frequencies of such values we can know nothing whatever (…) I suggest that we may speak without confusion of the likelihood of one value of $p$ being thrice the likelihood of another (…) likelihood is not here used loosely as a synonym of probability, but simply to express the relative frequencies with which such values of the hypothetical quantity $p$ would in fact yield the observed sample”. [Which I understand as a defense of the relativity of the likelihood values, which connects with the point that it is only defined up to a multiplicative constant, as e.g. when comparing the likelihood for the entire sample and for a sufficient statistic.]
Another point he makes repeatedly (both in 1912 and 1922) is the lack of invariance of the probability measure obtained by attaching a d$θ$ to the likelihood function $L(θ)$ and normalising it into a density: while the likelihood “is entirely unchanged by any [one-to-one] transformation”, this definition of a probability distribution is not. Fisher actually distanced himself from a Bayesian “uniform prior” throughout the 1920’s and opting for a uniform (improper) prior is indeed making an arbitrary choice of a particular prior. [Which connects with my critical answer that to turn the likelihood into a density, a dominating measure must first be chosen and that there is no compelling argument to make the Lebesgue measure as a default choice.]
Fisher however made things more complicated when introducing the fiducial distribution in the 1950's since, to quote from Dennis Lindley (1958):
according to Fisher (1956) [the fact that the fiducial distribution is consistent under sequential updating] is true, though no formal proof is given, for he says (p. 51) "The concept of probability involved [in the fiducial argument] is entirely identical with the classical probability of the early writers, such as Bayes". Again he says (p. 125) "This fiducial distribution supplies information of exactly the same sort as would a distribution given a priori".
Although this is not exactly related with the original question, but for a uniform prior being used in both instances, let me point out that Lindley (1958) establishes that "therefore the fiducial argument is only consistent in the case of a single sufficient statistic when the distribution is of the gamma or normal forms, or transformable thereto." | Intuition for why likelihood function sometimes *is* a PDF | To quote from Ronald Fisher himself (and intersecting with the answer by NicoFish as well as the answer by WHuber to the earlier question):
when defining the likelihood function (as a function of the | Intuition for why likelihood function sometimes *is* a PDF
To quote from Ronald Fisher himself (and intersecting with the answer by NicoFish as well as the answer by WHuber to the earlier question):
when defining the likelihood function (as a function of the parameter $\theta$), Fisher (in his 1912 undergraduate memoir) warns against integrating it w.r.t. the parameter: “the integration with respect to [the mean parameter] $m$ is illegitimate and has no definite meaning with respect to inverse probability. [The likelihood is] a relative probability only, suitable to compare point with point, but incapable of being interpreted as a probability distribution over a region, or of giving any estimate of absolute probability.” And again in 1922: “[the likelihood] is not a differential element, and is incapable of being integrated: it is assigned to a particular point of the range of variation, not to a particular element of it”.
He introduced the very term “likelihood” especially to avoid the confusion with a probability density and to separate it and himself from Bayesian analysis: “I perceive that the word probability is wrongly used in such a connection: probability is a ratio of frequencies, and about the frequencies of such values we can know nothing whatever (…) I suggest that we may speak without confusion of the likelihood of one value of $p$ being thrice the likelihood of another (…) likelihood is not here used loosely as a synonym of probability, but simply to express the relative frequencies with which such values of the hypothetical quantity $p$ would in fact yield the observed sample”. [Which I understand as a defense of the relativity of the likelihood values, which connects with the point that it is only defined up to a multiplicative constant, as e.g. when comparing the likelihood for the entire sample and for a sufficient statistic.]
Another point he makes repeatedly (both in 1912 and 1922) is the lack of invariance of the probability measure obtained by attaching a d$θ$ to the likelihood function $L(θ)$ and normalising it into a density: while the likelihood “is entirely unchanged by any [one-to-one] transformation”, this definition of a probability distribution is not. Fisher actually distanced himself from a Bayesian “uniform prior” throughout the 1920’s and opting for a uniform (improper) prior is indeed making an arbitrary choice of a particular prior. [Which connects with my critical answer that to turn the likelihood into a density, a dominating measure must first be chosen and that there is no compelling argument to make the Lebesgue measure as a default choice.]
Fisher however made things more complicated when introducing the fiducial distribution in the 1950's since, to quote from Dennis Lindley (1958):
according to Fisher (1956) [the fact that the fiducial distribution is consistent under sequential updating] is true, though no formal proof is given, for he says (p. 51) "The concept of probability involved [in the fiducial argument] is entirely identical with the classical probability of the early writers, such as Bayes". Again he says (p. 125) "This fiducial distribution supplies information of exactly the same sort as would a distribution given a priori".
Although this is not exactly related with the original question, but for a uniform prior being used in both instances, let me point out that Lindley (1958) establishes that "therefore the fiducial argument is only consistent in the case of a single sufficient statistic when the distribution is of the gamma or normal forms, or transformable thereto." | Intuition for why likelihood function sometimes *is* a PDF
To quote from Ronald Fisher himself (and intersecting with the answer by NicoFish as well as the answer by WHuber to the earlier question):
when defining the likelihood function (as a function of the |
38,834 | Every second customer converts better. Can this be by chance? | With just the data you've posted, you can analyze it as a binomial distribution with each week being at trial. That would give a p-value of $2^{-11}$, or about $0.05\%$. You could also do a paired test, which would give you a binomial distribution with each pair of ids being a trial. Then there's a t-test on the total accepted amounts over odd ids and evens, but there's the issue of whether the underlying distribution is sufficiently normal.
Choosing what statistical test to do is problematic when you've already seen the data, as you'll be tailoring the test to match the pattern that you've already seen. However, there are different standards for when you're making a conclusion, versus when you're looking at whether something warrants further study. A p-value of $0.02\%$, even if it may be the result of p-hacking, justifies further investigation.
The data you've presented is very summary. You should get a more detailed look at the data. For instance, create a scatter plot with date of loan on one axis, size of loan (or perhaps log of size, if they are distributed over many orders of magnitude) on another, and different colors for odd or even ids. | Every second customer converts better. Can this be by chance? | With just the data you've posted, you can analyze it as a binomial distribution with each week being at trial. That would give a p-value of $2^{-11}$, or about $0.05\%$. You could also do a paired te | Every second customer converts better. Can this be by chance?
With just the data you've posted, you can analyze it as a binomial distribution with each week being at trial. That would give a p-value of $2^{-11}$, or about $0.05\%$. You could also do a paired test, which would give you a binomial distribution with each pair of ids being a trial. Then there's a t-test on the total accepted amounts over odd ids and evens, but there's the issue of whether the underlying distribution is sufficiently normal.
Choosing what statistical test to do is problematic when you've already seen the data, as you'll be tailoring the test to match the pattern that you've already seen. However, there are different standards for when you're making a conclusion, versus when you're looking at whether something warrants further study. A p-value of $0.02\%$, even if it may be the result of p-hacking, justifies further investigation.
The data you've presented is very summary. You should get a more detailed look at the data. For instance, create a scatter plot with date of loan on one axis, size of loan (or perhaps log of size, if they are distributed over many orders of magnitude) on another, and different colors for odd or even ids. | Every second customer converts better. Can this be by chance?
With just the data you've posted, you can analyze it as a binomial distribution with each week being at trial. That would give a p-value of $2^{-11}$, or about $0.05\%$. You could also do a paired te |
38,835 | Every second customer converts better. Can this be by chance? | There are a number of statistical test you could use to answer a question like this, but the simplest is the 2×2 chi-square contingency test (example here). | Every second customer converts better. Can this be by chance? | There are a number of statistical test you could use to answer a question like this, but the simplest is the 2×2 chi-square contingency test (example here). | Every second customer converts better. Can this be by chance?
There are a number of statistical test you could use to answer a question like this, but the simplest is the 2×2 chi-square contingency test (example here). | Every second customer converts better. Can this be by chance?
There are a number of statistical test you could use to answer a question like this, but the simplest is the 2×2 chi-square contingency test (example here). |
38,836 | Every second customer converts better. Can this be by chance? | Just add up all the accepted applications with odd and even IDs across all the dates so that you have two numbers: $N_{odd}, N_{even}$. Call your random variable $X \in \{0,1\}$ where 0 means even and 1 means odd. The ex-ante probability of $X=0$ (given that odd/even is random) is $p=0.5$. You've got $N=N_{odd}+N_{even}$ trials and you want to know the probability that $N_{even}$ of them are even given $p=0.5$. So, the distribution you want is the Binomial distribution, and thus $X\sim Binomial(N,p)$.
If $P(X=1\mid N,p)<x$ where $x$ is something suitably small, then you have a problem. If not then you could say it was chance. | Every second customer converts better. Can this be by chance? | Just add up all the accepted applications with odd and even IDs across all the dates so that you have two numbers: $N_{odd}, N_{even}$. Call your random variable $X \in \{0,1\}$ where 0 means even and | Every second customer converts better. Can this be by chance?
Just add up all the accepted applications with odd and even IDs across all the dates so that you have two numbers: $N_{odd}, N_{even}$. Call your random variable $X \in \{0,1\}$ where 0 means even and 1 means odd. The ex-ante probability of $X=0$ (given that odd/even is random) is $p=0.5$. You've got $N=N_{odd}+N_{even}$ trials and you want to know the probability that $N_{even}$ of them are even given $p=0.5$. So, the distribution you want is the Binomial distribution, and thus $X\sim Binomial(N,p)$.
If $P(X=1\mid N,p)<x$ where $x$ is something suitably small, then you have a problem. If not then you could say it was chance. | Every second customer converts better. Can this be by chance?
Just add up all the accepted applications with odd and even IDs across all the dates so that you have two numbers: $N_{odd}, N_{even}$. Call your random variable $X \in \{0,1\}$ where 0 means even and |
38,837 | Every second customer converts better. Can this be by chance? | At face value you have 11 samples in every case with B bigger than A. There are 2048 choices that could have happened (2^11) - viewing the choices as 11 binary bits makes it easy to visualise (assume bit is 0 for A>B and 1 for A<B). There is only one way B could always be bigger - the bit sequence 11111111111. But you had no a priori reason to think B would be bigger, so the equally extreme sequence 00000000000 is also equally valid. That would lead to a 1 in 1024 chance of the observed effect, highly significant (P~=0.001)
BUT as people have noted, you've only asked because you've seen an extreme pattern. So maybe 1023 other banks never asked.
AND look 2/3 of the way down your table. "B is bigger" seems to be untrue for 533 vs 527 (it is untrue for the ratios as well). So we've back to a lower probability, as any of the 11 could be 'reversed' and be just as extreme as your data. So that's another 22 cases that are just as extreme. So that's 24 of 2048, which is no longer significant at p=0.01.
Bottom line however - you're a new bank, it is quite an extreme pattern. I'd believe it was a true effect until I saw contradictory data. I don't know what programming language you're using but I'd suspect a reuse of a variable is causing the problem (or less likely a memory leak)
There is more information available in the actual ratios than in just saying whether A>B, but this is already enough of a smoking gun to look at the code - anything could happen statistically, it's not proof, the proof will be finding what's wrong with the code. | Every second customer converts better. Can this be by chance? | At face value you have 11 samples in every case with B bigger than A. There are 2048 choices that could have happened (2^11) - viewing the choices as 11 binary bits makes it easy to visualise (assume | Every second customer converts better. Can this be by chance?
At face value you have 11 samples in every case with B bigger than A. There are 2048 choices that could have happened (2^11) - viewing the choices as 11 binary bits makes it easy to visualise (assume bit is 0 for A>B and 1 for A<B). There is only one way B could always be bigger - the bit sequence 11111111111. But you had no a priori reason to think B would be bigger, so the equally extreme sequence 00000000000 is also equally valid. That would lead to a 1 in 1024 chance of the observed effect, highly significant (P~=0.001)
BUT as people have noted, you've only asked because you've seen an extreme pattern. So maybe 1023 other banks never asked.
AND look 2/3 of the way down your table. "B is bigger" seems to be untrue for 533 vs 527 (it is untrue for the ratios as well). So we've back to a lower probability, as any of the 11 could be 'reversed' and be just as extreme as your data. So that's another 22 cases that are just as extreme. So that's 24 of 2048, which is no longer significant at p=0.01.
Bottom line however - you're a new bank, it is quite an extreme pattern. I'd believe it was a true effect until I saw contradictory data. I don't know what programming language you're using but I'd suspect a reuse of a variable is causing the problem (or less likely a memory leak)
There is more information available in the actual ratios than in just saying whether A>B, but this is already enough of a smoking gun to look at the code - anything could happen statistically, it's not proof, the proof will be finding what's wrong with the code. | Every second customer converts better. Can this be by chance?
At face value you have 11 samples in every case with B bigger than A. There are 2048 choices that could have happened (2^11) - viewing the choices as 11 binary bits makes it easy to visualise (assume |
38,838 | infinite coin toss probability | For a fair coin $n_H/n_T\to 1$, but it is not the case that $n_H-n_T\to 0$. We know by the central limit theorem that the approximate distribution of $n_H$ is $N(n/2, n/4)$, so that the approximate distribution of $n_H-n_T$ is $N(0, n)$.
That is, $n_H-n_T$ has mean zero, but has typical size $\sqrt{n}$.
The approximate distribution of $M_n=2^{n_H-n_T}$ is logNormal. If $$\log_2 M_n\sim N(0,n)$$
then
$$\log M_n\sim N(0,(n)(\log 2)^2)$$
The mean of a logNormal distribution with log mean of $\mu$ and log variance of $\sigma^2$ is $\exp(\mu+\sigma^2/2)$, which comes to
$$\exp(0+(n/2)(\log 2)^2)\approx 1.27^n$$
This isn't exactly the $(5/4)^n$ that you get from the first approach, but it's not that far off given the relatively crudeness of the Normal approximation for small $n$. | infinite coin toss probability | For a fair coin $n_H/n_T\to 1$, but it is not the case that $n_H-n_T\to 0$. We know by the central limit theorem that the approximate distribution of $n_H$ is $N(n/2, n/4)$, so that the approximate d | infinite coin toss probability
For a fair coin $n_H/n_T\to 1$, but it is not the case that $n_H-n_T\to 0$. We know by the central limit theorem that the approximate distribution of $n_H$ is $N(n/2, n/4)$, so that the approximate distribution of $n_H-n_T$ is $N(0, n)$.
That is, $n_H-n_T$ has mean zero, but has typical size $\sqrt{n}$.
The approximate distribution of $M_n=2^{n_H-n_T}$ is logNormal. If $$\log_2 M_n\sim N(0,n)$$
then
$$\log M_n\sim N(0,(n)(\log 2)^2)$$
The mean of a logNormal distribution with log mean of $\mu$ and log variance of $\sigma^2$ is $\exp(\mu+\sigma^2/2)$, which comes to
$$\exp(0+(n/2)(\log 2)^2)\approx 1.27^n$$
This isn't exactly the $(5/4)^n$ that you get from the first approach, but it's not that far off given the relatively crudeness of the Normal approximation for small $n$. | infinite coin toss probability
For a fair coin $n_H/n_T\to 1$, but it is not the case that $n_H-n_T\to 0$. We know by the central limit theorem that the approximate distribution of $n_H$ is $N(n/2, n/4)$, so that the approximate d |
38,839 | infinite coin toss probability | Your 1st case
You could make your expression $\mathbb{E}(X)=\frac{1}{2}2+\frac{1}{2}\frac{1}{2}=\frac{5}{4}$ more correctly like:
$$\mathbb{E}(M_{n+1})=\frac{1}{2}2\mathbb{E}(M_{n})+\frac{1}{2}\frac{1}{2}\mathbb{E}(M_{n})=\frac{5}{4} \mathbb{E}(M_{n})$$
and as a result:
$$\mathbb{E}(M_{n})= \left( \frac{5}{4} \right)^n$$
I believe that this is the correct expression as I can relate it to two other paths:
computational By simulating a lot of cases I find that the power-law with a factor 5/4 seems correct.
# settings
set.seed(1)
ktoss <- 1:50
n <- 10^6
Q <- rep(0,length(ktoss))
# compute for 1 to 50 tosses n <- 10^6 million trials
for (k in ktoss) {
t <- rbinom(n,k,0.5)
Q[k-min(ktoss)+1] <- mean(2^(k-2*t))
}
# plotting
plot(ktoss,Q, log = "y")
lines(ktoss,(5/4)^ktoss)
Exact expression There is a direct way to compute the expectation for the power of a binomial distribution using the moment generating function (This is demonstrated in this question: Mean and variance of log-binomial distribution)
For the binomial distribution we have
$$E(e^{kX}) = M_{X}(k) = (1-p+p e^k)^n $$
and using shifting and scaling properties of the moment generating function you can get to
$$E(2^{2X_n-n}) = M_{2X_n-n}(\ln(2)) = e^{-ln(2)n}(1-p+p e^{ln(2) 2})^n = 1.25^n$$
I am not sure why the log-normal distribution does not approach the log-binomial distribution.
Your 2nd cse
The problem with the second argument is that
$$E(2^{X_n}) \neq 2^{E(X_n)}$$
But the expectation for the logarithm of the money is constant in time. | infinite coin toss probability | Your 1st case
You could make your expression $\mathbb{E}(X)=\frac{1}{2}2+\frac{1}{2}\frac{1}{2}=\frac{5}{4}$ more correctly like:
$$\mathbb{E}(M_{n+1})=\frac{1}{2}2\mathbb{E}(M_{n})+\frac{1}{2}\frac{1 | infinite coin toss probability
Your 1st case
You could make your expression $\mathbb{E}(X)=\frac{1}{2}2+\frac{1}{2}\frac{1}{2}=\frac{5}{4}$ more correctly like:
$$\mathbb{E}(M_{n+1})=\frac{1}{2}2\mathbb{E}(M_{n})+\frac{1}{2}\frac{1}{2}\mathbb{E}(M_{n})=\frac{5}{4} \mathbb{E}(M_{n})$$
and as a result:
$$\mathbb{E}(M_{n})= \left( \frac{5}{4} \right)^n$$
I believe that this is the correct expression as I can relate it to two other paths:
computational By simulating a lot of cases I find that the power-law with a factor 5/4 seems correct.
# settings
set.seed(1)
ktoss <- 1:50
n <- 10^6
Q <- rep(0,length(ktoss))
# compute for 1 to 50 tosses n <- 10^6 million trials
for (k in ktoss) {
t <- rbinom(n,k,0.5)
Q[k-min(ktoss)+1] <- mean(2^(k-2*t))
}
# plotting
plot(ktoss,Q, log = "y")
lines(ktoss,(5/4)^ktoss)
Exact expression There is a direct way to compute the expectation for the power of a binomial distribution using the moment generating function (This is demonstrated in this question: Mean and variance of log-binomial distribution)
For the binomial distribution we have
$$E(e^{kX}) = M_{X}(k) = (1-p+p e^k)^n $$
and using shifting and scaling properties of the moment generating function you can get to
$$E(2^{2X_n-n}) = M_{2X_n-n}(\ln(2)) = e^{-ln(2)n}(1-p+p e^{ln(2) 2})^n = 1.25^n$$
I am not sure why the log-normal distribution does not approach the log-binomial distribution.
Your 2nd cse
The problem with the second argument is that
$$E(2^{X_n}) \neq 2^{E(X_n)}$$
But the expectation for the logarithm of the money is constant in time. | infinite coin toss probability
Your 1st case
You could make your expression $\mathbb{E}(X)=\frac{1}{2}2+\frac{1}{2}\frac{1}{2}=\frac{5}{4}$ more correctly like:
$$\mathbb{E}(M_{n+1})=\frac{1}{2}2\mathbb{E}(M_{n})+\frac{1}{2}\frac{1 |
38,840 | infinite coin toss probability | Some caution is warranted here: Starting with a 'fortune' of \$1,
the variance of the fortune under the model described becomes
infinite. The analyses for a finite number of
coin tosses are OK, but the original question asks for behavior
as $n \rightarrow \infty.$
It doesn't take a run of hugely many successive H's or T's to overflow or underflow a double precision representation of the fortune. (More money than there is in the world, or an infinitesimal fraction of a cent.) Eventually, in a long sequence of tosses, such long runs
are inevitable.
For example, plots of fortunes for six simulated runs of
the experiment (each through a planned 100,000 coin tosses) are shown below.
The vertical scale for money is a log scale, so the horizontal line at $0$
represents no gain or loss.
set.seed(2020); n = 10^5
par(mfrow=c(2,3))
for(i in 1:6){
ht = sample(c(.5,2), n, rep=T)
money = cumprod(ht)
plot(1:n, log(money), ylim=c(-300,300), type="l")
abline(h=0, col="darkgreen") }
par(mfrow=c(1,1)) | infinite coin toss probability | Some caution is warranted here: Starting with a 'fortune' of \$1,
the variance of the fortune under the model described becomes
infinite. The analyses for a finite number of
coin tosses are OK, but th | infinite coin toss probability
Some caution is warranted here: Starting with a 'fortune' of \$1,
the variance of the fortune under the model described becomes
infinite. The analyses for a finite number of
coin tosses are OK, but the original question asks for behavior
as $n \rightarrow \infty.$
It doesn't take a run of hugely many successive H's or T's to overflow or underflow a double precision representation of the fortune. (More money than there is in the world, or an infinitesimal fraction of a cent.) Eventually, in a long sequence of tosses, such long runs
are inevitable.
For example, plots of fortunes for six simulated runs of
the experiment (each through a planned 100,000 coin tosses) are shown below.
The vertical scale for money is a log scale, so the horizontal line at $0$
represents no gain or loss.
set.seed(2020); n = 10^5
par(mfrow=c(2,3))
for(i in 1:6){
ht = sample(c(.5,2), n, rep=T)
money = cumprod(ht)
plot(1:n, log(money), ylim=c(-300,300), type="l")
abline(h=0, col="darkgreen") }
par(mfrow=c(1,1)) | infinite coin toss probability
Some caution is warranted here: Starting with a 'fortune' of \$1,
the variance of the fortune under the model described becomes
infinite. The analyses for a finite number of
coin tosses are OK, but th |
38,841 | Calibration curve of XGBoost for binary classification | I'm not sure "the objective function of XGBoost is 'binary:logistic', the probabilities should be well calibrated" is correct: gradient boosting tends to push probability toward 0 and 1. Furthermore, you're applying weights, which should also skew your probabilities.
Because gradient boosting pushes probabilities outward rather than inward, using Platt scaling (method='sigmoid') is generally not the best bet. On the other hand, your original calibration plot does look vaguely like the leftmost part of a sigmoid function. But that explains why your recalibrated scores get cut off at 0.75: fitting a sigmoid onto your calibration plot (which isn't actually what happens, but close enough) will have the right half of the sigmoid cut off.
For expediency, I would first try method='isotonic'. For better understanding, I would suggest shifting scores to account for the weighting you gave, and see where the calibration plot sits then. (The shifting correction is better documented for logistic regression, but see Does down-sampling change logistic regression coefficients? and Convert predicted probabilities after downsampling to actual probabilities in classification .
Finally, sklearn's calibration_curve uses equal-width bins by default, which in an inbalanced dataset is probably not best. You might want to modify it to use equal-size (as in, number of datapoints) bins instead to get a better picture. In particular, I suspect the last two points on your second calibration curve represent very few datapoints, and should be taken with a grain of salt. (In sklearn v0.21, this became easier with the new parameter strategy='quantile'.) | Calibration curve of XGBoost for binary classification | I'm not sure "the objective function of XGBoost is 'binary:logistic', the probabilities should be well calibrated" is correct: gradient boosting tends to push probability toward 0 and 1. Furthermore, | Calibration curve of XGBoost for binary classification
I'm not sure "the objective function of XGBoost is 'binary:logistic', the probabilities should be well calibrated" is correct: gradient boosting tends to push probability toward 0 and 1. Furthermore, you're applying weights, which should also skew your probabilities.
Because gradient boosting pushes probabilities outward rather than inward, using Platt scaling (method='sigmoid') is generally not the best bet. On the other hand, your original calibration plot does look vaguely like the leftmost part of a sigmoid function. But that explains why your recalibrated scores get cut off at 0.75: fitting a sigmoid onto your calibration plot (which isn't actually what happens, but close enough) will have the right half of the sigmoid cut off.
For expediency, I would first try method='isotonic'. For better understanding, I would suggest shifting scores to account for the weighting you gave, and see where the calibration plot sits then. (The shifting correction is better documented for logistic regression, but see Does down-sampling change logistic regression coefficients? and Convert predicted probabilities after downsampling to actual probabilities in classification .
Finally, sklearn's calibration_curve uses equal-width bins by default, which in an inbalanced dataset is probably not best. You might want to modify it to use equal-size (as in, number of datapoints) bins instead to get a better picture. In particular, I suspect the last two points on your second calibration curve represent very few datapoints, and should be taken with a grain of salt. (In sklearn v0.21, this became easier with the new parameter strategy='quantile'.) | Calibration curve of XGBoost for binary classification
I'm not sure "the objective function of XGBoost is 'binary:logistic', the probabilities should be well calibrated" is correct: gradient boosting tends to push probability toward 0 and 1. Furthermore, |
38,842 | Calibration curve of XGBoost for binary classification | I'm not that familiar with gradient boosting, but I would assume that if you scale your minority class then your model will not be well calibrated. At the end of the day, it has learnt the distribution of the training data which does not reflect reality.
As for CalibratedClassifierCV, from reading the docs it seems that the sigmoid method is not applicable here given your distortion is not sigmoid shaped. Hence, if you have enough data that overfitting is not an issue, then why not try method='isotonic'? | Calibration curve of XGBoost for binary classification | I'm not that familiar with gradient boosting, but I would assume that if you scale your minority class then your model will not be well calibrated. At the end of the day, it has learnt the distributio | Calibration curve of XGBoost for binary classification
I'm not that familiar with gradient boosting, but I would assume that if you scale your minority class then your model will not be well calibrated. At the end of the day, it has learnt the distribution of the training data which does not reflect reality.
As for CalibratedClassifierCV, from reading the docs it seems that the sigmoid method is not applicable here given your distortion is not sigmoid shaped. Hence, if you have enough data that overfitting is not an issue, then why not try method='isotonic'? | Calibration curve of XGBoost for binary classification
I'm not that familiar with gradient boosting, but I would assume that if you scale your minority class then your model will not be well calibrated. At the end of the day, it has learnt the distributio |
38,843 | Calibration curve of XGBoost for binary classification | Answer:
No wonder your post-calibration plot looks like this. Look at your reliability curve pre-calibration. The more predicted score grows, the more actual positives it picks up. However, the best your model can do is to extract around 20% of actual positives (when the predicted score is over 0.9). The ideal calibrator would squeeze your probability predictions into [0, 0.2] interval because your model can't do any better. In other words, a great calibrator would map your orange points onto the diagonal line by moving them approximately sideways to the left. You can't expect to get a well-calibrated score of 0.7 ever with this model because it's just not as good.
Additional remarks:
You're using Platt Scaling, and that's probably a good choice. As @Ben Reinger noted, your calibrator should look like a "leftmost part of a sigmoid function" and you should be able to train such a calibrator with the sigmoid method. You can check that by following a tutorial on Beta Calibration. The author plots three different calibration models to asses their performance.
Note: the default binning strategy you're using (uniform) is probably a good choice despite the top answer. "strategy"="uniform" bins the predictions by regular predicted_score intervals. For example, bin [0, 0.1) contains all the predictions with a score in that range. However, there might be more predictions in the [0, 0.1) than in the [0.1, 0.2) bin. This is desirable since we can independently asses the calibration in disjoint bins. The alternative "strategy"="quantile" works by binning the predictions so that all contain the same number of samples. This doesn't work well with imbalanced data because the calibration curve will depend greatly on the huge number of low-score predictions (see the histogram of predicted scores). However, we are much more interested in the high-score bins (provided there is enough data in them). | Calibration curve of XGBoost for binary classification | Answer:
No wonder your post-calibration plot looks like this. Look at your reliability curve pre-calibration. The more predicted score grows, the more actual positives it picks up. However, the best y | Calibration curve of XGBoost for binary classification
Answer:
No wonder your post-calibration plot looks like this. Look at your reliability curve pre-calibration. The more predicted score grows, the more actual positives it picks up. However, the best your model can do is to extract around 20% of actual positives (when the predicted score is over 0.9). The ideal calibrator would squeeze your probability predictions into [0, 0.2] interval because your model can't do any better. In other words, a great calibrator would map your orange points onto the diagonal line by moving them approximately sideways to the left. You can't expect to get a well-calibrated score of 0.7 ever with this model because it's just not as good.
Additional remarks:
You're using Platt Scaling, and that's probably a good choice. As @Ben Reinger noted, your calibrator should look like a "leftmost part of a sigmoid function" and you should be able to train such a calibrator with the sigmoid method. You can check that by following a tutorial on Beta Calibration. The author plots three different calibration models to asses their performance.
Note: the default binning strategy you're using (uniform) is probably a good choice despite the top answer. "strategy"="uniform" bins the predictions by regular predicted_score intervals. For example, bin [0, 0.1) contains all the predictions with a score in that range. However, there might be more predictions in the [0, 0.1) than in the [0.1, 0.2) bin. This is desirable since we can independently asses the calibration in disjoint bins. The alternative "strategy"="quantile" works by binning the predictions so that all contain the same number of samples. This doesn't work well with imbalanced data because the calibration curve will depend greatly on the huge number of low-score predictions (see the histogram of predicted scores). However, we are much more interested in the high-score bins (provided there is enough data in them). | Calibration curve of XGBoost for binary classification
Answer:
No wonder your post-calibration plot looks like this. Look at your reliability curve pre-calibration. The more predicted score grows, the more actual positives it picks up. However, the best y |
38,844 | Calculate variance without calculating the mean | The median absolute deviation is defined as
$$\text{MAD}(X) = \text{median} |X-\text{median}(X)|$$
and is considered an alternative to the standard deviation. But this is not the variance. In particular, it always exists, whether or not $X$ allows for moments. For instance, the MAD of a standard Cauchy is equal to one since
$$\underbrace{\Bbb P(|X-0|<1)}_\text{0 is the median}=\arctan(1)/\pi-\arctan(-1)/\pi=\frac{1}{2}$$ | Calculate variance without calculating the mean | The median absolute deviation is defined as
$$\text{MAD}(X) = \text{median} |X-\text{median}(X)|$$
and is considered an alternative to the standard deviation. But this is not the variance. In particu | Calculate variance without calculating the mean
The median absolute deviation is defined as
$$\text{MAD}(X) = \text{median} |X-\text{median}(X)|$$
and is considered an alternative to the standard deviation. But this is not the variance. In particular, it always exists, whether or not $X$ allows for moments. For instance, the MAD of a standard Cauchy is equal to one since
$$\underbrace{\Bbb P(|X-0|<1)}_\text{0 is the median}=\arctan(1)/\pi-\arctan(-1)/\pi=\frac{1}{2}$$ | Calculate variance without calculating the mean
The median absolute deviation is defined as
$$\text{MAD}(X) = \text{median} |X-\text{median}(X)|$$
and is considered an alternative to the standard deviation. But this is not the variance. In particu |
38,845 | Calculate variance without calculating the mean | There is already a solution for this question on Math.stackexchange:
I summarize the answers:
You can use that the variance is $\overline{x^2} - \overline {x}^2$, which takes only one pass (computing the mean and the mean of the squares simultaneously), but can be more prone to roundoff error if the variance is small compared with the mean.
How about sum of squared pairwise differences ? Indeed, you can check by direct computation that
$$
2v_X = \frac{1}{n(n-1)}\sum_{1 \le i < j \le n}(x_i - x_j)^2.
$$
The sample variance without mean is calculated as:
$$ v_{X}=\frac{1}{n-1}\left [ \sum_{i=1}^{n}x_{i}^{2}-\frac{1}{n}\left ( \sum_{i=1}^{n}x_{i} \right ) ^{2}\right ] $$ | Calculate variance without calculating the mean | There is already a solution for this question on Math.stackexchange:
I summarize the answers:
You can use that the variance is $\overline{x^2} - \overline {x}^2$, which takes only one pass (computing | Calculate variance without calculating the mean
There is already a solution for this question on Math.stackexchange:
I summarize the answers:
You can use that the variance is $\overline{x^2} - \overline {x}^2$, which takes only one pass (computing the mean and the mean of the squares simultaneously), but can be more prone to roundoff error if the variance is small compared with the mean.
How about sum of squared pairwise differences ? Indeed, you can check by direct computation that
$$
2v_X = \frac{1}{n(n-1)}\sum_{1 \le i < j \le n}(x_i - x_j)^2.
$$
The sample variance without mean is calculated as:
$$ v_{X}=\frac{1}{n-1}\left [ \sum_{i=1}^{n}x_{i}^{2}-\frac{1}{n}\left ( \sum_{i=1}^{n}x_{i} \right ) ^{2}\right ] $$ | Calculate variance without calculating the mean
There is already a solution for this question on Math.stackexchange:
I summarize the answers:
You can use that the variance is $\overline{x^2} - \overline {x}^2$, which takes only one pass (computing |
38,846 | Why does gls model without random effects yield a similar fit to mixed effects model? | Random effects also model correlations. To explain this more formally, the model that both lme() and gls() are fitting is the following
$$y_i = X_i\beta + \varepsilon_i, \quad \varepsilon_i \sim \mathcal N(0, V_i),$$
where $y_i$ denotes the outcome variable for the $i$-th group (i.e., follicles in your example, and the groups are indicated by the Mare variable), $X_i$ is the design matrix for the fixed effects $\beta$ (in your example $X_i$ has three columns, the intercept, sin(2 * pi * Time), and cos(2 * pi * Time)).
In your question, the focus is on $V_i$, which is the variance-covariance matrix for the error terms for the $i$-th group. You have the following options:
When you use gls() you postulate that $V_i = \Sigma_i$, where the structure of $\Sigma_i$ is determined by the option you have selected in the correlation argument. I.e., you specified an ARMA model for it.
When you use lme() in which you specify only the random argument but not the correlation argument, then you postulate that $V_i = Z_i D Z_i^\top + \sigma^2 \texttt{I}$, where $Z_i$ denotes the design matrix of the random effects, $D$ is the variance-covariance matrix of the random effects, and $\sigma^2$ is the variance of the within groups error terms with $\texttt I$ denoting the identity matrix. In your example, you specified that $Z_i$ has two columns (intercept and sin(2 * pi * Time)), and that the $2 \times 2$ covariance matrix of the random effects is diagonal with the covariance set to zero.
When you use lme() in which you specify both the random and correlation argument, then you say that $V_i = Z_i D Z_i^\top + \Sigma_i$, where $\Sigma_i$ is the same matrix as in gls(). That is, you model the marginal covariance matrix $V_i$ using both random effects and a serial correlation structure. In you example, you combined the serial correlation structure mentioned in the first bullet with the random-effect structure mentioned in the second bullet.
The results of the likelihood ratio test between the two models suggest that the inclusion of random effects, i.e., the inclusion of the $Z_i D Z_i^\top$ term in the marginal covariance matrix does not improve the fit of the model over just using the ARMA serial correlation term $\Sigma_i$. | Why does gls model without random effects yield a similar fit to mixed effects model? | Random effects also model correlations. To explain this more formally, the model that both lme() and gls() are fitting is the following
$$y_i = X_i\beta + \varepsilon_i, \quad \varepsilon_i \sim \mat | Why does gls model without random effects yield a similar fit to mixed effects model?
Random effects also model correlations. To explain this more formally, the model that both lme() and gls() are fitting is the following
$$y_i = X_i\beta + \varepsilon_i, \quad \varepsilon_i \sim \mathcal N(0, V_i),$$
where $y_i$ denotes the outcome variable for the $i$-th group (i.e., follicles in your example, and the groups are indicated by the Mare variable), $X_i$ is the design matrix for the fixed effects $\beta$ (in your example $X_i$ has three columns, the intercept, sin(2 * pi * Time), and cos(2 * pi * Time)).
In your question, the focus is on $V_i$, which is the variance-covariance matrix for the error terms for the $i$-th group. You have the following options:
When you use gls() you postulate that $V_i = \Sigma_i$, where the structure of $\Sigma_i$ is determined by the option you have selected in the correlation argument. I.e., you specified an ARMA model for it.
When you use lme() in which you specify only the random argument but not the correlation argument, then you postulate that $V_i = Z_i D Z_i^\top + \sigma^2 \texttt{I}$, where $Z_i$ denotes the design matrix of the random effects, $D$ is the variance-covariance matrix of the random effects, and $\sigma^2$ is the variance of the within groups error terms with $\texttt I$ denoting the identity matrix. In your example, you specified that $Z_i$ has two columns (intercept and sin(2 * pi * Time)), and that the $2 \times 2$ covariance matrix of the random effects is diagonal with the covariance set to zero.
When you use lme() in which you specify both the random and correlation argument, then you say that $V_i = Z_i D Z_i^\top + \Sigma_i$, where $\Sigma_i$ is the same matrix as in gls(). That is, you model the marginal covariance matrix $V_i$ using both random effects and a serial correlation structure. In you example, you combined the serial correlation structure mentioned in the first bullet with the random-effect structure mentioned in the second bullet.
The results of the likelihood ratio test between the two models suggest that the inclusion of random effects, i.e., the inclusion of the $Z_i D Z_i^\top$ term in the marginal covariance matrix does not improve the fit of the model over just using the ARMA serial correlation term $\Sigma_i$. | Why does gls model without random effects yield a similar fit to mixed effects model?
Random effects also model correlations. To explain this more formally, the model that both lme() and gls() are fitting is the following
$$y_i = X_i\beta + \varepsilon_i, \quad \varepsilon_i \sim \mat |
38,847 | Calculating total estimated degrees of freedom for a GAM | The correct terminology for the degrees of freedom that you need to compute is model degrees of freedom. You could also compute residual degrees of freedom.
The model degrees of freedom are indeed calculated by adding up the degrees of freedom used by the parametric and non-parametric (or smooth) terms in your model.
Here is an example of gam model for which you can check the computation of model degrees of freedom:
library(mgcv)
set.seed(6)
dat <- gamSim(1,n=400,dist="poisson",scale=.1)
m <-gam(y~s(x0)+s(x1)+s(x2)+ s(x3),family=poisson,data=dat,method="REML")
plot(m,pages=1)
summary(m)
The output produced by this model is as follows:
Family: poisson
Link function: log
Formula:
y ~ s(x0) + s(x1) + s(x2) + s(x3)
Parametric coefficients:
Estimate Std. Error z value Pr(>|z|)
(Intercept) 0.82292 0.03419 24.07 <2e-16 ***
---
Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
Approximate significance of smooth terms:
edf Ref.df Chi.sq p-value
s(x0) 2.432 3.029 5.517 0.141
s(x1) 1.563 1.928 33.913 3.12e-08 ***
s(x2) 6.317 7.473 99.405 < 2e-16 ***
s(x3) 1.001 1.003 0.240 0.626
---
Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
R-sq.(adj) = 0.256 Deviance explained = 24.2%
-REML = 744.98 Scale est. = 1 n = 400
If you add the degrees of freedom used by the parametric terms (i.e., 1 degree of freedom for the intercept) and the degrees of freedom used by the non-parametric terms (i.e., the effective degrees of freedom listed in the edf column), you get:
1 + 2.432 + 1.563 + 6.317 + 1.001 = 12.313
You can double-check that your computation is correct via the command:
sum(influence(m))
which produces the output below:
> sum(influence(m))
[1] 12.31309
The residual degrees of freedom would be computed as the difference between the number of observations included in the model (n) and the model degrees of freedom (mdf): n - mdf. For the present example, n = 400 and mdf = 12.313, so that the residual degrees of freedom would be 400 - 12.313 = 387.687.
Note that, if you were to compare your model against the intercept-only model, the anova function would report slightly different residual degrees of freedom, since it uses a different formula for the computation of model degrees of freedom and this affects the computation of the residual degrees of freedom.
m0 <- gam(y~1,family=poisson,data=dat,method="REML")
m0
m <-gam(y~s(x0)+s(x1)+s(x2)+ s(x3),family=poisson,data=dat,method="REML")
m
anova(m0,m, test="Chisq")
The output of the anova command would look like this:
> anova(m0,m, test="Chisq")
Analysis of Deviance Table
Model 1: y ~ 1
Model 2: y ~ s(x0) + s(x1) + s(x2) + s(x3)
Resid. Df Resid. Dev Df Deviance Pr(>Chi)
1 399.00 625.87
2 383.45 474.38 15.552 151.48 < 2.2e-16 ***
---
Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
The residual degrees of freedom reported by the anova for Model 2 (i.e., m) are equal to 383.45 (rather than 387.687).
See https://web.as.uky.edu/statistics/users/pbreheny/621/F12/notes/11-29.pdf (slide 25/30) for an explanation of the difference in formulas used in the summary() and anova() functions when it comes to the computation of the model degrees of freedom. | Calculating total estimated degrees of freedom for a GAM | The correct terminology for the degrees of freedom that you need to compute is model degrees of freedom. You could also compute residual degrees of freedom.
The model degrees of freedom are indeed | Calculating total estimated degrees of freedom for a GAM
The correct terminology for the degrees of freedom that you need to compute is model degrees of freedom. You could also compute residual degrees of freedom.
The model degrees of freedom are indeed calculated by adding up the degrees of freedom used by the parametric and non-parametric (or smooth) terms in your model.
Here is an example of gam model for which you can check the computation of model degrees of freedom:
library(mgcv)
set.seed(6)
dat <- gamSim(1,n=400,dist="poisson",scale=.1)
m <-gam(y~s(x0)+s(x1)+s(x2)+ s(x3),family=poisson,data=dat,method="REML")
plot(m,pages=1)
summary(m)
The output produced by this model is as follows:
Family: poisson
Link function: log
Formula:
y ~ s(x0) + s(x1) + s(x2) + s(x3)
Parametric coefficients:
Estimate Std. Error z value Pr(>|z|)
(Intercept) 0.82292 0.03419 24.07 <2e-16 ***
---
Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
Approximate significance of smooth terms:
edf Ref.df Chi.sq p-value
s(x0) 2.432 3.029 5.517 0.141
s(x1) 1.563 1.928 33.913 3.12e-08 ***
s(x2) 6.317 7.473 99.405 < 2e-16 ***
s(x3) 1.001 1.003 0.240 0.626
---
Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
R-sq.(adj) = 0.256 Deviance explained = 24.2%
-REML = 744.98 Scale est. = 1 n = 400
If you add the degrees of freedom used by the parametric terms (i.e., 1 degree of freedom for the intercept) and the degrees of freedom used by the non-parametric terms (i.e., the effective degrees of freedom listed in the edf column), you get:
1 + 2.432 + 1.563 + 6.317 + 1.001 = 12.313
You can double-check that your computation is correct via the command:
sum(influence(m))
which produces the output below:
> sum(influence(m))
[1] 12.31309
The residual degrees of freedom would be computed as the difference between the number of observations included in the model (n) and the model degrees of freedom (mdf): n - mdf. For the present example, n = 400 and mdf = 12.313, so that the residual degrees of freedom would be 400 - 12.313 = 387.687.
Note that, if you were to compare your model against the intercept-only model, the anova function would report slightly different residual degrees of freedom, since it uses a different formula for the computation of model degrees of freedom and this affects the computation of the residual degrees of freedom.
m0 <- gam(y~1,family=poisson,data=dat,method="REML")
m0
m <-gam(y~s(x0)+s(x1)+s(x2)+ s(x3),family=poisson,data=dat,method="REML")
m
anova(m0,m, test="Chisq")
The output of the anova command would look like this:
> anova(m0,m, test="Chisq")
Analysis of Deviance Table
Model 1: y ~ 1
Model 2: y ~ s(x0) + s(x1) + s(x2) + s(x3)
Resid. Df Resid. Dev Df Deviance Pr(>Chi)
1 399.00 625.87
2 383.45 474.38 15.552 151.48 < 2.2e-16 ***
---
Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
The residual degrees of freedom reported by the anova for Model 2 (i.e., m) are equal to 383.45 (rather than 387.687).
See https://web.as.uky.edu/statistics/users/pbreheny/621/F12/notes/11-29.pdf (slide 25/30) for an explanation of the difference in formulas used in the summary() and anova() functions when it comes to the computation of the model degrees of freedom. | Calculating total estimated degrees of freedom for a GAM
The correct terminology for the degrees of freedom that you need to compute is model degrees of freedom. You could also compute residual degrees of freedom.
The model degrees of freedom are indeed |
38,848 | hard voting versus soft voting in ensemble based methods [duplicate] | Suppose you have probabilities:
0.45
0.45
0.90
Then hard voting would give you a score of 1/3 (1 vote in favour and 2 against), so it would classify as a "negative".
Soft voting would give you the average of the probabilities, which is 0.6, and would be a "positive".
Soft voting takes into account how certain each voter is, rather than just a binary input from the voter. | hard voting versus soft voting in ensemble based methods [duplicate] | Suppose you have probabilities:
0.45
0.45
0.90
Then hard voting would give you a score of 1/3 (1 vote in favour and 2 against), so it would classify as a "negative".
Soft voting would give you the ave | hard voting versus soft voting in ensemble based methods [duplicate]
Suppose you have probabilities:
0.45
0.45
0.90
Then hard voting would give you a score of 1/3 (1 vote in favour and 2 against), so it would classify as a "negative".
Soft voting would give you the average of the probabilities, which is 0.6, and would be a "positive".
Soft voting takes into account how certain each voter is, rather than just a binary input from the voter. | hard voting versus soft voting in ensemble based methods [duplicate]
Suppose you have probabilities:
0.45
0.45
0.90
Then hard voting would give you a score of 1/3 (1 vote in favour and 2 against), so it would classify as a "negative".
Soft voting would give you the ave |
38,849 | What is a strict definition of U-shaped relationship? | The short answer to your question (as stated elsewhere) is that
there is no single mathematical definition of a U-shape. The comment by @whuber is the
best general definition that I have seen.
I do research on tests of U-shapes and for my presentation I have a slide with the title
"What does a U mean to you?", meaning that it is subjective what people mean by
the term "U-shape". The most important thing is that when you use the term
"U-shape", you define exactly what you mean by it, without assuming that
others will know what you mean.
Since you specified the case of only one regressor, I'll focus on that. I've
seen the following definitions used in various articles:
A U-shape is a quadratic.
A U-shape means convexity (for an application along these lines, see Van Landeghem's 2012 "A test for the convexity of human well-being over the life cycle: Longitudinal evidence from a 20-year panel").
A U-shape is a function with weighted average derivative negative until a point, and weighted average derivative positive after that point (see Uri Simonsohn's Two-Lines: The First Valid Test of U-Shaped Relationships).
A U-shape is a function with exactly one turning point. This corresponds to a function that is quasi-convex but not monotone.
One complication that comes up is what if the turning point is close to the
ends of the range of the x variable? Should we still consider such a function a
U-shape? In my opinion, such a discussion should be had when you define what a
U-shape means to you for your application, and when you specify your null
hypothesis.
The definition I use in my paper, Non-Parametric Testing of U-Shaped Relationships, is the following:
Let $m(x)$ be the regression function and let $S\left(X\right)$ be the support of $X$. For a specified set $A_{0}\subset S\left(X\right)$, we are interested in testing the following:
$$\begin{align*}
H_{0}\colon & \exists a\in A_{0}\mbox{ st }\forall x\in S\left(X\right)\\
& m^{'}\left(x\right)\left(x-a\right)\ge0\\
\text{versus}\\H_{A}\colon & \forall a\in A_{0},\,\exists x\in S\left(X\right)\mbox{ st}\\
& m^{'}\left(x\right)\left(x-a\right)<0
\end{align*}$$
For example, in an application I test for a U-shape of life satisfaction in age
from age 20 to 70, where the turning point is between ages 30 and 60. Arbitrary
decisions are necessary with this proposed framework. The important thing is to be open
about them and check how sensitive results are to changes (and to challenge others to do the same).
In addition to stating the null hypothesis, as always you should state the
assumptions you rely on. For example, a common assumption is that the
regression function is either U-shaped on monotone. See, for example, Lind and
Mehlum's 2009 "With or Without U? The Appropriate Test for a U-Shaped
Relationship", where they propose an improvement on the vanilla OLS quadratic test by testing that the derivative of a specified functional
form is negative at the beginning of the range, and positive at the end.
An additional point to consider is: Do you want a test that rejects the null hypothesis because of a small violation of U-shapedness? If yes, consider the R package qmutest, which implements a non-parametric tests based on splines of the null hypotheses that the regression function is quasi-convex, and separately that it is monotone. If you do not want a test that gives inference against a U-shape because of a small violation, Uri's two lines test might be best if you want to test that a regression function is mostly decreasing and then mostly increasing.
Since your question was about the use of the term "U-shape" and the
definition, I find it relevant to list some terms here that are used often to
refer to the same thing that "U-shape" and "inverted U-shape" are used to refer
to: "valley-shaped", "trough-shaped", "hill-shaped", "unimodal",
"single-peaked", and "bell-shaped". There is no inherent reason why "U-shape"
is a better term than the others, but its use seems to have caught on.
I'm working on a general R package that will just be an interface to
specific R packages (such as qmutest) that test for U-shaped relationships however they choose to
define them. The goal will be to help users compare different tests and to
think hard about the exact null hypothesis they want to test, and which
assumptions they are prepared to make. | What is a strict definition of U-shaped relationship? | The short answer to your question (as stated elsewhere) is that
there is no single mathematical definition of a U-shape. The comment by @whuber is the
best general definition that I have seen.
I do re | What is a strict definition of U-shaped relationship?
The short answer to your question (as stated elsewhere) is that
there is no single mathematical definition of a U-shape. The comment by @whuber is the
best general definition that I have seen.
I do research on tests of U-shapes and for my presentation I have a slide with the title
"What does a U mean to you?", meaning that it is subjective what people mean by
the term "U-shape". The most important thing is that when you use the term
"U-shape", you define exactly what you mean by it, without assuming that
others will know what you mean.
Since you specified the case of only one regressor, I'll focus on that. I've
seen the following definitions used in various articles:
A U-shape is a quadratic.
A U-shape means convexity (for an application along these lines, see Van Landeghem's 2012 "A test for the convexity of human well-being over the life cycle: Longitudinal evidence from a 20-year panel").
A U-shape is a function with weighted average derivative negative until a point, and weighted average derivative positive after that point (see Uri Simonsohn's Two-Lines: The First Valid Test of U-Shaped Relationships).
A U-shape is a function with exactly one turning point. This corresponds to a function that is quasi-convex but not monotone.
One complication that comes up is what if the turning point is close to the
ends of the range of the x variable? Should we still consider such a function a
U-shape? In my opinion, such a discussion should be had when you define what a
U-shape means to you for your application, and when you specify your null
hypothesis.
The definition I use in my paper, Non-Parametric Testing of U-Shaped Relationships, is the following:
Let $m(x)$ be the regression function and let $S\left(X\right)$ be the support of $X$. For a specified set $A_{0}\subset S\left(X\right)$, we are interested in testing the following:
$$\begin{align*}
H_{0}\colon & \exists a\in A_{0}\mbox{ st }\forall x\in S\left(X\right)\\
& m^{'}\left(x\right)\left(x-a\right)\ge0\\
\text{versus}\\H_{A}\colon & \forall a\in A_{0},\,\exists x\in S\left(X\right)\mbox{ st}\\
& m^{'}\left(x\right)\left(x-a\right)<0
\end{align*}$$
For example, in an application I test for a U-shape of life satisfaction in age
from age 20 to 70, where the turning point is between ages 30 and 60. Arbitrary
decisions are necessary with this proposed framework. The important thing is to be open
about them and check how sensitive results are to changes (and to challenge others to do the same).
In addition to stating the null hypothesis, as always you should state the
assumptions you rely on. For example, a common assumption is that the
regression function is either U-shaped on monotone. See, for example, Lind and
Mehlum's 2009 "With or Without U? The Appropriate Test for a U-Shaped
Relationship", where they propose an improvement on the vanilla OLS quadratic test by testing that the derivative of a specified functional
form is negative at the beginning of the range, and positive at the end.
An additional point to consider is: Do you want a test that rejects the null hypothesis because of a small violation of U-shapedness? If yes, consider the R package qmutest, which implements a non-parametric tests based on splines of the null hypotheses that the regression function is quasi-convex, and separately that it is monotone. If you do not want a test that gives inference against a U-shape because of a small violation, Uri's two lines test might be best if you want to test that a regression function is mostly decreasing and then mostly increasing.
Since your question was about the use of the term "U-shape" and the
definition, I find it relevant to list some terms here that are used often to
refer to the same thing that "U-shape" and "inverted U-shape" are used to refer
to: "valley-shaped", "trough-shaped", "hill-shaped", "unimodal",
"single-peaked", and "bell-shaped". There is no inherent reason why "U-shape"
is a better term than the others, but its use seems to have caught on.
I'm working on a general R package that will just be an interface to
specific R packages (such as qmutest) that test for U-shaped relationships however they choose to
define them. The goal will be to help users compare different tests and to
think hard about the exact null hypothesis they want to test, and which
assumptions they are prepared to make. | What is a strict definition of U-shaped relationship?
The short answer to your question (as stated elsewhere) is that
there is no single mathematical definition of a U-shape. The comment by @whuber is the
best general definition that I have seen.
I do re |
38,850 | What is a strict definition of U-shaped relationship? | "U-shaped relationship" is not a mathematically precise term and there is no universally accepted definition. It usually means that the relationship is first decreasing and then increasing, or vice versa.
In other words, it means that the relationship is not monotonic (non-monotonic), but instead has exactly one extremum (maximum or minimum). In computer science this is sometimes called "bitonic".
Uri Simonsohn has recently written an interesting paper about testing U-shaped relationships. See his preprint Two-Lines: A Valid Alternative to the Invalid Testing of U-Shaped Relationships with Quadratic Regressions which is very readable and amusing. Here is how the paper starts:
Is there such thing as too many options, virtues, or examples in an opening
sentence? Researchers are often interested in these types of questions, in assessing if the effect of $x$ on $y$ is positive for low values of $x$, but negative for high values of $x$. For ease of exposition, I refer to all
such relationships as 'u-shaped,' whether they are symmetric
or not (i.e., U or J shaped), and whether the effect of $x$ on $y$ goes from negative to positive or vice versa (i.e., U or inverted-U).
This supports the definition I gave above.
For a short overview of Uri's paper, one can read his DataColada post Two-lines: The First Valid Test of U-Shaped Relationships. The main point is that using quadratic regression to test the presence of a U-shaped relationship is very very wrong. Apparently quadratic fits are often used in some fields to argue in favor of a U-shaped relationship (i.e. t-test for the quadratic term is taken to be the test of U-shape-ness); this is troubling.
Here is the key figure:
Update: There is some criticism of Uri's paper in the comments. I would like to stress that he never suggests that discontinuous two-line fits are supposed to model the data well (or that the jump at the discontinuity has some physical meaning). No. This fit is used for the sole purpose of providing a statistical test of U-shape-ness.
Of course I agree with @FrankHarrell that it makes much more sense to use a spline model to fit such nonlinear relationships. But splines do not provide a test of U-shape-ness, whereas Uri's two-line fit does. | What is a strict definition of U-shaped relationship? | "U-shaped relationship" is not a mathematically precise term and there is no universally accepted definition. It usually means that the relationship is first decreasing and then increasing, or vice ve | What is a strict definition of U-shaped relationship?
"U-shaped relationship" is not a mathematically precise term and there is no universally accepted definition. It usually means that the relationship is first decreasing and then increasing, or vice versa.
In other words, it means that the relationship is not monotonic (non-monotonic), but instead has exactly one extremum (maximum or minimum). In computer science this is sometimes called "bitonic".
Uri Simonsohn has recently written an interesting paper about testing U-shaped relationships. See his preprint Two-Lines: A Valid Alternative to the Invalid Testing of U-Shaped Relationships with Quadratic Regressions which is very readable and amusing. Here is how the paper starts:
Is there such thing as too many options, virtues, or examples in an opening
sentence? Researchers are often interested in these types of questions, in assessing if the effect of $x$ on $y$ is positive for low values of $x$, but negative for high values of $x$. For ease of exposition, I refer to all
such relationships as 'u-shaped,' whether they are symmetric
or not (i.e., U or J shaped), and whether the effect of $x$ on $y$ goes from negative to positive or vice versa (i.e., U or inverted-U).
This supports the definition I gave above.
For a short overview of Uri's paper, one can read his DataColada post Two-lines: The First Valid Test of U-Shaped Relationships. The main point is that using quadratic regression to test the presence of a U-shaped relationship is very very wrong. Apparently quadratic fits are often used in some fields to argue in favor of a U-shaped relationship (i.e. t-test for the quadratic term is taken to be the test of U-shape-ness); this is troubling.
Here is the key figure:
Update: There is some criticism of Uri's paper in the comments. I would like to stress that he never suggests that discontinuous two-line fits are supposed to model the data well (or that the jump at the discontinuity has some physical meaning). No. This fit is used for the sole purpose of providing a statistical test of U-shape-ness.
Of course I agree with @FrankHarrell that it makes much more sense to use a spline model to fit such nonlinear relationships. But splines do not provide a test of U-shape-ness, whereas Uri's two-line fit does. | What is a strict definition of U-shaped relationship?
"U-shaped relationship" is not a mathematically precise term and there is no universally accepted definition. It usually means that the relationship is first decreasing and then increasing, or vice ve |
38,851 | Ridge Regression -Increase in $\lambda$ leads to a decrease in flexibilty | Let's ignore the penalty term for a moment, while we explore the sensitivity of the solution to changes in a single observation. This has ramifications for all linear least-squares models, not just Ridge regression.
Notation
To simplify the notation, let $X$ be the model matrix, including a column of constant values (and therefore having $p+1$ columns indexed from $0$ through $p$), let $y$ be the response $n$-vector, and let $\beta=(\beta_0, \beta_1, \ldots, \beta_p)$ be the $p+1$-vector of coefficients. Write $\mathbf{x}_i = (x_{i0}, x_{i1}, \ldots, x_{ip})$ for observation $i$. The unpenalized objective is the (squared) $L_2$ norm of the difference,
$$RSS(\beta)=||y - X\beta||^2 = \sum_{i=1}^n (y_i - \mathbf{x}_i\beta)^2.\tag{1}$$
Without any loss of generality, order the observations so the one in question is the last. Let $k$ be the index of any one of the variables ($0 \le k \le p$).
Analysis
The aim is to expose the essential simplicity of this situation by focusing on how the sum of squares $RSS$ depends on $x_{nk}$ and $\beta_k$--nothing else matters. To this end, split $RSS$ into the contributions from the first $n-1$ observations and the last one:
$$RSS(\beta) = (y_n - \mathbf{x}_n\beta)^2 + \sum_{i=1}^{n-1} (y_i - \mathbf{x}_i\beta)^2.$$
Both terms are quadratic functions of $\beta_k$. Considering all the other $\beta_j,$ $j\ne k$, as constants for the moment, this means the objective can be written in the form
$$RSS(\beta_k) = (x_{nk}^2 \beta_k^2 + E\beta_kx_{nk} + F) + (A^2\beta_k^2 + B\beta_k + C).$$
The new quantities $A\cdots F$ do not depend on $\beta_k$ or $x_{nk}$. Combining the terms and completing the square gives something in the form
$$RSS(\beta_k) = \left(\beta_k\sqrt{x_{nk}^2 + A^2} + \frac{Ex_{nk}+B}{2\sqrt{x_{nk}^2+A^2}} \right)^2 + G - \frac{(Ex_{nk}+B)^2}{4(x_{nk}^2+A^2)}\tag{2}$$
where the quantity $G$ does not depend on $x_{nk}$ or $\beta_k$.
Estimating sensitivity
We may readily estimate the sizes of the coefficients in $(2)$ when $|x_{nk}|$ grows large compared to $|A|$. When that is the case,
$$RSS(\beta_k) \approx \left(\beta_k x_{nk} + E/2\right)^2 + G-E^2/4.$$
This makes it easy to see what changing $|x_{nk}|$ must do to the optimum $\hat\beta_k$. For sufficiently large $|x_{nk}|$, $\beta_k$ will be inversely proportional to $x_{nk}$.
We actually have learned, and proven, much more than was requested, because Ridge regression can be formulated as model $(1)$. Specifically, to the original $n$ observations you will adjoin $p+1$ fake observations of the form $\mathbf{x}_{n+i} = (0,0,\ldots, 0,1,0,\ldots,0)$ and then you will multiply them all by the penalty parameter $\lambda$. The preceding analysis shows that for $\lambda$ sufficiently large (and "sufficiently" can be computed in terms of $|A|$, which is a function of the actual data only), every one of the $\hat\beta_k$ will be approximately inversely proportional to $\lambda$.
An analysis that requires some more sophisticated results from Linear Algebra appears at The proof of shrinking coefficients using ridge regression through "spectral decomposition". It does add one insight: the coefficients in the asymptotic relationships $\hat\beta_k \sim 1/\lambda$ will be the reciprocal nonzero singular values of $X$. | Ridge Regression -Increase in $\lambda$ leads to a decrease in flexibilty | Let's ignore the penalty term for a moment, while we explore the sensitivity of the solution to changes in a single observation. This has ramifications for all linear least-squares models, not just R | Ridge Regression -Increase in $\lambda$ leads to a decrease in flexibilty
Let's ignore the penalty term for a moment, while we explore the sensitivity of the solution to changes in a single observation. This has ramifications for all linear least-squares models, not just Ridge regression.
Notation
To simplify the notation, let $X$ be the model matrix, including a column of constant values (and therefore having $p+1$ columns indexed from $0$ through $p$), let $y$ be the response $n$-vector, and let $\beta=(\beta_0, \beta_1, \ldots, \beta_p)$ be the $p+1$-vector of coefficients. Write $\mathbf{x}_i = (x_{i0}, x_{i1}, \ldots, x_{ip})$ for observation $i$. The unpenalized objective is the (squared) $L_2$ norm of the difference,
$$RSS(\beta)=||y - X\beta||^2 = \sum_{i=1}^n (y_i - \mathbf{x}_i\beta)^2.\tag{1}$$
Without any loss of generality, order the observations so the one in question is the last. Let $k$ be the index of any one of the variables ($0 \le k \le p$).
Analysis
The aim is to expose the essential simplicity of this situation by focusing on how the sum of squares $RSS$ depends on $x_{nk}$ and $\beta_k$--nothing else matters. To this end, split $RSS$ into the contributions from the first $n-1$ observations and the last one:
$$RSS(\beta) = (y_n - \mathbf{x}_n\beta)^2 + \sum_{i=1}^{n-1} (y_i - \mathbf{x}_i\beta)^2.$$
Both terms are quadratic functions of $\beta_k$. Considering all the other $\beta_j,$ $j\ne k$, as constants for the moment, this means the objective can be written in the form
$$RSS(\beta_k) = (x_{nk}^2 \beta_k^2 + E\beta_kx_{nk} + F) + (A^2\beta_k^2 + B\beta_k + C).$$
The new quantities $A\cdots F$ do not depend on $\beta_k$ or $x_{nk}$. Combining the terms and completing the square gives something in the form
$$RSS(\beta_k) = \left(\beta_k\sqrt{x_{nk}^2 + A^2} + \frac{Ex_{nk}+B}{2\sqrt{x_{nk}^2+A^2}} \right)^2 + G - \frac{(Ex_{nk}+B)^2}{4(x_{nk}^2+A^2)}\tag{2}$$
where the quantity $G$ does not depend on $x_{nk}$ or $\beta_k$.
Estimating sensitivity
We may readily estimate the sizes of the coefficients in $(2)$ when $|x_{nk}|$ grows large compared to $|A|$. When that is the case,
$$RSS(\beta_k) \approx \left(\beta_k x_{nk} + E/2\right)^2 + G-E^2/4.$$
This makes it easy to see what changing $|x_{nk}|$ must do to the optimum $\hat\beta_k$. For sufficiently large $|x_{nk}|$, $\beta_k$ will be inversely proportional to $x_{nk}$.
We actually have learned, and proven, much more than was requested, because Ridge regression can be formulated as model $(1)$. Specifically, to the original $n$ observations you will adjoin $p+1$ fake observations of the form $\mathbf{x}_{n+i} = (0,0,\ldots, 0,1,0,\ldots,0)$ and then you will multiply them all by the penalty parameter $\lambda$. The preceding analysis shows that for $\lambda$ sufficiently large (and "sufficiently" can be computed in terms of $|A|$, which is a function of the actual data only), every one of the $\hat\beta_k$ will be approximately inversely proportional to $\lambda$.
An analysis that requires some more sophisticated results from Linear Algebra appears at The proof of shrinking coefficients using ridge regression through "spectral decomposition". It does add one insight: the coefficients in the asymptotic relationships $\hat\beta_k \sim 1/\lambda$ will be the reciprocal nonzero singular values of $X$. | Ridge Regression -Increase in $\lambda$ leads to a decrease in flexibilty
Let's ignore the penalty term for a moment, while we explore the sensitivity of the solution to changes in a single observation. This has ramifications for all linear least-squares models, not just R |
38,852 | Ridge Regression -Increase in $\lambda$ leads to a decrease in flexibilty | This can be most easily seen through Lagrange duality: there exists some $C$ so that $$\arg\min_{\beta \in \mathbb{R}^p} RSS + \lambda \sum_{i=0}^p \beta_i^2 = \arg\min_{\beta\in\mathbb{R}^p \, : \, \|\beta\|_2^2 \leq C} RSS.$$ Further, we know that larger $\lambda$ corresponds to smaller $C$. Therefore, increasing the tuning parameter $\lambda$ further constrains the $\ell_2$ norm of the coefficients, leading to less flexibility. | Ridge Regression -Increase in $\lambda$ leads to a decrease in flexibilty | This can be most easily seen through Lagrange duality: there exists some $C$ so that $$\arg\min_{\beta \in \mathbb{R}^p} RSS + \lambda \sum_{i=0}^p \beta_i^2 = \arg\min_{\beta\in\mathbb{R}^p \, : \, \ | Ridge Regression -Increase in $\lambda$ leads to a decrease in flexibilty
This can be most easily seen through Lagrange duality: there exists some $C$ so that $$\arg\min_{\beta \in \mathbb{R}^p} RSS + \lambda \sum_{i=0}^p \beta_i^2 = \arg\min_{\beta\in\mathbb{R}^p \, : \, \|\beta\|_2^2 \leq C} RSS.$$ Further, we know that larger $\lambda$ corresponds to smaller $C$. Therefore, increasing the tuning parameter $\lambda$ further constrains the $\ell_2$ norm of the coefficients, leading to less flexibility. | Ridge Regression -Increase in $\lambda$ leads to a decrease in flexibilty
This can be most easily seen through Lagrange duality: there exists some $C$ so that $$\arg\min_{\beta \in \mathbb{R}^p} RSS + \lambda \sum_{i=0}^p \beta_i^2 = \arg\min_{\beta\in\mathbb{R}^p \, : \, \ |
38,853 | Ridge Regression -Increase in $\lambda$ leads to a decrease in flexibilty | Here, we can see that a general increase in the β vector will decrease
RSS and increase the other term.
That is not strictly true. For example, check what happens to your $RSS$ if $p$ is $1$ and $y=0$ for all $n$ points as you increase $\beta$. | Ridge Regression -Increase in $\lambda$ leads to a decrease in flexibilty | Here, we can see that a general increase in the β vector will decrease
RSS and increase the other term.
That is not strictly true. For example, check what happens to your $RSS$ if $p$ is $1$ and $ | Ridge Regression -Increase in $\lambda$ leads to a decrease in flexibilty
Here, we can see that a general increase in the β vector will decrease
RSS and increase the other term.
That is not strictly true. For example, check what happens to your $RSS$ if $p$ is $1$ and $y=0$ for all $n$ points as you increase $\beta$. | Ridge Regression -Increase in $\lambda$ leads to a decrease in flexibilty
Here, we can see that a general increase in the β vector will decrease
RSS and increase the other term.
That is not strictly true. For example, check what happens to your $RSS$ if $p$ is $1$ and $ |
38,854 | Percentage as dependent variable in multiple linear regression | You should not use linear regression here, nor should you transform your data with the logit transformation. You have a percentage variable in a sense, but that's just a way to display your data in a simplified manner. In another sense, you have a count of obese children out of a known total of kids. That is, you have binomial data.
Thus, you should use logistic regression, using the counts of actual children. How that will be done, exactly, depends on how your software implements this, for a discussion of SAS and R, see: Difference in output between SAS's proc genmod and R's glm. People often think of logistic regression as the option to use when your response is 0/1, but it is actually applicable to any binomial distribution, even when there is more than one Bernoulli trial. | Percentage as dependent variable in multiple linear regression | You should not use linear regression here, nor should you transform your data with the logit transformation. You have a percentage variable in a sense, but that's just a way to display your data in a | Percentage as dependent variable in multiple linear regression
You should not use linear regression here, nor should you transform your data with the logit transformation. You have a percentage variable in a sense, but that's just a way to display your data in a simplified manner. In another sense, you have a count of obese children out of a known total of kids. That is, you have binomial data.
Thus, you should use logistic regression, using the counts of actual children. How that will be done, exactly, depends on how your software implements this, for a discussion of SAS and R, see: Difference in output between SAS's proc genmod and R's glm. People often think of logistic regression as the option to use when your response is 0/1, but it is actually applicable to any binomial distribution, even when there is more than one Bernoulli trial. | Percentage as dependent variable in multiple linear regression
You should not use linear regression here, nor should you transform your data with the logit transformation. You have a percentage variable in a sense, but that's just a way to display your data in a |
38,855 | Percentage as dependent variable in multiple linear regression | In linear regression, there are several assumptions which include the normality and independence of the independent variables and the error terms. Based on theory, the expectation of dependent variable $E(Y)$ would be also normality distributed. However, in reality it's hard to see a perfectly bell-shaped distribution for the dependent variable $Y$. Hence, in my opinion, it's more important to ensure that the assumptions on the errors terms based on the fitted model is not violated.
You can perform diagnostic test such as QQ-plot to ensure that the residuals are (1) normally distributed and have (2) equal variance across the independent variables. Also, if you have a large $N$, the model is usually very robust against the assumptions. You could plot the histogram of the variables to ensure that there is no skewness or major deviations, else you can consider data-transformation.
Lastly to answer your question regarding the right model to use, I think that using a linear regression is justifiable as long as the there is a strong linear-relationship between your $X$ and $Y$ variable. As long as the model is not used to extrapolate outside the range of your fitted variables it will be fine. But of course, you could use models like log-binomial or beta-regression, which caters to {0,1} interval for $Y$, but each has different assumption on the dependent variable. You should first inspect the distribution of Y before deciding the appropriate model to use.
Hope this helps. | Percentage as dependent variable in multiple linear regression | In linear regression, there are several assumptions which include the normality and independence of the independent variables and the error terms. Based on theory, the expectation of dependent variabl | Percentage as dependent variable in multiple linear regression
In linear regression, there are several assumptions which include the normality and independence of the independent variables and the error terms. Based on theory, the expectation of dependent variable $E(Y)$ would be also normality distributed. However, in reality it's hard to see a perfectly bell-shaped distribution for the dependent variable $Y$. Hence, in my opinion, it's more important to ensure that the assumptions on the errors terms based on the fitted model is not violated.
You can perform diagnostic test such as QQ-plot to ensure that the residuals are (1) normally distributed and have (2) equal variance across the independent variables. Also, if you have a large $N$, the model is usually very robust against the assumptions. You could plot the histogram of the variables to ensure that there is no skewness or major deviations, else you can consider data-transformation.
Lastly to answer your question regarding the right model to use, I think that using a linear regression is justifiable as long as the there is a strong linear-relationship between your $X$ and $Y$ variable. As long as the model is not used to extrapolate outside the range of your fitted variables it will be fine. But of course, you could use models like log-binomial or beta-regression, which caters to {0,1} interval for $Y$, but each has different assumption on the dependent variable. You should first inspect the distribution of Y before deciding the appropriate model to use.
Hope this helps. | Percentage as dependent variable in multiple linear regression
In linear regression, there are several assumptions which include the normality and independence of the independent variables and the error terms. Based on theory, the expectation of dependent variabl |
38,856 | Poisson Regression : expectation vs probability for each outcome | If you have a fitted expectation (as you show you can get), using that as a parameter in a Poisson pdf should work.
That is, given $\hat{\lambda}_i = E(Y=0|X=\boldsymbol{x}_i)$ you can use that to calculate whichever probability you want:
$$\hat{P}(Y=k|X=\boldsymbol{x}_i) = \frac{\exp(-\hat{\lambda}_i)\, \hat{\lambda}_i^k}{k!}$$
(In R you'd use dpois() with the parameter set to the fitted mean for that kind of calculation. The process should be about as easy in any number of other packages.) | Poisson Regression : expectation vs probability for each outcome | If you have a fitted expectation (as you show you can get), using that as a parameter in a Poisson pdf should work.
That is, given $\hat{\lambda}_i = E(Y=0|X=\boldsymbol{x}_i)$ you can use that to ca | Poisson Regression : expectation vs probability for each outcome
If you have a fitted expectation (as you show you can get), using that as a parameter in a Poisson pdf should work.
That is, given $\hat{\lambda}_i = E(Y=0|X=\boldsymbol{x}_i)$ you can use that to calculate whichever probability you want:
$$\hat{P}(Y=k|X=\boldsymbol{x}_i) = \frac{\exp(-\hat{\lambda}_i)\, \hat{\lambda}_i^k}{k!}$$
(In R you'd use dpois() with the parameter set to the fitted mean for that kind of calculation. The process should be about as easy in any number of other packages.) | Poisson Regression : expectation vs probability for each outcome
If you have a fitted expectation (as you show you can get), using that as a parameter in a Poisson pdf should work.
That is, given $\hat{\lambda}_i = E(Y=0|X=\boldsymbol{x}_i)$ you can use that to ca |
38,857 | Poisson Regression : expectation vs probability for each outcome | Just to illustrate the canonical answer by Glen (and with the peace of mind of being late for the party to the point that the answer to the OP has rightfully been adjudicated), let me run a toy example in R, crediting this post also by Glen.
Instead of cars and money, I'll make it more picturesque, and focus on the number of fish caught by a fishing company, in relation to the number of vessels out in the sea - if the numbers seem small, imagine that the units are in $10,000$, or something else. The number of fish caught will follow a Poisson distribution with a rate parameter identical to the number of boats from $\lambda=1$ to $\lambda = 14.$
set.seed(0)
sam = 1000 # Random values from a Pois for each lambda.
lambda = c(1,4,7,10,13) # And these are the lambda values.
x = c(rep(lambda[1], sam), rep(lambda[2], sam), rep(lambda[3], sam),
rep(lambda[4], sam), rep(lambda[5],sam)) # These are the number of boats
peixos = rpois(length(x), x) # And the number of fish caught.
We are establishing a relationship between the expected mean and the $x$ axis strictly linear in this simulation:
$\mathbb E(Y\;\vert\;\text{no. boats})= X\beta + \varepsilon$
but with a Poisson distribution of errors, which parameter changes with the value of the explanatory variable.
The rate parameter $\lambda$ increases strictly linearly with the number of boats. In the case of a single boat $(\lambda = 1)$ the distribution around the expected mean is manifest in the density of points close to $1$ in the $y$-axis on the plot below - the data points produce a stripped pattern due to the discrete nature of the Poisson distribution. As the value of lambda increases, the distribution of points, and the corresponding histogram, assume more of a normal shape:
The errors (or residuals if you want) are differently spread depending on the number of boats, because we used $5$ different rate parameters. However, once you know the rate parameter for a given value of the explanatory variable, the probability mass function is determined, allowing you to calculate the probability of any other value.
If we tried to recover the lambdas ($\lambda =\{1,4,7,10,13\}$), we'd only have to run the following command:
> fit = glm(peixos ~ x, family = poisson(link = identity))
> unique(predict(fit))
[1] 1.038018 4.023809 7.009600 9.995391 12.981182
Notice that in keeping with the set up of the toy dataset, the rate parameter was linearly dependent with an identity link. The output would have been off if we had run
> fit <- glm(peixos ~ x, "poisson")
> exp(unique(predict(fit)))
[1] 2.270660 3.602671 5.716065 9.069216 14.389387
implicitly using a $\log$ link function - see this post.
code here | Poisson Regression : expectation vs probability for each outcome | Just to illustrate the canonical answer by Glen (and with the peace of mind of being late for the party to the point that the answer to the OP has rightfully been adjudicated), let me run a toy exampl | Poisson Regression : expectation vs probability for each outcome
Just to illustrate the canonical answer by Glen (and with the peace of mind of being late for the party to the point that the answer to the OP has rightfully been adjudicated), let me run a toy example in R, crediting this post also by Glen.
Instead of cars and money, I'll make it more picturesque, and focus on the number of fish caught by a fishing company, in relation to the number of vessels out in the sea - if the numbers seem small, imagine that the units are in $10,000$, or something else. The number of fish caught will follow a Poisson distribution with a rate parameter identical to the number of boats from $\lambda=1$ to $\lambda = 14.$
set.seed(0)
sam = 1000 # Random values from a Pois for each lambda.
lambda = c(1,4,7,10,13) # And these are the lambda values.
x = c(rep(lambda[1], sam), rep(lambda[2], sam), rep(lambda[3], sam),
rep(lambda[4], sam), rep(lambda[5],sam)) # These are the number of boats
peixos = rpois(length(x), x) # And the number of fish caught.
We are establishing a relationship between the expected mean and the $x$ axis strictly linear in this simulation:
$\mathbb E(Y\;\vert\;\text{no. boats})= X\beta + \varepsilon$
but with a Poisson distribution of errors, which parameter changes with the value of the explanatory variable.
The rate parameter $\lambda$ increases strictly linearly with the number of boats. In the case of a single boat $(\lambda = 1)$ the distribution around the expected mean is manifest in the density of points close to $1$ in the $y$-axis on the plot below - the data points produce a stripped pattern due to the discrete nature of the Poisson distribution. As the value of lambda increases, the distribution of points, and the corresponding histogram, assume more of a normal shape:
The errors (or residuals if you want) are differently spread depending on the number of boats, because we used $5$ different rate parameters. However, once you know the rate parameter for a given value of the explanatory variable, the probability mass function is determined, allowing you to calculate the probability of any other value.
If we tried to recover the lambdas ($\lambda =\{1,4,7,10,13\}$), we'd only have to run the following command:
> fit = glm(peixos ~ x, family = poisson(link = identity))
> unique(predict(fit))
[1] 1.038018 4.023809 7.009600 9.995391 12.981182
Notice that in keeping with the set up of the toy dataset, the rate parameter was linearly dependent with an identity link. The output would have been off if we had run
> fit <- glm(peixos ~ x, "poisson")
> exp(unique(predict(fit)))
[1] 2.270660 3.602671 5.716065 9.069216 14.389387
implicitly using a $\log$ link function - see this post.
code here | Poisson Regression : expectation vs probability for each outcome
Just to illustrate the canonical answer by Glen (and with the peace of mind of being late for the party to the point that the answer to the OP has rightfully been adjudicated), let me run a toy exampl |
38,858 | Batch Normalization shift/scale parameters defeat the point | I'm by no means an expert on this topic, but here are my thoughts.
I think the main point of batch normalization is that training of each network layer is unaffected by changes in scale of the preceding layers. The author wrote
$$BN(Wu) = BN((aW)u)$$
for any scalar $a$. Thus, also backpropagated error is unaffected as well. So there is no scale explosion, even when learning rate is high.
If you simply apply
$$BN(x) = y_i = \gamma_ix_i + \beta_i, \text{ where } x = Wu$$
the above no longer holds.
Parameters $\gamma$ and $\beta$ are a must have, because otherwise the normalized outputs $\hat{x_i}$ would be mostly close to $0$, which would hinder the network ability to fully utilize nonlinear transformations (authors give an example of sigmoid function, which is close to identity transformation in $0$ proximity)
Finally, one can argue that the input $y = Wx + b$ to the BN layer, as a combination of many factors, may resemble Gaussian distribution (CLT). So by studentizing it we keep the inputs stable and, hopefully, following standard normal distribution to some degree. | Batch Normalization shift/scale parameters defeat the point | I'm by no means an expert on this topic, but here are my thoughts.
I think the main point of batch normalization is that training of each network layer is unaffected by changes in scale of the precedi | Batch Normalization shift/scale parameters defeat the point
I'm by no means an expert on this topic, but here are my thoughts.
I think the main point of batch normalization is that training of each network layer is unaffected by changes in scale of the preceding layers. The author wrote
$$BN(Wu) = BN((aW)u)$$
for any scalar $a$. Thus, also backpropagated error is unaffected as well. So there is no scale explosion, even when learning rate is high.
If you simply apply
$$BN(x) = y_i = \gamma_ix_i + \beta_i, \text{ where } x = Wu$$
the above no longer holds.
Parameters $\gamma$ and $\beta$ are a must have, because otherwise the normalized outputs $\hat{x_i}$ would be mostly close to $0$, which would hinder the network ability to fully utilize nonlinear transformations (authors give an example of sigmoid function, which is close to identity transformation in $0$ proximity)
Finally, one can argue that the input $y = Wx + b$ to the BN layer, as a combination of many factors, may resemble Gaussian distribution (CLT). So by studentizing it we keep the inputs stable and, hopefully, following standard normal distribution to some degree. | Batch Normalization shift/scale parameters defeat the point
I'm by no means an expert on this topic, but here are my thoughts.
I think the main point of batch normalization is that training of each network layer is unaffected by changes in scale of the precedi |
38,859 | Batch Normalization shift/scale parameters defeat the point | If someone passes by this question in the future, Ian Goodfellow and Yoshua Bengio and Aaron Courville's Deep Learning, Section 8.7.1 can give a good explanation:
Normalizing the mean and standard deviation of a unit can reduce the expressive power of the neural network containing that unit. To maintain the expressive power of the network, it is common to replace the batch of hidden unit activations $H$ with $\gamma H+\beta$ rather than simply the normalized $H$. The variables $\gamma$ and $\beta$ are learned parameters that allow the new variable to have any mean and standard deviation. At first glance, this may seem useless — why did we set the mean to $0$, and then introduce a parameter that allows it to be set back to any arbitrary value $\beta$?
The answer is that the new parametrization can represent the same family of functions of the input as the old parametrization, but the new parametrization has different learning dynamics. In the old parametrization, the mean of $H$ was determined by a complicated interaction between the parameters in the layers below $H$. In the new parametrization, the mean of $\gamma H+\beta$ is determined solely by $\beta$. The new parametrization is much easier to learn with gradient descent. | Batch Normalization shift/scale parameters defeat the point | If someone passes by this question in the future, Ian Goodfellow and Yoshua Bengio and Aaron Courville's Deep Learning, Section 8.7.1 can give a good explanation:
Normalizing the mean and standard de | Batch Normalization shift/scale parameters defeat the point
If someone passes by this question in the future, Ian Goodfellow and Yoshua Bengio and Aaron Courville's Deep Learning, Section 8.7.1 can give a good explanation:
Normalizing the mean and standard deviation of a unit can reduce the expressive power of the neural network containing that unit. To maintain the expressive power of the network, it is common to replace the batch of hidden unit activations $H$ with $\gamma H+\beta$ rather than simply the normalized $H$. The variables $\gamma$ and $\beta$ are learned parameters that allow the new variable to have any mean and standard deviation. At first glance, this may seem useless — why did we set the mean to $0$, and then introduce a parameter that allows it to be set back to any arbitrary value $\beta$?
The answer is that the new parametrization can represent the same family of functions of the input as the old parametrization, but the new parametrization has different learning dynamics. In the old parametrization, the mean of $H$ was determined by a complicated interaction between the parameters in the layers below $H$. In the new parametrization, the mean of $\gamma H+\beta$ is determined solely by $\beta$. The new parametrization is much easier to learn with gradient descent. | Batch Normalization shift/scale parameters defeat the point
If someone passes by this question in the future, Ian Goodfellow and Yoshua Bengio and Aaron Courville's Deep Learning, Section 8.7.1 can give a good explanation:
Normalizing the mean and standard de |
38,860 | Batch Normalization shift/scale parameters defeat the point | Correct me if I am wrong...
The BN normalization values are calculated for each components to normalize the input to a neuron (i.e. elliptic distribution becomes circular). The resulting distribution may be too wide or too narrow and shifted to "activate" well the activation function. To my understanding, the gamma and beta learnt parameters are constants applied to all components (not gamma and beta values per component) learnt, re-scaling and shifting optimally the more circular distribution before applying the activation function. Thus not equivalent to only learn beta and gamma (which is already learnt by backprop in W and b coef) without prior normalization. | Batch Normalization shift/scale parameters defeat the point | Correct me if I am wrong...
The BN normalization values are calculated for each components to normalize the input to a neuron (i.e. elliptic distribution becomes circular). The resulting distribution | Batch Normalization shift/scale parameters defeat the point
Correct me if I am wrong...
The BN normalization values are calculated for each components to normalize the input to a neuron (i.e. elliptic distribution becomes circular). The resulting distribution may be too wide or too narrow and shifted to "activate" well the activation function. To my understanding, the gamma and beta learnt parameters are constants applied to all components (not gamma and beta values per component) learnt, re-scaling and shifting optimally the more circular distribution before applying the activation function. Thus not equivalent to only learn beta and gamma (which is already learnt by backprop in W and b coef) without prior normalization. | Batch Normalization shift/scale parameters defeat the point
Correct me if I am wrong...
The BN normalization values are calculated for each components to normalize the input to a neuron (i.e. elliptic distribution becomes circular). The resulting distribution |
38,861 | 2D convolution with depth | You already understand that the dimension of a single kernel is 3x3x3 and there are 5 kernels. So each kernel is a 2D window of 3x3 pixels and there are 3 components in each kernel, one corresponding to each color channel (R,G,B). When the kernel is placed at a particular location over the input image its 3 components are multiplied (dot product) with the corresponding channel's pixel data to produce a single scalar number for every component (or channel). So you get 3 scalars, one for each channel. Then these scalars are summed up and another scalar representing the bias of the filter is added to the sum. The end result is a single scalar.
You can view an animated demo under the convolution demo section on this page. Use the Toggle Movement button to pause the animation and look at how the output is being generated.
In the screenshot above (taken at a random instance) the portions of the image channels to which convolution is being applied are outlined in Blue. The three components of filter W1 are outlined in Red. If you take the dot product of each 3x3 Blue rectangle with it's component of the filter you get a scalar. The 3 scalars obtained for each channel are summed up along with the bias of Filter W1, shown as a single cell below the filter components. The result is a single scalar, the number 2, outlined green in the last column.
The text also describes how convolution is being carried out. | 2D convolution with depth | You already understand that the dimension of a single kernel is 3x3x3 and there are 5 kernels. So each kernel is a 2D window of 3x3 pixels and there are 3 components in each kernel, one corresponding | 2D convolution with depth
You already understand that the dimension of a single kernel is 3x3x3 and there are 5 kernels. So each kernel is a 2D window of 3x3 pixels and there are 3 components in each kernel, one corresponding to each color channel (R,G,B). When the kernel is placed at a particular location over the input image its 3 components are multiplied (dot product) with the corresponding channel's pixel data to produce a single scalar number for every component (or channel). So you get 3 scalars, one for each channel. Then these scalars are summed up and another scalar representing the bias of the filter is added to the sum. The end result is a single scalar.
You can view an animated demo under the convolution demo section on this page. Use the Toggle Movement button to pause the animation and look at how the output is being generated.
In the screenshot above (taken at a random instance) the portions of the image channels to which convolution is being applied are outlined in Blue. The three components of filter W1 are outlined in Red. If you take the dot product of each 3x3 Blue rectangle with it's component of the filter you get a scalar. The 3 scalars obtained for each channel are summed up along with the bias of Filter W1, shown as a single cell below the filter components. The result is a single scalar, the number 2, outlined green in the last column.
The text also describes how convolution is being carried out. | 2D convolution with depth
You already understand that the dimension of a single kernel is 3x3x3 and there are 5 kernels. So each kernel is a 2D window of 3x3 pixels and there are 3 components in each kernel, one corresponding |
38,862 | 2D convolution with depth | I had this exact same question and came here to find the answer. @farhanhubble, your answer was very helpful. Here is the math of the convolution drawn on top of images from the site you shared just for further clarification.
Images from the same site as farhanhubble's answer. | 2D convolution with depth | I had this exact same question and came here to find the answer. @farhanhubble, your answer was very helpful. Here is the math of the convolution drawn on top of images from the site you shared just f | 2D convolution with depth
I had this exact same question and came here to find the answer. @farhanhubble, your answer was very helpful. Here is the math of the convolution drawn on top of images from the site you shared just for further clarification.
Images from the same site as farhanhubble's answer. | 2D convolution with depth
I had this exact same question and came here to find the answer. @farhanhubble, your answer was very helpful. Here is the math of the convolution drawn on top of images from the site you shared just f |
38,863 | Which statistical test to use when there's no data of SD but just know the mean? | No, I do not believe there's any formal test that you can apply. (By the way, the usual term for such samples is pooled.)
You are right that repeating the blot will not tell you more about the biological variance in population. You could try to look up the variance obtained by others in similar, but non-pooled experiments (if there is any), and use it to make a very rough and informal test. But I would suggest you to stick to non-statistical comparisons, because to achieve significance with $n=6$ the differences would need to be obvious anyway.
EDIT - would like to clarify my reasoning, in response to good points by @whuber below: I agree that any comparison, or any logical reasoning at all, should follow basic rules of statistics and probability. Probably a better way to express what I (and @Joshua?) meant is that at small $n$, conclusions are very dependent on the priors. In the given situation, using my experience, I could make some guess of the variance in protein expression between healthy animals, but if $n=1$, I have only my guess to plug in a test. With $n=3$, I might still want to check whether the estimated variance corresponds to my expectations, and with $n=100$ I throw the guess out the window, because the estimate by now is likely more reliable than my expertise.
While the Bayesian framework can incorporate all that, converting expertise to actual numeric values is very complicated, and we end up with a conclusion "groups look kinda different". That is what I meant by a non-statistical comparison. It is certainly crude, but I believe that the discussion section of any study is just such eyeballed conclusions combining data with prior knowledge. | Which statistical test to use when there's no data of SD but just know the mean? | No, I do not believe there's any formal test that you can apply. (By the way, the usual term for such samples is pooled.)
You are right that repeating the blot will not tell you more about the biologi | Which statistical test to use when there's no data of SD but just know the mean?
No, I do not believe there's any formal test that you can apply. (By the way, the usual term for such samples is pooled.)
You are right that repeating the blot will not tell you more about the biological variance in population. You could try to look up the variance obtained by others in similar, but non-pooled experiments (if there is any), and use it to make a very rough and informal test. But I would suggest you to stick to non-statistical comparisons, because to achieve significance with $n=6$ the differences would need to be obvious anyway.
EDIT - would like to clarify my reasoning, in response to good points by @whuber below: I agree that any comparison, or any logical reasoning at all, should follow basic rules of statistics and probability. Probably a better way to express what I (and @Joshua?) meant is that at small $n$, conclusions are very dependent on the priors. In the given situation, using my experience, I could make some guess of the variance in protein expression between healthy animals, but if $n=1$, I have only my guess to plug in a test. With $n=3$, I might still want to check whether the estimated variance corresponds to my expectations, and with $n=100$ I throw the guess out the window, because the estimate by now is likely more reliable than my expertise.
While the Bayesian framework can incorporate all that, converting expertise to actual numeric values is very complicated, and we end up with a conclusion "groups look kinda different". That is what I meant by a non-statistical comparison. It is certainly crude, but I believe that the discussion section of any study is just such eyeballed conclusions combining data with prior knowledge. | Which statistical test to use when there's no data of SD but just know the mean?
No, I do not believe there's any formal test that you can apply. (By the way, the usual term for such samples is pooled.)
You are right that repeating the blot will not tell you more about the biologi |
38,864 | Which statistical test to use when there's no data of SD but just know the mean? | There is probably not much to be done.
If there is some way to estimate the within-group variance of unpooled western blot results from previous data, you could use this to generate an estimate of the standard deviation for the pooled western blot and use that to run a test. But it does not sound like this is the case.
As an interesting aside I offer that you could generate a confidence interval for the difference in means using the methodology explained here : What can we say about population mean from a sample size of 1?
However, since this CI will always include zero, this will not be of much help in terms of significance testing. | Which statistical test to use when there's no data of SD but just know the mean? | There is probably not much to be done.
If there is some way to estimate the within-group variance of unpooled western blot results from previous data, you could use this to generate an estimate of th | Which statistical test to use when there's no data of SD but just know the mean?
There is probably not much to be done.
If there is some way to estimate the within-group variance of unpooled western blot results from previous data, you could use this to generate an estimate of the standard deviation for the pooled western blot and use that to run a test. But it does not sound like this is the case.
As an interesting aside I offer that you could generate a confidence interval for the difference in means using the methodology explained here : What can we say about population mean from a sample size of 1?
However, since this CI will always include zero, this will not be of much help in terms of significance testing. | Which statistical test to use when there's no data of SD but just know the mean?
There is probably not much to be done.
If there is some way to estimate the within-group variance of unpooled western blot results from previous data, you could use this to generate an estimate of th |
38,865 | Which statistical test to use when there's no data of SD but just know the mean? | I would look into nonparametric statistic to find a test that would work for your situation. These tests don't have as many parameters to match to make the test work and are designed to work for smaller sample sizes. | Which statistical test to use when there's no data of SD but just know the mean? | I would look into nonparametric statistic to find a test that would work for your situation. These tests don't have as many parameters to match to make the test work and are designed to work for sm | Which statistical test to use when there's no data of SD but just know the mean?
I would look into nonparametric statistic to find a test that would work for your situation. These tests don't have as many parameters to match to make the test work and are designed to work for smaller sample sizes. | Which statistical test to use when there's no data of SD but just know the mean?
I would look into nonparametric statistic to find a test that would work for your situation. These tests don't have as many parameters to match to make the test work and are designed to work for sm |
38,866 | How is a Chi-square distribution a gamma distribution if it only has one parameter? | Let's start with the p.d.f. of a gamma-distributed random variable $X$, where $\alpha$ is the shape parameter and $\beta$ is the rate parameter (the p.d.f. is a little bit different if $\beta$ is a scale parameter; both parameters are strictly positive):
$$
f_X(x) = \frac{x ^ {\alpha - 1} \beta ^ \alpha e ^ {-\beta x}}{\Gamma(\alpha)}
$$
Now let $\alpha = \nu / 2$ and $\beta = 1/2$. After making these substitutions in the equation above, we get
$$
f_X(x) = \frac{x ^ {\frac{\nu}{2} - 1} e ^ {-x / 2}}{\Gamma(\nu / 2) 2 ^ {\nu / 2}},
$$
which you can recognize as the p.d.f. of a chi-square-distributed random variable. Since we fixed $\beta$ as a constant (1/2), we've transformed a 2-parameter random variable into one that depends on only one parameter ($\nu$). | How is a Chi-square distribution a gamma distribution if it only has one parameter? | Let's start with the p.d.f. of a gamma-distributed random variable $X$, where $\alpha$ is the shape parameter and $\beta$ is the rate parameter (the p.d.f. is a little bit different if $\beta$ is a sc | How is a Chi-square distribution a gamma distribution if it only has one parameter?
Let's start with the p.d.f. of a gamma-distributed random variable $X$, where $\alpha$ is the shape parameter and $\beta$ is the rate parameter (the p.d.f. is a little bit different if $\beta$ is a scale parameter; both parameters are strictly positive):
$$
f_X(x) = \frac{x ^ {\alpha - 1} \beta ^ \alpha e ^ {-\beta x}}{\Gamma(\alpha)}
$$
Now let $\alpha = \nu / 2$ and $\beta = 1/2$. After making these substitutions in the equation above, we get
$$
f_X(x) = \frac{x ^ {\frac{\nu}{2} - 1} e ^ {-x / 2}}{\Gamma(\nu / 2) 2 ^ {\nu / 2}},
$$
which you can recognize as the p.d.f. of a chi-square-distributed random variable. Since we fixed $\beta$ as a constant (1/2), we've transformed a 2-parameter random variable into one that depends on only one parameter ($\nu$). | How is a Chi-square distribution a gamma distribution if it only has one parameter?
Let's start with the p.d.f. of a gamma-distributed random variable $X$, where $\alpha$ is the shape parameter and $\beta$ is the rate parameter (the p.d.f. is a little bit different if $\beta$ is a sc |
38,867 | Pdf of $y = - \log(X)$ when $X$ is beta distributed The expected value of $Y$ | Let $Y=-\ln X,\quad X \sim Beta(\alpha,\beta)$ then
$$
F_Y(y)=P(Y<y)=P(-\ln X < y)=P(X > e^{-y})=\int_{e^{-y}}^1\frac{\Gamma(\alpha+\beta)}{\Gamma(\alpha)\Gamma(\beta)}x^{\alpha-1}(1-x)^{\beta-1}dx
$$
$$
f_Y(y)=\frac{d}{dy}F_Y(y)=\frac{d}{dx}\int_{e^{-y}}^1\frac{\Gamma(\alpha+\beta)}{\Gamma(\alpha)\Gamma(\beta)}x^{\alpha-1}(1-x)^{\beta-1}dx
=\frac{\Gamma(\alpha+\beta)}{\Gamma(\alpha)\Gamma(\beta)}[(e^{-y})^{\alpha-1}(1-e^{-y})^{\beta-1}(e^{-y})]=e^{-y}f_X(e^{-y})
$$
The expected value
$$
E(Y)=E(-\ln X)=-E(\ln X)
$$
$$
\begin{align}
\operatorname{E}(\ln X)
&= \int_0^1 \ln x\, f(x;\alpha,\beta)\,dx \\
&= \int_0^1 \ln x \,\frac{ x^{\alpha-1}(1-x)^{\beta-1}}{B(\alpha,\beta)}\,dx \\
&= \frac{1}{B(\alpha,\beta)} \, \int_0^1 \frac{\partial x^{\alpha-1}(1-x)^{\beta-1}}{\partial \alpha}\,dx \\
&= \frac{1}{B(\alpha,\beta)} \frac{\partial}{\partial \alpha} \int_0^1 x^{\alpha-1}(1-x)^{\beta-1}\,dx \\
&= \frac{1}{B(\alpha,\beta)} \frac{\partial B(\alpha,\beta)}{\partial \alpha} \\
&= \frac{\partial \ln B(\alpha,\beta)}{\partial \alpha} \\
&= \frac{\partial \ln \Gamma(\alpha)}{\partial \alpha} - \frac{\partial \ln \Gamma(\alpha + \beta)}{\partial \alpha} \\
&= \psi(\alpha) - \psi(\alpha + \beta)
\end{align}
$$
$$
E(Y)=-E(\ln X)=\psi(\alpha + \beta)-\psi(\alpha)
$$
where $\psi$ is the digamma function. | Pdf of $y = - \log(X)$ when $X$ is beta distributed The expected value of $Y$ | Let $Y=-\ln X,\quad X \sim Beta(\alpha,\beta)$ then
$$
F_Y(y)=P(Y<y)=P(-\ln X < y)=P(X > e^{-y})=\int_{e^{-y}}^1\frac{\Gamma(\alpha+\beta)}{\Gamma(\alpha)\Gamma(\beta)}x^{\alpha-1}(1-x)^{\beta-1}dx
$$ | Pdf of $y = - \log(X)$ when $X$ is beta distributed The expected value of $Y$
Let $Y=-\ln X,\quad X \sim Beta(\alpha,\beta)$ then
$$
F_Y(y)=P(Y<y)=P(-\ln X < y)=P(X > e^{-y})=\int_{e^{-y}}^1\frac{\Gamma(\alpha+\beta)}{\Gamma(\alpha)\Gamma(\beta)}x^{\alpha-1}(1-x)^{\beta-1}dx
$$
$$
f_Y(y)=\frac{d}{dy}F_Y(y)=\frac{d}{dx}\int_{e^{-y}}^1\frac{\Gamma(\alpha+\beta)}{\Gamma(\alpha)\Gamma(\beta)}x^{\alpha-1}(1-x)^{\beta-1}dx
=\frac{\Gamma(\alpha+\beta)}{\Gamma(\alpha)\Gamma(\beta)}[(e^{-y})^{\alpha-1}(1-e^{-y})^{\beta-1}(e^{-y})]=e^{-y}f_X(e^{-y})
$$
The expected value
$$
E(Y)=E(-\ln X)=-E(\ln X)
$$
$$
\begin{align}
\operatorname{E}(\ln X)
&= \int_0^1 \ln x\, f(x;\alpha,\beta)\,dx \\
&= \int_0^1 \ln x \,\frac{ x^{\alpha-1}(1-x)^{\beta-1}}{B(\alpha,\beta)}\,dx \\
&= \frac{1}{B(\alpha,\beta)} \, \int_0^1 \frac{\partial x^{\alpha-1}(1-x)^{\beta-1}}{\partial \alpha}\,dx \\
&= \frac{1}{B(\alpha,\beta)} \frac{\partial}{\partial \alpha} \int_0^1 x^{\alpha-1}(1-x)^{\beta-1}\,dx \\
&= \frac{1}{B(\alpha,\beta)} \frac{\partial B(\alpha,\beta)}{\partial \alpha} \\
&= \frac{\partial \ln B(\alpha,\beta)}{\partial \alpha} \\
&= \frac{\partial \ln \Gamma(\alpha)}{\partial \alpha} - \frac{\partial \ln \Gamma(\alpha + \beta)}{\partial \alpha} \\
&= \psi(\alpha) - \psi(\alpha + \beta)
\end{align}
$$
$$
E(Y)=-E(\ln X)=\psi(\alpha + \beta)-\psi(\alpha)
$$
where $\psi$ is the digamma function. | Pdf of $y = - \log(X)$ when $X$ is beta distributed The expected value of $Y$
Let $Y=-\ln X,\quad X \sim Beta(\alpha,\beta)$ then
$$
F_Y(y)=P(Y<y)=P(-\ln X < y)=P(X > e^{-y})=\int_{e^{-y}}^1\frac{\Gamma(\alpha+\beta)}{\Gamma(\alpha)\Gamma(\beta)}x^{\alpha-1}(1-x)^{\beta-1}dx
$$ |
38,868 | Why is this not a valid moment generating function? | There's no playing about with series needed, no worrying about integrals (well not directly). This is "think about what MGFs are" kind of question.
Consider the definition of an MGF -- $\quad M_X(t)=E(e^{tX})$.
Given that definition, what should $M_X(0)$ be?
Do you notice the problem? | Why is this not a valid moment generating function? | There's no playing about with series needed, no worrying about integrals (well not directly). This is "think about what MGFs are" kind of question.
Consider the definition of an MGF -- $\quad M_X(t)=E | Why is this not a valid moment generating function?
There's no playing about with series needed, no worrying about integrals (well not directly). This is "think about what MGFs are" kind of question.
Consider the definition of an MGF -- $\quad M_X(t)=E(e^{tX})$.
Given that definition, what should $M_X(0)$ be?
Do you notice the problem? | Why is this not a valid moment generating function?
There's no playing about with series needed, no worrying about integrals (well not directly). This is "think about what MGFs are" kind of question.
Consider the definition of an MGF -- $\quad M_X(t)=E |
38,869 | What is the difference between MLP and RBF? | MLP: uses dot products (between inputs and weights) and sigmoidal activation functions (or other monotonic functions such as ReLU) and training is usually done through backpropagation for all layers (which can be as many as you want). This type of neural network is used in deep learning with the help of many techniques (such as dropout or batch normalization);
RBF: uses Euclidean distances (between inputs and weights, which can be viewed as centers) and (usually) Gaussian activation functions (which could be multivariate), which makes neurons more locally sensitive. Thus, RBF neurons have maximum activation when the center/weights are equal to the inputs (look at the image below). Due to this property, RBF neural networks are good for novelty detection (if each neuron is centered on a training example, inputs far away from all neurons constitute novel patterns) but not so good at extrapolation. Also, RBFs may use backpropagation for learning, or hybrid approaches with unsupervised learning in the hidden layer (they usually have just 1 hidden layer). Finally, RBFs make it easier to grow new neurons during training. | What is the difference between MLP and RBF? | MLP: uses dot products (between inputs and weights) and sigmoidal activation functions (or other monotonic functions such as ReLU) and training is usually done through backpropagation for all layers ( | What is the difference between MLP and RBF?
MLP: uses dot products (between inputs and weights) and sigmoidal activation functions (or other monotonic functions such as ReLU) and training is usually done through backpropagation for all layers (which can be as many as you want). This type of neural network is used in deep learning with the help of many techniques (such as dropout or batch normalization);
RBF: uses Euclidean distances (between inputs and weights, which can be viewed as centers) and (usually) Gaussian activation functions (which could be multivariate), which makes neurons more locally sensitive. Thus, RBF neurons have maximum activation when the center/weights are equal to the inputs (look at the image below). Due to this property, RBF neural networks are good for novelty detection (if each neuron is centered on a training example, inputs far away from all neurons constitute novel patterns) but not so good at extrapolation. Also, RBFs may use backpropagation for learning, or hybrid approaches with unsupervised learning in the hidden layer (they usually have just 1 hidden layer). Finally, RBFs make it easier to grow new neurons during training. | What is the difference between MLP and RBF?
MLP: uses dot products (between inputs and weights) and sigmoidal activation functions (or other monotonic functions such as ReLU) and training is usually done through backpropagation for all layers ( |
38,870 | What is the difference between MLP and RBF? | RBF and MLP belong to a class of neural networks called feed-forward networks.
Hidden layer of RBF is different from MLP. It performs some computations. Each hidden unit act as a point in input space and activation/output for any instance depends on the distance between that point(Hidden Unit) and instance(Also a point in space).
Thus, RBF learns two kinds of parameters:
1) Centers and width of RBFs
2) Weights to from linear combination of outputs obtained from hidden layer
The first set of parameters can be learned independently from the second set of parameters. i.e. by performing K-means clustering, you can come with centers and width of RBFs.
In nutshell, RBFs use the distance between RBFs centers and instances as the similarity measure.
One disadvantage is RBFs give the same weight to every attribute as they are considered equally in the distance computation. | What is the difference between MLP and RBF? | RBF and MLP belong to a class of neural networks called feed-forward networks.
Hidden layer of RBF is different from MLP. It performs some computations. Each hidden unit act as a point in input space | What is the difference between MLP and RBF?
RBF and MLP belong to a class of neural networks called feed-forward networks.
Hidden layer of RBF is different from MLP. It performs some computations. Each hidden unit act as a point in input space and activation/output for any instance depends on the distance between that point(Hidden Unit) and instance(Also a point in space).
Thus, RBF learns two kinds of parameters:
1) Centers and width of RBFs
2) Weights to from linear combination of outputs obtained from hidden layer
The first set of parameters can be learned independently from the second set of parameters. i.e. by performing K-means clustering, you can come with centers and width of RBFs.
In nutshell, RBFs use the distance between RBFs centers and instances as the similarity measure.
One disadvantage is RBFs give the same weight to every attribute as they are considered equally in the distance computation. | What is the difference between MLP and RBF?
RBF and MLP belong to a class of neural networks called feed-forward networks.
Hidden layer of RBF is different from MLP. It performs some computations. Each hidden unit act as a point in input space |
38,871 | Proof for Irreducible Error statement in ISLR page 19 [duplicate] | \begin{align*}
\mathbb{E}\left[(Y-\hat Y)^2\right]
&=\mathbb{E}\left[\left(f(X)+\epsilon-\hat{f}(X)\right)^2\right] \\
&=\mathbb{E}\left[\left(f(X)+\epsilon-\hat{f}(X)\right)
\left(f(X)+\epsilon-\hat{f}(X)\right)\right] \\
&=\mathbb{E}\left[\left(f(X)-\hat{f}(X)\right)
\left(f(X)+\epsilon-\hat{f}(X)\right)
+\epsilon
\left(f(X)+\epsilon-\hat{f}(X)\right)\right] \\
&=\mathbb{E}\left[\left(f(X)-\hat{f}(X)\right)^2
+\epsilon
\left(f(X)-\hat{f}(X)\right)
+\epsilon
\left(f(X)-\hat{f}(X)\right)
+\epsilon^2\right] \\
\text{Because the expectation is linear}&\\
&=\mathbb{E}\left[\left(f(X)-\hat{f}(X)\right)^2\right]
+\mathbb{E}\left[\epsilon^2\right]
+2\mathbb{E}\left[\epsilon
\left(f(X)-\hat{f}(X)\right)\right] \\
\text{Because the expectation of $f$ and $\hat{f}$ are constant}&\\
&=\left[f(X)-\hat{f}(X)\right]^2
+\mathbb{E}\left[\epsilon^2\right]
+2\mathbb{E}\left[\epsilon
\left(f(X)-\hat{f}(X)\right)\right] \\
\text{Because the mean of $\epsilon$ is zero}&\\
&=\left[f(X)-\hat{f}(X)\right]^2
+\mathbb{E}\left[\epsilon^2\right] \\
\text{Because the variance of $\epsilon$ is $\mathbb{E}(\epsilon^2)$}&\\
&=\left[f(X)-\hat{f}(X)\right]^2 + \text{Var}(\epsilon)
\end{align*} | Proof for Irreducible Error statement in ISLR page 19 [duplicate] | \begin{align*}
\mathbb{E}\left[(Y-\hat Y)^2\right]
&=\mathbb{E}\left[\left(f(X)+\epsilon-\hat{f}(X)\right)^2\right] \\
&=\mathbb{E}\left[\left(f(X)+\epsilon-\hat{f}(X)\right)
\ | Proof for Irreducible Error statement in ISLR page 19 [duplicate]
\begin{align*}
\mathbb{E}\left[(Y-\hat Y)^2\right]
&=\mathbb{E}\left[\left(f(X)+\epsilon-\hat{f}(X)\right)^2\right] \\
&=\mathbb{E}\left[\left(f(X)+\epsilon-\hat{f}(X)\right)
\left(f(X)+\epsilon-\hat{f}(X)\right)\right] \\
&=\mathbb{E}\left[\left(f(X)-\hat{f}(X)\right)
\left(f(X)+\epsilon-\hat{f}(X)\right)
+\epsilon
\left(f(X)+\epsilon-\hat{f}(X)\right)\right] \\
&=\mathbb{E}\left[\left(f(X)-\hat{f}(X)\right)^2
+\epsilon
\left(f(X)-\hat{f}(X)\right)
+\epsilon
\left(f(X)-\hat{f}(X)\right)
+\epsilon^2\right] \\
\text{Because the expectation is linear}&\\
&=\mathbb{E}\left[\left(f(X)-\hat{f}(X)\right)^2\right]
+\mathbb{E}\left[\epsilon^2\right]
+2\mathbb{E}\left[\epsilon
\left(f(X)-\hat{f}(X)\right)\right] \\
\text{Because the expectation of $f$ and $\hat{f}$ are constant}&\\
&=\left[f(X)-\hat{f}(X)\right]^2
+\mathbb{E}\left[\epsilon^2\right]
+2\mathbb{E}\left[\epsilon
\left(f(X)-\hat{f}(X)\right)\right] \\
\text{Because the mean of $\epsilon$ is zero}&\\
&=\left[f(X)-\hat{f}(X)\right]^2
+\mathbb{E}\left[\epsilon^2\right] \\
\text{Because the variance of $\epsilon$ is $\mathbb{E}(\epsilon^2)$}&\\
&=\left[f(X)-\hat{f}(X)\right]^2 + \text{Var}(\epsilon)
\end{align*} | Proof for Irreducible Error statement in ISLR page 19 [duplicate]
\begin{align*}
\mathbb{E}\left[(Y-\hat Y)^2\right]
&=\mathbb{E}\left[\left(f(X)+\epsilon-\hat{f}(X)\right)^2\right] \\
&=\mathbb{E}\left[\left(f(X)+\epsilon-\hat{f}(X)\right)
\ |
38,872 | Auto-regression versus linear regression of x(t)-with-t for modelling time series | Auto-regressive models (ARIMA) use previous values as predictors depending upon the form of the model and forecasts are adaptive in form generally responding to previous values. Models using time as a predictor can be understood as using previous values to estimate the model parameters (thus previous values do come into play ) but they are otherwise not part of the forecast equation thus being generally non-adaptive or fixed until re-estimation occurs. Models using time or time-squared or time-cubed etc. are anachronistic and generally not used/preferred except in very simple textbooks and in very simple classroom exercises. Models using time variables will generally exhibit auto-correlated residuals thus should be studiously avoided as the presumed model. However my work usually includes/investigates both procedures as tentative/possible approaches since only the data knows which approach is better or which approach delivers a more efficient model.
Response to comment @Veneeth :
I didn't say less accurate I wrote (implied) different. A time based model predicts based upon the input variable/series 1,2,3,3,...t which means that the prediction for t+2 ,t+ 3 , t+ 4 is fixed or deterministic or unchanged because when you observe y(t+1) as it was before you observed y(t+1). The new value has no effect on the prediction if you don't re-estimate parameters while a model that uses the value of y(t+1) et. al. and is ARIMA based will provide different forecasts. If you use the time predictor approach and re-estimate with y(t+1) in addition to all the previous y's the impact of the new observation will be normally minimal on the model coefficients unless the sample size is very small or the new observation is an anomaly which should be identified and neutralized.
Since @Veneeth asked for a quantitative example , I attempt here to answer that.
With apologies to Charles Dickens one could entitle this as " A tale of three approaches" I selected a real world example not a trivial textbook example which emphasizes the impact of presumption when it comes to model identification . Consider 1) The time based model (the only non-automatic run ) . Here is the actual fit and forecast with equation and residual plot . Followed by 2) The ARIMA model . Now consider a hybrid model incorporating both deterministic structure (input series) and ARIMA . The variance of the errors from each of the three models reduced dramatically. The deterministic structure that was identified in the hybrid approach was a Level/Step Shift which reflects an intercept change. Visually one could make a case for a possible two-trended model using approach 1 yielding but no no avail | Auto-regression versus linear regression of x(t)-with-t for modelling time series | Auto-regressive models (ARIMA) use previous values as predictors depending upon the form of the model and forecasts are adaptive in form generally responding to previous values. Models using time as a | Auto-regression versus linear regression of x(t)-with-t for modelling time series
Auto-regressive models (ARIMA) use previous values as predictors depending upon the form of the model and forecasts are adaptive in form generally responding to previous values. Models using time as a predictor can be understood as using previous values to estimate the model parameters (thus previous values do come into play ) but they are otherwise not part of the forecast equation thus being generally non-adaptive or fixed until re-estimation occurs. Models using time or time-squared or time-cubed etc. are anachronistic and generally not used/preferred except in very simple textbooks and in very simple classroom exercises. Models using time variables will generally exhibit auto-correlated residuals thus should be studiously avoided as the presumed model. However my work usually includes/investigates both procedures as tentative/possible approaches since only the data knows which approach is better or which approach delivers a more efficient model.
Response to comment @Veneeth :
I didn't say less accurate I wrote (implied) different. A time based model predicts based upon the input variable/series 1,2,3,3,...t which means that the prediction for t+2 ,t+ 3 , t+ 4 is fixed or deterministic or unchanged because when you observe y(t+1) as it was before you observed y(t+1). The new value has no effect on the prediction if you don't re-estimate parameters while a model that uses the value of y(t+1) et. al. and is ARIMA based will provide different forecasts. If you use the time predictor approach and re-estimate with y(t+1) in addition to all the previous y's the impact of the new observation will be normally minimal on the model coefficients unless the sample size is very small or the new observation is an anomaly which should be identified and neutralized.
Since @Veneeth asked for a quantitative example , I attempt here to answer that.
With apologies to Charles Dickens one could entitle this as " A tale of three approaches" I selected a real world example not a trivial textbook example which emphasizes the impact of presumption when it comes to model identification . Consider 1) The time based model (the only non-automatic run ) . Here is the actual fit and forecast with equation and residual plot . Followed by 2) The ARIMA model . Now consider a hybrid model incorporating both deterministic structure (input series) and ARIMA . The variance of the errors from each of the three models reduced dramatically. The deterministic structure that was identified in the hybrid approach was a Level/Step Shift which reflects an intercept change. Visually one could make a case for a possible two-trended model using approach 1 yielding but no no avail | Auto-regression versus linear regression of x(t)-with-t for modelling time series
Auto-regressive models (ARIMA) use previous values as predictors depending upon the form of the model and forecasts are adaptive in form generally responding to previous values. Models using time as a |
38,873 | Auto-regression versus linear regression of x(t)-with-t for modelling time series | My response is more from a practical perspective. I'm specifically going to address your second part of question: why can't we use machine learning techniques for time series?
Reason #1: there is NO empirical evidence that machine learning are known to be superior than simple statistical time series models. Why bother with machine learning when there is no evidence present that it works in time series data?. I once read an article by the editor of the international journal of forecasting (a leading journal in time series forecasting) who said they very rarely if at all publish machine learning methods because machine learning can't even show superiority to naive methods like simple exponential smoothing.
Reason #2: I read the book, The Elements of Statistical Learning: Data Mining, Inference, and Prediction, Second Edition (Springer Series in Statistics) by Hastie et, al which is considered a bible for modern machine learning. If you look hard at the index the number of times "time series/time" is mentioned guess what, it is 0(zero). Same can be said for other machine learning books, I have very rarely come across time series in a machine learning context.
Statisticians have elegantly handled time in methods that they have developed, I doubt if there exist similar methods in machine learning, may be its in infancy/ more research needed.
I'm yet to see any empirical evidence that shows any machine learning techniques have superiority of traditional methods, may be someone can share it. | Auto-regression versus linear regression of x(t)-with-t for modelling time series | My response is more from a practical perspective. I'm specifically going to address your second part of question: why can't we use machine learning techniques for time series?
Reason #1: there is NO e | Auto-regression versus linear regression of x(t)-with-t for modelling time series
My response is more from a practical perspective. I'm specifically going to address your second part of question: why can't we use machine learning techniques for time series?
Reason #1: there is NO empirical evidence that machine learning are known to be superior than simple statistical time series models. Why bother with machine learning when there is no evidence present that it works in time series data?. I once read an article by the editor of the international journal of forecasting (a leading journal in time series forecasting) who said they very rarely if at all publish machine learning methods because machine learning can't even show superiority to naive methods like simple exponential smoothing.
Reason #2: I read the book, The Elements of Statistical Learning: Data Mining, Inference, and Prediction, Second Edition (Springer Series in Statistics) by Hastie et, al which is considered a bible for modern machine learning. If you look hard at the index the number of times "time series/time" is mentioned guess what, it is 0(zero). Same can be said for other machine learning books, I have very rarely come across time series in a machine learning context.
Statisticians have elegantly handled time in methods that they have developed, I doubt if there exist similar methods in machine learning, may be its in infancy/ more research needed.
I'm yet to see any empirical evidence that shows any machine learning techniques have superiority of traditional methods, may be someone can share it. | Auto-regression versus linear regression of x(t)-with-t for modelling time series
My response is more from a practical perspective. I'm specifically going to address your second part of question: why can't we use machine learning techniques for time series?
Reason #1: there is NO e |
38,874 | Machine Learning Book (Python) | As mentioned in the page linked to by gung, the Elements of Statistical Learning is a great, in-depth reference. An Introduction to Statistical Learning is a more approachable book that covers many of the same topics and also provides examples in R.
I have also found Applied Predictive Modeling to be a really good, practical machine learning reference that has examples in R.
A recent Machine Learning book for Python is Building Machine Learning Systems with Python. I haven't used it yet, but it seems to provide a pretty good intro to machine learning.
Lastly, the scikit-learn Examples page provides many good examples if you already have an idea of the theory behind what you're trying to do. | Machine Learning Book (Python) | As mentioned in the page linked to by gung, the Elements of Statistical Learning is a great, in-depth reference. An Introduction to Statistical Learning is a more approachable book that covers many of | Machine Learning Book (Python)
As mentioned in the page linked to by gung, the Elements of Statistical Learning is a great, in-depth reference. An Introduction to Statistical Learning is a more approachable book that covers many of the same topics and also provides examples in R.
I have also found Applied Predictive Modeling to be a really good, practical machine learning reference that has examples in R.
A recent Machine Learning book for Python is Building Machine Learning Systems with Python. I haven't used it yet, but it seems to provide a pretty good intro to machine learning.
Lastly, the scikit-learn Examples page provides many good examples if you already have an idea of the theory behind what you're trying to do. | Machine Learning Book (Python)
As mentioned in the page linked to by gung, the Elements of Statistical Learning is a great, in-depth reference. An Introduction to Statistical Learning is a more approachable book that covers many of |
38,875 | Machine Learning Book (Python) | I would recommend that you get two books:
General reference
I can definitely recommend Pattern Recognition and Machine Learning by Christopher Bishop. It is a bit older (2006) but you will obtain the foundation to dive in state of the art research papers.
The already mentioned Elements of Statistical Learning is also a good starting point. Especially as you can download it for free.
Python / Programming
It would be good to know whether you have previous programming experience in a scripting language (Python, R, Matlab). It is quite hard to find a book that provides both an adequate technical level and good programming examples.
If you don't have prior knowledge in "statistical programming" I would recommend a book such as Python for Data Analysis by Wes McKinney. My experience has shown that data analysis beginner have more problems with the data itself (formatting, merging) than with algorithms as there are normally toolboxes with already implemented algorithms. | Machine Learning Book (Python) | I would recommend that you get two books:
General reference
I can definitely recommend Pattern Recognition and Machine Learning by Christopher Bishop. It is a bit older (2006) but you will obtain the | Machine Learning Book (Python)
I would recommend that you get two books:
General reference
I can definitely recommend Pattern Recognition and Machine Learning by Christopher Bishop. It is a bit older (2006) but you will obtain the foundation to dive in state of the art research papers.
The already mentioned Elements of Statistical Learning is also a good starting point. Especially as you can download it for free.
Python / Programming
It would be good to know whether you have previous programming experience in a scripting language (Python, R, Matlab). It is quite hard to find a book that provides both an adequate technical level and good programming examples.
If you don't have prior knowledge in "statistical programming" I would recommend a book such as Python for Data Analysis by Wes McKinney. My experience has shown that data analysis beginner have more problems with the data itself (formatting, merging) than with algorithms as there are normally toolboxes with already implemented algorithms. | Machine Learning Book (Python)
I would recommend that you get two books:
General reference
I can definitely recommend Pattern Recognition and Machine Learning by Christopher Bishop. It is a bit older (2006) but you will obtain the |
38,876 | Machine Learning Book (Python) | Murphy's "Machine Learning" is a good book with many examples. They use MATLAB as a programming language, which means most of it can be easily run using Octave or translated to Python. | Machine Learning Book (Python) | Murphy's "Machine Learning" is a good book with many examples. They use MATLAB as a programming language, which means most of it can be easily run using Octave or translated to Python. | Machine Learning Book (Python)
Murphy's "Machine Learning" is a good book with many examples. They use MATLAB as a programming language, which means most of it can be easily run using Octave or translated to Python. | Machine Learning Book (Python)
Murphy's "Machine Learning" is a good book with many examples. They use MATLAB as a programming language, which means most of it can be easily run using Octave or translated to Python. |
38,877 | Machine Learning Book (Python) | A very recent book is Data Science from Scratch by Grus, which covers "k-nearest Neighbors, Naive Bayes, linear and logistic regression, decision trees, neural networks, and clustering." I haven't read it myself, but I have heard good things. | Machine Learning Book (Python) | A very recent book is Data Science from Scratch by Grus, which covers "k-nearest Neighbors, Naive Bayes, linear and logistic regression, decision trees, neural networks, and clustering." I haven't rea | Machine Learning Book (Python)
A very recent book is Data Science from Scratch by Grus, which covers "k-nearest Neighbors, Naive Bayes, linear and logistic regression, decision trees, neural networks, and clustering." I haven't read it myself, but I have heard good things. | Machine Learning Book (Python)
A very recent book is Data Science from Scratch by Grus, which covers "k-nearest Neighbors, Naive Bayes, linear and logistic regression, decision trees, neural networks, and clustering." I haven't rea |
38,878 | Machine Learning Book (Python) | A Course in Machine Learning by Hal Daumé III
(227 pages, 2013-2017)
aims to build intuition, with a nice blend of narrative, diagrams, equations and pseudocode (not python); the lively teacher comes through.
One can download the
whole book pdf,
or individual chapters:
Decision Trees
Limits of Learning
Geometry and Nearest Neighbors
The Perceptron
Practical Issues
Beyond Binary Classification
Linear Models
Bias and Fairness
Probabilistic Modeling
Neural Networks
Kernel Methods
Learning Theory
Ensemble Methods
Efficient Learning
Unsupervised Learning
Expectation Maximization
Structured Prediction
Imitation Learning | Machine Learning Book (Python) | A Course in Machine Learning by Hal Daumé III
(227 pages, 2013-2017)
aims to build intuition, with a nice blend of narrative, diagrams, equations and pseudocode (not python); the lively teacher comes | Machine Learning Book (Python)
A Course in Machine Learning by Hal Daumé III
(227 pages, 2013-2017)
aims to build intuition, with a nice blend of narrative, diagrams, equations and pseudocode (not python); the lively teacher comes through.
One can download the
whole book pdf,
or individual chapters:
Decision Trees
Limits of Learning
Geometry and Nearest Neighbors
The Perceptron
Practical Issues
Beyond Binary Classification
Linear Models
Bias and Fairness
Probabilistic Modeling
Neural Networks
Kernel Methods
Learning Theory
Ensemble Methods
Efficient Learning
Unsupervised Learning
Expectation Maximization
Structured Prediction
Imitation Learning | Machine Learning Book (Python)
A Course in Machine Learning by Hal Daumé III
(227 pages, 2013-2017)
aims to build intuition, with a nice blend of narrative, diagrams, equations and pseudocode (not python); the lively teacher comes |
38,879 | Machine Learning Book (Python) | In my experience I recommend the book Practical Econometrics with Python. I love this book because links theory with real examples in Python. It goes from basic topics like OLS to advanced topics like VARMA. | Machine Learning Book (Python) | In my experience I recommend the book Practical Econometrics with Python. I love this book because links theory with real examples in Python. It goes from basic topics like OLS to advanced topics like | Machine Learning Book (Python)
In my experience I recommend the book Practical Econometrics with Python. I love this book because links theory with real examples in Python. It goes from basic topics like OLS to advanced topics like VARMA. | Machine Learning Book (Python)
In my experience I recommend the book Practical Econometrics with Python. I love this book because links theory with real examples in Python. It goes from basic topics like OLS to advanced topics like |
38,880 | Conditional vs. Marginal models | Either of the models you used are probably fine approaches -- and it's certainly reassuring that the results are similar.
Marginal models are population-average models whereas conditional models are subject-specific. As a result, there are subtle differences in interpretation. For example if you were studying the effect of BMI on blood pressure and you were using marginal model, you would say something like, "a 1 unit increase in BMI is associated with a $Z$-unit average increase in blood pressure" while with a conditional model you would say something like "a 1 unit increase in BMI is associated with a $Z$-unit average increase in blood pressure, holding each random effect for individual constant."
Diggle, Liang, and Zeger (1994) have recommended the use of marginal models when the objective of the study is to make population-based inferences (as is typically the case in epidemiological settings), and mixed models/conditional models when attempting to make inferences about individual responses.
However many others argue that conditional models should always be preferred to marginal models as conditional models can incorporate conditional AND marginal effects. See for example, Lee and Nelder (2004).
I personally prefer to use marginal models, but that's because I'm often concerned with model misspecification (but you may not be). Marginal models are quite robust and less susceptible to biases from misspecification of random effects (obviously). See Heagerty and Kurland (2001). | Conditional vs. Marginal models | Either of the models you used are probably fine approaches -- and it's certainly reassuring that the results are similar.
Marginal models are population-average models whereas conditional models are s | Conditional vs. Marginal models
Either of the models you used are probably fine approaches -- and it's certainly reassuring that the results are similar.
Marginal models are population-average models whereas conditional models are subject-specific. As a result, there are subtle differences in interpretation. For example if you were studying the effect of BMI on blood pressure and you were using marginal model, you would say something like, "a 1 unit increase in BMI is associated with a $Z$-unit average increase in blood pressure" while with a conditional model you would say something like "a 1 unit increase in BMI is associated with a $Z$-unit average increase in blood pressure, holding each random effect for individual constant."
Diggle, Liang, and Zeger (1994) have recommended the use of marginal models when the objective of the study is to make population-based inferences (as is typically the case in epidemiological settings), and mixed models/conditional models when attempting to make inferences about individual responses.
However many others argue that conditional models should always be preferred to marginal models as conditional models can incorporate conditional AND marginal effects. See for example, Lee and Nelder (2004).
I personally prefer to use marginal models, but that's because I'm often concerned with model misspecification (but you may not be). Marginal models are quite robust and less susceptible to biases from misspecification of random effects (obviously). See Heagerty and Kurland (2001). | Conditional vs. Marginal models
Either of the models you used are probably fine approaches -- and it's certainly reassuring that the results are similar.
Marginal models are population-average models whereas conditional models are s |
38,881 | Conditional vs. Marginal models | One can view the marginal model as providing crude estimates of the regression coefficients [i.e. unadjusted for subjects] while the conditional model has regression coefficients that are assumed common to subjects and so the estimates are adjusted for subjects. In this sense, one is asking whether the subjects at hand are confounding. This is rather typical of confounding assessment : often involving how the subjects were obtained. The comparison of crude and adjusted is a confounding matter. One can also argue for quite elaborate assessments of confounding. Maybe one needs both intercept and slope as subject components. | Conditional vs. Marginal models | One can view the marginal model as providing crude estimates of the regression coefficients [i.e. unadjusted for subjects] while the conditional model has regression coefficients that are assumed comm | Conditional vs. Marginal models
One can view the marginal model as providing crude estimates of the regression coefficients [i.e. unadjusted for subjects] while the conditional model has regression coefficients that are assumed common to subjects and so the estimates are adjusted for subjects. In this sense, one is asking whether the subjects at hand are confounding. This is rather typical of confounding assessment : often involving how the subjects were obtained. The comparison of crude and adjusted is a confounding matter. One can also argue for quite elaborate assessments of confounding. Maybe one needs both intercept and slope as subject components. | Conditional vs. Marginal models
One can view the marginal model as providing crude estimates of the regression coefficients [i.e. unadjusted for subjects] while the conditional model has regression coefficients that are assumed comm |
38,882 | Just "take the average" they say. It's not that straightforward, right? | This is not a direct answer to your question about loss functions, but I am a Statistician, and I use the jargon of my domain, not the jargon of machine learning. I will attempt to answer the question: "which statistic is the best estimator of the population mean?"
It's incorrect to say generally that the arithmetic mean results in a loss of information. In fact in some circumstances, it can be proven that the arithmetic mean or some function of it contains as much information (Fisher information) as the data themselves. This is the concept of a sufficient statistic, i.e. some summary of the data that is sufficient for the data.
For example, if you know that your data follow a Poisson distribution then the sufficient statistic is $T(X) = X_1 + ... + X_n$. Which is simply the sum of the data. For a Normal distribution where you know the variance then the arithmetic sample mean is the sufficient statistic for the population mean. That is, it contains all of the information and no other statistic will do better. Now granted, we are never in the situation where we know are data are normally distributed and happen to know exactly the variance. But that is why we have the central limit theorem. Even for skewed data, if what you really care about is the population mean, then the arithmetic mean is pretty good bet, especially if you have a lot of observations. So to that end, I would say in a lot of circumstances, especially when you have a lot of observations the arithmetic mean is best if what you care about is the population mean.
Now, if you happen to be in the privileged position of knowing your data come from some other distribution, perhaps some pathological negative exponential distribution, then you're correct there may be a better sufficient statistic. In that circumstance the sufficient statistic for $\mu$ is the minimum observation. This is favorite example of Mukhopadhyay in Probability and Statistical Inference and you will find all exercises you can stomach in there to demonstrate.
To answer your question more generally, about how to choose the best statistic: plot your data. Look at it. Think about where it came from and how it was collected. Think about what it is you are actually trying to make inference on, and whether the way these data were collected is actually appropriate for that. Think about the form your data take: Are they strictly integer data? Proportions with a known denominator? Are they skewed, if so would a log-normal make a for a good approximation? Choose a parametric family that seems to satisfy and caveat if you must. | Just "take the average" they say. It's not that straightforward, right? | This is not a direct answer to your question about loss functions, but I am a Statistician, and I use the jargon of my domain, not the jargon of machine learning. I will attempt to answer the question | Just "take the average" they say. It's not that straightforward, right?
This is not a direct answer to your question about loss functions, but I am a Statistician, and I use the jargon of my domain, not the jargon of machine learning. I will attempt to answer the question: "which statistic is the best estimator of the population mean?"
It's incorrect to say generally that the arithmetic mean results in a loss of information. In fact in some circumstances, it can be proven that the arithmetic mean or some function of it contains as much information (Fisher information) as the data themselves. This is the concept of a sufficient statistic, i.e. some summary of the data that is sufficient for the data.
For example, if you know that your data follow a Poisson distribution then the sufficient statistic is $T(X) = X_1 + ... + X_n$. Which is simply the sum of the data. For a Normal distribution where you know the variance then the arithmetic sample mean is the sufficient statistic for the population mean. That is, it contains all of the information and no other statistic will do better. Now granted, we are never in the situation where we know are data are normally distributed and happen to know exactly the variance. But that is why we have the central limit theorem. Even for skewed data, if what you really care about is the population mean, then the arithmetic mean is pretty good bet, especially if you have a lot of observations. So to that end, I would say in a lot of circumstances, especially when you have a lot of observations the arithmetic mean is best if what you care about is the population mean.
Now, if you happen to be in the privileged position of knowing your data come from some other distribution, perhaps some pathological negative exponential distribution, then you're correct there may be a better sufficient statistic. In that circumstance the sufficient statistic for $\mu$ is the minimum observation. This is favorite example of Mukhopadhyay in Probability and Statistical Inference and you will find all exercises you can stomach in there to demonstrate.
To answer your question more generally, about how to choose the best statistic: plot your data. Look at it. Think about where it came from and how it was collected. Think about what it is you are actually trying to make inference on, and whether the way these data were collected is actually appropriate for that. Think about the form your data take: Are they strictly integer data? Proportions with a known denominator? Are they skewed, if so would a log-normal make a for a good approximation? Choose a parametric family that seems to satisfy and caveat if you must. | Just "take the average" they say. It's not that straightforward, right?
This is not a direct answer to your question about loss functions, but I am a Statistician, and I use the jargon of my domain, not the jargon of machine learning. I will attempt to answer the question |
38,883 | Just "take the average" they say. It's not that straightforward, right? | Piggy-backing / building off of Dalton's answer:
Your question, as posed, is incomplete. "Information" as a statistical concept is only defined with reference to an unknown parameter as well as some statistic (function of the full data)—including the degenerate case of the full data. Exactly no statistic of the data has more information about any parameter than the full data, but sometimes statistics have just as much information as the full data about a specific parameter.
Your intuition seems to be that summary statistics reduce the informational content of the full data, but again, there is no informational content to even the full data unless it is with reference to some parameter. It is true that, if you are estimating the variance of a Normal population, the statistic $S^2$ (sample variance) has no informational content about $\mu$ (the population mean). But as pointed out above, $\bar{X}$ contains equal information about $\mu$ as does the full data.
Your question is incomplete because the intuitive, casual definition of "information" is very different from its mathematical definition. For any specific real-world scenario, you will of course have to judge what is an appropriate assumption for the distribution (accounting for skewness, support, etc) and, consequently, what specific statistics preserve the information you need.
As an aside, $\bar{X}$ gives you no information about the variance of a Normal($\mu$, $\sigma^2$) distribution, either, but knowing the pair $(\bar{X}, S^2)$ provides the same information as the full data about both parameters. | Just "take the average" they say. It's not that straightforward, right? | Piggy-backing / building off of Dalton's answer:
Your question, as posed, is incomplete. "Information" as a statistical concept is only defined with reference to an unknown parameter as well as some s | Just "take the average" they say. It's not that straightforward, right?
Piggy-backing / building off of Dalton's answer:
Your question, as posed, is incomplete. "Information" as a statistical concept is only defined with reference to an unknown parameter as well as some statistic (function of the full data)—including the degenerate case of the full data. Exactly no statistic of the data has more information about any parameter than the full data, but sometimes statistics have just as much information as the full data about a specific parameter.
Your intuition seems to be that summary statistics reduce the informational content of the full data, but again, there is no informational content to even the full data unless it is with reference to some parameter. It is true that, if you are estimating the variance of a Normal population, the statistic $S^2$ (sample variance) has no informational content about $\mu$ (the population mean). But as pointed out above, $\bar{X}$ contains equal information about $\mu$ as does the full data.
Your question is incomplete because the intuitive, casual definition of "information" is very different from its mathematical definition. For any specific real-world scenario, you will of course have to judge what is an appropriate assumption for the distribution (accounting for skewness, support, etc) and, consequently, what specific statistics preserve the information you need.
As an aside, $\bar{X}$ gives you no information about the variance of a Normal($\mu$, $\sigma^2$) distribution, either, but knowing the pair $(\bar{X}, S^2)$ provides the same information as the full data about both parameters. | Just "take the average" they say. It's not that straightforward, right?
Piggy-backing / building off of Dalton's answer:
Your question, as posed, is incomplete. "Information" as a statistical concept is only defined with reference to an unknown parameter as well as some s |
38,884 | Observed Vs Unobserved Variables [duplicate] | Observed variables are variables for which you have measurements in your dataset, whereas unobserved (or latent) variables are variables for which you don't.
When your analysis reveals correlations between observed variables, you might look for unobserved variables to explain the correlation, especially in cases where you doubt that there's a direct causal relationship between them. To offer a contrived example, suppose your dataset includes strongly correlated variables "ice cream consumption" and "air conditioner usage". You might suspect that there's an unobserved variable (temperature), acting as a common cause, driving the correlation.
Sometimes the unobserved variable is unobserved because it isn't directly measurable. (Perhaps the variable is more theoretical in nature, or perhaps the variable is in principle directly measurable, but it would be difficult/expensive to measure it in practice.) For example, we can't measure intelligence directly, so we use proxy measurements such as performance on intelligence tests as a substitute. | Observed Vs Unobserved Variables [duplicate] | Observed variables are variables for which you have measurements in your dataset, whereas unobserved (or latent) variables are variables for which you don't.
When your analysis reveals correlations be | Observed Vs Unobserved Variables [duplicate]
Observed variables are variables for which you have measurements in your dataset, whereas unobserved (or latent) variables are variables for which you don't.
When your analysis reveals correlations between observed variables, you might look for unobserved variables to explain the correlation, especially in cases where you doubt that there's a direct causal relationship between them. To offer a contrived example, suppose your dataset includes strongly correlated variables "ice cream consumption" and "air conditioner usage". You might suspect that there's an unobserved variable (temperature), acting as a common cause, driving the correlation.
Sometimes the unobserved variable is unobserved because it isn't directly measurable. (Perhaps the variable is more theoretical in nature, or perhaps the variable is in principle directly measurable, but it would be difficult/expensive to measure it in practice.) For example, we can't measure intelligence directly, so we use proxy measurements such as performance on intelligence tests as a substitute. | Observed Vs Unobserved Variables [duplicate]
Observed variables are variables for which you have measurements in your dataset, whereas unobserved (or latent) variables are variables for which you don't.
When your analysis reveals correlations be |
38,885 | Observed Vs Unobserved Variables [duplicate] | Are you doing research within economics?
Usually, the unobservable characteristics are those that are captured by the error term and bias your estimates, for instance through heteroskedasticity.
Let's me give you an example.
When you conduct a so called correspondence test in the labor market to study ethnic discrimination in hiring, you send out bogus matched job applications. One application concerns the "red" applicant while the other application concerns the "green" applicant (where "green" and "red" are two whatever ethnic groups).
The ethnicity is the only observable characteristic that differ between the two bogus applicants; however, in the applications there are many other characteristics that are the same (well, actually they are equivalent, not really the same) for the two applicants, such as: reached level of studies, age, work experience, etc... All these characteristics are observable (from the point of view of the experimenter and from that of the employer) because they are listed in the CV, while the ethnicity can be understood from the applicants' name.
Other characteristics that are not listed in the CV are thus observable neither by the employers nor by the experimenters. These characteristics are the so called "unobservable characteristics".
These unobservable characteristics will affect the estimate of discrimination in hiring through heteroskedasticity (=different variance of the residuals, for the two compared groups). For more insights on this point see this article and this article.
A similar problem arises from audit tests where, instead of sending fictitious written applicants, the experimenter sends two actors to apply in person to job interview. The two actors are matched on all characteristics except for the ethnic group.
However, there will be different characteristics between the two applicants that have not been observed by the experimenter, but that will be observed by the employer, also in this case we speak of unobservable characteristics. For instance, one applicant has a more pleasant voice, or applicant stinks a little during the day of the interview or did not comb his/her hair properly, etc...while these examples may sound silly, these different unobservable characteristics might eventually determine a systematic difference in the hiring decisions for the two bogus applicants and thus bias the results. | Observed Vs Unobserved Variables [duplicate] | Are you doing research within economics?
Usually, the unobservable characteristics are those that are captured by the error term and bias your estimates, for instance through heteroskedasticity.
Let's | Observed Vs Unobserved Variables [duplicate]
Are you doing research within economics?
Usually, the unobservable characteristics are those that are captured by the error term and bias your estimates, for instance through heteroskedasticity.
Let's me give you an example.
When you conduct a so called correspondence test in the labor market to study ethnic discrimination in hiring, you send out bogus matched job applications. One application concerns the "red" applicant while the other application concerns the "green" applicant (where "green" and "red" are two whatever ethnic groups).
The ethnicity is the only observable characteristic that differ between the two bogus applicants; however, in the applications there are many other characteristics that are the same (well, actually they are equivalent, not really the same) for the two applicants, such as: reached level of studies, age, work experience, etc... All these characteristics are observable (from the point of view of the experimenter and from that of the employer) because they are listed in the CV, while the ethnicity can be understood from the applicants' name.
Other characteristics that are not listed in the CV are thus observable neither by the employers nor by the experimenters. These characteristics are the so called "unobservable characteristics".
These unobservable characteristics will affect the estimate of discrimination in hiring through heteroskedasticity (=different variance of the residuals, for the two compared groups). For more insights on this point see this article and this article.
A similar problem arises from audit tests where, instead of sending fictitious written applicants, the experimenter sends two actors to apply in person to job interview. The two actors are matched on all characteristics except for the ethnic group.
However, there will be different characteristics between the two applicants that have not been observed by the experimenter, but that will be observed by the employer, also in this case we speak of unobservable characteristics. For instance, one applicant has a more pleasant voice, or applicant stinks a little during the day of the interview or did not comb his/her hair properly, etc...while these examples may sound silly, these different unobservable characteristics might eventually determine a systematic difference in the hiring decisions for the two bogus applicants and thus bias the results. | Observed Vs Unobserved Variables [duplicate]
Are you doing research within economics?
Usually, the unobservable characteristics are those that are captured by the error term and bias your estimates, for instance through heteroskedasticity.
Let's |
38,886 | Can percentages be averaged? | Specific advice is difficult here. We see no data and have only a broad idea of what is being done. What are the precise questions being answered?
Averaging percents is often going to be a bad idea, but the question needs to be made broader to allow good recommendations.
For example, if reducing time spent is of primary interest, then the savings as measured in seconds are key. Often the fast can't get much faster, but the slower have a lot of scope to be slower still if there is some physical or mental skill that is essential for rapid completion, but difficult for some. Working with percents could then obscure the key issues.
So the first thing to get clear is whether percent improvement is a good scale at all, on which some general advice is possible. Working with percents can make sense if changes are generally multiplicative. So talking about price or income changes as percents can make sense because that is, to a good approximation, the way that many bodies do change prices or incomes. Is there something similar here?
Times to complete a task
Are often best analysed as they come, as there is scientific, and especially practical, interest in time as it would be spent.
Sometimes are best analysed on logarithmic scale, as they are often highly skewed (imagine times to run 1 km, even among those who can run). Working on logarithmic scale and percent change are basically the same idea.
Sometimes are best analysed on reciprocal scale, as that gives a speed or rate of completion. (People who never finish can be regarded as having zero speed, which is unflattering in the abstract, but makes them easier to plot and average.)
Suppose person X changes on A from 10 s to 20 s and on B from 20 s to 10 s. That is a 50% improvement in one case and a -100% improvement in the other. What would be an appropriate summary? It is easy to imagine cases in which different kinds of changes would be averaged to the same average percent, which will be at best not helpful and at worst highly confusing. But do they occur in the dataset?
In broad terms,
The raw data should always be accessible to anyone asked to judge on this so any reduction can be checked and revised.
If the two sets of improvement percents are very close, then that is the best basis for averaging, but even if that is true, it is often better just to present both sets of results any way. That should not take more space as you can use the same graphs and tables.
Your examples may be plucked out of the air, but if there are substantial differences between percent change on the methods, you need to be focusing on the differences, not taking the average. | Can percentages be averaged? | Specific advice is difficult here. We see no data and have only a broad idea of what is being done. What are the precise questions being answered?
Averaging percents is often going to be a bad idea, | Can percentages be averaged?
Specific advice is difficult here. We see no data and have only a broad idea of what is being done. What are the precise questions being answered?
Averaging percents is often going to be a bad idea, but the question needs to be made broader to allow good recommendations.
For example, if reducing time spent is of primary interest, then the savings as measured in seconds are key. Often the fast can't get much faster, but the slower have a lot of scope to be slower still if there is some physical or mental skill that is essential for rapid completion, but difficult for some. Working with percents could then obscure the key issues.
So the first thing to get clear is whether percent improvement is a good scale at all, on which some general advice is possible. Working with percents can make sense if changes are generally multiplicative. So talking about price or income changes as percents can make sense because that is, to a good approximation, the way that many bodies do change prices or incomes. Is there something similar here?
Times to complete a task
Are often best analysed as they come, as there is scientific, and especially practical, interest in time as it would be spent.
Sometimes are best analysed on logarithmic scale, as they are often highly skewed (imagine times to run 1 km, even among those who can run). Working on logarithmic scale and percent change are basically the same idea.
Sometimes are best analysed on reciprocal scale, as that gives a speed or rate of completion. (People who never finish can be regarded as having zero speed, which is unflattering in the abstract, but makes them easier to plot and average.)
Suppose person X changes on A from 10 s to 20 s and on B from 20 s to 10 s. That is a 50% improvement in one case and a -100% improvement in the other. What would be an appropriate summary? It is easy to imagine cases in which different kinds of changes would be averaged to the same average percent, which will be at best not helpful and at worst highly confusing. But do they occur in the dataset?
In broad terms,
The raw data should always be accessible to anyone asked to judge on this so any reduction can be checked and revised.
If the two sets of improvement percents are very close, then that is the best basis for averaging, but even if that is true, it is often better just to present both sets of results any way. That should not take more space as you can use the same graphs and tables.
Your examples may be plucked out of the air, but if there are substantial differences between percent change on the methods, you need to be focusing on the differences, not taking the average. | Can percentages be averaged?
Specific advice is difficult here. We see no data and have only a broad idea of what is being done. What are the precise questions being answered?
Averaging percents is often going to be a bad idea, |
38,887 | Can percentages be averaged? | I quite agree with Nick Cox's response, to give an example where one has to be wary, take compliance with a particular standard by an organisation with just two cost centres where the sample size in the first case is 10 and in the second it is 100. In the first case 8 out of 10 may be compliant, while in the second only 40 out of 100 may be compliant. If one wants to know what the average among cost centres is then the answer is 60%, while if one wants to know what the average is across the organisation as a whole, then it is better to aggregate the underlying numbers, i.e. 48/110 making 44%. | Can percentages be averaged? | I quite agree with Nick Cox's response, to give an example where one has to be wary, take compliance with a particular standard by an organisation with just two cost centres where the sample size in t | Can percentages be averaged?
I quite agree with Nick Cox's response, to give an example where one has to be wary, take compliance with a particular standard by an organisation with just two cost centres where the sample size in the first case is 10 and in the second it is 100. In the first case 8 out of 10 may be compliant, while in the second only 40 out of 100 may be compliant. If one wants to know what the average among cost centres is then the answer is 60%, while if one wants to know what the average is across the organisation as a whole, then it is better to aggregate the underlying numbers, i.e. 48/110 making 44%. | Can percentages be averaged?
I quite agree with Nick Cox's response, to give an example where one has to be wary, take compliance with a particular standard by an organisation with just two cost centres where the sample size in t |
38,888 | Can percentages be averaged? | If Subject 1 went from 10 sec to 5 sec (50% improvement) while Subject 2 went from 10 sec to 7.5 sec (25% improvement) then it is valid to average the percentages in this case and say that the average improvement is about 37.5%. | Can percentages be averaged? | If Subject 1 went from 10 sec to 5 sec (50% improvement) while Subject 2 went from 10 sec to 7.5 sec (25% improvement) then it is valid to average the percentages in this case and say that the average | Can percentages be averaged?
If Subject 1 went from 10 sec to 5 sec (50% improvement) while Subject 2 went from 10 sec to 7.5 sec (25% improvement) then it is valid to average the percentages in this case and say that the average improvement is about 37.5%. | Can percentages be averaged?
If Subject 1 went from 10 sec to 5 sec (50% improvement) while Subject 2 went from 10 sec to 7.5 sec (25% improvement) then it is valid to average the percentages in this case and say that the average |
38,889 | In linear regression, what does $\beta_1 = 0$ really mean? | Part of the problem here is that your model is conceptually confused, as @CagdasOzgenc has correctly pointed out.(Edit: This has now been fixed.) I think I can address two of your specific questions.
If $\beta_1 = 0$ (note the absence of the 'hat'), and standard assumptions hold, then empirically, as we make ever more measurements of our data, $\hat\beta_1$ will approach $0$ at the limit.
In mathematical notation:
$$
\lim_{N\to\infty} \hat\beta_1 = 0
$$
If $\beta_1 = 0$, and $X_1$ and $X_2$ are uncorrelated, then formally, in the population of our data, $x_1$ is uncorrelated with $y$, linearly independent of $y$, but not necessarily independent of $y$*. (Edit: as @CagdasOzgenc points out, if we take the model provided as literally the DGP, independence holds as well.)
In mathematical notation:
$$
{\rm Cor}(x_1, y) = 0
$$
* From the Wikipedia page on correlation and dependence, consider this figure:
The patterns in the bottom row all have correlation $0$, but show various patterns of dependence.
I don't understand the part after the bolded text.(Edit: The referenced portion of the question has now been removed.) | In linear regression, what does $\beta_1 = 0$ really mean? | Part of the problem here is that your model is conceptually confused, as @CagdasOzgenc has correctly pointed out.(Edit: This has now been fixed.) I think I can address two of your specific questions. | In linear regression, what does $\beta_1 = 0$ really mean?
Part of the problem here is that your model is conceptually confused, as @CagdasOzgenc has correctly pointed out.(Edit: This has now been fixed.) I think I can address two of your specific questions.
If $\beta_1 = 0$ (note the absence of the 'hat'), and standard assumptions hold, then empirically, as we make ever more measurements of our data, $\hat\beta_1$ will approach $0$ at the limit.
In mathematical notation:
$$
\lim_{N\to\infty} \hat\beta_1 = 0
$$
If $\beta_1 = 0$, and $X_1$ and $X_2$ are uncorrelated, then formally, in the population of our data, $x_1$ is uncorrelated with $y$, linearly independent of $y$, but not necessarily independent of $y$*. (Edit: as @CagdasOzgenc points out, if we take the model provided as literally the DGP, independence holds as well.)
In mathematical notation:
$$
{\rm Cor}(x_1, y) = 0
$$
* From the Wikipedia page on correlation and dependence, consider this figure:
The patterns in the bottom row all have correlation $0$, but show various patterns of dependence.
I don't understand the part after the bolded text.(Edit: The referenced portion of the question has now been removed.) | In linear regression, what does $\beta_1 = 0$ really mean?
Part of the problem here is that your model is conceptually confused, as @CagdasOzgenc has correctly pointed out.(Edit: This has now been fixed.) I think I can address two of your specific questions. |
38,890 | In linear regression, what does $\beta_1 = 0$ really mean? | You are confusing the real data generation process with a model trying to make an approximation of this process (this is quite normal, I also banged my head to the wall several times regarding this matter).
First of all
$y = \beta_0 + \beta_1x_1 + \beta_2x_2$
is a deterministic model. Usually in regression, the model is probabilistic hence, the correct representation of the model is
$y = \beta_0 + \beta_1x_1 + \beta_2x_2 + \epsilon$ and $\epsilon$ ~ some distribution(usually normal)
Now suppose that above model is exactly capturing the underlying real data generation. In that case $\beta_1$ = 0 means it is always 0 in reality.
However when you propose the above model you need to estimate the parameters from sample data.
In that case
$\hat{\beta_1}$ (estimation of $\beta_1$) can be anything. The probability that it will be exactly 0 is 0. If in reality it is 0, and if you did proper sampling and used a consistent estimation procedure as sample size increases it will approach 0. | In linear regression, what does $\beta_1 = 0$ really mean? | You are confusing the real data generation process with a model trying to make an approximation of this process (this is quite normal, I also banged my head to the wall several times regarding this ma | In linear regression, what does $\beta_1 = 0$ really mean?
You are confusing the real data generation process with a model trying to make an approximation of this process (this is quite normal, I also banged my head to the wall several times regarding this matter).
First of all
$y = \beta_0 + \beta_1x_1 + \beta_2x_2$
is a deterministic model. Usually in regression, the model is probabilistic hence, the correct representation of the model is
$y = \beta_0 + \beta_1x_1 + \beta_2x_2 + \epsilon$ and $\epsilon$ ~ some distribution(usually normal)
Now suppose that above model is exactly capturing the underlying real data generation. In that case $\beta_1$ = 0 means it is always 0 in reality.
However when you propose the above model you need to estimate the parameters from sample data.
In that case
$\hat{\beta_1}$ (estimation of $\beta_1$) can be anything. The probability that it will be exactly 0 is 0. If in reality it is 0, and if you did proper sampling and used a consistent estimation procedure as sample size increases it will approach 0. | In linear regression, what does $\beta_1 = 0$ really mean?
You are confusing the real data generation process with a model trying to make an approximation of this process (this is quite normal, I also banged my head to the wall several times regarding this ma |
38,891 | In linear regression, what does $\beta_1 = 0$ really mean? | Gung's answer is excellent, but I want to add an interpretation that I think goes underappreciated.
You wrote out the model as
$$
Y = \beta_0 + \beta_1 X_1 + \beta_2 X_2 + \varepsilon
$$
You didn't specify this, but presumably $\varepsilon$ is an error term with $\operatorname{\mathbb{E}}\left(\varepsilon\,|\,X\right) = 0$ and $\varepsilon \perp X$. Here you are postulating a particular data-generating process: given $X_1$ and $X_2$, $Y$ is a deterministic function of $X_1$ and $X_2$, plus a random error term. This is what is usually taught in undergrad econometrics class.
Now just for the heck of it, define a function $\mu(x_1, x_2) = \beta_0 + \beta_1 x_1 + \beta_2 x_2$ so that the model can be written as
$$
Y = \mu(X_1, X_2) + \varepsilon
$$
or, perhaps more precisely,
$$
Y\,|\,(X_1 = x_1, X_2 = x_2) = \mu(x_1, x_2) + \varepsilon
$$
Remember that we assumed $\operatorname{\mathbb{E}}\left(\varepsilon\,|\,X_1 = x_1, X_2 = x_2\right) = 0$. Taking the hint, let's compute
$$
\begin{align}
\operatorname{\mathbb{E}}(Y\,|\,X_1 = x_1, X_2 = x_2) &= \operatorname{\mathbb{E}}(\mu(x_1, x_2)) &+& \operatorname{\mathbb{E}}\left(\varepsilon\,|\,X_1 = x_1, X_2 = x_2\right) \\
\operatorname{\mathbb{E}}(Y\,|\,X_1 = x_1, X_2 = x_2) &= \mu(x_1, x_2) &+& 0 \\
\operatorname{\mathbb{E}}(Y\,|\,X_1 = x_1, X_2 = x_2) &= \beta_0 + \beta_1 x_1 + \beta_2 x_2
\end{align}
$$
This is powerful stuff: "regression line" is really the expected $Y$ as a function of $X$.
You asked what it means if $\beta_1 = 0$. In this interpretation, it means that the expectation of $Y$ does not depend on $X_1$. That is,
$$\begin{align}
\operatorname{\mathbb{E}}(Y\,|\,X_1 = x_1, X_2 = x_2) &= \beta_0 &+ 0 \cdot x_1 &+ \beta_2 x_2 \\
\operatorname{\mathbb{E}}(Y\,|\,X_1 = x_1, X_2 = x_2) &= \beta_0 &&+ \beta_2 x_2
\end{align}$$
In other words, $\beta_1 = 0$ means $X_1$ does not belong in the model. The slope of the regression line (i.e. the "conditional expectation line") is 0 with respect to $X_1$. Compare: $z = 2x + 2y$ and $z = 0x + 2y$
Now remember our second assumption that $\varepsilon \perp X$. From this we can conclude that in fact $Y \perp X_1$. We have already established that changing the value of $X_1$ has no effect on $\mu$, the average $Y$ given $X_1$ and $X_2$, but if $\varepsilon \perp X_1$ as well, then there's just nowhere else for $X_1$ to enter the data generating process. It doesn't affect the average $Y$ and it doesn't effect the variation of $Y$ around its average, so it just doesn't affect $Y$ at all.
Empirically, this means that any value we estimate for $\beta_1$, which we usually denote $\hat \beta_1$, should be close to zero. If we use OLS to fit the model, we know that $\operatorname{\mathbb{E}}(\hat \beta_1) = \beta_1 = 0$ and $\hat \beta_1 \xrightarrow[]{n \to \infty} \beta_1$. So the expectation of $\hat \beta_1$ will be zero, and $\hat \beta_1$ will approach zero as the sample grows. | In linear regression, what does $\beta_1 = 0$ really mean? | Gung's answer is excellent, but I want to add an interpretation that I think goes underappreciated.
You wrote out the model as
$$
Y = \beta_0 + \beta_1 X_1 + \beta_2 X_2 + \varepsilon
$$
You didn't sp | In linear regression, what does $\beta_1 = 0$ really mean?
Gung's answer is excellent, but I want to add an interpretation that I think goes underappreciated.
You wrote out the model as
$$
Y = \beta_0 + \beta_1 X_1 + \beta_2 X_2 + \varepsilon
$$
You didn't specify this, but presumably $\varepsilon$ is an error term with $\operatorname{\mathbb{E}}\left(\varepsilon\,|\,X\right) = 0$ and $\varepsilon \perp X$. Here you are postulating a particular data-generating process: given $X_1$ and $X_2$, $Y$ is a deterministic function of $X_1$ and $X_2$, plus a random error term. This is what is usually taught in undergrad econometrics class.
Now just for the heck of it, define a function $\mu(x_1, x_2) = \beta_0 + \beta_1 x_1 + \beta_2 x_2$ so that the model can be written as
$$
Y = \mu(X_1, X_2) + \varepsilon
$$
or, perhaps more precisely,
$$
Y\,|\,(X_1 = x_1, X_2 = x_2) = \mu(x_1, x_2) + \varepsilon
$$
Remember that we assumed $\operatorname{\mathbb{E}}\left(\varepsilon\,|\,X_1 = x_1, X_2 = x_2\right) = 0$. Taking the hint, let's compute
$$
\begin{align}
\operatorname{\mathbb{E}}(Y\,|\,X_1 = x_1, X_2 = x_2) &= \operatorname{\mathbb{E}}(\mu(x_1, x_2)) &+& \operatorname{\mathbb{E}}\left(\varepsilon\,|\,X_1 = x_1, X_2 = x_2\right) \\
\operatorname{\mathbb{E}}(Y\,|\,X_1 = x_1, X_2 = x_2) &= \mu(x_1, x_2) &+& 0 \\
\operatorname{\mathbb{E}}(Y\,|\,X_1 = x_1, X_2 = x_2) &= \beta_0 + \beta_1 x_1 + \beta_2 x_2
\end{align}
$$
This is powerful stuff: "regression line" is really the expected $Y$ as a function of $X$.
You asked what it means if $\beta_1 = 0$. In this interpretation, it means that the expectation of $Y$ does not depend on $X_1$. That is,
$$\begin{align}
\operatorname{\mathbb{E}}(Y\,|\,X_1 = x_1, X_2 = x_2) &= \beta_0 &+ 0 \cdot x_1 &+ \beta_2 x_2 \\
\operatorname{\mathbb{E}}(Y\,|\,X_1 = x_1, X_2 = x_2) &= \beta_0 &&+ \beta_2 x_2
\end{align}$$
In other words, $\beta_1 = 0$ means $X_1$ does not belong in the model. The slope of the regression line (i.e. the "conditional expectation line") is 0 with respect to $X_1$. Compare: $z = 2x + 2y$ and $z = 0x + 2y$
Now remember our second assumption that $\varepsilon \perp X$. From this we can conclude that in fact $Y \perp X_1$. We have already established that changing the value of $X_1$ has no effect on $\mu$, the average $Y$ given $X_1$ and $X_2$, but if $\varepsilon \perp X_1$ as well, then there's just nowhere else for $X_1$ to enter the data generating process. It doesn't affect the average $Y$ and it doesn't effect the variation of $Y$ around its average, so it just doesn't affect $Y$ at all.
Empirically, this means that any value we estimate for $\beta_1$, which we usually denote $\hat \beta_1$, should be close to zero. If we use OLS to fit the model, we know that $\operatorname{\mathbb{E}}(\hat \beta_1) = \beta_1 = 0$ and $\hat \beta_1 \xrightarrow[]{n \to \infty} \beta_1$. So the expectation of $\hat \beta_1$ will be zero, and $\hat \beta_1$ will approach zero as the sample grows. | In linear regression, what does $\beta_1 = 0$ really mean?
Gung's answer is excellent, but I want to add an interpretation that I think goes underappreciated.
You wrote out the model as
$$
Y = \beta_0 + \beta_1 X_1 + \beta_2 X_2 + \varepsilon
$$
You didn't sp |
38,892 | Probability that randomly chosen value from one distribution is greater than randomly chosen value from another distribution | Your bootstrap simulation suggests the A's and B's are independent; I will assume so.
Note that $P(A>B)=P(A-B>0)$.
In the case where A and B are also normal, $D=A-B \sim N(\mu_A-\mu_B,\sigma^2_A+\sigma^2_B)$
In that case
\begin{eqnarray*}
P(D>0) &=& P(\frac{D-\mu_D}{\sigma_D}>\frac{0-\mu_D}{\sigma_D}) \\
&=& P(Z>-\frac{\mu_A-\mu_B}{\sqrt{\sigma^2_A+\sigma^2_B}})=P(-Z<\frac{\mu_A-\mu_B}{\sqrt{\sigma^2_A+\sigma^2_B}})\\
&=&\Phi\left(\frac{\mu_A-\mu_B}{\sqrt{\sigma^2_A+\sigma^2_B}}\right)
\end{eqnarray*}
In the case of other distributions there may be no simple "closed" form (you'll get one for a few distributions but you can't expect in in general). For specific instances the value of the probability can be calculated via numerical convolution.
(If you have bivariate normality but not independence, you can do a similar calculation.) | Probability that randomly chosen value from one distribution is greater than randomly chosen value f | Your bootstrap simulation suggests the A's and B's are independent; I will assume so.
Note that $P(A>B)=P(A-B>0)$.
In the case where A and B are also normal, $D=A-B \sim N(\mu_A-\mu_B,\sigma^2_A+\sigm | Probability that randomly chosen value from one distribution is greater than randomly chosen value from another distribution
Your bootstrap simulation suggests the A's and B's are independent; I will assume so.
Note that $P(A>B)=P(A-B>0)$.
In the case where A and B are also normal, $D=A-B \sim N(\mu_A-\mu_B,\sigma^2_A+\sigma^2_B)$
In that case
\begin{eqnarray*}
P(D>0) &=& P(\frac{D-\mu_D}{\sigma_D}>\frac{0-\mu_D}{\sigma_D}) \\
&=& P(Z>-\frac{\mu_A-\mu_B}{\sqrt{\sigma^2_A+\sigma^2_B}})=P(-Z<\frac{\mu_A-\mu_B}{\sqrt{\sigma^2_A+\sigma^2_B}})\\
&=&\Phi\left(\frac{\mu_A-\mu_B}{\sqrt{\sigma^2_A+\sigma^2_B}}\right)
\end{eqnarray*}
In the case of other distributions there may be no simple "closed" form (you'll get one for a few distributions but you can't expect in in general). For specific instances the value of the probability can be calculated via numerical convolution.
(If you have bivariate normality but not independence, you can do a similar calculation.) | Probability that randomly chosen value from one distribution is greater than randomly chosen value f
Your bootstrap simulation suggests the A's and B's are independent; I will assume so.
Note that $P(A>B)=P(A-B>0)$.
In the case where A and B are also normal, $D=A-B \sim N(\mu_A-\mu_B,\sigma^2_A+\sigm |
38,893 | Probability that randomly chosen value from one distribution is greater than randomly chosen value from another distribution | Answer: AUC
Probability that randomly chosen value from one distribution is greater than randomly chosen value from another distribution
This an eloquent description of the what the Area Under The Curve is estimating.
Check out the Wilcoxon-Mann-Whitney U (rank sum) test if you want a hypothesis-test (as others pointed out). AUC is the standardized and interpretable U-statistic.
If you're into R look at for example pROC if you necessarily need a bootstrapped AUC. For mere AUC-calculation I use the lightweight WeightedROC-package
To use standard packages, organize your data with "labels" as 0 for sample a and 1s for sample b then use the measurements as the "score". AUC is then an estimate for $P\left(A_i<B_j\right)$ | Probability that randomly chosen value from one distribution is greater than randomly chosen value f | Answer: AUC
Probability that randomly chosen value from one distribution is greater than randomly chosen value from another distribution
This an eloquent description of the what the Area Under The | Probability that randomly chosen value from one distribution is greater than randomly chosen value from another distribution
Answer: AUC
Probability that randomly chosen value from one distribution is greater than randomly chosen value from another distribution
This an eloquent description of the what the Area Under The Curve is estimating.
Check out the Wilcoxon-Mann-Whitney U (rank sum) test if you want a hypothesis-test (as others pointed out). AUC is the standardized and interpretable U-statistic.
If you're into R look at for example pROC if you necessarily need a bootstrapped AUC. For mere AUC-calculation I use the lightweight WeightedROC-package
To use standard packages, organize your data with "labels" as 0 for sample a and 1s for sample b then use the measurements as the "score". AUC is then an estimate for $P\left(A_i<B_j\right)$ | Probability that randomly chosen value from one distribution is greater than randomly chosen value f
Answer: AUC
Probability that randomly chosen value from one distribution is greater than randomly chosen value from another distribution
This an eloquent description of the what the Area Under The |
38,894 | AR(q) model with F-test | The regression model for the AR model that you specify departs from the assumptions of the classical regression model in that the explanatory variables are not deterministic or fixed. The explanatory variables are stochastic because they are lags of the dependent variable and hence depend on the stochastic term $\epsilon_i$. I think this is the point you are referring to with random design.
To avoid confusion with the dependent variable and for simplicity, I will denote as $Z$ the whole set of explanatory variables $X_{i-1}$, $X_{i-2}$,..., $X_{i-q}$.
In the context of stochastic regressors, we may have three situations, the explanatory variables and the disturbance term $\epsilon_i$ are:
independent of each other, $E(Z_i \epsilon_{i-k}) = 0$, $\forall i,k$;
contemporaneously uncorrelated, $E(Z_i \epsilon_i) = 0$, $\forall i$;
contemporaneously correlated, $E(Z_i \epsilon_i) \neq 0$
for some $i$.
In the context of the AR model we are in the second case (lagged versions of $X$ depend on lagged values of $\epsilon$, but not on the current value at time $i$ or at future times).
Your suggestion of conditioning on $Z$ is not appropriate. To see this, the joint distribution of the dependent variable $X$ is given by the product of the conditional and the marginal distributions:
$$
f(X,Z;\vec{\beta},\sigma^2) = f(X|Z;\vec{\beta},\sigma^2) f(Z;\cdot) \,.
$$
If the marginal distribution did not depend on the parameters of the model, then we could get rid of it and work with the conditional distribution. However, since the explanatory variables follow the same AR model, the marginal distribution depends on the parameters of the model and we actually have $f(Z;\vec{\beta},\sigma^2)$. Hence, we cannot ignore it and things are not as easier as they would be in the other case.
Although the explanatory variables are not independent of the innovations
$\epsilon$, they are contemporaneously uncorrelated, i.e., at a given time $i$, $Z_{i-j}$ with $j>0$ depends on past values of $\epsilon_i$ but not on the current value $\epsilon_i$. In this case, the distribution of the test statistics is unknown in finite (small) samples. However, the classical results still apply asymptotically and the $F$-test statistic asymptotically follows the $\chi^2$ distribution with $q-p$ degrees of freedom.
Note: be careful, the degrees of freedom would be $(q-p)$, not $(q−p\,, n−q)$ that you suggest, that would be the degrees of freedom of the Snedecor's $F$-distribution to be used in finite samples when the classical assumptions hold.
Details (in addition to the reference given by @CristiánAntuña): The above is true under the classical assumptions and the requirement that $\hbox{plim } Z'Z/n = Q$ is a finite and positive definite matrix. Then, the Mann and Wald theorem, Slutsky's theorem and Cramér's theorem can be applied to show the above result.
Edit 2
Note: When using the asymptotic test statistic, be aware that it needs to be normalized before comparing it with the $\chi^2$ distribution. In particular, the standard $F$-test statistic must be multiplied by the degrees of freedom in the numerator of the $F$ distribution. To see this, note that if a random variable $Y$ has an $F$ distribution and $X_1$, $X_2$ denote $\chi^2$ distributions with $n_1$ and $n_2$ degrees of freedom respectively, then $Y$ can be written as $Y=\frac{X_1/n_1}{X_2/n_2}$, i.e., the ratio of the two $\chi^2$ divided each by their degrees of freedom. The degrees of freedom in the denominator of the $F$-test goes to infinity, making $X_2/n_2$ go to one, hence, we are left with $Y=X_1/n_1$ and hence it is $n_1\times Y$ (not $Y$) what follows the $\chi^2$ distribution.
One issue still remains to be taken into account. As the explanatory variables
are lagged versions of the same variable, they are likely to be correlated
(more than likely if $X_t$ actually follows an AR structure). This will cause larger standard errors of parameter estimates, which may in turn affect the test statistic.
Roughly, the consequences of collinearity are the same as those caused by a small sample size. There isn't enough information in the data to discern to which variable the influence of their common component should be attributed. As we have already mentioned that in this context we need a large sample size, bootstrapping the test statistic would be a useful strategy that may get to kill two birds with one stone.
Someone may think, why would you want to do this test? Why care about the $F$-test in an AR model? I don't think you want to test for example an economic theory, as it's done with econometric models. If the purpose is to choose the optimal lag order for the AR model, then the Akaike's or Bayesian information criteria might be a better alternative. Anyway, I find this an interesting question and a nice example to discuss the classical regression model and variations that relax some of the assumptions.
Edit (revised)
For illustration, I show a small simulation exercise to assess the issues discussed above. According to this small experiment, the asymptotic test statistic performs well for a sample size of 100 observations. The empirical level found in this exercise was 0.047, close to the chosen nominal level, 5% For a smaller sample size of 60 observations similar results were obtained. The R code that replicates the results of the exercise is shown below.
Generate data (1000 series of length 100) from an AR(2) model. The same data set is used in both cases below.
set.seed(123)
xdata <- matrix(nrow = 100, ncol = 1000)
n <- nrow(xdata) # sample size
niter <- ncol(xdata) # number of iterations
for (i in seq_len(niter))
xdata[,i] <- arima.sim(n = n, model = list(ar = c(0.6, -0.2)))
Compute the empirical level of the asymptotic $\chi^2$-test statistic for the null that the AR coefficients or order 3 and 4 are zero.
chisq.stats <- pvals <- rep(NA, niter)
resids <- matrix(nrow = n-4, ncol = niter)
coefs <- matrix(nrow = niter, ncol = 2)
for (i in seq_len(niter))
{
x <- xdata[,i]
# restricted model
fit1 <- lm(x[5:n] ~ x[4:(n-1)] + x[3:(n-2)])
# save estimated coefficients and residuals (extended with zeros)
# to save computatons next in the bootstrap case
coefs[i,] <- coef(fit1)[-1]
resids[,i] <- residuals(fit1)
# unrestricited model
fit2 <- lm(x[5:n] ~ x[4:(n-1)] + x[3:(n-2)] + x[2:(n-3)] + x[1:(n-4)])
# Chisq-test statistic and p-value
chisq.stats[i] <- 2 * anova(fit1, fit2)$F[2]
pvals[i] <- pchisq(chisq.stats[i], df = 2, lower.tail = FALSE)
}
sum(pvals < 0.05) / niter
#[1] 0.047 | AR(q) model with F-test | The regression model for the AR model that you specify departs from the assumptions of the classical regression model in that the explanatory variables are not deterministic or fixed. The explanatory | AR(q) model with F-test
The regression model for the AR model that you specify departs from the assumptions of the classical regression model in that the explanatory variables are not deterministic or fixed. The explanatory variables are stochastic because they are lags of the dependent variable and hence depend on the stochastic term $\epsilon_i$. I think this is the point you are referring to with random design.
To avoid confusion with the dependent variable and for simplicity, I will denote as $Z$ the whole set of explanatory variables $X_{i-1}$, $X_{i-2}$,..., $X_{i-q}$.
In the context of stochastic regressors, we may have three situations, the explanatory variables and the disturbance term $\epsilon_i$ are:
independent of each other, $E(Z_i \epsilon_{i-k}) = 0$, $\forall i,k$;
contemporaneously uncorrelated, $E(Z_i \epsilon_i) = 0$, $\forall i$;
contemporaneously correlated, $E(Z_i \epsilon_i) \neq 0$
for some $i$.
In the context of the AR model we are in the second case (lagged versions of $X$ depend on lagged values of $\epsilon$, but not on the current value at time $i$ or at future times).
Your suggestion of conditioning on $Z$ is not appropriate. To see this, the joint distribution of the dependent variable $X$ is given by the product of the conditional and the marginal distributions:
$$
f(X,Z;\vec{\beta},\sigma^2) = f(X|Z;\vec{\beta},\sigma^2) f(Z;\cdot) \,.
$$
If the marginal distribution did not depend on the parameters of the model, then we could get rid of it and work with the conditional distribution. However, since the explanatory variables follow the same AR model, the marginal distribution depends on the parameters of the model and we actually have $f(Z;\vec{\beta},\sigma^2)$. Hence, we cannot ignore it and things are not as easier as they would be in the other case.
Although the explanatory variables are not independent of the innovations
$\epsilon$, they are contemporaneously uncorrelated, i.e., at a given time $i$, $Z_{i-j}$ with $j>0$ depends on past values of $\epsilon_i$ but not on the current value $\epsilon_i$. In this case, the distribution of the test statistics is unknown in finite (small) samples. However, the classical results still apply asymptotically and the $F$-test statistic asymptotically follows the $\chi^2$ distribution with $q-p$ degrees of freedom.
Note: be careful, the degrees of freedom would be $(q-p)$, not $(q−p\,, n−q)$ that you suggest, that would be the degrees of freedom of the Snedecor's $F$-distribution to be used in finite samples when the classical assumptions hold.
Details (in addition to the reference given by @CristiánAntuña): The above is true under the classical assumptions and the requirement that $\hbox{plim } Z'Z/n = Q$ is a finite and positive definite matrix. Then, the Mann and Wald theorem, Slutsky's theorem and Cramér's theorem can be applied to show the above result.
Edit 2
Note: When using the asymptotic test statistic, be aware that it needs to be normalized before comparing it with the $\chi^2$ distribution. In particular, the standard $F$-test statistic must be multiplied by the degrees of freedom in the numerator of the $F$ distribution. To see this, note that if a random variable $Y$ has an $F$ distribution and $X_1$, $X_2$ denote $\chi^2$ distributions with $n_1$ and $n_2$ degrees of freedom respectively, then $Y$ can be written as $Y=\frac{X_1/n_1}{X_2/n_2}$, i.e., the ratio of the two $\chi^2$ divided each by their degrees of freedom. The degrees of freedom in the denominator of the $F$-test goes to infinity, making $X_2/n_2$ go to one, hence, we are left with $Y=X_1/n_1$ and hence it is $n_1\times Y$ (not $Y$) what follows the $\chi^2$ distribution.
One issue still remains to be taken into account. As the explanatory variables
are lagged versions of the same variable, they are likely to be correlated
(more than likely if $X_t$ actually follows an AR structure). This will cause larger standard errors of parameter estimates, which may in turn affect the test statistic.
Roughly, the consequences of collinearity are the same as those caused by a small sample size. There isn't enough information in the data to discern to which variable the influence of their common component should be attributed. As we have already mentioned that in this context we need a large sample size, bootstrapping the test statistic would be a useful strategy that may get to kill two birds with one stone.
Someone may think, why would you want to do this test? Why care about the $F$-test in an AR model? I don't think you want to test for example an economic theory, as it's done with econometric models. If the purpose is to choose the optimal lag order for the AR model, then the Akaike's or Bayesian information criteria might be a better alternative. Anyway, I find this an interesting question and a nice example to discuss the classical regression model and variations that relax some of the assumptions.
Edit (revised)
For illustration, I show a small simulation exercise to assess the issues discussed above. According to this small experiment, the asymptotic test statistic performs well for a sample size of 100 observations. The empirical level found in this exercise was 0.047, close to the chosen nominal level, 5% For a smaller sample size of 60 observations similar results were obtained. The R code that replicates the results of the exercise is shown below.
Generate data (1000 series of length 100) from an AR(2) model. The same data set is used in both cases below.
set.seed(123)
xdata <- matrix(nrow = 100, ncol = 1000)
n <- nrow(xdata) # sample size
niter <- ncol(xdata) # number of iterations
for (i in seq_len(niter))
xdata[,i] <- arima.sim(n = n, model = list(ar = c(0.6, -0.2)))
Compute the empirical level of the asymptotic $\chi^2$-test statistic for the null that the AR coefficients or order 3 and 4 are zero.
chisq.stats <- pvals <- rep(NA, niter)
resids <- matrix(nrow = n-4, ncol = niter)
coefs <- matrix(nrow = niter, ncol = 2)
for (i in seq_len(niter))
{
x <- xdata[,i]
# restricted model
fit1 <- lm(x[5:n] ~ x[4:(n-1)] + x[3:(n-2)])
# save estimated coefficients and residuals (extended with zeros)
# to save computatons next in the bootstrap case
coefs[i,] <- coef(fit1)[-1]
resids[,i] <- residuals(fit1)
# unrestricited model
fit2 <- lm(x[5:n] ~ x[4:(n-1)] + x[3:(n-2)] + x[2:(n-3)] + x[1:(n-4)])
# Chisq-test statistic and p-value
chisq.stats[i] <- 2 * anova(fit1, fit2)$F[2]
pvals[i] <- pchisq(chisq.stats[i], df = 2, lower.tail = FALSE)
}
sum(pvals < 0.05) / niter
#[1] 0.047 | AR(q) model with F-test
The regression model for the AR model that you specify departs from the assumptions of the classical regression model in that the explanatory variables are not deterministic or fixed. The explanatory |
38,895 | AR(q) model with F-test | This answer can be found on Hamilton's "Time Series Analysis", page 215 (http://www.amazon.com/Series-Analysis-James-Douglas-Hamilton/dp/0691042896)
I am sure it is asymptotically valid if you include a constant term in your model:
Since $X_{t+j}, j=1,2,...$ are not independent from $\epsilon_t$, the F test does not hold for small samples but still, its F statistic is distributed $\chi^2$ asymptotically (you can find the proof in the book, pp 215-216, but it is essentially the same as in regular OLS, again if you include a constant term).
If your model must not include a constant term, then I don't know the answer. | AR(q) model with F-test | This answer can be found on Hamilton's "Time Series Analysis", page 215 (http://www.amazon.com/Series-Analysis-James-Douglas-Hamilton/dp/0691042896)
I am sure it is asymptotically valid if you include | AR(q) model with F-test
This answer can be found on Hamilton's "Time Series Analysis", page 215 (http://www.amazon.com/Series-Analysis-James-Douglas-Hamilton/dp/0691042896)
I am sure it is asymptotically valid if you include a constant term in your model:
Since $X_{t+j}, j=1,2,...$ are not independent from $\epsilon_t$, the F test does not hold for small samples but still, its F statistic is distributed $\chi^2$ asymptotically (you can find the proof in the book, pp 215-216, but it is essentially the same as in regular OLS, again if you include a constant term).
If your model must not include a constant term, then I don't know the answer. | AR(q) model with F-test
This answer can be found on Hamilton's "Time Series Analysis", page 215 (http://www.amazon.com/Series-Analysis-James-Douglas-Hamilton/dp/0691042896)
I am sure it is asymptotically valid if you include |
38,896 | How to describe a bin in a histogram? | This is partly a question of statistics terminology and partly one of English usage. (Clearly, some points may be irrelevant or need changing for anyone interested in this question but for some language other than English.)
Let's focus first on measured data.
To be completely clear in describing your bin to me you have to tell me somehow (1) where it starts, (2) how wide it is, and (3) what happens at bin boundaries. That's a matter of statistics. Sometimes (2) or even (3) are obvious from context, e.g. (2) may be obvious by looking at the graph.
In English, "between" is best paired with "and" and "from" with "to", but a problem with both usages is that they leave ambiguous what happens at the boundaries. So, "between 2 and 3", "between 3 and 4", etc. or "from 2 to 3", "from 3 to 4", etc., raise the question of what happens if data are exactly 3.
For completeness, I will stress that units of measurement when used (kg, m, USD/year, etc.) should always be mentioned prominently at least once.
While I am focusing on English usage, I'll note that usages such as "between 2-3" and "from 2-3", although very common, are widely disapproved by usage pundits and recommended against by many style guides as poor style, but you will also encounter views that such an attitude is anywhere between conservative and reactionary. (On this issue, I line up with the conservatives.) That is, it is considered poor style to use a hyphen or dash as replacement for the second word, namely "and" or "to". The argument appears to be one of symmetry, that words that deserve to be paired should indeed be paired.
If you tell me that a bin is for values $2 \le x < 3$ or for $[2, 3)$ you have told me everything I need to know. So, if you need to refer to a particular bin, using a little mathematics can be simpler and better than ambiguous wording. Naturally for $x$ feel free to substitute a word description of the variable. Or use that word description elsewhere and use some example-based explanation as this.
Bin width is 1 and lower limits are inclusive, so (e.g.) the bin for 2-3 includes values reported as 2.0.
Things are usually and naturally simpler with discrete (e.g.) counted data. It is still best to report that bins are (e.g.) 0-3, 4-7, 8-11, etc. and never as 0-4, 4-8, 8-12, etc. (It may surprise you how common the latter practice is.)
However, much depends on your readership. Perhaps your readership are not comfortable with notation for inequalities, in which case you still have the problem of explaining what happens at bin boundaries, although only context and audience can determine how far that matters. I've found that you can't presume familiarity with use of $[, )$ notation unless you are addressing people with good mathematical backgrounds. Even statistics users forget much of what school or college mathematics they once knew if they don't use it routinely.
I wouldn't presume that all bins are labelled with their numeric limits on the histogram. If there are tens or even hundreds of bins that would usually be busy, impracticable or both. Conversely, it is difficult to imagine discussing an individual bin unless it is identifiable.
EDIT: Thanks to other contributors for reminding me of interval notation. | How to describe a bin in a histogram? | This is partly a question of statistics terminology and partly one of English usage. (Clearly, some points may be irrelevant or need changing for anyone interested in this question but for some langua | How to describe a bin in a histogram?
This is partly a question of statistics terminology and partly one of English usage. (Clearly, some points may be irrelevant or need changing for anyone interested in this question but for some language other than English.)
Let's focus first on measured data.
To be completely clear in describing your bin to me you have to tell me somehow (1) where it starts, (2) how wide it is, and (3) what happens at bin boundaries. That's a matter of statistics. Sometimes (2) or even (3) are obvious from context, e.g. (2) may be obvious by looking at the graph.
In English, "between" is best paired with "and" and "from" with "to", but a problem with both usages is that they leave ambiguous what happens at the boundaries. So, "between 2 and 3", "between 3 and 4", etc. or "from 2 to 3", "from 3 to 4", etc., raise the question of what happens if data are exactly 3.
For completeness, I will stress that units of measurement when used (kg, m, USD/year, etc.) should always be mentioned prominently at least once.
While I am focusing on English usage, I'll note that usages such as "between 2-3" and "from 2-3", although very common, are widely disapproved by usage pundits and recommended against by many style guides as poor style, but you will also encounter views that such an attitude is anywhere between conservative and reactionary. (On this issue, I line up with the conservatives.) That is, it is considered poor style to use a hyphen or dash as replacement for the second word, namely "and" or "to". The argument appears to be one of symmetry, that words that deserve to be paired should indeed be paired.
If you tell me that a bin is for values $2 \le x < 3$ or for $[2, 3)$ you have told me everything I need to know. So, if you need to refer to a particular bin, using a little mathematics can be simpler and better than ambiguous wording. Naturally for $x$ feel free to substitute a word description of the variable. Or use that word description elsewhere and use some example-based explanation as this.
Bin width is 1 and lower limits are inclusive, so (e.g.) the bin for 2-3 includes values reported as 2.0.
Things are usually and naturally simpler with discrete (e.g.) counted data. It is still best to report that bins are (e.g.) 0-3, 4-7, 8-11, etc. and never as 0-4, 4-8, 8-12, etc. (It may surprise you how common the latter practice is.)
However, much depends on your readership. Perhaps your readership are not comfortable with notation for inequalities, in which case you still have the problem of explaining what happens at bin boundaries, although only context and audience can determine how far that matters. I've found that you can't presume familiarity with use of $[, )$ notation unless you are addressing people with good mathematical backgrounds. Even statistics users forget much of what school or college mathematics they once knew if they don't use it routinely.
I wouldn't presume that all bins are labelled with their numeric limits on the histogram. If there are tens or even hundreds of bins that would usually be busy, impracticable or both. Conversely, it is difficult to imagine discussing an individual bin unless it is identifiable.
EDIT: Thanks to other contributors for reminding me of interval notation. | How to describe a bin in a histogram?
This is partly a question of statistics terminology and partly one of English usage. (Clearly, some points may be irrelevant or need changing for anyone interested in this question but for some langua |
38,897 | How to describe a bin in a histogram? | I agree with Nick's post - it's important advice for describing what a bin contains.
However, for this answer, I'll assume we're in a context where the content of the bins was already clear.
if I was simply referring to a particular bin**, I'd most likely refer to a bin by its ordinal position (first bin, second bin, ...). If the end to start counting at were not specified (like in "third bin from the right"), such counting would presumably follow the cultural convention of counting from the left (at least it seems to be conventional among people who write left-to-right).
** and there were not a lot of bins (likely no more than say ten bins).
So for example, I might say something like "the third bin has many more observations than the usual uniform model would predict".
If there were many bins, I might either refer to it by one of its limits ("the bin starting from 25") or by a roundish number somewhere near its middle ("the bin containing 40"), or by some obvious feature ("the bin immediately to the right of the mode").
If there's any possibility of ambiguity, though, it's best to fall back to the complete description (e.g. "the bin on the interval $[25,27)$"). | How to describe a bin in a histogram? | I agree with Nick's post - it's important advice for describing what a bin contains.
However, for this answer, I'll assume we're in a context where the content of the bins was already clear.
if I was | How to describe a bin in a histogram?
I agree with Nick's post - it's important advice for describing what a bin contains.
However, for this answer, I'll assume we're in a context where the content of the bins was already clear.
if I was simply referring to a particular bin**, I'd most likely refer to a bin by its ordinal position (first bin, second bin, ...). If the end to start counting at were not specified (like in "third bin from the right"), such counting would presumably follow the cultural convention of counting from the left (at least it seems to be conventional among people who write left-to-right).
** and there were not a lot of bins (likely no more than say ten bins).
So for example, I might say something like "the third bin has many more observations than the usual uniform model would predict".
If there were many bins, I might either refer to it by one of its limits ("the bin starting from 25") or by a roundish number somewhere near its middle ("the bin containing 40"), or by some obvious feature ("the bin immediately to the right of the mode").
If there's any possibility of ambiguity, though, it's best to fall back to the complete description (e.g. "the bin on the interval $[25,27)$"). | How to describe a bin in a histogram?
I agree with Nick's post - it's important advice for describing what a bin contains.
However, for this answer, I'll assume we're in a context where the content of the bins was already clear.
if I was |
38,898 | Correcting biased survey results | As Tim pointed out, you should use survey weighting.
In your case, more specifically, if all the auxiliary variables (your demographic variables) you want to use to make your sample match your population are qualitative variables you will use:
Post-stratification: If you have the full joint distribution of these variables on the population
Raking: If you only have the marginal distributions of these variables on the population
More generally, if you have qualitative and quantitative auxiliary variables, you can use a Calibration approach.
Tim also pointed out the survey package in R. There you can find three functions that implements these methods:
Post-stratification: postStratify
Raking: rake
Calibration: calibrate
There is the sampling package in R containing the function for weighting.
Calibration: calib
It is important to note though that these weighting methods were originally developed under a probability sampling framework, which does not appear to be your case (you referred to your sample as "non-random"). These methods might mitigate some potential bias in your estimates, as long as the auxiliary variables used in the weighting adjustments are related to your outcome variables and to the selection mechanism of your sample. See this paper by Little and Vartivarian for a similar discussion in survey nonresponse. | Correcting biased survey results | As Tim pointed out, you should use survey weighting.
In your case, more specifically, if all the auxiliary variables (your demographic variables) you want to use to make your sample match your popula | Correcting biased survey results
As Tim pointed out, you should use survey weighting.
In your case, more specifically, if all the auxiliary variables (your demographic variables) you want to use to make your sample match your population are qualitative variables you will use:
Post-stratification: If you have the full joint distribution of these variables on the population
Raking: If you only have the marginal distributions of these variables on the population
More generally, if you have qualitative and quantitative auxiliary variables, you can use a Calibration approach.
Tim also pointed out the survey package in R. There you can find three functions that implements these methods:
Post-stratification: postStratify
Raking: rake
Calibration: calibrate
There is the sampling package in R containing the function for weighting.
Calibration: calib
It is important to note though that these weighting methods were originally developed under a probability sampling framework, which does not appear to be your case (you referred to your sample as "non-random"). These methods might mitigate some potential bias in your estimates, as long as the auxiliary variables used in the weighting adjustments are related to your outcome variables and to the selection mechanism of your sample. See this paper by Little and Vartivarian for a similar discussion in survey nonresponse. | Correcting biased survey results
As Tim pointed out, you should use survey weighting.
In your case, more specifically, if all the auxiliary variables (your demographic variables) you want to use to make your sample match your popula |
38,899 | Correcting biased survey results | The common thing to do in this kind of situation is to use survey weighting (or an intro here). A clear definition could be found on Wikipedia:
data should usually be weighted if the sample design does not give
each individual an equal chance of being selected. For instance, when
households have equal selection probabilities but one person is
interviewed from within each household, this gives people from large
households a smaller chance of being interviewed. This can be
accounted for using survey weights. Similarly, households with more
than one telephone line have a greater chance of being selected in a
random digit dialing sample, and weights can adjust for this.
There is an survey package for R that enables you to use weighting (check also JSS article describing it). Generally, you can use weights with different functions in R (e.g. lm has weights argument). | Correcting biased survey results | The common thing to do in this kind of situation is to use survey weighting (or an intro here). A clear definition could be found on Wikipedia:
data should usually be weighted if the sample design do | Correcting biased survey results
The common thing to do in this kind of situation is to use survey weighting (or an intro here). A clear definition could be found on Wikipedia:
data should usually be weighted if the sample design does not give
each individual an equal chance of being selected. For instance, when
households have equal selection probabilities but one person is
interviewed from within each household, this gives people from large
households a smaller chance of being interviewed. This can be
accounted for using survey weights. Similarly, households with more
than one telephone line have a greater chance of being selected in a
random digit dialing sample, and weights can adjust for this.
There is an survey package for R that enables you to use weighting (check also JSS article describing it). Generally, you can use weights with different functions in R (e.g. lm has weights argument). | Correcting biased survey results
The common thing to do in this kind of situation is to use survey weighting (or an intro here). A clear definition could be found on Wikipedia:
data should usually be weighted if the sample design do |
38,900 | Correcting biased survey results | I follow both Raphael and Tim in their suggestions -- especially about the use of the R package survey. However, as Raphael suggested, these weighting techniques were developed for probability samples and it might not be your case.
If you are familiar to multilevel modeling and have quality auxiliary data to estimate the weights you may use the R package lme4 (which is flexible and friendly-user) to implement Andrew Gelman's suggestions in this and this articles.
I have not applied this to my own work but Gelman's results are impressive. I think these papers are, at least, food for thought. | Correcting biased survey results | I follow both Raphael and Tim in their suggestions -- especially about the use of the R package survey. However, as Raphael suggested, these weighting techniques were developed for probability samples | Correcting biased survey results
I follow both Raphael and Tim in their suggestions -- especially about the use of the R package survey. However, as Raphael suggested, these weighting techniques were developed for probability samples and it might not be your case.
If you are familiar to multilevel modeling and have quality auxiliary data to estimate the weights you may use the R package lme4 (which is flexible and friendly-user) to implement Andrew Gelman's suggestions in this and this articles.
I have not applied this to my own work but Gelman's results are impressive. I think these papers are, at least, food for thought. | Correcting biased survey results
I follow both Raphael and Tim in their suggestions -- especially about the use of the R package survey. However, as Raphael suggested, these weighting techniques were developed for probability samples |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.