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 |
|---|---|---|---|---|---|---|
34,401 | Is there a way to force a relationship between coefficients in logistic regression? | The answer above is correct. For reference, here's some elaborated working R code to compute it. I have take the liberty of adding an intercept, because you probably do want one of those.
## make some data
set.seed(1234)
N <- 2000
x1 <- rnorm(N)
x2 <- rnorm(N)
## create linear predictor
lpred <- 0.5 + 0.5 * x1 + 0.25 * x2
## apply inverse link function
ey <- 1/(1 + exp(-lpred))
## sample some dependent variable
y <- rbinom(N, prob=ey, size=rep(1,N))
dat <- matrix(c(x1, x2, y), nrow=N, ncol=3)
colnames(dat) <- c('x1', 'x2', 'y')
Now construct a log likelihood function to maximise, here using dbinom because it's there, and summing the results
## the log likelihood function
log.like <- function(beta, dat){
lpred <- beta[1] + dat[,'x1'] * beta[2] + dat[,'x2'] * beta[2]**2
ey <- 1/(1 + exp(-lpred))
sum(dbinom(dat[,'y'], prob=ey, size=rep(1,nrow(dat)), log=TRUE))
}
and fit the model by maximum likelihood. I haven't bothered to offer a gradient or choose an optimisation method, but you might want to do both.
## fit
res <- optim(par=c(1,1), ## starting values
fn=log.like,
control=list(fnscale=-1), ## maximise not minimise
hessian=TRUE, ## for SEs
dat=dat)
Now have a look at the results. The ML parameter estimates and asymptotic SEs are:
## results
data.frame(coef=res$par,
SE=sqrt(diag(solve(-res$hessian))))
which should be
## coef SE
## 1 0.4731680 0.04828779
## 2 0.5799311 0.03363505
or there's a bug (which is always possible).
The usual caveats about Hessian-derived standard errors apply. | Is there a way to force a relationship between coefficients in logistic regression? | The answer above is correct. For reference, here's some elaborated working R code to compute it. I have take the liberty of adding an intercept, because you probably do want one of those.
## make | Is there a way to force a relationship between coefficients in logistic regression?
The answer above is correct. For reference, here's some elaborated working R code to compute it. I have take the liberty of adding an intercept, because you probably do want one of those.
## make some data
set.seed(1234)
N <- 2000
x1 <- rnorm(N)
x2 <- rnorm(N)
## create linear predictor
lpred <- 0.5 + 0.5 * x1 + 0.25 * x2
## apply inverse link function
ey <- 1/(1 + exp(-lpred))
## sample some dependent variable
y <- rbinom(N, prob=ey, size=rep(1,N))
dat <- matrix(c(x1, x2, y), nrow=N, ncol=3)
colnames(dat) <- c('x1', 'x2', 'y')
Now construct a log likelihood function to maximise, here using dbinom because it's there, and summing the results
## the log likelihood function
log.like <- function(beta, dat){
lpred <- beta[1] + dat[,'x1'] * beta[2] + dat[,'x2'] * beta[2]**2
ey <- 1/(1 + exp(-lpred))
sum(dbinom(dat[,'y'], prob=ey, size=rep(1,nrow(dat)), log=TRUE))
}
and fit the model by maximum likelihood. I haven't bothered to offer a gradient or choose an optimisation method, but you might want to do both.
## fit
res <- optim(par=c(1,1), ## starting values
fn=log.like,
control=list(fnscale=-1), ## maximise not minimise
hessian=TRUE, ## for SEs
dat=dat)
Now have a look at the results. The ML parameter estimates and asymptotic SEs are:
## results
data.frame(coef=res$par,
SE=sqrt(diag(solve(-res$hessian))))
which should be
## coef SE
## 1 0.4731680 0.04828779
## 2 0.5799311 0.03363505
or there's a bug (which is always possible).
The usual caveats about Hessian-derived standard errors apply. | Is there a way to force a relationship between coefficients in logistic regression?
The answer above is correct. For reference, here's some elaborated working R code to compute it. I have take the liberty of adding an intercept, because you probably do want one of those.
## make |
34,402 | Is MLE with regularization a bayesian method? | It means that the analysis has a Bayesian interpretation, but that doesn't mean that it might not also have a frequentist interpretation as well. The MAP estimate might be viewed as being a partialy Bayesian approach, with a more complete Bayesian approach being to consider the posterior distribution over the parameters. It is still a Bayesian approach though, as the definition of probability would be a "degree of plausibility", rather than a long run frequency. | Is MLE with regularization a bayesian method? | It means that the analysis has a Bayesian interpretation, but that doesn't mean that it might not also have a frequentist interpretation as well. The MAP estimate might be viewed as being a partialy | Is MLE with regularization a bayesian method?
It means that the analysis has a Bayesian interpretation, but that doesn't mean that it might not also have a frequentist interpretation as well. The MAP estimate might be viewed as being a partialy Bayesian approach, with a more complete Bayesian approach being to consider the posterior distribution over the parameters. It is still a Bayesian approach though, as the definition of probability would be a "degree of plausibility", rather than a long run frequency. | Is MLE with regularization a bayesian method?
It means that the analysis has a Bayesian interpretation, but that doesn't mean that it might not also have a frequentist interpretation as well. The MAP estimate might be viewed as being a partialy |
34,403 | Is MLE with regularization a bayesian method? | If you use the L2 norm, i.e., quadratic penalty on the log likelihood function, penalization is very similar to a Bayesian procedure with a Gaussian prior with mean zero for the non-intercept regression coefficients. But unlike the full Bayesian procedure that factors in the uncertainty about the the amount of penalization (analogous to treating the variance of random effects as if it were a known constant), the penalized maximum likelihood procedure pretends that the optimum penalty was pre-specified and is not an unknown parameter. So it results in confidence limits that are a bit too narrow. | Is MLE with regularization a bayesian method? | If you use the L2 norm, i.e., quadratic penalty on the log likelihood function, penalization is very similar to a Bayesian procedure with a Gaussian prior with mean zero for the non-intercept regressi | Is MLE with regularization a bayesian method?
If you use the L2 norm, i.e., quadratic penalty on the log likelihood function, penalization is very similar to a Bayesian procedure with a Gaussian prior with mean zero for the non-intercept regression coefficients. But unlike the full Bayesian procedure that factors in the uncertainty about the the amount of penalization (analogous to treating the variance of random effects as if it were a known constant), the penalized maximum likelihood procedure pretends that the optimum penalty was pre-specified and is not an unknown parameter. So it results in confidence limits that are a bit too narrow. | Is MLE with regularization a bayesian method?
If you use the L2 norm, i.e., quadratic penalty on the log likelihood function, penalization is very similar to a Bayesian procedure with a Gaussian prior with mean zero for the non-intercept regressi |
34,404 | Is every correlation matrix positive semi-definite? | A correlation matrix is really the covariance matrix of a bunch of variables which have been rescaled to have variance one.
But every population covariance matrix is positive semi-definite, and if we rule out weird cases (such as with missing data, or "numerical fuzz" turning a small eigenvalue to a negative one), so is every sample covariance matrix.
So if a matrix is supposed to be a correlation matrix, it should be positive semi-definite.
Note that the semi-definite is important here. In the bivariate case, take your two variables to be perfectly positively correlated and then the correlation matrix is $\pmatrix{1 & 1 \\ 1& 1}$ which has eigenvalues of $2$ and $0$: the zero eigenvalue means it is not positive definite. | Is every correlation matrix positive semi-definite? | A correlation matrix is really the covariance matrix of a bunch of variables which have been rescaled to have variance one.
But every population covariance matrix is positive semi-definite, and if we | Is every correlation matrix positive semi-definite?
A correlation matrix is really the covariance matrix of a bunch of variables which have been rescaled to have variance one.
But every population covariance matrix is positive semi-definite, and if we rule out weird cases (such as with missing data, or "numerical fuzz" turning a small eigenvalue to a negative one), so is every sample covariance matrix.
So if a matrix is supposed to be a correlation matrix, it should be positive semi-definite.
Note that the semi-definite is important here. In the bivariate case, take your two variables to be perfectly positively correlated and then the correlation matrix is $\pmatrix{1 & 1 \\ 1& 1}$ which has eigenvalues of $2$ and $0$: the zero eigenvalue means it is not positive definite. | Is every correlation matrix positive semi-definite?
A correlation matrix is really the covariance matrix of a bunch of variables which have been rescaled to have variance one.
But every population covariance matrix is positive semi-definite, and if we |
34,405 | Is every correlation matrix positive semi-definite? | Negative eigenvalues would imply that by the diagonalizing transformation the random vector would have negative variance in some components. Negative variances do never exist. | Is every correlation matrix positive semi-definite? | Negative eigenvalues would imply that by the diagonalizing transformation the random vector would have negative variance in some components. Negative variances do never exist. | Is every correlation matrix positive semi-definite?
Negative eigenvalues would imply that by the diagonalizing transformation the random vector would have negative variance in some components. Negative variances do never exist. | Is every correlation matrix positive semi-definite?
Negative eigenvalues would imply that by the diagonalizing transformation the random vector would have negative variance in some components. Negative variances do never exist. |
34,406 | Is every correlation matrix positive semi-definite? | A correlation matrix is positive semi-definite, period. Numerics, however, might refuse to acknowledge that mathematical fact depending on how you arrive at the numeric representation of the correlation matrix.
The solution is to choose a representation of your matrix that cannot fail to be positive semi-definite by representing the matrix in a suitable decomposed form. I am not up to scratch, but there are things like LUD decompositions or square root forms that essentially are unable to represent anything but truly positive semi-definite matrices and which you can usually update incrementally similarly to how you would update the full matrix, possibly even easier. | Is every correlation matrix positive semi-definite? | A correlation matrix is positive semi-definite, period. Numerics, however, might refuse to acknowledge that mathematical fact depending on how you arrive at the numeric representation of the correlat | Is every correlation matrix positive semi-definite?
A correlation matrix is positive semi-definite, period. Numerics, however, might refuse to acknowledge that mathematical fact depending on how you arrive at the numeric representation of the correlation matrix.
The solution is to choose a representation of your matrix that cannot fail to be positive semi-definite by representing the matrix in a suitable decomposed form. I am not up to scratch, but there are things like LUD decompositions or square root forms that essentially are unable to represent anything but truly positive semi-definite matrices and which you can usually update incrementally similarly to how you would update the full matrix, possibly even easier. | Is every correlation matrix positive semi-definite?
A correlation matrix is positive semi-definite, period. Numerics, however, might refuse to acknowledge that mathematical fact depending on how you arrive at the numeric representation of the correlat |
34,407 | $E(\frac{1}{1+x^2})$ under a Gaussian | Let $f_\sigma(x) = \frac{1}{\sqrt{2\pi}\sigma}\exp\left(-\frac{x^2}{2\sigma^2}\right)$ be the Normal$(0,\sigma)$ PDF and $g(x) = \frac{1}{\pi}\left(1+x^2\right)^{-1}$ be the PDF of a Student t distribution with one d.f. Because the PDF of a Normal$(\mu,\sigma)$ variable $X$ is $f_\sigma(x-\mu) = f_\sigma(\mu-x)$ (by symmetry), the expectation equals
$$\mathbb{E}_{\sigma,\mu}\left(\frac{1}{1+X^2}\right) = \mathbb{E}_{\sigma,\mu}\left(\pi g(X)\right) = \int_\mathbb{R} f_\sigma\left((\mu-x)^2\right) \pi g(x)dx.$$
This is the defining formula for the convolution $(f\star \pi g)(\mu)$. The most basic result of Fourier analysis is that the Fourier transform of a convolution is the product of Fourier transforms. Moreover, characteristic functions (c.f.) are (up to suitable multiples) Fourier transforms of PDFs. The c.f. of a Normal$(0,\sigma)$ distribution is
$$\widehat{f}_\sigma(t) = \exp(-t^2\sigma^2/2)$$
and the c.f. of this Student t distribution is
$$\widehat{g}(t) = \exp(-|t|).$$
(Both can be obtained by elementary methods.) The value of the inverse Fourier transform of their product at $\mu$ is, by definition,
$$\frac{1}{2\pi}\int_\mathbb{R} \widehat{f}_\sigma(t)\pi\widehat{g}(t) \exp(-i t \mu) dt =\frac{1}{2}\int_\mathbb{R} \exp(-t^2\sigma^2/2-|t|-i t \mu) dt.$$
Its calculation is elementary: carry it out separately over the intervals $(-\infty,0]$ and $[0,\infty)$ to simplify $|t|$ to $-t$ and $t$, respectively, and complete the square each time. Integrals akin to the Normal CDF are obtained--but with complex arguments. One way to write the solution is
$$\mathbb{E}_{\sigma,\mu}\left(\frac{1}{1+X^2}\right) = \frac{\sqrt{\frac{\pi }{2}} e^{-\frac{(\mu +i)^2}{2 \sigma ^2}} \left(e^{\frac{2 i \mu }{\sigma ^2}} \text{erfc}\left(\frac{1+i \mu }{\sqrt{2} \sigma }\right)-\text{erf}\left(\frac{-1+i\mu}{\sqrt{2} \sigma }\right)+1\right)}{2 \sigma }.$$
Here, $\text{erfc}(z) = 1 - \text{erf}(z)$ is the complementary error function where
$$\text{erf}(z) = \frac{2}{\sqrt{\pi}}\int_0^z \exp(-t^2)dt.$$
A special case is $\mu=0, \sigma=1$ for which this expression reduces to $$\mathbb{E}_{1, 0}\left(\frac{1}{1+X^2}\right) = \sqrt{\frac{e\pi}{2}}\text{erfc}\left(\frac{1}{\sqrt{2}}\right)=0.65567954241879847154\ldots.$$
Here is contour plot of $\mathbb{E}_{\sigma,\mu}$ (on a logarithmic axis for $\sigma$). | $E(\frac{1}{1+x^2})$ under a Gaussian | Let $f_\sigma(x) = \frac{1}{\sqrt{2\pi}\sigma}\exp\left(-\frac{x^2}{2\sigma^2}\right)$ be the Normal$(0,\sigma)$ PDF and $g(x) = \frac{1}{\pi}\left(1+x^2\right)^{-1}$ be the PDF of a Student t distrib | $E(\frac{1}{1+x^2})$ under a Gaussian
Let $f_\sigma(x) = \frac{1}{\sqrt{2\pi}\sigma}\exp\left(-\frac{x^2}{2\sigma^2}\right)$ be the Normal$(0,\sigma)$ PDF and $g(x) = \frac{1}{\pi}\left(1+x^2\right)^{-1}$ be the PDF of a Student t distribution with one d.f. Because the PDF of a Normal$(\mu,\sigma)$ variable $X$ is $f_\sigma(x-\mu) = f_\sigma(\mu-x)$ (by symmetry), the expectation equals
$$\mathbb{E}_{\sigma,\mu}\left(\frac{1}{1+X^2}\right) = \mathbb{E}_{\sigma,\mu}\left(\pi g(X)\right) = \int_\mathbb{R} f_\sigma\left((\mu-x)^2\right) \pi g(x)dx.$$
This is the defining formula for the convolution $(f\star \pi g)(\mu)$. The most basic result of Fourier analysis is that the Fourier transform of a convolution is the product of Fourier transforms. Moreover, characteristic functions (c.f.) are (up to suitable multiples) Fourier transforms of PDFs. The c.f. of a Normal$(0,\sigma)$ distribution is
$$\widehat{f}_\sigma(t) = \exp(-t^2\sigma^2/2)$$
and the c.f. of this Student t distribution is
$$\widehat{g}(t) = \exp(-|t|).$$
(Both can be obtained by elementary methods.) The value of the inverse Fourier transform of their product at $\mu$ is, by definition,
$$\frac{1}{2\pi}\int_\mathbb{R} \widehat{f}_\sigma(t)\pi\widehat{g}(t) \exp(-i t \mu) dt =\frac{1}{2}\int_\mathbb{R} \exp(-t^2\sigma^2/2-|t|-i t \mu) dt.$$
Its calculation is elementary: carry it out separately over the intervals $(-\infty,0]$ and $[0,\infty)$ to simplify $|t|$ to $-t$ and $t$, respectively, and complete the square each time. Integrals akin to the Normal CDF are obtained--but with complex arguments. One way to write the solution is
$$\mathbb{E}_{\sigma,\mu}\left(\frac{1}{1+X^2}\right) = \frac{\sqrt{\frac{\pi }{2}} e^{-\frac{(\mu +i)^2}{2 \sigma ^2}} \left(e^{\frac{2 i \mu }{\sigma ^2}} \text{erfc}\left(\frac{1+i \mu }{\sqrt{2} \sigma }\right)-\text{erf}\left(\frac{-1+i\mu}{\sqrt{2} \sigma }\right)+1\right)}{2 \sigma }.$$
Here, $\text{erfc}(z) = 1 - \text{erf}(z)$ is the complementary error function where
$$\text{erf}(z) = \frac{2}{\sqrt{\pi}}\int_0^z \exp(-t^2)dt.$$
A special case is $\mu=0, \sigma=1$ for which this expression reduces to $$\mathbb{E}_{1, 0}\left(\frac{1}{1+X^2}\right) = \sqrt{\frac{e\pi}{2}}\text{erfc}\left(\frac{1}{\sqrt{2}}\right)=0.65567954241879847154\ldots.$$
Here is contour plot of $\mathbb{E}_{\sigma,\mu}$ (on a logarithmic axis for $\sigma$). | $E(\frac{1}{1+x^2})$ under a Gaussian
Let $f_\sigma(x) = \frac{1}{\sqrt{2\pi}\sigma}\exp\left(-\frac{x^2}{2\sigma^2}\right)$ be the Normal$(0,\sigma)$ PDF and $g(x) = \frac{1}{\pi}\left(1+x^2\right)^{-1}$ be the PDF of a Student t distrib |
34,408 | $E(\frac{1}{1+x^2})$ under a Gaussian | This is an idea how to solve it which uses the identity
$$\frac{1}{S}=\int_0^\infty \exp(-tS)dt$$
which was proposed by Did here. You could use
\begin{align}E\left(\frac{1}{x^2+1}\right) &= \frac{1}{\sqrt{2\pi}}\int_0^\infty \int_{-\infty}^{\infty}\exp\left(-t(x^2+1)\right)\exp\left(-\frac{x^2}{2}\right)\mathrm dx \mathrm dt\\
&=\int_0^\infty \exp\left(-t\right)\left(1+2t\right)^{-\frac{1}{2}} \mathrm dt\\
&=\sqrt{\frac{e\pi}{2}}\left[\mbox{erf}\left(\sqrt{t+\frac{1}{2}}\right)\right]_0^\infty\\
&=\sqrt{\frac{e\pi}{2}}\left(1-\mbox{erf}\left(\sqrt{\frac{1}{2}}\right)\right)\end{align} | $E(\frac{1}{1+x^2})$ under a Gaussian | This is an idea how to solve it which uses the identity
$$\frac{1}{S}=\int_0^\infty \exp(-tS)dt$$
which was proposed by Did here. You could use
\begin{align}E\left(\frac{1}{x^2+1}\right) &= \frac{1}{ | $E(\frac{1}{1+x^2})$ under a Gaussian
This is an idea how to solve it which uses the identity
$$\frac{1}{S}=\int_0^\infty \exp(-tS)dt$$
which was proposed by Did here. You could use
\begin{align}E\left(\frac{1}{x^2+1}\right) &= \frac{1}{\sqrt{2\pi}}\int_0^\infty \int_{-\infty}^{\infty}\exp\left(-t(x^2+1)\right)\exp\left(-\frac{x^2}{2}\right)\mathrm dx \mathrm dt\\
&=\int_0^\infty \exp\left(-t\right)\left(1+2t\right)^{-\frac{1}{2}} \mathrm dt\\
&=\sqrt{\frac{e\pi}{2}}\left[\mbox{erf}\left(\sqrt{t+\frac{1}{2}}\right)\right]_0^\infty\\
&=\sqrt{\frac{e\pi}{2}}\left(1-\mbox{erf}\left(\sqrt{\frac{1}{2}}\right)\right)\end{align} | $E(\frac{1}{1+x^2})$ under a Gaussian
This is an idea how to solve it which uses the identity
$$\frac{1}{S}=\int_0^\infty \exp(-tS)dt$$
which was proposed by Did here. You could use
\begin{align}E\left(\frac{1}{x^2+1}\right) &= \frac{1}{ |
34,409 | Is the sampling distribution for small samples of a normal population normal or t distributed? [closed] | 1) a set of random observations from a population with distribution $F$ are samples from that distribution. So even single values sampled from a normal population are normally distributed. (Well, speaking slightly more strictly, the random variable that represents the single draw is the thing that's normally distributed.)
2) If the observations are independent draws from a normal distribution, the sample means are normal. (If they're dependent, it matters what the dependence structure is.)
3) Here's something that will be t-distributed, if the data are i.i.d draws from a normal population: t-statistics. (We get something other than normal because there's a numerator and a denominator)
I understand that small samples tend to be t distributed
This is a mistaken understanding. On what is this understanding based?
[This seems to be such a common misunderstanding that I can only assume it's in some popular or once-popular book somewhere. If you do find such a book, post details in your question or in a comment, because I'd love to know where it comes from.] | Is the sampling distribution for small samples of a normal population normal or t distributed? [clos | 1) a set of random observations from a population with distribution $F$ are samples from that distribution. So even single values sampled from a normal population are normally distributed. (Well, spea | Is the sampling distribution for small samples of a normal population normal or t distributed? [closed]
1) a set of random observations from a population with distribution $F$ are samples from that distribution. So even single values sampled from a normal population are normally distributed. (Well, speaking slightly more strictly, the random variable that represents the single draw is the thing that's normally distributed.)
2) If the observations are independent draws from a normal distribution, the sample means are normal. (If they're dependent, it matters what the dependence structure is.)
3) Here's something that will be t-distributed, if the data are i.i.d draws from a normal population: t-statistics. (We get something other than normal because there's a numerator and a denominator)
I understand that small samples tend to be t distributed
This is a mistaken understanding. On what is this understanding based?
[This seems to be such a common misunderstanding that I can only assume it's in some popular or once-popular book somewhere. If you do find such a book, post details in your question or in a comment, because I'd love to know where it comes from.] | Is the sampling distribution for small samples of a normal population normal or t distributed? [clos
1) a set of random observations from a population with distribution $F$ are samples from that distribution. So even single values sampled from a normal population are normally distributed. (Well, spea |
34,410 | Is the sampling distribution for small samples of a normal population normal or t distributed? [closed] | If you intend to take a value from a normally distributed population, that value has the same probability density function as that of the population. So any draw $x_{i}$ from a population $X \sim N(\mu, \sigma ^{2})$ will be drawn from the same population distribution $N(\mu, \sigma ^{2})$
So that means that small samples are still distributed Normal, right? Well, sure, in that if each draw is from a Normal distribution, it will itself have a Normal distribution (before we actually take the draw, at least).
It seems like you're asking about $\bar{x}$, since we're talking about samples, t-distributions, and the like. $\bar{x}$ isn't is still Normal for small samples, even though because each observation $x_i$ has a Normal distribution. Why? Because it's just a sum of other Normal random variables!
Glen_b made a nice catch where I conflated $\bar{x}$ and the $t$-statistic. It's important to note that while $\bar{x}$ is still Normal for any sample size (if the population it's sampled from is Normal), $t$ statistics constructed from a Normal sample aren't Normal for small sample sizes. Why?
Well, we have two distinct cases here. It is possible that the distribution is already known, in which case we know the true value of $\sigma^{2}$. It is also possible that $\sigma^{2}$ is not known, in which case we will have to estimate it.
1: We know $\sigma^{2}$. This means we can use a $z$ statistic calculated directly from population parameter $\sigma^2$.
If we are certain about the true value of $\sigma^{2}$, then we can perform e.g. hypothesis testing on $\bar{x}$ using a distribution $N(\mu, \frac{\sigma ^{2}}{\sqrt{n}})$. In particular, we can standardize it, transforming it into a value $Z$, for which the distribution is $N(0, 1)$ And if we know the value of $\sigma^{2}$, then we can just use the Standard Normal distribution for our calculations. It's Normal, no matter how large or small our sample might be!
2: We don't know $\sigma^{2}$, and so we estimate it by $s^2$.
If we don't know $\sigma^{2}$, then we need to substitute the calculated value of an estimator for the true population value. Typically, that will be $s^2$, the sample variance. But the sample variance has its own distribution, too! So we aren't actually certain about its value. And if our sample size is small, then the 'variance of the sample variance' is significant enough to affect the way $\bar{x}$ is distributed. So when we standardize $\bar{x}$, it's not Normally distributed anymore, even though all of the $x_i$ that went into calculating it are distributed Normal.
For more information, read about the definition of the t-distribution, and the distribution of the sample variance. | Is the sampling distribution for small samples of a normal population normal or t distributed? [clos | If you intend to take a value from a normally distributed population, that value has the same probability density function as that of the population. So any draw $x_{i}$ from a population $X \sim N(\m | Is the sampling distribution for small samples of a normal population normal or t distributed? [closed]
If you intend to take a value from a normally distributed population, that value has the same probability density function as that of the population. So any draw $x_{i}$ from a population $X \sim N(\mu, \sigma ^{2})$ will be drawn from the same population distribution $N(\mu, \sigma ^{2})$
So that means that small samples are still distributed Normal, right? Well, sure, in that if each draw is from a Normal distribution, it will itself have a Normal distribution (before we actually take the draw, at least).
It seems like you're asking about $\bar{x}$, since we're talking about samples, t-distributions, and the like. $\bar{x}$ isn't is still Normal for small samples, even though because each observation $x_i$ has a Normal distribution. Why? Because it's just a sum of other Normal random variables!
Glen_b made a nice catch where I conflated $\bar{x}$ and the $t$-statistic. It's important to note that while $\bar{x}$ is still Normal for any sample size (if the population it's sampled from is Normal), $t$ statistics constructed from a Normal sample aren't Normal for small sample sizes. Why?
Well, we have two distinct cases here. It is possible that the distribution is already known, in which case we know the true value of $\sigma^{2}$. It is also possible that $\sigma^{2}$ is not known, in which case we will have to estimate it.
1: We know $\sigma^{2}$. This means we can use a $z$ statistic calculated directly from population parameter $\sigma^2$.
If we are certain about the true value of $\sigma^{2}$, then we can perform e.g. hypothesis testing on $\bar{x}$ using a distribution $N(\mu, \frac{\sigma ^{2}}{\sqrt{n}})$. In particular, we can standardize it, transforming it into a value $Z$, for which the distribution is $N(0, 1)$ And if we know the value of $\sigma^{2}$, then we can just use the Standard Normal distribution for our calculations. It's Normal, no matter how large or small our sample might be!
2: We don't know $\sigma^{2}$, and so we estimate it by $s^2$.
If we don't know $\sigma^{2}$, then we need to substitute the calculated value of an estimator for the true population value. Typically, that will be $s^2$, the sample variance. But the sample variance has its own distribution, too! So we aren't actually certain about its value. And if our sample size is small, then the 'variance of the sample variance' is significant enough to affect the way $\bar{x}$ is distributed. So when we standardize $\bar{x}$, it's not Normally distributed anymore, even though all of the $x_i$ that went into calculating it are distributed Normal.
For more information, read about the definition of the t-distribution, and the distribution of the sample variance. | Is the sampling distribution for small samples of a normal population normal or t distributed? [clos
If you intend to take a value from a normally distributed population, that value has the same probability density function as that of the population. So any draw $x_{i}$ from a population $X \sim N(\m |
34,411 | GLM Gaussian vs GLM Binomial vs log-link GLM Gaussian | There are three components to a glm. A probability distribution, a linear predictor, and a link function that relates the linear predictor to the expected value of the probability distribution for the response which I will denote as $Y$. First of all, notice that for both of the gaussian models the outcome is a continuous random variable.
For GLM gaussian, I assume this has the default identity link, so $E(Y)=X\beta$, then this is no different than a regular linear model with $Y \sim N(X\beta, \sigma^2)$. Notice this case assumes constant variance as the mean of $Y$ changes linearly with $X$.
For log-linked GLM gaussian, $log(E(Y))=X\beta$, so $E(Y) = e^{X\beta}$ and $Y \sim N( e^{X\beta}, \sigma^2)$. This example is perhaps the cleanest of the three you asked about that will help elucidate the three components. The link is log, the linear predictor is $X\beta$, and the probability distribution is normal. Using this model would be one way to account for a very particular function form of a non-linear relationship between your predictors $X$ and the response, though it still assumes constant variance around the mean $e^{X\beta}$.
For GLM gamma, see When to use gamma GLMs? | GLM Gaussian vs GLM Binomial vs log-link GLM Gaussian | There are three components to a glm. A probability distribution, a linear predictor, and a link function that relates the linear predictor to the expected value of the probability distribution for th | GLM Gaussian vs GLM Binomial vs log-link GLM Gaussian
There are three components to a glm. A probability distribution, a linear predictor, and a link function that relates the linear predictor to the expected value of the probability distribution for the response which I will denote as $Y$. First of all, notice that for both of the gaussian models the outcome is a continuous random variable.
For GLM gaussian, I assume this has the default identity link, so $E(Y)=X\beta$, then this is no different than a regular linear model with $Y \sim N(X\beta, \sigma^2)$. Notice this case assumes constant variance as the mean of $Y$ changes linearly with $X$.
For log-linked GLM gaussian, $log(E(Y))=X\beta$, so $E(Y) = e^{X\beta}$ and $Y \sim N( e^{X\beta}, \sigma^2)$. This example is perhaps the cleanest of the three you asked about that will help elucidate the three components. The link is log, the linear predictor is $X\beta$, and the probability distribution is normal. Using this model would be one way to account for a very particular function form of a non-linear relationship between your predictors $X$ and the response, though it still assumes constant variance around the mean $e^{X\beta}$.
For GLM gamma, see When to use gamma GLMs? | GLM Gaussian vs GLM Binomial vs log-link GLM Gaussian
There are three components to a glm. A probability distribution, a linear predictor, and a link function that relates the linear predictor to the expected value of the probability distribution for th |
34,412 | How to deal with unbalanced group sizes in mixed design analysis? | If you use type 3 for ANOVAs it is critical in R that you set the contrast to effect coding (i.e., "contr.sum").
The default contrast in R is dummy coding (or in R parlance, treatment coding) in which 0 represents the first factor level. This doesn't make too much sense when having interactions as explaind on the page I linked to.
To set effect coding, run the following:
options(contrasts=c("contr.sum","contr.poly"))
Alternatively, you can use the afex package, which has similar goals as ez, with the difference that it automatically sets the contrasts to effects coding and uses type 3 as default. | How to deal with unbalanced group sizes in mixed design analysis? | If you use type 3 for ANOVAs it is critical in R that you set the contrast to effect coding (i.e., "contr.sum").
The default contrast in R is dummy coding (or in R parlance, treatment coding) in whic | How to deal with unbalanced group sizes in mixed design analysis?
If you use type 3 for ANOVAs it is critical in R that you set the contrast to effect coding (i.e., "contr.sum").
The default contrast in R is dummy coding (or in R parlance, treatment coding) in which 0 represents the first factor level. This doesn't make too much sense when having interactions as explaind on the page I linked to.
To set effect coding, run the following:
options(contrasts=c("contr.sum","contr.poly"))
Alternatively, you can use the afex package, which has similar goals as ez, with the difference that it automatically sets the contrasts to effects coding and uses type 3 as default. | How to deal with unbalanced group sizes in mixed design analysis?
If you use type 3 for ANOVAs it is critical in R that you set the contrast to effect coding (i.e., "contr.sum").
The default contrast in R is dummy coding (or in R parlance, treatment coding) in whic |
34,413 | How to deal with unbalanced group sizes in mixed design analysis? | I'm certainly no ANOVA expert but I guess the other way to do this analysis is to switch to a regression framework and use lme4 which doesn't mind unbalanced data and will itself work out what it 'between' and what is 'within'. I believe the relevant line for an additive model would be
mod0 <- lmer(top_start ~ (1 | id) + task + org + sex, data=df)
where you could add interactions/asterisks as appropriate. | How to deal with unbalanced group sizes in mixed design analysis? | I'm certainly no ANOVA expert but I guess the other way to do this analysis is to switch to a regression framework and use lme4 which doesn't mind unbalanced data and will itself work out what it 'bet | How to deal with unbalanced group sizes in mixed design analysis?
I'm certainly no ANOVA expert but I guess the other way to do this analysis is to switch to a regression framework and use lme4 which doesn't mind unbalanced data and will itself work out what it 'between' and what is 'within'. I believe the relevant line for an additive model would be
mod0 <- lmer(top_start ~ (1 | id) + task + org + sex, data=df)
where you could add interactions/asterisks as appropriate. | How to deal with unbalanced group sizes in mixed design analysis?
I'm certainly no ANOVA expert but I guess the other way to do this analysis is to switch to a regression framework and use lme4 which doesn't mind unbalanced data and will itself work out what it 'bet |
34,414 | Understanding of GLM | You have several questions bundled together. My answer is partial and focuses on link function and transformation, which I take to be more different than they seem.
I think it's important to keep the similar but not identical ideas of transformations and link functions distinct. The introductory literature I have seen does not do an especially good job on that, probably because the authors were too smart to realise that other people could get confused. A first approximation is that the link function has a loosely similar role to transformation of the response (outcome, dependent variable), but that aside the differences are crucial.
Focus on the common and relatively simple case of trying to predict $\log Y$ rather than $Y$ with some $\beta_0 + \beta_1 X$. Here the crucial detail is that the regression in no sense knows about the transformation. Rather, it's your decision that it would be a good idea to transform first (I will call this the "before" step). But the regression doesn't know what you did before. It is oblivious of where the data come from and just sees some $Y_\text{different}$. Also the assumption about the error term distribution is still that the error term is normal. Otherwise put, in
$$\log Y = Y_\text{different} = \beta_0 + \beta_1 X + \epsilon$$
the first equality is your private knowledge and the second is what defines the regression model. Thinking that the normal assumption about errors corresponds to a lognormal distribution on your original scale is also private (and such errors would be multiplicative not additive).
Similarly, with classical regression there is often an "after" step, in which for example you reverse the transformation to get predictions of the original $Y$, and perhaps even adjust the confidence intervals to correct for side-effects of transformation, at least to a good approximation. But that is nothing to do with the regression. Indeed, this step is not compulsory, and sometimes it is a good idea to stay on a logarithmic scale and think on that scale. (In effect, using units of measurement such as pH or decibels that are logarithmic is a decision of this kind, even if such a decision would be regarded as scientific rather than statistical.)
Contrast this with generalised linear models -- in this example, using a logarithmic link -- in which "before", fitting and "after" stages are tightly linked, indeed inseparable as far as a data analyst is concerned. The link makes the transformation of the response unnecessary, but the model fitting automatically includes the equivalent of the "after" stage, thus yielding predictions on the original scale. The invertibility of the link is naturally crucial here.
All this refers only to transformations of the response. Using a generalised linear model can still mean transforming predictor variables if that is appropriate.
I've found Lane's paper to be very helpful as a fairly informal but trustworthy discussion.
Lane, P.W. 2002. Generalized linear models in soil science. European Journal of Soil Science 53: 241–251. doi: 10.1046/j.1365-2389.2002.00440.x | Understanding of GLM | You have several questions bundled together. My answer is partial and focuses on link function and transformation, which I take to be more different than they seem.
I think it's important to keep the | Understanding of GLM
You have several questions bundled together. My answer is partial and focuses on link function and transformation, which I take to be more different than they seem.
I think it's important to keep the similar but not identical ideas of transformations and link functions distinct. The introductory literature I have seen does not do an especially good job on that, probably because the authors were too smart to realise that other people could get confused. A first approximation is that the link function has a loosely similar role to transformation of the response (outcome, dependent variable), but that aside the differences are crucial.
Focus on the common and relatively simple case of trying to predict $\log Y$ rather than $Y$ with some $\beta_0 + \beta_1 X$. Here the crucial detail is that the regression in no sense knows about the transformation. Rather, it's your decision that it would be a good idea to transform first (I will call this the "before" step). But the regression doesn't know what you did before. It is oblivious of where the data come from and just sees some $Y_\text{different}$. Also the assumption about the error term distribution is still that the error term is normal. Otherwise put, in
$$\log Y = Y_\text{different} = \beta_0 + \beta_1 X + \epsilon$$
the first equality is your private knowledge and the second is what defines the regression model. Thinking that the normal assumption about errors corresponds to a lognormal distribution on your original scale is also private (and such errors would be multiplicative not additive).
Similarly, with classical regression there is often an "after" step, in which for example you reverse the transformation to get predictions of the original $Y$, and perhaps even adjust the confidence intervals to correct for side-effects of transformation, at least to a good approximation. But that is nothing to do with the regression. Indeed, this step is not compulsory, and sometimes it is a good idea to stay on a logarithmic scale and think on that scale. (In effect, using units of measurement such as pH or decibels that are logarithmic is a decision of this kind, even if such a decision would be regarded as scientific rather than statistical.)
Contrast this with generalised linear models -- in this example, using a logarithmic link -- in which "before", fitting and "after" stages are tightly linked, indeed inseparable as far as a data analyst is concerned. The link makes the transformation of the response unnecessary, but the model fitting automatically includes the equivalent of the "after" stage, thus yielding predictions on the original scale. The invertibility of the link is naturally crucial here.
All this refers only to transformations of the response. Using a generalised linear model can still mean transforming predictor variables if that is appropriate.
I've found Lane's paper to be very helpful as a fairly informal but trustworthy discussion.
Lane, P.W. 2002. Generalized linear models in soil science. European Journal of Soil Science 53: 241–251. doi: 10.1046/j.1365-2389.2002.00440.x | Understanding of GLM
You have several questions bundled together. My answer is partial and focuses on link function and transformation, which I take to be more different than they seem.
I think it's important to keep the |
34,415 | Simulation of Fisher's exact test is underestimating power | Fisher's Exact Test is conservative (i.e. the false positive rate for the nominal 0.05 test is actually less than 0.05 when the null hypothesis is true). What you're finding there is no coincidence. To say that a test is "exact" does not mean that it is of the right size, but that the interpretation of the p-value in small samples is correct.
Here's a reference from university lecture notes on biostatistics
Applied Biostatistics by Scott S. Emerson, Professor of Biostatistics
University of Washington | Simulation of Fisher's exact test is underestimating power | Fisher's Exact Test is conservative (i.e. the false positive rate for the nominal 0.05 test is actually less than 0.05 when the null hypothesis is true). What you're finding there is no coincidence. T | Simulation of Fisher's exact test is underestimating power
Fisher's Exact Test is conservative (i.e. the false positive rate for the nominal 0.05 test is actually less than 0.05 when the null hypothesis is true). What you're finding there is no coincidence. To say that a test is "exact" does not mean that it is of the right size, but that the interpretation of the p-value in small samples is correct.
Here's a reference from university lecture notes on biostatistics
Applied Biostatistics by Scott S. Emerson, Professor of Biostatistics
University of Washington | Simulation of Fisher's exact test is underestimating power
Fisher's Exact Test is conservative (i.e. the false positive rate for the nominal 0.05 test is actually less than 0.05 when the null hypothesis is true). What you're finding there is no coincidence. T |
34,416 | Simulation of Fisher's exact test is underestimating power | Fisher's test is conditional on both margins of the table; your simulation is only conditional on one margin.
[You're right, there's more to it:
(1) Your first calculation with power.prop.test uses the asymptotic approximation of the Binomial distribution to the Normal, so won't give exactly the same answer as an exact test.
(2) Any exact test will be conservative because there's only a finite number of possible contingency tables & you can't find a subset to form the rejection region with exactly 5% probability under the null hypothesis, so you have to settle for a bit less (@AdamO's answer).
(3) There are different exact tests formed by conditioning on the grand total, the row total, the column total, or both row & column totals. Choosing a different conditioning scheme means (a) asking a different question of the test, & (b) changing the number of possible contingency tables (so tests that condition most tend to be most conservative - e.g. Fisher's).
(4) There are also different test statistics that can be used, which do not necessarily give the same ordering of possible tables under the null hypothesis.
(5) And when you're simulating, there's simulation error to take into account (@Maarten's answer).] | Simulation of Fisher's exact test is underestimating power | Fisher's test is conditional on both margins of the table; your simulation is only conditional on one margin.
[You're right, there's more to it:
(1) Your first calculation with power.prop.test uses th | Simulation of Fisher's exact test is underestimating power
Fisher's test is conditional on both margins of the table; your simulation is only conditional on one margin.
[You're right, there's more to it:
(1) Your first calculation with power.prop.test uses the asymptotic approximation of the Binomial distribution to the Normal, so won't give exactly the same answer as an exact test.
(2) Any exact test will be conservative because there's only a finite number of possible contingency tables & you can't find a subset to form the rejection region with exactly 5% probability under the null hypothesis, so you have to settle for a bit less (@AdamO's answer).
(3) There are different exact tests formed by conditioning on the grand total, the row total, the column total, or both row & column totals. Choosing a different conditioning scheme means (a) asking a different question of the test, & (b) changing the number of possible contingency tables (so tests that condition most tend to be most conservative - e.g. Fisher's).
(4) There are also different test statistics that can be used, which do not necessarily give the same ordering of possible tables under the null hypothesis.
(5) And when you're simulating, there's simulation error to take into account (@Maarten's answer).] | Simulation of Fisher's exact test is underestimating power
Fisher's test is conditional on both margins of the table; your simulation is only conditional on one margin.
[You're right, there's more to it:
(1) Your first calculation with power.prop.test uses th |
34,417 | Simulation of Fisher's exact test is underestimating power | There is randomness in your Monte Carlo simulation (as there should be), so even if the true rejection rate is exactly .05 and there are no errors in your program you'll still be likely to find small deviations from that number. If you were to repeat your Monte Carlo simulation with 10,000 replications many times and the test functioned exactly as it should, then you would still expect to find that (approximately) 95% of these simulations would result in rejection rates between 4.6% and 5.4%. These bounds are based on the 2.5$^{\mathrm{th}}$ and 97.5$^{\mathrm{th}}$ percentiles of a binomial distribution with n=10,000 and p=.05. So the fact that you found a rejection rate of 4.8% in a simulation with 10,000 replications does not provide all that strong evidence against the Fisher's exact test. As AdamO pointed out, you'll in all likelihood find the rejection rate to be less than 5% even if you increase the number of replications, but the current simulation does not have enough replications to reliably find that phenomenon. | Simulation of Fisher's exact test is underestimating power | There is randomness in your Monte Carlo simulation (as there should be), so even if the true rejection rate is exactly .05 and there are no errors in your program you'll still be likely to find small | Simulation of Fisher's exact test is underestimating power
There is randomness in your Monte Carlo simulation (as there should be), so even if the true rejection rate is exactly .05 and there are no errors in your program you'll still be likely to find small deviations from that number. If you were to repeat your Monte Carlo simulation with 10,000 replications many times and the test functioned exactly as it should, then you would still expect to find that (approximately) 95% of these simulations would result in rejection rates between 4.6% and 5.4%. These bounds are based on the 2.5$^{\mathrm{th}}$ and 97.5$^{\mathrm{th}}$ percentiles of a binomial distribution with n=10,000 and p=.05. So the fact that you found a rejection rate of 4.8% in a simulation with 10,000 replications does not provide all that strong evidence against the Fisher's exact test. As AdamO pointed out, you'll in all likelihood find the rejection rate to be less than 5% even if you increase the number of replications, but the current simulation does not have enough replications to reliably find that phenomenon. | Simulation of Fisher's exact test is underestimating power
There is randomness in your Monte Carlo simulation (as there should be), so even if the true rejection rate is exactly .05 and there are no errors in your program you'll still be likely to find small |
34,418 | Series dimensionality reduction for classification Input | I'm not sure that I'd classify a Fourier transform as a dimensionality reduction technique per se, though you can certainly use it that way.
As you probably know, a Fourier transform converts a time-domain function $f(t)$ into a frequency-domain representation $F(\omega)$. In the original function, the $t$ usually denotes time: for example, f(1) might denote someone's account balance on the first day, or the volume of the first sample of a song's recording, while f(2) indicates the following day's balance/sample value). However, the argument $\omega$ in $F(\omega$) usually denotes frequency: F(10) indicates the extent to which the signal fluctuates at 10 cycles/second (or whatever your temporal units are), while F(20) indicates the extent to which it fluctuates twice as fast. The Fourier transform "works" by reconstructing your original signal as a weighted sum of sinusoids (you actually get "weight", usually called amplitude, and a "shift", typically called the phase, values for each frequency component). The wikipedia article is a bit complex, but there are a bunch of decent tutorials floating around the web.
The Fourier transform, by itself, doesn't get you any dimensionality reduction. If your signal is of length $N$, you'll get about $N/2$ amplitudes and $N/2$ phases back (1), which is clearly not a huge savings. However, for some signals, most of those amplitudes are close to zero or are a priori known to be irrelevant. You could then throw out the coefficients for these frequencies, since you don't need them to reconstruct the signal, which can lead to a considerable savings in space (again, depending on the signal). This is what the linked book is describing as "dimensionality reduction."
A Fourier representation could be useful if:
Your signal is periodic, and
Useful information is encoded in the periodicity of the signal.
For example, suppose you're recording a patient's vital signs. The electrical signal from the EKG (or the sound from a stethoscope) is a high-dimensional signal (say, 200+ samples/second). However, for some applications, you might be more interested in the subject's heart rate, which is likely to be the location of the peak in the FFT, and thus representable by a single digit.
A major limitation of the FFT is that it considers the whole signal at once--it cannot localize a changes in it. For example, suppose you look at the coefficient associated with 10 cycles/second. You'll get similar amplitude values if
There is consistent, but moderate-sized 10 Hz oscillation in the signal,
That oscillation is twice as large in the first half of the signal, but totally absent in the 2nd half, and
The oscillation is totally absent in the first half, but twice as large as #1 in the 2nd half.
(and so on)
I obviously don't know much about your business, but I'd imagine these could be very relevant features. Another major limitation of the FFT is that it operates on a single time scale. For example, suppose one customer religiously visits your business every other day: he has a "frequency" of 0.5 visits/day (or a period of 2 days). Another customer might also consistently come for two days in a row, take two off, and then visit again for the next two. Mathematically, the second customer is "oscillating" twice as slowly as the first, but I'd bet that these two are equally likely to churn.
A time-frequency approach helps get around this issues by localizing changes in both frequency and time. One simple approach is the short-time FFT, which divides your signal into little windows, and then computes the Fourier transform of each window. This assumes that the signal is stationary within a window, but changes across them. Wavelet analysis is a more powerful (and mathematically rigorous approach). There are lots of Wavelet tutorials around--the charmingly named Wavelets for Kids is a good place to start, even if it is a bit much for all but the smartest actual children. There are several wavelet packages for R, but their syntax is pretty straightforward (see page 3 of wavelet package documentation for one). You need to choose an appropriate wavelet for your application--this ideally looks something like the fluctuation of interest in your signal, but a Morlet wavelet might be a reasonable starting point. Like the FFT, the wavelet transform itself won't give you much dimensionality reduction. Instead, it represents your original signal as a function of two parameters ("scale", which is analogous to frequency, and "translation", which is akin to position in time). Like the FFT coefficients, you can safely discard coefficients whose amplitude is close to zero, which gives you some effective dimensionality reduction.
Finally, I want to conclude by asking you if dimensionality reduction is really what you want here. The techniques you've been asking about are all essentially ways to reduce the size of the data while preserving it as faithfully as possible. However, to get the best classification performance we typically want to collect and transform the data to make relevant features as explicit as possible, while discarding everything else.
Sometimes, Fourier or Wavelet analysis is exactly what is needed (e.g., turning a high dimensional EKG signal into a single heart rate value); other times, you'd be better off with completely different approaches (moving averages, derivatives, etc). I'd encourage you to have a good think about your actual problem (and maybe even brainstorm with sales/customer retention folks to see if they have any intuitions) and use those ideas to generate features, instead of blindly trying a bunch of transforms. | Series dimensionality reduction for classification Input | I'm not sure that I'd classify a Fourier transform as a dimensionality reduction technique per se, though you can certainly use it that way.
As you probably know, a Fourier transform converts a time- | Series dimensionality reduction for classification Input
I'm not sure that I'd classify a Fourier transform as a dimensionality reduction technique per se, though you can certainly use it that way.
As you probably know, a Fourier transform converts a time-domain function $f(t)$ into a frequency-domain representation $F(\omega)$. In the original function, the $t$ usually denotes time: for example, f(1) might denote someone's account balance on the first day, or the volume of the first sample of a song's recording, while f(2) indicates the following day's balance/sample value). However, the argument $\omega$ in $F(\omega$) usually denotes frequency: F(10) indicates the extent to which the signal fluctuates at 10 cycles/second (or whatever your temporal units are), while F(20) indicates the extent to which it fluctuates twice as fast. The Fourier transform "works" by reconstructing your original signal as a weighted sum of sinusoids (you actually get "weight", usually called amplitude, and a "shift", typically called the phase, values for each frequency component). The wikipedia article is a bit complex, but there are a bunch of decent tutorials floating around the web.
The Fourier transform, by itself, doesn't get you any dimensionality reduction. If your signal is of length $N$, you'll get about $N/2$ amplitudes and $N/2$ phases back (1), which is clearly not a huge savings. However, for some signals, most of those amplitudes are close to zero or are a priori known to be irrelevant. You could then throw out the coefficients for these frequencies, since you don't need them to reconstruct the signal, which can lead to a considerable savings in space (again, depending on the signal). This is what the linked book is describing as "dimensionality reduction."
A Fourier representation could be useful if:
Your signal is periodic, and
Useful information is encoded in the periodicity of the signal.
For example, suppose you're recording a patient's vital signs. The electrical signal from the EKG (or the sound from a stethoscope) is a high-dimensional signal (say, 200+ samples/second). However, for some applications, you might be more interested in the subject's heart rate, which is likely to be the location of the peak in the FFT, and thus representable by a single digit.
A major limitation of the FFT is that it considers the whole signal at once--it cannot localize a changes in it. For example, suppose you look at the coefficient associated with 10 cycles/second. You'll get similar amplitude values if
There is consistent, but moderate-sized 10 Hz oscillation in the signal,
That oscillation is twice as large in the first half of the signal, but totally absent in the 2nd half, and
The oscillation is totally absent in the first half, but twice as large as #1 in the 2nd half.
(and so on)
I obviously don't know much about your business, but I'd imagine these could be very relevant features. Another major limitation of the FFT is that it operates on a single time scale. For example, suppose one customer religiously visits your business every other day: he has a "frequency" of 0.5 visits/day (or a period of 2 days). Another customer might also consistently come for two days in a row, take two off, and then visit again for the next two. Mathematically, the second customer is "oscillating" twice as slowly as the first, but I'd bet that these two are equally likely to churn.
A time-frequency approach helps get around this issues by localizing changes in both frequency and time. One simple approach is the short-time FFT, which divides your signal into little windows, and then computes the Fourier transform of each window. This assumes that the signal is stationary within a window, but changes across them. Wavelet analysis is a more powerful (and mathematically rigorous approach). There are lots of Wavelet tutorials around--the charmingly named Wavelets for Kids is a good place to start, even if it is a bit much for all but the smartest actual children. There are several wavelet packages for R, but their syntax is pretty straightforward (see page 3 of wavelet package documentation for one). You need to choose an appropriate wavelet for your application--this ideally looks something like the fluctuation of interest in your signal, but a Morlet wavelet might be a reasonable starting point. Like the FFT, the wavelet transform itself won't give you much dimensionality reduction. Instead, it represents your original signal as a function of two parameters ("scale", which is analogous to frequency, and "translation", which is akin to position in time). Like the FFT coefficients, you can safely discard coefficients whose amplitude is close to zero, which gives you some effective dimensionality reduction.
Finally, I want to conclude by asking you if dimensionality reduction is really what you want here. The techniques you've been asking about are all essentially ways to reduce the size of the data while preserving it as faithfully as possible. However, to get the best classification performance we typically want to collect and transform the data to make relevant features as explicit as possible, while discarding everything else.
Sometimes, Fourier or Wavelet analysis is exactly what is needed (e.g., turning a high dimensional EKG signal into a single heart rate value); other times, you'd be better off with completely different approaches (moving averages, derivatives, etc). I'd encourage you to have a good think about your actual problem (and maybe even brainstorm with sales/customer retention folks to see if they have any intuitions) and use those ideas to generate features, instead of blindly trying a bunch of transforms. | Series dimensionality reduction for classification Input
I'm not sure that I'd classify a Fourier transform as a dimensionality reduction technique per se, though you can certainly use it that way.
As you probably know, a Fourier transform converts a time- |
34,419 | Series dimensionality reduction for classification Input | As Matt said, I'm not sure the DFT will produce relevant features for your application. But as you ask in this question, here is an R code to build to features for the quantiles of the DFT of a 1D signal x, using the function detrend (for example with the package pracma).
l <- length(x)
detrended <- detrend(x)
dft <- fft(detrended)/l
amplitude <- 2*abs(dft[1:l/2])
plot(amplitude, type='l')
quantiles <- quantile(amplitude) | Series dimensionality reduction for classification Input | As Matt said, I'm not sure the DFT will produce relevant features for your application. But as you ask in this question, here is an R code to build to features for the quantiles of the DFT of a 1D sig | Series dimensionality reduction for classification Input
As Matt said, I'm not sure the DFT will produce relevant features for your application. But as you ask in this question, here is an R code to build to features for the quantiles of the DFT of a 1D signal x, using the function detrend (for example with the package pracma).
l <- length(x)
detrended <- detrend(x)
dft <- fft(detrended)/l
amplitude <- 2*abs(dft[1:l/2])
plot(amplitude, type='l')
quantiles <- quantile(amplitude) | Series dimensionality reduction for classification Input
As Matt said, I'm not sure the DFT will produce relevant features for your application. But as you ask in this question, here is an R code to build to features for the quantiles of the DFT of a 1D sig |
34,420 | Series dimensionality reduction for classification Input | I wouldn't use the FFT here at all unless you have some model that suggests it is the right thing to do, and, from the information you've given, I don't see any reason to believe simply looking at the FFT of your data is appropriate. I suggest instead of looking at the FFT, which is likely to be a dead-end, consider other approaches.
More appropriate methods might be a moving average filter (eg, the average sales in the last N days) or a weighted moving average filter (same except more weight is given to values that are believed to be more significant, either because you have a model/hypothesis that supports this, or actual data that indicates that this is how it's been in the past. For example, you might weight more recent figures, or you might weight data from mondays because you have data that suggests that monday sales are predictive for some reason).
Another approach might be to simply use regression (especially logistic regression). This may seem traditional and boring, but it works. | Series dimensionality reduction for classification Input | I wouldn't use the FFT here at all unless you have some model that suggests it is the right thing to do, and, from the information you've given, I don't see any reason to believe simply looking at the | Series dimensionality reduction for classification Input
I wouldn't use the FFT here at all unless you have some model that suggests it is the right thing to do, and, from the information you've given, I don't see any reason to believe simply looking at the FFT of your data is appropriate. I suggest instead of looking at the FFT, which is likely to be a dead-end, consider other approaches.
More appropriate methods might be a moving average filter (eg, the average sales in the last N days) or a weighted moving average filter (same except more weight is given to values that are believed to be more significant, either because you have a model/hypothesis that supports this, or actual data that indicates that this is how it's been in the past. For example, you might weight more recent figures, or you might weight data from mondays because you have data that suggests that monday sales are predictive for some reason).
Another approach might be to simply use regression (especially logistic regression). This may seem traditional and boring, but it works. | Series dimensionality reduction for classification Input
I wouldn't use the FFT here at all unless you have some model that suggests it is the right thing to do, and, from the information you've given, I don't see any reason to believe simply looking at the |
34,421 | What is a "thin" svd? | Let the SVD of an $m \times n$ matrix be $A=U \Sigma V^T$. Further, suppose it has rank $r$. Then, $A$ can be written as
$$ A = \sum_{i=1}^r \sigma_i u_i v_i^T + \sum_{i=r+1}^{\min(n,m)}0 \cdot u_i v_i^T$$.
The "thin" SVD is just the first part where the "fat" (?) SVD is the entire expression. In other words, the remaining parts can be discarded. Therefore, if we know the matrix is of rank $r$, we only need to find those $r$ terms. | What is a "thin" svd? | Let the SVD of an $m \times n$ matrix be $A=U \Sigma V^T$. Further, suppose it has rank $r$. Then, $A$ can be written as
$$ A = \sum_{i=1}^r \sigma_i u_i v_i^T + \sum_{i=r+1}^{\min(n,m)}0 \cdot u_i v_ | What is a "thin" svd?
Let the SVD of an $m \times n$ matrix be $A=U \Sigma V^T$. Further, suppose it has rank $r$. Then, $A$ can be written as
$$ A = \sum_{i=1}^r \sigma_i u_i v_i^T + \sum_{i=r+1}^{\min(n,m)}0 \cdot u_i v_i^T$$.
The "thin" SVD is just the first part where the "fat" (?) SVD is the entire expression. In other words, the remaining parts can be discarded. Therefore, if we know the matrix is of rank $r$, we only need to find those $r$ terms. | What is a "thin" svd?
Let the SVD of an $m \times n$ matrix be $A=U \Sigma V^T$. Further, suppose it has rank $r$. Then, $A$ can be written as
$$ A = \sum_{i=1}^r \sigma_i u_i v_i^T + \sum_{i=r+1}^{\min(n,m)}0 \cdot u_i v_ |
34,422 | Two-sample one-sided Kolmogorov-Smirnov test vs one-sided Wilcoxon-Mann-Whitney test | Both are testing for displacement of the x variable with respect to the y variable, but the 2 tests have opposite meanings for the term "greater" (and therefor also or "less").
In the ks.test "greater" means that the CDF of 'x' is higher than the CDF of 'y' which means that things like the mean and the median will be smaller values in 'x' than in 'y' if the CDF of 'x' is "greater" than the CDF of 'y'. In 'wicox.test' and 't.test' the mean, median, etc. will be greater in 'x' than in 'y' if you believe that the alternative of "greater" is true.
An example from R:
> x <- rnorm(25)
> y <- rnorm(25, 1)
>
> ks.test(x,y, alt='greater')
Two-sample Kolmogorov-Smirnov test
data: x and y
D = 0.6, p-value = 0.0001625
alternative hypothesis: two-sided
> wilcox.test( x, y, alt='greater' )
Wilcoxon rank sum test
data: x and y
W = 127, p-value = 0.9999
alternative hypothesis: true location shift is greater than 0
> wilcox.test( x, y, alt='less' )
Wilcoxon rank sum test
data: x and y
W = 127, p-value = 0.000101
alternative hypothesis: true location shift is less than 0
Here I generated 2 samples from a normal distribution, both with sample size 25 and standard deviation of 1. The x variable comes from a distribution of mean 0 and the y variable from a distribution of mean 1. You can see the results of ks.test give a very significant result testing in the "greater" direction even though x has the smaller mean, this is because the CDF of x is above that of y. The wilcox.test function shows lack of significance in the "greater" direction, but similar level of significance in the "less" direction.
Both tests are different approaches to testing the same idea, but what "greater" and "less" mean to the 2 tests are different (and conceptually opposite). | Two-sample one-sided Kolmogorov-Smirnov test vs one-sided Wilcoxon-Mann-Whitney test | Both are testing for displacement of the x variable with respect to the y variable, but the 2 tests have opposite meanings for the term "greater" (and therefor also or "less").
In the ks.test "greater | Two-sample one-sided Kolmogorov-Smirnov test vs one-sided Wilcoxon-Mann-Whitney test
Both are testing for displacement of the x variable with respect to the y variable, but the 2 tests have opposite meanings for the term "greater" (and therefor also or "less").
In the ks.test "greater" means that the CDF of 'x' is higher than the CDF of 'y' which means that things like the mean and the median will be smaller values in 'x' than in 'y' if the CDF of 'x' is "greater" than the CDF of 'y'. In 'wicox.test' and 't.test' the mean, median, etc. will be greater in 'x' than in 'y' if you believe that the alternative of "greater" is true.
An example from R:
> x <- rnorm(25)
> y <- rnorm(25, 1)
>
> ks.test(x,y, alt='greater')
Two-sample Kolmogorov-Smirnov test
data: x and y
D = 0.6, p-value = 0.0001625
alternative hypothesis: two-sided
> wilcox.test( x, y, alt='greater' )
Wilcoxon rank sum test
data: x and y
W = 127, p-value = 0.9999
alternative hypothesis: true location shift is greater than 0
> wilcox.test( x, y, alt='less' )
Wilcoxon rank sum test
data: x and y
W = 127, p-value = 0.000101
alternative hypothesis: true location shift is less than 0
Here I generated 2 samples from a normal distribution, both with sample size 25 and standard deviation of 1. The x variable comes from a distribution of mean 0 and the y variable from a distribution of mean 1. You can see the results of ks.test give a very significant result testing in the "greater" direction even though x has the smaller mean, this is because the CDF of x is above that of y. The wilcox.test function shows lack of significance in the "greater" direction, but similar level of significance in the "less" direction.
Both tests are different approaches to testing the same idea, but what "greater" and "less" mean to the 2 tests are different (and conceptually opposite). | Two-sample one-sided Kolmogorov-Smirnov test vs one-sided Wilcoxon-Mann-Whitney test
Both are testing for displacement of the x variable with respect to the y variable, but the 2 tests have opposite meanings for the term "greater" (and therefor also or "less").
In the ks.test "greater |
34,423 | Two-sample one-sided Kolmogorov-Smirnov test vs one-sided Wilcoxon-Mann-Whitney test | I disagree with R and @GregSnow on this point. Here is why.
set.seed(123)
x <- rnorm(25)
y <- rnorm(25, sd=5)
ks.test(x, y, alternative='greater')
# Two-sample Kolmogorov-Smirnov test
#
# data: x and y
# D^+ = 0.44, p-value = 0.007907
# alternative hypothesis: the CDF of x lies above that of y
#
ks.test(x, y, alternative='less')
# Two-sample Kolmogorov-Smirnov test
#
# data: x and y
# D^- = 0.36, p-value = 0.03916
# alternative hypothesis: the CDF of x lies below that of y
In the case that the variances are different, the CDF of x lies both above and below that of y. So rejecting the one-sided hypothesis does not mean anything about the mean or the median. It does not even say anything about stochastic dominance.
You can find more about this misconception there and some discussion there. In my opinion, the one sided KS test has some theoretical attractiveness, but it is wrong to draw a conclusion about the first moment from it. For this purpose, the Wilcoxon test is more appropriate. | Two-sample one-sided Kolmogorov-Smirnov test vs one-sided Wilcoxon-Mann-Whitney test | I disagree with R and @GregSnow on this point. Here is why.
set.seed(123)
x <- rnorm(25)
y <- rnorm(25, sd=5)
ks.test(x, y, alternative='greater')
# Two-sample Kolmogorov-Smirnov test
#
# data: x | Two-sample one-sided Kolmogorov-Smirnov test vs one-sided Wilcoxon-Mann-Whitney test
I disagree with R and @GregSnow on this point. Here is why.
set.seed(123)
x <- rnorm(25)
y <- rnorm(25, sd=5)
ks.test(x, y, alternative='greater')
# Two-sample Kolmogorov-Smirnov test
#
# data: x and y
# D^+ = 0.44, p-value = 0.007907
# alternative hypothesis: the CDF of x lies above that of y
#
ks.test(x, y, alternative='less')
# Two-sample Kolmogorov-Smirnov test
#
# data: x and y
# D^- = 0.36, p-value = 0.03916
# alternative hypothesis: the CDF of x lies below that of y
In the case that the variances are different, the CDF of x lies both above and below that of y. So rejecting the one-sided hypothesis does not mean anything about the mean or the median. It does not even say anything about stochastic dominance.
You can find more about this misconception there and some discussion there. In my opinion, the one sided KS test has some theoretical attractiveness, but it is wrong to draw a conclusion about the first moment from it. For this purpose, the Wilcoxon test is more appropriate. | Two-sample one-sided Kolmogorov-Smirnov test vs one-sided Wilcoxon-Mann-Whitney test
I disagree with R and @GregSnow on this point. Here is why.
set.seed(123)
x <- rnorm(25)
y <- rnorm(25, sd=5)
ks.test(x, y, alternative='greater')
# Two-sample Kolmogorov-Smirnov test
#
# data: x |
34,424 | Sufficiency in Lehmann Scheffe | The problem is (2), as others have noted. Let $X_1, ..., X_n$ be iid normal with mean $\theta$ and variance $1$. The statistic $T(X_1, ..., X_n) = X_1$ is complete, because the normal family is complete. But it is not uncorrelated with all unbiased estimators of $0$; take $\hat 0 = X_1 - X_2$. In constructing unbiased estimators of $0$ we are allowed to use the entire data, whereas completeness is only a property of the marginal distribution of $T(X_1, ..., X_n)$.
The logic in Casella and Berger is this: if $T = T(X_1, ..., X_n)$ is sufficient then it suffices to only consider the distribution of $T$ when looking for unbiased estimators, by Rao-Blackwell. This is what sufficiency is giving you - it allows you to ignore everything except $T$. So it suffices to show, if $g(T)$ is unbiased for $\theta$, that $g(T)$ is uncorrelated with every unbiased estimate of $0$, $\hat 0(T)$ [note: because of sufficiency, we have reduced the problem of showing uncorrelatedness with every estimator of $0$ to only have to show it for estimators that depend only on $T$]. But if $T$ is complete then there are no unbiased estimators $\hat 0(T)$ other than $0$ which $g(T)$ is uncorrelated with, so we are done. Of course, now that we've established that $g(T)$ is the UMVUE, it follows a posteriori that $g(T)$ is uncorrelated with all unbiased estimators of $0$, $\hat 0(X_1, ..., X_n)$, that depend on the entire sample. | Sufficiency in Lehmann Scheffe | The problem is (2), as others have noted. Let $X_1, ..., X_n$ be iid normal with mean $\theta$ and variance $1$. The statistic $T(X_1, ..., X_n) = X_1$ is complete, because the normal family is comple | Sufficiency in Lehmann Scheffe
The problem is (2), as others have noted. Let $X_1, ..., X_n$ be iid normal with mean $\theta$ and variance $1$. The statistic $T(X_1, ..., X_n) = X_1$ is complete, because the normal family is complete. But it is not uncorrelated with all unbiased estimators of $0$; take $\hat 0 = X_1 - X_2$. In constructing unbiased estimators of $0$ we are allowed to use the entire data, whereas completeness is only a property of the marginal distribution of $T(X_1, ..., X_n)$.
The logic in Casella and Berger is this: if $T = T(X_1, ..., X_n)$ is sufficient then it suffices to only consider the distribution of $T$ when looking for unbiased estimators, by Rao-Blackwell. This is what sufficiency is giving you - it allows you to ignore everything except $T$. So it suffices to show, if $g(T)$ is unbiased for $\theta$, that $g(T)$ is uncorrelated with every unbiased estimate of $0$, $\hat 0(T)$ [note: because of sufficiency, we have reduced the problem of showing uncorrelatedness with every estimator of $0$ to only have to show it for estimators that depend only on $T$]. But if $T$ is complete then there are no unbiased estimators $\hat 0(T)$ other than $0$ which $g(T)$ is uncorrelated with, so we are done. Of course, now that we've established that $g(T)$ is the UMVUE, it follows a posteriori that $g(T)$ is uncorrelated with all unbiased estimators of $0$, $\hat 0(X_1, ..., X_n)$, that depend on the entire sample. | Sufficiency in Lehmann Scheffe
The problem is (2), as others have noted. Let $X_1, ..., X_n$ be iid normal with mean $\theta$ and variance $1$. The statistic $T(X_1, ..., X_n) = X_1$ is complete, because the normal family is comple |
34,425 | Sufficiency in Lehmann Scheffe | If your Uniformly Minimum Variance Unbiased Estimator $U$ of $\theta$ were not a function of a sufficient statistic $S$ alone (a.s.), then, by the Rao-Blackwell Theorem, the random variable $V=\textrm{E}_\theta[U\mid S]$ would be an unbiased estimator of $\theta$ that has variance uniformly smaller than $U$, which contradicts the fact that $U$ is an Uniformly Minimum Variance Unbiased Estimator of $\theta$. A Lehmann-Scheffé style result without the sufficiency assumption would leave that window open. | Sufficiency in Lehmann Scheffe | If your Uniformly Minimum Variance Unbiased Estimator $U$ of $\theta$ were not a function of a sufficient statistic $S$ alone (a.s.), then, by the Rao-Blackwell Theorem, the random variable $V=\textrm | Sufficiency in Lehmann Scheffe
If your Uniformly Minimum Variance Unbiased Estimator $U$ of $\theta$ were not a function of a sufficient statistic $S$ alone (a.s.), then, by the Rao-Blackwell Theorem, the random variable $V=\textrm{E}_\theta[U\mid S]$ would be an unbiased estimator of $\theta$ that has variance uniformly smaller than $U$, which contradicts the fact that $U$ is an Uniformly Minimum Variance Unbiased Estimator of $\theta$. A Lehmann-Scheffé style result without the sufficiency assumption would leave that window open. | Sufficiency in Lehmann Scheffe
If your Uniformly Minimum Variance Unbiased Estimator $U$ of $\theta$ were not a function of a sufficient statistic $S$ alone (a.s.), then, by the Rao-Blackwell Theorem, the random variable $V=\textrm |
34,426 | Sufficiency in Lehmann Scheffe | Even though this is an old question I thought it would be helpful to have a more detailed answer.
Step 2 only follows for sure if your complete estimator $T$ is also sufficient. Suppose $U$ is any random variable with $E(U)=0$. Then
$$
E(E(U|T)) = E(U) = 0 \Rightarrow E(U|T) = 0
$$
Note that this result depends on sufficiency, because $E(U|T)$ needs to be the same function for all $\theta$, so generally it can't depend on $\theta$. It follows that
$$
Cov(T,U) = E(TU) -E(T)E(U) = E(TU) = E(TE(U|T)) = E(T*0) = 0.
$$
Take the example by guy above. There we have $E(U|T) = E(X_1-X_2|X_1) = X_1-\theta$, a function that depends on $\theta$, and thus we don't necessarily get zero covariance with every mean zero random variable. | Sufficiency in Lehmann Scheffe | Even though this is an old question I thought it would be helpful to have a more detailed answer.
Step 2 only follows for sure if your complete estimator $T$ is also sufficient. Suppose $U$ is any ran | Sufficiency in Lehmann Scheffe
Even though this is an old question I thought it would be helpful to have a more detailed answer.
Step 2 only follows for sure if your complete estimator $T$ is also sufficient. Suppose $U$ is any random variable with $E(U)=0$. Then
$$
E(E(U|T)) = E(U) = 0 \Rightarrow E(U|T) = 0
$$
Note that this result depends on sufficiency, because $E(U|T)$ needs to be the same function for all $\theta$, so generally it can't depend on $\theta$. It follows that
$$
Cov(T,U) = E(TU) -E(T)E(U) = E(TU) = E(TE(U|T)) = E(T*0) = 0.
$$
Take the example by guy above. There we have $E(U|T) = E(X_1-X_2|X_1) = X_1-\theta$, a function that depends on $\theta$, and thus we don't necessarily get zero covariance with every mean zero random variable. | Sufficiency in Lehmann Scheffe
Even though this is an old question I thought it would be helpful to have a more detailed answer.
Step 2 only follows for sure if your complete estimator $T$ is also sufficient. Suppose $U$ is any ran |
34,427 | Whether to use original or reverse coded items in factor analysis? | It doesn't matter which you use. The signs on the factor loadings will simply flip. For example, let's say that item 1 and item 2 should load on the same factor, but item 2 is reverse scored. The factor loading for item 1 might be .53, and the factor loading for item 2 might be -.41, but if you had used the recoded variable instead, it would have been .41. Just don't put both in! | Whether to use original or reverse coded items in factor analysis? | It doesn't matter which you use. The signs on the factor loadings will simply flip. For example, let's say that item 1 and item 2 should load on the same factor, but item 2 is reverse scored. The f | Whether to use original or reverse coded items in factor analysis?
It doesn't matter which you use. The signs on the factor loadings will simply flip. For example, let's say that item 1 and item 2 should load on the same factor, but item 2 is reverse scored. The factor loading for item 1 might be .53, and the factor loading for item 2 might be -.41, but if you had used the recoded variable instead, it would have been .41. Just don't put both in! | Whether to use original or reverse coded items in factor analysis?
It doesn't matter which you use. The signs on the factor loadings will simply flip. For example, let's say that item 1 and item 2 should load on the same factor, but item 2 is reverse scored. The f |
34,428 | Whether to use original or reverse coded items in factor analysis? | As gung said, recoding reverse-scored variables will only reverse the sign of their factor loadings, so the decision is only important because you will have to keep track of (and specify in anything you write about it) which variables are reverse-scored, or whether you recoded them.
An unrelated concern arises with factor analysis of Likert scale ratings. Likert scales produce ordinal (i.e., polytomous, ordered, categorical) data, not continuous data. Factor analysis generally assumes any raw data input are continuous. Here's a quote from Reise, Moore, and Haviland (2010):
Ordinary confirmatory factor analytic techniques do not apply to dichotomous or polytomous data (Byrne, 2006). Instead, special estimation procedures are required (Wirth & Edwards, 2007). There basically are three options for working with polytomous item response data. The first is to compute a polychoric matrix and then apply standard factor analytic methods
(see Knol & Berger, 1991). A second option is to use full-information item factor analysis (Gibbons & Hedeker, 1992). The third is to use limited information estimation procedures
designed specifically for ordered data such as weighted least squares with mean and variance adjustment (MPLUS; Muthén & Muthén, 2009).
I would recommend combining both the first and third approaches (i.e., use diagonally weighted least squares estimation on a polychoric correlation matrix), based on Wang and Cunningham's (2005) discussion of the problems with typical alternatives:
When confirmatory factor analysis was conducted with nonnormal ordinal data using maximum likelihood and based on Pearson product-moment correlations, the downward parameter estimates produced in this study were consistent with Olsson's (1979) findings. In other
words, the magnitude of nonnormality in the observed ordinal variables is a major determinant of the accuracy of parameter estimates.
The results also support the findings of Babakus, et al. (1987). When maximum likelihood estimation is used with a polychoric correlation input matrix in confirmatory factor analyses, the solutions tend to result in unacceptable
and therefore significant chi-square values together with poor fit statistics.
SPSS has some solutions for exploratory factor analysis of Likert scale ratings. The second solution for producing polychoric correlations should work with confirmatory factor analysis too. It seems you can use generalized (weighted) least squares estimation in SPSS, but not diagonally weighted least squares ($DWLS$). Another precaution from Wang and Cunningham (2005):
Because weighted least squares estimation is based on fourth-order moments, this approach
frequently leads to practical problems and is very computationally demanding. This means that weighted least squares estimation may lack robustness when used to evaluate models of medium, i.e., with 10 indicators, to large size and small to moderate sample sizes.
It isn't clear to me whether the same concern applies to $DWLS$ estimation; regardless, the authors recommend that estimator. In case you're willing to switch programs to use $DWLS$:
R (R Core Team, 2012) is free. You'll need an old version (e.g., 2.15.2) for these packages:
The psych package (Revelle, 2013) contains the polychoric function.
The fa.parallel function can help identify the number of factors to extract.
The lavaan package (Rosseel, 2012) offers $DWLS$ estimation for latent variable analysis.
The semTools package contains the efaUnrotate, orthRotate, and oblqRotate functions.
I imagine Mplus (Muthén & Muthén, 1998-2011) would work too, but the free demo version won't accommodate more than six measurements, and the licensed version isn't cheap. It may be worth it if you can afford it though; people love Mplus, and the Muthéns' customer service via their forums is incredible!
P.S. If one headache for the sake of psychometric validity isn't too many, you may want to consider analyzing problems with extreme response style as well, given the subjective nature of Likert scale ratings.
References
Babakus, E., Ferguson, J. C. E., & Jöreskog, K. G. (1987). The sensitivity of confirmatory maximum likelihood factor analysis to violations of measurement scale and distributional assumptions. Journal of Marketing Research, 24, 222–228.
Byrne, B. M. (2006). Structural Equation Modeling with EQS. Mahwah, NJ:
Lawrence Erlbaum.
Gibbons, R. D., & Hedeker, D. R. (1992). Full-information item bi-factor analysis.
Psychometrika, 57, 423–436.
Knol, D. L., & Berger, M. P. F. (1991). Empirical comparison between factor analysis and multidimensional item response models. Multivariate Behavioral Research, 26, 457–477.
Muthén, L. K., & Muthén, B. O. (1998-2011). Mplus user's guide (6th ed.). Los Angeles, CA: Muthén & Muthén.
Muthén, L. K., & Muthén, B. O. (2009). Mplus (Version 4.00). [Computer
software]. Los Angeles, CA: Author. URL: http://www.statmodel.com.
Olsson, U. (1979). Maximum likelihood estimates for the polychoric correlation coefficient.
Psychometrika, 44, 443–460.
R Core Team. (2012). R: A language and environment for statistical computing. R Foundation for Statistical Computing, Vienna, Austria. ISBN 3-900051-07-0, URL: http://www.R-project.org/.
Reise, S. P., Moore, T. M., & Haviland, M. G. (2010). Bifactor models and rotations: Exploring the extent to which multidimensional data yield univocal scale scores. Journal of Personality Assessment, 92(6), 544–559. Retrieved November 21, 2013. Freely available online, URL: http://www.ncbi.nlm.nih.gov/pmc/articles/PMC2981404/.
Revelle, W. (2013). psych: Procedures for Personality and Psychological Research. Northwestern University, Evanston, Illinois, USA. URL: http://CRAN.R-project.org/package=psych. Version = 1.3.2.
Rosseel, Y. (2012). lavaan: An R Package for Structural Equation Modeling. Journal of Statistical Software, 48(2), 1–36. URL: http://www.jstatsoft.org/v48/i02/.
Wirth, R. J., & Edwards, M. C. (2007). Item factor analysis: Current approaches
and future directions. Psychological Methods, 12, 58–79. Retrieved November 21, 2013. Freely available online, URL: http://www.ncbi.nlm.nih.gov/pmc/articles/PMC3162326/. | Whether to use original or reverse coded items in factor analysis? | As gung said, recoding reverse-scored variables will only reverse the sign of their factor loadings, so the decision is only important because you will have to keep track of (and specify in anything y | Whether to use original or reverse coded items in factor analysis?
As gung said, recoding reverse-scored variables will only reverse the sign of their factor loadings, so the decision is only important because you will have to keep track of (and specify in anything you write about it) which variables are reverse-scored, or whether you recoded them.
An unrelated concern arises with factor analysis of Likert scale ratings. Likert scales produce ordinal (i.e., polytomous, ordered, categorical) data, not continuous data. Factor analysis generally assumes any raw data input are continuous. Here's a quote from Reise, Moore, and Haviland (2010):
Ordinary confirmatory factor analytic techniques do not apply to dichotomous or polytomous data (Byrne, 2006). Instead, special estimation procedures are required (Wirth & Edwards, 2007). There basically are three options for working with polytomous item response data. The first is to compute a polychoric matrix and then apply standard factor analytic methods
(see Knol & Berger, 1991). A second option is to use full-information item factor analysis (Gibbons & Hedeker, 1992). The third is to use limited information estimation procedures
designed specifically for ordered data such as weighted least squares with mean and variance adjustment (MPLUS; Muthén & Muthén, 2009).
I would recommend combining both the first and third approaches (i.e., use diagonally weighted least squares estimation on a polychoric correlation matrix), based on Wang and Cunningham's (2005) discussion of the problems with typical alternatives:
When confirmatory factor analysis was conducted with nonnormal ordinal data using maximum likelihood and based on Pearson product-moment correlations, the downward parameter estimates produced in this study were consistent with Olsson's (1979) findings. In other
words, the magnitude of nonnormality in the observed ordinal variables is a major determinant of the accuracy of parameter estimates.
The results also support the findings of Babakus, et al. (1987). When maximum likelihood estimation is used with a polychoric correlation input matrix in confirmatory factor analyses, the solutions tend to result in unacceptable
and therefore significant chi-square values together with poor fit statistics.
SPSS has some solutions for exploratory factor analysis of Likert scale ratings. The second solution for producing polychoric correlations should work with confirmatory factor analysis too. It seems you can use generalized (weighted) least squares estimation in SPSS, but not diagonally weighted least squares ($DWLS$). Another precaution from Wang and Cunningham (2005):
Because weighted least squares estimation is based on fourth-order moments, this approach
frequently leads to practical problems and is very computationally demanding. This means that weighted least squares estimation may lack robustness when used to evaluate models of medium, i.e., with 10 indicators, to large size and small to moderate sample sizes.
It isn't clear to me whether the same concern applies to $DWLS$ estimation; regardless, the authors recommend that estimator. In case you're willing to switch programs to use $DWLS$:
R (R Core Team, 2012) is free. You'll need an old version (e.g., 2.15.2) for these packages:
The psych package (Revelle, 2013) contains the polychoric function.
The fa.parallel function can help identify the number of factors to extract.
The lavaan package (Rosseel, 2012) offers $DWLS$ estimation for latent variable analysis.
The semTools package contains the efaUnrotate, orthRotate, and oblqRotate functions.
I imagine Mplus (Muthén & Muthén, 1998-2011) would work too, but the free demo version won't accommodate more than six measurements, and the licensed version isn't cheap. It may be worth it if you can afford it though; people love Mplus, and the Muthéns' customer service via their forums is incredible!
P.S. If one headache for the sake of psychometric validity isn't too many, you may want to consider analyzing problems with extreme response style as well, given the subjective nature of Likert scale ratings.
References
Babakus, E., Ferguson, J. C. E., & Jöreskog, K. G. (1987). The sensitivity of confirmatory maximum likelihood factor analysis to violations of measurement scale and distributional assumptions. Journal of Marketing Research, 24, 222–228.
Byrne, B. M. (2006). Structural Equation Modeling with EQS. Mahwah, NJ:
Lawrence Erlbaum.
Gibbons, R. D., & Hedeker, D. R. (1992). Full-information item bi-factor analysis.
Psychometrika, 57, 423–436.
Knol, D. L., & Berger, M. P. F. (1991). Empirical comparison between factor analysis and multidimensional item response models. Multivariate Behavioral Research, 26, 457–477.
Muthén, L. K., & Muthén, B. O. (1998-2011). Mplus user's guide (6th ed.). Los Angeles, CA: Muthén & Muthén.
Muthén, L. K., & Muthén, B. O. (2009). Mplus (Version 4.00). [Computer
software]. Los Angeles, CA: Author. URL: http://www.statmodel.com.
Olsson, U. (1979). Maximum likelihood estimates for the polychoric correlation coefficient.
Psychometrika, 44, 443–460.
R Core Team. (2012). R: A language and environment for statistical computing. R Foundation for Statistical Computing, Vienna, Austria. ISBN 3-900051-07-0, URL: http://www.R-project.org/.
Reise, S. P., Moore, T. M., & Haviland, M. G. (2010). Bifactor models and rotations: Exploring the extent to which multidimensional data yield univocal scale scores. Journal of Personality Assessment, 92(6), 544–559. Retrieved November 21, 2013. Freely available online, URL: http://www.ncbi.nlm.nih.gov/pmc/articles/PMC2981404/.
Revelle, W. (2013). psych: Procedures for Personality and Psychological Research. Northwestern University, Evanston, Illinois, USA. URL: http://CRAN.R-project.org/package=psych. Version = 1.3.2.
Rosseel, Y. (2012). lavaan: An R Package for Structural Equation Modeling. Journal of Statistical Software, 48(2), 1–36. URL: http://www.jstatsoft.org/v48/i02/.
Wirth, R. J., & Edwards, M. C. (2007). Item factor analysis: Current approaches
and future directions. Psychological Methods, 12, 58–79. Retrieved November 21, 2013. Freely available online, URL: http://www.ncbi.nlm.nih.gov/pmc/articles/PMC3162326/. | Whether to use original or reverse coded items in factor analysis?
As gung said, recoding reverse-scored variables will only reverse the sign of their factor loadings, so the decision is only important because you will have to keep track of (and specify in anything y |
34,429 | How to determine the effect size of a Wilcoxon rank-sum test in R? | The estimator that corresponds to the Wilcoxon test is the Hodges-Lehmann estimator; it's returned by wilcox.test using the conf.int=TRUE option, under "difference in location".
For your example:
> wilcox.test(b~a,data=d, conf.int=TRUE)
Wilcoxon rank sum test
data: b by a
W = 355, p-value = 6.914e-06
alternative hypothesis: true location shift is not equal to 0
95 percent confidence interval:
0.008657301 0.021523993
sample estimates:
difference in location
0.01442617
For more on the Wilcoxon and the assumptions behind it, and what it actually tests for, and other nonparametric estimators, this document is (possibly) helpful:
www.stat.umn.edu/geyer/old03/5102/notes/rank.pdf | How to determine the effect size of a Wilcoxon rank-sum test in R? | The estimator that corresponds to the Wilcoxon test is the Hodges-Lehmann estimator; it's returned by wilcox.test using the conf.int=TRUE option, under "difference in location".
For your example:
> w | How to determine the effect size of a Wilcoxon rank-sum test in R?
The estimator that corresponds to the Wilcoxon test is the Hodges-Lehmann estimator; it's returned by wilcox.test using the conf.int=TRUE option, under "difference in location".
For your example:
> wilcox.test(b~a,data=d, conf.int=TRUE)
Wilcoxon rank sum test
data: b by a
W = 355, p-value = 6.914e-06
alternative hypothesis: true location shift is not equal to 0
95 percent confidence interval:
0.008657301 0.021523993
sample estimates:
difference in location
0.01442617
For more on the Wilcoxon and the assumptions behind it, and what it actually tests for, and other nonparametric estimators, this document is (possibly) helpful:
www.stat.umn.edu/geyer/old03/5102/notes/rank.pdf | How to determine the effect size of a Wilcoxon rank-sum test in R?
The estimator that corresponds to the Wilcoxon test is the Hodges-Lehmann estimator; it's returned by wilcox.test using the conf.int=TRUE option, under "difference in location".
For your example:
> w |
34,430 | How to determine the effect size of a Wilcoxon rank-sum test in R? | Get the z for your formula by
library(coin)
mydf <- as.data.frame(d)
wilcoxsign_test(b ~ a, data = mydf, distribution="exact")
and compute the effect size with your formula, setting N to 40 | How to determine the effect size of a Wilcoxon rank-sum test in R? | Get the z for your formula by
library(coin)
mydf <- as.data.frame(d)
wilcoxsign_test(b ~ a, data = mydf, distribution="exact")
and compute the effect size with your formula, setting N to 40 | How to determine the effect size of a Wilcoxon rank-sum test in R?
Get the z for your formula by
library(coin)
mydf <- as.data.frame(d)
wilcoxsign_test(b ~ a, data = mydf, distribution="exact")
and compute the effect size with your formula, setting N to 40 | How to determine the effect size of a Wilcoxon rank-sum test in R?
Get the z for your formula by
library(coin)
mydf <- as.data.frame(d)
wilcoxsign_test(b ~ a, data = mydf, distribution="exact")
and compute the effect size with your formula, setting N to 40 |
34,431 | Strange result of post-hoc test | Think of it this way - overall, there's a significant difference, but it's a little hard to say exactly which two are significantly different. Alternatively, consider the chances of having three p-values less than 0.1 (even though they aren't independent of each other) - pretty small, right? So, again overall, we might suspect something significant is in the data, without being able to tell exactly where.
Your small sample sizes don't help; they mean the powers of your tests are very low, and also severely constrain what sort of p-values you can get, as the following example shows:
> g1a <- rnorm(3,0,1)
> g2a <- rnorm(3,2.5,1)
> g3a <- rnorm(3,5,1)
>
> y <- list(g1a,g2a,g3a)
> y
[[1]]
[1] -2.31356435 -0.09903136 -0.42037052
[[2]]
[1] 2.806082 2.799857 3.383844
[[3]]
[1] 6.543636 6.845559 4.838341
> kruskal.test(y)
Kruskal-Wallis rank sum test
data: y
Kruskal-Wallis chi-squared = 7.2, df = 2, p-value = 0.02732
So far, so good. On to the three Wilcoxon tests:
> wilcox.test(g1a,g2a,paired=FALSE,exact=TRUE)
Wilcoxon rank sum test
data: g1a and g2a
W = 0, p-value = 0.1
alternative hypothesis: true location shift is not equal to 0
> wilcox.test(g2a,g3a,paired=FALSE,exact=TRUE)
Wilcoxon rank sum test
data: g2a and g3a
W = 0, p-value = 0.1
alternative hypothesis: true location shift is not equal to 0
> wilcox.test(g1a,g3a,paired=FALSE,exact=TRUE)
Wilcoxon rank sum test
data: g1a and g3a
W = 0, p-value = 0.1
alternative hypothesis: true location shift is not equal to 0
All three p-values at 0.1, but we can't get more extreme - W = 0 - so evidently we've hit a sample size imposed limit on p-values. | Strange result of post-hoc test | Think of it this way - overall, there's a significant difference, but it's a little hard to say exactly which two are significantly different. Alternatively, consider the chances of having three p-va | Strange result of post-hoc test
Think of it this way - overall, there's a significant difference, but it's a little hard to say exactly which two are significantly different. Alternatively, consider the chances of having three p-values less than 0.1 (even though they aren't independent of each other) - pretty small, right? So, again overall, we might suspect something significant is in the data, without being able to tell exactly where.
Your small sample sizes don't help; they mean the powers of your tests are very low, and also severely constrain what sort of p-values you can get, as the following example shows:
> g1a <- rnorm(3,0,1)
> g2a <- rnorm(3,2.5,1)
> g3a <- rnorm(3,5,1)
>
> y <- list(g1a,g2a,g3a)
> y
[[1]]
[1] -2.31356435 -0.09903136 -0.42037052
[[2]]
[1] 2.806082 2.799857 3.383844
[[3]]
[1] 6.543636 6.845559 4.838341
> kruskal.test(y)
Kruskal-Wallis rank sum test
data: y
Kruskal-Wallis chi-squared = 7.2, df = 2, p-value = 0.02732
So far, so good. On to the three Wilcoxon tests:
> wilcox.test(g1a,g2a,paired=FALSE,exact=TRUE)
Wilcoxon rank sum test
data: g1a and g2a
W = 0, p-value = 0.1
alternative hypothesis: true location shift is not equal to 0
> wilcox.test(g2a,g3a,paired=FALSE,exact=TRUE)
Wilcoxon rank sum test
data: g2a and g3a
W = 0, p-value = 0.1
alternative hypothesis: true location shift is not equal to 0
> wilcox.test(g1a,g3a,paired=FALSE,exact=TRUE)
Wilcoxon rank sum test
data: g1a and g3a
W = 0, p-value = 0.1
alternative hypothesis: true location shift is not equal to 0
All three p-values at 0.1, but we can't get more extreme - W = 0 - so evidently we've hit a sample size imposed limit on p-values. | Strange result of post-hoc test
Think of it this way - overall, there's a significant difference, but it's a little hard to say exactly which two are significantly different. Alternatively, consider the chances of having three p-va |
34,432 | Strange result of post-hoc test | Your mistake is in choosing the Wilcoxon/Mann-Whitney rank-sum tests as your post hoc tests following the rejection of the Kruskal-Wallis. The appropriate pos hoc test is Dunn's test* which properly (1) accounts for pooled variance assumed by the null hypothesis, and (2) uses the same ranks for your data as used in the construction of the Kruskal-Wallis test. The vanilla rank-sum tests entail separate estimates of variance for each pair-wise test, and ignore the rankings of the total data set as performed with a Kruskal-Wallis test.
Dunn's test is implemented for Stata in the dunntest package (within Stata type net describe dunntest, from(https://alexisdinno.com/stata)), and for R in the dunn.test package. Not sure about implementations in SAS.
Reference
Dunn, O. J. (1964). Multiple comparisons using rank sums. Technometrics, 6(3):241–252.
* There are some far less used alternatives to Dunn's test including the Conover-Iman (like Dunn, but based on the t distribution, rather than the z distribution, implemented for Stata in the conovertest package, and for R in the conover.test package), and the Dwass-Steel-Citchlow-Fligner tests.
The second issue, which arises even when using appropriate tests, is that you are making the false assumption that rejection of an omnibus null hypothesis means there must be at least one rejection of pairwise post hoc null hypothesis. | Strange result of post-hoc test | Your mistake is in choosing the Wilcoxon/Mann-Whitney rank-sum tests as your post hoc tests following the rejection of the Kruskal-Wallis. The appropriate pos hoc test is Dunn's test* which properly ( | Strange result of post-hoc test
Your mistake is in choosing the Wilcoxon/Mann-Whitney rank-sum tests as your post hoc tests following the rejection of the Kruskal-Wallis. The appropriate pos hoc test is Dunn's test* which properly (1) accounts for pooled variance assumed by the null hypothesis, and (2) uses the same ranks for your data as used in the construction of the Kruskal-Wallis test. The vanilla rank-sum tests entail separate estimates of variance for each pair-wise test, and ignore the rankings of the total data set as performed with a Kruskal-Wallis test.
Dunn's test is implemented for Stata in the dunntest package (within Stata type net describe dunntest, from(https://alexisdinno.com/stata)), and for R in the dunn.test package. Not sure about implementations in SAS.
Reference
Dunn, O. J. (1964). Multiple comparisons using rank sums. Technometrics, 6(3):241–252.
* There are some far less used alternatives to Dunn's test including the Conover-Iman (like Dunn, but based on the t distribution, rather than the z distribution, implemented for Stata in the conovertest package, and for R in the conover.test package), and the Dwass-Steel-Citchlow-Fligner tests.
The second issue, which arises even when using appropriate tests, is that you are making the false assumption that rejection of an omnibus null hypothesis means there must be at least one rejection of pairwise post hoc null hypothesis. | Strange result of post-hoc test
Your mistake is in choosing the Wilcoxon/Mann-Whitney rank-sum tests as your post hoc tests following the rejection of the Kruskal-Wallis. The appropriate pos hoc test is Dunn's test* which properly ( |
34,433 | Strange result of post-hoc test | The same thing can happen with the ANOVA test when normal distributions can be assumed. The differences beteween the three is apparently just large enough to see that they are different but not quite large enough to distinguish the difference between pairs. Note the overall p-value is a little less than 0.05 and each of the pairwise tests are all slightly larger than 0.05. With a larger sample size you might find that each one is different from the other two. But the inference here is that the medians differ but you aren't sure which pair(s) you can attribute this to. | Strange result of post-hoc test | The same thing can happen with the ANOVA test when normal distributions can be assumed. The differences beteween the three is apparently just large enough to see that they are different but not quite | Strange result of post-hoc test
The same thing can happen with the ANOVA test when normal distributions can be assumed. The differences beteween the three is apparently just large enough to see that they are different but not quite large enough to distinguish the difference between pairs. Note the overall p-value is a little less than 0.05 and each of the pairwise tests are all slightly larger than 0.05. With a larger sample size you might find that each one is different from the other two. But the inference here is that the medians differ but you aren't sure which pair(s) you can attribute this to. | Strange result of post-hoc test
The same thing can happen with the ANOVA test when normal distributions can be assumed. The differences beteween the three is apparently just large enough to see that they are different but not quite |
34,434 | Strange result of post-hoc test | This is a well-known problem in two-stage comparisons, observed e.g., already by Gabriel [Gabriel KR (1969) Simultaneous test procedures - some theory of multiple comparisons.
The Annals Mathematical Statistics 40(1):224-250]. | Strange result of post-hoc test | This is a well-known problem in two-stage comparisons, observed e.g., already by Gabriel [Gabriel KR (1969) Simultaneous test procedures - some theory of multiple comparisons.
The Annals Mathematical | Strange result of post-hoc test
This is a well-known problem in two-stage comparisons, observed e.g., already by Gabriel [Gabriel KR (1969) Simultaneous test procedures - some theory of multiple comparisons.
The Annals Mathematical Statistics 40(1):224-250]. | Strange result of post-hoc test
This is a well-known problem in two-stage comparisons, observed e.g., already by Gabriel [Gabriel KR (1969) Simultaneous test procedures - some theory of multiple comparisons.
The Annals Mathematical |
34,435 | Test randomness of a generated password? | On top of Daniel's great suggestion to use the information measures, you can consider breaking down the characters into groups to overcome the limitation of having to deal with way too many combinations. A natural breakdown is to capital letters (26), lower case letters (26), numbers (10), and other symbols (5-15 depending on implementation). So instead of having 70 independent symbols, you can deal with groups that have probabilities 26/70, 26/70, 10/70 and 8/70.
Alternatively, you can consider the transition probabilities from one character to the next. The password "blah273blah" would imply the transition probabilities "lower case -> lower case" of 6/10, "number -> number" 2/10, "lower case -> number" of 1/10, and "number -> lower case" of 1/10. All other probabilities are zeroes. These should be compared to the uniform transition probabilities (given above), although arguably Pearson $\chi^2$ will hardly work well with so many zero cells. I guess this is an extension of the run test for binary events. I am sure a multinomial extension exists and is applicable to this situation.
In any case, you need to have a reference distribution of whatever "test statistic" you will end up with, which can be obtained by simulation from your own reliable source of random passwords. It is arguably better to use the true random numbers for this purpose, e.g., from http://www.random.org. | Test randomness of a generated password? | On top of Daniel's great suggestion to use the information measures, you can consider breaking down the characters into groups to overcome the limitation of having to deal with way too many combinatio | Test randomness of a generated password?
On top of Daniel's great suggestion to use the information measures, you can consider breaking down the characters into groups to overcome the limitation of having to deal with way too many combinations. A natural breakdown is to capital letters (26), lower case letters (26), numbers (10), and other symbols (5-15 depending on implementation). So instead of having 70 independent symbols, you can deal with groups that have probabilities 26/70, 26/70, 10/70 and 8/70.
Alternatively, you can consider the transition probabilities from one character to the next. The password "blah273blah" would imply the transition probabilities "lower case -> lower case" of 6/10, "number -> number" 2/10, "lower case -> number" of 1/10, and "number -> lower case" of 1/10. All other probabilities are zeroes. These should be compared to the uniform transition probabilities (given above), although arguably Pearson $\chi^2$ will hardly work well with so many zero cells. I guess this is an extension of the run test for binary events. I am sure a multinomial extension exists and is applicable to this situation.
In any case, you need to have a reference distribution of whatever "test statistic" you will end up with, which can be obtained by simulation from your own reliable source of random passwords. It is arguably better to use the true random numbers for this purpose, e.g., from http://www.random.org. | Test randomness of a generated password?
On top of Daniel's great suggestion to use the information measures, you can consider breaking down the characters into groups to overcome the limitation of having to deal with way too many combinatio |
34,436 | Test randomness of a generated password? | When considering random generators and random number generators for security purposes you have to be extremely careful. To answer your question, there are many tests that you can carry out on RNGs, for example see the links offered here: http://csrc.nist.gov/groups/ST/toolkit/rng/batteries_stats_test.html
Please note that I am assuming that you are actually asking about "how to test random number generators for password generators" as opposed to the question "how can I measure the randomness (or entropy) of a given random array of bits" - which has been answered above.
Note that a random number generated can be easily used to generate passwords: generate several bytes of data and transform this data into the password using some transformation of your choice.
I wish to draw your attention to the notion of cryptographically secure RNGs. While the Mersenne Twister is generally considered as one of the better RNGs you can use because it is efficient and has very large periods before repetition, etc..., it is NOT considered to be cryptographically secure.
A cryptographically secure RNG algorithm is important for security sensitive applications (such as password generators). Without this property, an attacker can infer the current state of your RNG and be able to predict your next password.
Now, RNG algorithms are all pseudorandom (unless you use a truly random source such as http://www.random.org or a Quantum Random Number generator card). Given knowledge about the current state of the algorithm, we can predict perfectly the next "random" number. An attacker that infers this state would therefore be able to predict your next "random" password.
Besides the myriad of tests for a good Pseudo-Random Number Generator, also make sure that you check that it actually is cryptographically secure. Otherwise go for a true random number generator source. | Test randomness of a generated password? | When considering random generators and random number generators for security purposes you have to be extremely careful. To answer your question, there are many tests that you can carry out on RNGs, f | Test randomness of a generated password?
When considering random generators and random number generators for security purposes you have to be extremely careful. To answer your question, there are many tests that you can carry out on RNGs, for example see the links offered here: http://csrc.nist.gov/groups/ST/toolkit/rng/batteries_stats_test.html
Please note that I am assuming that you are actually asking about "how to test random number generators for password generators" as opposed to the question "how can I measure the randomness (or entropy) of a given random array of bits" - which has been answered above.
Note that a random number generated can be easily used to generate passwords: generate several bytes of data and transform this data into the password using some transformation of your choice.
I wish to draw your attention to the notion of cryptographically secure RNGs. While the Mersenne Twister is generally considered as one of the better RNGs you can use because it is efficient and has very large periods before repetition, etc..., it is NOT considered to be cryptographically secure.
A cryptographically secure RNG algorithm is important for security sensitive applications (such as password generators). Without this property, an attacker can infer the current state of your RNG and be able to predict your next password.
Now, RNG algorithms are all pseudorandom (unless you use a truly random source such as http://www.random.org or a Quantum Random Number generator card). Given knowledge about the current state of the algorithm, we can predict perfectly the next "random" number. An attacker that infers this state would therefore be able to predict your next "random" password.
Besides the myriad of tests for a good Pseudo-Random Number Generator, also make sure that you check that it actually is cryptographically secure. Otherwise go for a true random number generator source. | Test randomness of a generated password?
When considering random generators and random number generators for security purposes you have to be extremely careful. To answer your question, there are many tests that you can carry out on RNGs, f |
34,437 | Test randomness of a generated password? | Information theoretic entropy is often viewed as a 'measure' of how 'random' a random variable is. This would not tell you how random a specific password is, but would tell you how random the method for creating the password is. In general, the uniform distribution gives the highest entropy. In the context of the password constructor (for a fixed password length), this corresponds to picking each character independently and uniformly. Note that the longer the password length allowed, the more random it will be (and thus will have higher entropy).
Another way to look at this is to assume nothing is known about the method of constructing the passwords (i.e. from the point of view of a hacker). Then, one could put a prior on the space of possible passwords. A smart prior would probably make passwords that contain english words more likely than strings of random characters, as people tend to make their passwords something meaningful to them since this makes it easier to remember. The 'measure' or 'randomness' would then be the probability assigned to the given password under your prior. If you had access to a number of passwords created by the generator, you could use this data to update your prior to a more accurate distribution.
However, if you are only shown one password, there is very little information to go on. It would be difficult to make a judgement of its 'randomness' unless more data on the generator could be collected. | Test randomness of a generated password? | Information theoretic entropy is often viewed as a 'measure' of how 'random' a random variable is. This would not tell you how random a specific password is, but would tell you how random the method f | Test randomness of a generated password?
Information theoretic entropy is often viewed as a 'measure' of how 'random' a random variable is. This would not tell you how random a specific password is, but would tell you how random the method for creating the password is. In general, the uniform distribution gives the highest entropy. In the context of the password constructor (for a fixed password length), this corresponds to picking each character independently and uniformly. Note that the longer the password length allowed, the more random it will be (and thus will have higher entropy).
Another way to look at this is to assume nothing is known about the method of constructing the passwords (i.e. from the point of view of a hacker). Then, one could put a prior on the space of possible passwords. A smart prior would probably make passwords that contain english words more likely than strings of random characters, as people tend to make their passwords something meaningful to them since this makes it easier to remember. The 'measure' or 'randomness' would then be the probability assigned to the given password under your prior. If you had access to a number of passwords created by the generator, you could use this data to update your prior to a more accurate distribution.
However, if you are only shown one password, there is very little information to go on. It would be difficult to make a judgement of its 'randomness' unless more data on the generator could be collected. | Test randomness of a generated password?
Information theoretic entropy is often viewed as a 'measure' of how 'random' a random variable is. This would not tell you how random a specific password is, but would tell you how random the method f |
34,438 | What is the distribution of the sum of independent normal variables? | To sum up the long series of comments:
Yes, your working is correct. More generally, if $X$ and $Y$ are independent
normal random variables with means $\mu_X$, $\mu_Y$ respectively
and variances $\sigma_X^2$ and $\sigma_Y^2$ respectively, then
$aX+bY$ is a normal random variable with mean $a\mu_X+b\mu_Y$
and variance $a^2\sigma_X^2 + b^2\sigma_Y^2$.
The various comments by whuber, cardinal, myself, and the Answer
by Tai Galili are all occasioned by the fact that there are at least
three different conventions for interpreting $X \sim N(a,b)$ as
a normal random variable. Usually, $a$ is the mean $\mu_X$
but $b$ can have different meanings.
$X \sim N(a,b)$ means that the standard deviation of $X$ is $b$.
(This is the convention you are using).
$X \sim N(a,b)$ means that the variance of $X$ is $b$.
$X \sim N(a,b)$ means that the variance of $X$ is $\dfrac{1}{b}$.
Fortunately, $X \sim N(0,1)$ (which is what you asked about)
means that $X$ is a standard
normal random variable in all three of the above conventions! | What is the distribution of the sum of independent normal variables? | To sum up the long series of comments:
Yes, your working is correct. More generally, if $X$ and $Y$ are independent
normal random variables with means $\mu_X$, $\mu_Y$ respectively
and variances $\si | What is the distribution of the sum of independent normal variables?
To sum up the long series of comments:
Yes, your working is correct. More generally, if $X$ and $Y$ are independent
normal random variables with means $\mu_X$, $\mu_Y$ respectively
and variances $\sigma_X^2$ and $\sigma_Y^2$ respectively, then
$aX+bY$ is a normal random variable with mean $a\mu_X+b\mu_Y$
and variance $a^2\sigma_X^2 + b^2\sigma_Y^2$.
The various comments by whuber, cardinal, myself, and the Answer
by Tai Galili are all occasioned by the fact that there are at least
three different conventions for interpreting $X \sim N(a,b)$ as
a normal random variable. Usually, $a$ is the mean $\mu_X$
but $b$ can have different meanings.
$X \sim N(a,b)$ means that the standard deviation of $X$ is $b$.
(This is the convention you are using).
$X \sim N(a,b)$ means that the variance of $X$ is $b$.
$X \sim N(a,b)$ means that the variance of $X$ is $\dfrac{1}{b}$.
Fortunately, $X \sim N(0,1)$ (which is what you asked about)
means that $X$ is a standard
normal random variable in all three of the above conventions! | What is the distribution of the sum of independent normal variables?
To sum up the long series of comments:
Yes, your working is correct. More generally, if $X$ and $Y$ are independent
normal random variables with means $\mu_X$, $\mu_Y$ respectively
and variances $\si |
34,439 | Three-level hierarchical regression using lmer | Not enough reputation to comment, so I'll post this as an answer.
There are a number of questions like this already around. you might want to look at this message.
However, (1|group1/group2) should work with all but very old versions of lme4, so if that gives you an error, there is probably something wrong with the way you set up your data. Note that once your data are correctly set up, (1|group1/group2) and (1|group1) + (1|group2) should give the same results. | Three-level hierarchical regression using lmer | Not enough reputation to comment, so I'll post this as an answer.
There are a number of questions like this already around. you might want to look at this message.
However, (1|group1/group2) should wo | Three-level hierarchical regression using lmer
Not enough reputation to comment, so I'll post this as an answer.
There are a number of questions like this already around. you might want to look at this message.
However, (1|group1/group2) should work with all but very old versions of lme4, so if that gives you an error, there is probably something wrong with the way you set up your data. Note that once your data are correctly set up, (1|group1/group2) and (1|group1) + (1|group2) should give the same results. | Three-level hierarchical regression using lmer
Not enough reputation to comment, so I'll post this as an answer.
There are a number of questions like this already around. you might want to look at this message.
However, (1|group1/group2) should wo |
34,440 | Three-level hierarchical regression using lmer | Based on your dataset and the above comments as well as your other post on run time problem with lmer, you'll need to specify that choicenum and ipnum are factors or lmer will treat them as covariates. This is probably what was causing your error message that group1:group2 is an interaction. I ran the model on your dataset as described and it worked fine.
dataset$choicenum <- as.factor(dataset$choicenum)
dataset$ipnum <- as.factor(dataset$ipnum)
mymodel <- lmer(ene ~ videocond + choicenum + (1|ipnum/choicenum),data=dataset) | Three-level hierarchical regression using lmer | Based on your dataset and the above comments as well as your other post on run time problem with lmer, you'll need to specify that choicenum and ipnum are factors or lmer will treat them as covariates | Three-level hierarchical regression using lmer
Based on your dataset and the above comments as well as your other post on run time problem with lmer, you'll need to specify that choicenum and ipnum are factors or lmer will treat them as covariates. This is probably what was causing your error message that group1:group2 is an interaction. I ran the model on your dataset as described and it worked fine.
dataset$choicenum <- as.factor(dataset$choicenum)
dataset$ipnum <- as.factor(dataset$ipnum)
mymodel <- lmer(ene ~ videocond + choicenum + (1|ipnum/choicenum),data=dataset) | Three-level hierarchical regression using lmer
Based on your dataset and the above comments as well as your other post on run time problem with lmer, you'll need to specify that choicenum and ipnum are factors or lmer will treat them as covariates |
34,441 | Calculating mean age from grouped census data | As @Bernd has pointed out, 2.5 really is the midpoint of the 0 to 4 year age group, etc. However, using midpoints at either end of the population distribution introduces bias. For instance, the midpoint of the 80 - 90 year group is approximately 83, because most people in this group are nearer 80 than 90. If this nicety matters (and it perhaps it does, if you are agonizing over a half-year difference), read on.
Demographers make their estimates using various methods of monotonic interpolation. A classic method is Sprague's Formula. This is well described in their literature; for an overview see Hubert Vaughan, Symmetry in Central Polynomial Interpolation, JIA 80, 1954. This method as published requires equally-spaced age groups but it can be adapted to variable spacings. @Rob Hyndman was the co-author of a nice paper on monotonic splines (Smith, Hyndman, & Wood, Spline Interpolation for Demographic Variables: The Monotonicity Problem, J. Pop. Res. 21 #1, 2004). The paper mentions R code for the "Hyman filter." It is still available on Rob's Web site.
Once you have an interpolated age distribution you can compute moments (and any other properties) according to the standard definitions. For instance, the mean is estimated by numerically integrating the age with respect to the distribution. | Calculating mean age from grouped census data | As @Bernd has pointed out, 2.5 really is the midpoint of the 0 to 4 year age group, etc. However, using midpoints at either end of the population distribution introduces bias. For instance, the midp | Calculating mean age from grouped census data
As @Bernd has pointed out, 2.5 really is the midpoint of the 0 to 4 year age group, etc. However, using midpoints at either end of the population distribution introduces bias. For instance, the midpoint of the 80 - 90 year group is approximately 83, because most people in this group are nearer 80 than 90. If this nicety matters (and it perhaps it does, if you are agonizing over a half-year difference), read on.
Demographers make their estimates using various methods of monotonic interpolation. A classic method is Sprague's Formula. This is well described in their literature; for an overview see Hubert Vaughan, Symmetry in Central Polynomial Interpolation, JIA 80, 1954. This method as published requires equally-spaced age groups but it can be adapted to variable spacings. @Rob Hyndman was the co-author of a nice paper on monotonic splines (Smith, Hyndman, & Wood, Spline Interpolation for Demographic Variables: The Monotonicity Problem, J. Pop. Res. 21 #1, 2004). The paper mentions R code for the "Hyman filter." It is still available on Rob's Web site.
Once you have an interpolated age distribution you can compute moments (and any other properties) according to the standard definitions. For instance, the mean is estimated by numerically integrating the age with respect to the distribution. | Calculating mean age from grouped census data
As @Bernd has pointed out, 2.5 really is the midpoint of the 0 to 4 year age group, etc. However, using midpoints at either end of the population distribution introduces bias. For instance, the midp |
34,442 | Calculating mean age from grouped census data | The 0-4 years group refers to the following age interval: $0 \leq x < 5$, i.e. a child which is 4 years and 364 days old still belongs to this group. So, let's compute the midpoint for that range:
> ((365+365+365+365+364)/2)/365
[1] 2.49863 | Calculating mean age from grouped census data | The 0-4 years group refers to the following age interval: $0 \leq x < 5$, i.e. a child which is 4 years and 364 days old still belongs to this group. So, let's compute the midpoint for that range:
> ( | Calculating mean age from grouped census data
The 0-4 years group refers to the following age interval: $0 \leq x < 5$, i.e. a child which is 4 years and 364 days old still belongs to this group. So, let's compute the midpoint for that range:
> ((365+365+365+365+364)/2)/365
[1] 2.49863 | Calculating mean age from grouped census data
The 0-4 years group refers to the following age interval: $0 \leq x < 5$, i.e. a child which is 4 years and 364 days old still belongs to this group. So, let's compute the midpoint for that range:
> ( |
34,443 | When estimating variance, why do unbiased estimators divide by n-1 yet maximum likelihood estimates divide by n? | The answer to your question is contained within your question.
When choosing an estimator for a parameter, you should ask yourself,
what property would you like your estimator to have:
Robustness
Unbiasedness
Have the distributional properties of a MLE
Consistency
Asymptotically normal
You know the population mean, but the variance is unknown
If your estimator is the one that is divided by (n-1), then you want an
unbiased estimtor of the variance. If your estimator is the one that is
divided by n, then you have an MLE estimator. Of course, when n is large;
dividing by either (n-1) or n will give you approximately the same results
and the estimator will be approximately unbiased and have the properties
of all MLE estimators. | When estimating variance, why do unbiased estimators divide by n-1 yet maximum likelihood estimates | The answer to your question is contained within your question.
When choosing an estimator for a parameter, you should ask yourself,
what property would you like your estimator to have:
Robustness
Un | When estimating variance, why do unbiased estimators divide by n-1 yet maximum likelihood estimates divide by n?
The answer to your question is contained within your question.
When choosing an estimator for a parameter, you should ask yourself,
what property would you like your estimator to have:
Robustness
Unbiasedness
Have the distributional properties of a MLE
Consistency
Asymptotically normal
You know the population mean, but the variance is unknown
If your estimator is the one that is divided by (n-1), then you want an
unbiased estimtor of the variance. If your estimator is the one that is
divided by n, then you have an MLE estimator. Of course, when n is large;
dividing by either (n-1) or n will give you approximately the same results
and the estimator will be approximately unbiased and have the properties
of all MLE estimators. | When estimating variance, why do unbiased estimators divide by n-1 yet maximum likelihood estimates
The answer to your question is contained within your question.
When choosing an estimator for a parameter, you should ask yourself,
what property would you like your estimator to have:
Robustness
Un |
34,444 | When estimating variance, why do unbiased estimators divide by n-1 yet maximum likelihood estimates divide by n? | The MLE is indeed found through division by n. However, MLE's are not guaranteed to be unbiased. So there is no contradiction in the fact that the unbiased estimator (divided by n-1) is used.
In practice, for reasonable sample sizes, it should not make a big difference anyway. | When estimating variance, why do unbiased estimators divide by n-1 yet maximum likelihood estimates | The MLE is indeed found through division by n. However, MLE's are not guaranteed to be unbiased. So there is no contradiction in the fact that the unbiased estimator (divided by n-1) is used.
In pract | When estimating variance, why do unbiased estimators divide by n-1 yet maximum likelihood estimates divide by n?
The MLE is indeed found through division by n. However, MLE's are not guaranteed to be unbiased. So there is no contradiction in the fact that the unbiased estimator (divided by n-1) is used.
In practice, for reasonable sample sizes, it should not make a big difference anyway. | When estimating variance, why do unbiased estimators divide by n-1 yet maximum likelihood estimates
The MLE is indeed found through division by n. However, MLE's are not guaranteed to be unbiased. So there is no contradiction in the fact that the unbiased estimator (divided by n-1) is used.
In pract |
34,445 | When estimating variance, why do unbiased estimators divide by n-1 yet maximum likelihood estimates divide by n? | one is unbiased estimator
one is maximum likelihood estimator
they are not contradictory, just serving different objectives
if you think about any distribution, the maximum point in the likelihood function is not necessarily the mean value | When estimating variance, why do unbiased estimators divide by n-1 yet maximum likelihood estimates | one is unbiased estimator
one is maximum likelihood estimator
they are not contradictory, just serving different objectives
if you think about any distribution, the maximum point in the likelihood fu | When estimating variance, why do unbiased estimators divide by n-1 yet maximum likelihood estimates divide by n?
one is unbiased estimator
one is maximum likelihood estimator
they are not contradictory, just serving different objectives
if you think about any distribution, the maximum point in the likelihood function is not necessarily the mean value | When estimating variance, why do unbiased estimators divide by n-1 yet maximum likelihood estimates
one is unbiased estimator
one is maximum likelihood estimator
they are not contradictory, just serving different objectives
if you think about any distribution, the maximum point in the likelihood fu |
34,446 | Adjusting sample weights in AdaBoost | mpq has already explained boosting in plain english.
A picture may substitute a thousand words ... (stolen from R. Meir and G. Rätsch. An introduction to boosting and leveraging)
Image remark: In the 1st Iteration the classifier based on all datapoints classifies all points correctly except those in x<0.2/y>0.8 and the point around 0.4/0.55 (see the circles in the second picture). In the second iteration exactly those points gain a higher weight so that the classifier based on that weighted sample classifies them correctly (2nd Iteration, added dashed line). The combined classifiers (i.e. "the combination of the dashed lines") result in the classifier represent by the green line. Now the second classifier produces another missclassifications (x in [0.5,0.6] / y in [0.3,0.4]), which gain more focus in the third iteration and so on and so on. In every step, the combined classifier gets closer and closer to the best shape (although not continuously). The final classifier (i.e. the combination of all single classifiers) in the 100th Iteration classifies all points correctly.
Now it should be more clear how boosting works. Two questions remain about the algorithmic details.
1. How to estimate missclassifications ?
In every iteration, only a sample of the training data available in this iteration is used for training the classifier, the rest is used for estimating the error / the missclassifications.
2. How to apply the weights ?
You can do this in the following ways:
You sample the data using an appropriate sample algorithm which can handle weights (e.g. weighted random sampling or rejection sampling) and build classification model on that sample. The resulting sample contains missclassified examples with a higher probability than correctly classified ones, hence the model learned on that sample is forced to concentrate on the missclassified part of the data space.
You use a classification model which is capable of handling such weights implicitly like e.g. Decision Trees. DT simply count. So instead of using 1 as counter/increment if an example with a certain predictor and class values is presented, it uses the specified weight w. If w = 0, the example is practically ignored. As a result, the missclassified examples have more influence on the class probability estimated by the model.
Regarding your document example:
Imagine a certain word separates the classes perfectly, but it only appears in a certain part of the data space (i.e. near the decision boundary). Then the word has no power to separate all documents (hence it's expressiveness for the whole dataset is low), but only those near the boundary (where the expressiveness is high). Hence the documents containing this word will be misclassified in the first iteration(s), and hence gain more focus in later applications. Restricting the dataspace to the boundary (by document weighting), your classifier will/should detect the expressiveness of the word and classify the examples in that subspace correctly.
(God help me, I can't think of a more precise example. If the muse later decides to spend some time with me, I will edit my answer).
Note that boosting assumes weak classifiers. E.g. Boosting applied together with NaiveBayes will have no significant effect (at least regarding my experience).
edit: Added some details on the algorithm and explanation for the picture. | Adjusting sample weights in AdaBoost | mpq has already explained boosting in plain english.
A picture may substitute a thousand words ... (stolen from R. Meir and G. Rätsch. An introduction to boosting and leveraging)
Image remark: In th | Adjusting sample weights in AdaBoost
mpq has already explained boosting in plain english.
A picture may substitute a thousand words ... (stolen from R. Meir and G. Rätsch. An introduction to boosting and leveraging)
Image remark: In the 1st Iteration the classifier based on all datapoints classifies all points correctly except those in x<0.2/y>0.8 and the point around 0.4/0.55 (see the circles in the second picture). In the second iteration exactly those points gain a higher weight so that the classifier based on that weighted sample classifies them correctly (2nd Iteration, added dashed line). The combined classifiers (i.e. "the combination of the dashed lines") result in the classifier represent by the green line. Now the second classifier produces another missclassifications (x in [0.5,0.6] / y in [0.3,0.4]), which gain more focus in the third iteration and so on and so on. In every step, the combined classifier gets closer and closer to the best shape (although not continuously). The final classifier (i.e. the combination of all single classifiers) in the 100th Iteration classifies all points correctly.
Now it should be more clear how boosting works. Two questions remain about the algorithmic details.
1. How to estimate missclassifications ?
In every iteration, only a sample of the training data available in this iteration is used for training the classifier, the rest is used for estimating the error / the missclassifications.
2. How to apply the weights ?
You can do this in the following ways:
You sample the data using an appropriate sample algorithm which can handle weights (e.g. weighted random sampling or rejection sampling) and build classification model on that sample. The resulting sample contains missclassified examples with a higher probability than correctly classified ones, hence the model learned on that sample is forced to concentrate on the missclassified part of the data space.
You use a classification model which is capable of handling such weights implicitly like e.g. Decision Trees. DT simply count. So instead of using 1 as counter/increment if an example with a certain predictor and class values is presented, it uses the specified weight w. If w = 0, the example is practically ignored. As a result, the missclassified examples have more influence on the class probability estimated by the model.
Regarding your document example:
Imagine a certain word separates the classes perfectly, but it only appears in a certain part of the data space (i.e. near the decision boundary). Then the word has no power to separate all documents (hence it's expressiveness for the whole dataset is low), but only those near the boundary (where the expressiveness is high). Hence the documents containing this word will be misclassified in the first iteration(s), and hence gain more focus in later applications. Restricting the dataspace to the boundary (by document weighting), your classifier will/should detect the expressiveness of the word and classify the examples in that subspace correctly.
(God help me, I can't think of a more precise example. If the muse later decides to spend some time with me, I will edit my answer).
Note that boosting assumes weak classifiers. E.g. Boosting applied together with NaiveBayes will have no significant effect (at least regarding my experience).
edit: Added some details on the algorithm and explanation for the picture. | Adjusting sample weights in AdaBoost
mpq has already explained boosting in plain english.
A picture may substitute a thousand words ... (stolen from R. Meir and G. Rätsch. An introduction to boosting and leveraging)
Image remark: In th |
34,447 | Adjusting sample weights in AdaBoost | The weights should be applied in calculating of the cost function when training the classifier.
For example, assume our cost function is sum-of-square, weighted sample means when we calculate cost function, each item of sum-of-square will multiply its sample weight(former misclassified samples will have a large weight, so training process of this classifier concentrate more on those samples). | Adjusting sample weights in AdaBoost | The weights should be applied in calculating of the cost function when training the classifier.
For example, assume our cost function is sum-of-square, weighted sample means when we calculate cost fu | Adjusting sample weights in AdaBoost
The weights should be applied in calculating of the cost function when training the classifier.
For example, assume our cost function is sum-of-square, weighted sample means when we calculate cost function, each item of sum-of-square will multiply its sample weight(former misclassified samples will have a large weight, so training process of this classifier concentrate more on those samples). | Adjusting sample weights in AdaBoost
The weights should be applied in calculating of the cost function when training the classifier.
For example, assume our cost function is sum-of-square, weighted sample means when we calculate cost fu |
34,448 | How to check if modified genetic algorithm is significantly better than the original? | You would not use a paired sample t-test. The reason for this is that a particular random seed cannot be assumed to bias the outcome of both algorithms in the same way, even if that random seed is only used to generate the population and not for later operations such as mutation and selection. In other words, its logically possible that, under one algorithm, a given population will evolve better than the average for that algorithm, but will perform in the opposite way under another. If you have reason to believe that there is a similar connection between seed and performance for both algorithms, you can test this using a Pearson correlation coefficient to compare each seed's performance on both tests. By default, however, I would assume that there is no connection, especially if you have reasonably large populations.
As far as running more than 10 times, of course more samples are always better, though your computational resources obviously may be a limiting factor. It could be a good idea to generate a power curve, which will show you the relationship between the size of difference needed for statistical significance at you're alpha level, and the SD and n. In other words, at a given n and SD, how big does the difference have to be? http://moon.ouhsc.edu/dthompso/CDM/power/hypoth.htm <-- see bottom of page for power curve info.
Finally, if you are running a genetic algorithm that actually has a defined stopping point, as yours does, you can just do a plain unpaired t-test on the number of generations needed to find the solution. Otherwise, quantifying algorithm performance tends to get a bit trickier
As far as pitfalls, and generalizability of algorithm efficiency to other problems, you really cannot take effectiveness of your algorithm for granted when porting it to other problems. In my experience, genetic algorithms usually have to be tweaked quite a bit for each new problem that you apply them to. Having said that, depending on how diverse your set of 8 tests is, they may give you some indication of how generalizable your results are, and within which scope of applications they are generalizable. | How to check if modified genetic algorithm is significantly better than the original? | You would not use a paired sample t-test. The reason for this is that a particular random seed cannot be assumed to bias the outcome of both algorithms in the same way, even if that random seed is onl | How to check if modified genetic algorithm is significantly better than the original?
You would not use a paired sample t-test. The reason for this is that a particular random seed cannot be assumed to bias the outcome of both algorithms in the same way, even if that random seed is only used to generate the population and not for later operations such as mutation and selection. In other words, its logically possible that, under one algorithm, a given population will evolve better than the average for that algorithm, but will perform in the opposite way under another. If you have reason to believe that there is a similar connection between seed and performance for both algorithms, you can test this using a Pearson correlation coefficient to compare each seed's performance on both tests. By default, however, I would assume that there is no connection, especially if you have reasonably large populations.
As far as running more than 10 times, of course more samples are always better, though your computational resources obviously may be a limiting factor. It could be a good idea to generate a power curve, which will show you the relationship between the size of difference needed for statistical significance at you're alpha level, and the SD and n. In other words, at a given n and SD, how big does the difference have to be? http://moon.ouhsc.edu/dthompso/CDM/power/hypoth.htm <-- see bottom of page for power curve info.
Finally, if you are running a genetic algorithm that actually has a defined stopping point, as yours does, you can just do a plain unpaired t-test on the number of generations needed to find the solution. Otherwise, quantifying algorithm performance tends to get a bit trickier
As far as pitfalls, and generalizability of algorithm efficiency to other problems, you really cannot take effectiveness of your algorithm for granted when porting it to other problems. In my experience, genetic algorithms usually have to be tweaked quite a bit for each new problem that you apply them to. Having said that, depending on how diverse your set of 8 tests is, they may give you some indication of how generalizable your results are, and within which scope of applications they are generalizable. | How to check if modified genetic algorithm is significantly better than the original?
You would not use a paired sample t-test. The reason for this is that a particular random seed cannot be assumed to bias the outcome of both algorithms in the same way, even if that random seed is onl |
34,449 | How to check if modified genetic algorithm is significantly better than the original? | I used paired t-test to compare my algorithm to GA, although I had about 200 test cases. You can use a non-parametric alternative such as the Wilcoxon Ranks Test. Regardless of what you use to test the statistical significance, bear in mind the "real-life" significance. If the performance improvement that your algorithm provides is below measurement limits, or below any practical interest, then even if it is statistically significant (i.e. "good" p-value), it doesn't matter. | How to check if modified genetic algorithm is significantly better than the original? | I used paired t-test to compare my algorithm to GA, although I had about 200 test cases. You can use a non-parametric alternative such as the Wilcoxon Ranks Test. Regardless of what you use to test t | How to check if modified genetic algorithm is significantly better than the original?
I used paired t-test to compare my algorithm to GA, although I had about 200 test cases. You can use a non-parametric alternative such as the Wilcoxon Ranks Test. Regardless of what you use to test the statistical significance, bear in mind the "real-life" significance. If the performance improvement that your algorithm provides is below measurement limits, or below any practical interest, then even if it is statistically significant (i.e. "good" p-value), it doesn't matter. | How to check if modified genetic algorithm is significantly better than the original?
I used paired t-test to compare my algorithm to GA, although I had about 200 test cases. You can use a non-parametric alternative such as the Wilcoxon Ranks Test. Regardless of what you use to test t |
34,450 | How to check if modified genetic algorithm is significantly better than the original? | It might not be what you want to hear, but from what I've seen the new algorithm is just compared to the old one on benchmark functions.
E.g. as done here: Efficient Natural Evolution Strategies, (Schaul, Sun Yi, Wierstra, Schmidhuber) | How to check if modified genetic algorithm is significantly better than the original? | It might not be what you want to hear, but from what I've seen the new algorithm is just compared to the old one on benchmark functions.
E.g. as done here: Efficient Natural Evolution Strategies, (Sch | How to check if modified genetic algorithm is significantly better than the original?
It might not be what you want to hear, but from what I've seen the new algorithm is just compared to the old one on benchmark functions.
E.g. as done here: Efficient Natural Evolution Strategies, (Schaul, Sun Yi, Wierstra, Schmidhuber) | How to check if modified genetic algorithm is significantly better than the original?
It might not be what you want to hear, but from what I've seen the new algorithm is just compared to the old one on benchmark functions.
E.g. as done here: Efficient Natural Evolution Strategies, (Sch |
34,451 | How to check if modified genetic algorithm is significantly better than the original? | I used a t-test (non-paired, ie independent) to compare 10 runs of my genetic algorithm with 10 runs of a hill climbing algorithm. I did one t-test to see if there was a significant difference between fitness of best solutions found, and another t-test to see if there was a significant difference between completion times. I used this online calculator to do it. The cut and paste option is very handy. | How to check if modified genetic algorithm is significantly better than the original? | I used a t-test (non-paired, ie independent) to compare 10 runs of my genetic algorithm with 10 runs of a hill climbing algorithm. I did one t-test to see if there was a significant difference between | How to check if modified genetic algorithm is significantly better than the original?
I used a t-test (non-paired, ie independent) to compare 10 runs of my genetic algorithm with 10 runs of a hill climbing algorithm. I did one t-test to see if there was a significant difference between fitness of best solutions found, and another t-test to see if there was a significant difference between completion times. I used this online calculator to do it. The cut and paste option is very handy. | How to check if modified genetic algorithm is significantly better than the original?
I used a t-test (non-paired, ie independent) to compare 10 runs of my genetic algorithm with 10 runs of a hill climbing algorithm. I did one t-test to see if there was a significant difference between |
34,452 | How to check if modified genetic algorithm is significantly better than the original? | I suspect that if the specifics of the statistical test you use matter, then the algorithms aren't much different.
Two comments:
the tests should be set up so that approximately the same amount of time is used by each algorithm. You might try varying the time allowed -- it is conceivable that the order changes with different time horizons.
the test suite should contain problems that are of the type that you care about. Whatever pair of algorithms you have, you can find problems for which one is better than the other. | How to check if modified genetic algorithm is significantly better than the original? | I suspect that if the specifics of the statistical test you use matter, then the algorithms aren't much different.
Two comments:
the tests should be set up so that approximately the same amount of ti | How to check if modified genetic algorithm is significantly better than the original?
I suspect that if the specifics of the statistical test you use matter, then the algorithms aren't much different.
Two comments:
the tests should be set up so that approximately the same amount of time is used by each algorithm. You might try varying the time allowed -- it is conceivable that the order changes with different time horizons.
the test suite should contain problems that are of the type that you care about. Whatever pair of algorithms you have, you can find problems for which one is better than the other. | How to check if modified genetic algorithm is significantly better than the original?
I suspect that if the specifics of the statistical test you use matter, then the algorithms aren't much different.
Two comments:
the tests should be set up so that approximately the same amount of ti |
34,453 | Minimum tickets required for specified probability of winning lottery | I should really ask what your thoughts are so far on this. This problem is very closely related to the "birthday problem". The easiest way to do these problems is to count the possible ways of either winning or losing. Usually one is much easier to do than the other, so the key is to find the right one. Before we get into the actual calculation, let's start with some heuristics.
Heuristics: Let $n$ be the total number of tickets and $m$ be the number of winning tickets. In this case $n = 50\,000\,000$ and $m = 5\,000\,000$. When $n$ is very large then purchasing multiple distinguishable tickets is almost the same as sampling with replacement from the population of tickets.
Let's suppose that, instead of having to purchase $k$ separate tickets, we purchased a ticket, looked to see if it was a winner and then returned it to the lottery. We then repeat this procedure where each such draw is independent from all of the previous ones. Then the probability of winning after purchasing $k$ tickets is just
$$
\Pr( \text{we won} \mid \text{purchased $k$ tickets} ) = 1 - \left(\frac{n-m}{n}\right)^k .
$$
For our case then, the right-hand side is $1 - (9/10)^k$ and so we set this equal to $1/2$ and solve for $k$ in order to get the number of tickets.
But, we're actually sampling without replacement. Below, we'll go through the development, with the point being that the heuristics above are more than good enough for the present problem and many similar ones.
There are $50\,000\,000$ tickets. Of these $5\,000\,000$ are winning ones and $45\,000\,000$ are losing ones. We seek
$$
\Pr(\text{we win}) \geq 1/2 \>,
$$
or, equivalently,
$$
\Pr(\text{we lose}) \leq 1/2 .
$$
The probability that we lose is simply the probability that we hold none of the winning tickets. Let $k$ be the number of tickets we purchase. If $k = 1$, then $\Pr(\text{we lose}) = 45\,000\,000 / 50\,000\,000 = 9/10 \geq 1/2$, so that won't do. If we choose two tickets then there are $45\,000\,000 \cdot 44\,999\,999$ ways to choose two losing tickets and there are $50\,000\,000 \cdot 49\,999\,999$ ways to choose any two tickets. So,
$$
\Pr( \text{we lose} ) = \frac{45\,000\,000 \cdot 44\,999\,999}{50\,000\,000 \cdot 49\,999\,999} \approx 0.9^2 = 0.81.
$$
Let's generalize now. Let $m$ be the number of winning tickets and $n$ the total number of tickets, as before. Then, if we purchase $k$ tickets,
$$
\Pr(\text{we lose}) = \frac{(n-m) (n-m-1) \cdots (n-m-k+1)}{n (n-1) \cdots (n-k+1)} .
$$
It would be tedious, but we can now just start plugging in values for $k$ until we get the probability below $1/2$. We can use a "trick", though, to get close to the answer, especially when $n$ is very large and $m$ is relatively small with respect to $n$.
Note that $\frac{n-m-k}{n-k} \leq \frac{n-m}{n}$ for all $k < m < n$. Hence
$$
\Pr(\text{we lose}) = \frac{(n-m) (n-m-1) \cdots (n-m-k+1)}{n (n-1) \cdots (n-k+1)} \leq \left(1 - \frac{m}{n} \right)^k ,
$$
and so we need to solve the equation $\left(1 - \frac{m}{n} \right)^k = \frac{1}{2}$ for $k$. But,
$$
k = \frac{\log \frac{1}{2}}{\log (1 - \frac{m}{n})} \>,
$$
and so when $m/n = 1/10$, we get $k \approx 6.58$.
So, $k = 7$ tickets ought to do the trick. If you plug it in to the exact equation above, you'll get that
$$
\Pr( \text{we win} \mid \text{k=7} ) \approx 52.2\%
$$ | Minimum tickets required for specified probability of winning lottery | I should really ask what your thoughts are so far on this. This problem is very closely related to the "birthday problem". The easiest way to do these problems is to count the possible ways of either | Minimum tickets required for specified probability of winning lottery
I should really ask what your thoughts are so far on this. This problem is very closely related to the "birthday problem". The easiest way to do these problems is to count the possible ways of either winning or losing. Usually one is much easier to do than the other, so the key is to find the right one. Before we get into the actual calculation, let's start with some heuristics.
Heuristics: Let $n$ be the total number of tickets and $m$ be the number of winning tickets. In this case $n = 50\,000\,000$ and $m = 5\,000\,000$. When $n$ is very large then purchasing multiple distinguishable tickets is almost the same as sampling with replacement from the population of tickets.
Let's suppose that, instead of having to purchase $k$ separate tickets, we purchased a ticket, looked to see if it was a winner and then returned it to the lottery. We then repeat this procedure where each such draw is independent from all of the previous ones. Then the probability of winning after purchasing $k$ tickets is just
$$
\Pr( \text{we won} \mid \text{purchased $k$ tickets} ) = 1 - \left(\frac{n-m}{n}\right)^k .
$$
For our case then, the right-hand side is $1 - (9/10)^k$ and so we set this equal to $1/2$ and solve for $k$ in order to get the number of tickets.
But, we're actually sampling without replacement. Below, we'll go through the development, with the point being that the heuristics above are more than good enough for the present problem and many similar ones.
There are $50\,000\,000$ tickets. Of these $5\,000\,000$ are winning ones and $45\,000\,000$ are losing ones. We seek
$$
\Pr(\text{we win}) \geq 1/2 \>,
$$
or, equivalently,
$$
\Pr(\text{we lose}) \leq 1/2 .
$$
The probability that we lose is simply the probability that we hold none of the winning tickets. Let $k$ be the number of tickets we purchase. If $k = 1$, then $\Pr(\text{we lose}) = 45\,000\,000 / 50\,000\,000 = 9/10 \geq 1/2$, so that won't do. If we choose two tickets then there are $45\,000\,000 \cdot 44\,999\,999$ ways to choose two losing tickets and there are $50\,000\,000 \cdot 49\,999\,999$ ways to choose any two tickets. So,
$$
\Pr( \text{we lose} ) = \frac{45\,000\,000 \cdot 44\,999\,999}{50\,000\,000 \cdot 49\,999\,999} \approx 0.9^2 = 0.81.
$$
Let's generalize now. Let $m$ be the number of winning tickets and $n$ the total number of tickets, as before. Then, if we purchase $k$ tickets,
$$
\Pr(\text{we lose}) = \frac{(n-m) (n-m-1) \cdots (n-m-k+1)}{n (n-1) \cdots (n-k+1)} .
$$
It would be tedious, but we can now just start plugging in values for $k$ until we get the probability below $1/2$. We can use a "trick", though, to get close to the answer, especially when $n$ is very large and $m$ is relatively small with respect to $n$.
Note that $\frac{n-m-k}{n-k} \leq \frac{n-m}{n}$ for all $k < m < n$. Hence
$$
\Pr(\text{we lose}) = \frac{(n-m) (n-m-1) \cdots (n-m-k+1)}{n (n-1) \cdots (n-k+1)} \leq \left(1 - \frac{m}{n} \right)^k ,
$$
and so we need to solve the equation $\left(1 - \frac{m}{n} \right)^k = \frac{1}{2}$ for $k$. But,
$$
k = \frac{\log \frac{1}{2}}{\log (1 - \frac{m}{n})} \>,
$$
and so when $m/n = 1/10$, we get $k \approx 6.58$.
So, $k = 7$ tickets ought to do the trick. If you plug it in to the exact equation above, you'll get that
$$
\Pr( \text{we win} \mid \text{k=7} ) \approx 52.2\%
$$ | Minimum tickets required for specified probability of winning lottery
I should really ask what your thoughts are so far on this. This problem is very closely related to the "birthday problem". The easiest way to do these problems is to count the possible ways of either |
34,454 | Why is the average of the highest value from 100 draws from a normal distribution different from the 98th percentile of the normal distribution? | The maximum does not have a normal distribution. Its cdf is $\Phi(x)^{100}$ where $\Phi(x)$ is the standard normal cdf. In general the moments of this distribution are tricky to obtain analytically. There is an ancient paper on this by Tippett (Biometrika, 1925). | Why is the average of the highest value from 100 draws from a normal distribution different from the | The maximum does not have a normal distribution. Its cdf is $\Phi(x)^{100}$ where $\Phi(x)$ is the standard normal cdf. In general the moments of this distribution are tricky to obtain analytically. T | Why is the average of the highest value from 100 draws from a normal distribution different from the 98th percentile of the normal distribution?
The maximum does not have a normal distribution. Its cdf is $\Phi(x)^{100}$ where $\Phi(x)$ is the standard normal cdf. In general the moments of this distribution are tricky to obtain analytically. There is an ancient paper on this by Tippett (Biometrika, 1925). | Why is the average of the highest value from 100 draws from a normal distribution different from the
The maximum does not have a normal distribution. Its cdf is $\Phi(x)^{100}$ where $\Phi(x)$ is the standard normal cdf. In general the moments of this distribution are tricky to obtain analytically. T |
34,455 | Why is the average of the highest value from 100 draws from a normal distribution different from the 98th percentile of the normal distribution? | I asked about why there was a difference between the average of the maximum of 100 draws from a random normal distribution and the 98th percentile of the normal distribution. The answer I received from Rob Hyndman was mostly acceptable, but too technically dense to accept without revision. I was left wondering whether it was possible to provide an answer that explains in intuitively understandable plain language why these two values are not equal.
Ultimately, my answer may be unsatisfyingly circular; but conceptually, the reason max(rnorm(100)) tends to be higher than qnorm(.98) is, in short, because on average the highest of 100 random normally distributed scores will on occasion exceed its expected value. However this distortion is non-symmetrical, since when low scores are drawn they are unlikely to end up being the highest out of the 100 scores. Each independent draw is a new chance to exceed the expected value, or to be ignored because the obtained value isn't the maximum of the 100 drawn values. For a visual demonstration compare the histogram of the maximum of 20 values to the histogram of the maximum of 100 values, the difference in skew, especially in the tails, is stark.
I arrived at this answer indirectly while working through a related problem/question I had asked in the comments. Specifically, if I found that someone's test scores were ranked in the 95th percentile, I'd expect that on average if I put them in a room with 99 other test takers that their rank would average out to be 95. This turns out to be more or less the case (R code)...
for (i in 1:NSIM)
{
rank[i] <- seq(1,100)[order(c(qnorm(.95),rnorm(99)))==1]
}
summary(rank)
As an extension of that logic, I had likewise been expecting that if I took 100 people in a room and selected the person with 95th highest score, then took another 99 people and had them take the same test, that on average the selected person would be ranked 95th in the new group. But this is not the case (R code)...
for (i in 1:NSIM)
{
testtakers <- rnorm(100)
testtakers <- testtakers[order(testtakers)]
testtakers <- testtakers[order(testtakers)]
ranked95 <- testtakers[95]
rank[i] <- seq(1,100)[order(c(ranked95,rnorm(99)))==1]
}
summary(rank)
What makes the first case different from the second case is that in the first case the individual's score places them at exactly the 95th percentile. In the second case their score may turn out to be somewhat higher or lower than the true 95th percentile. Since they can not possibly rank higher than 100, groups that produce a rank 95 score that is actually at the 99th percentile or higher can not offset (in terms of average rank) those cases where the rank 95 score is much lower than the true 90th percentile. If you look at the histograms for the two rank vectors provided in this answer it is easy to see that there is a restriction of range in the upper ends that is a consequence of this process I have been describing. | Why is the average of the highest value from 100 draws from a normal distribution different from the | I asked about why there was a difference between the average of the maximum of 100 draws from a random normal distribution and the 98th percentile of the normal distribution. The answer I received fr | Why is the average of the highest value from 100 draws from a normal distribution different from the 98th percentile of the normal distribution?
I asked about why there was a difference between the average of the maximum of 100 draws from a random normal distribution and the 98th percentile of the normal distribution. The answer I received from Rob Hyndman was mostly acceptable, but too technically dense to accept without revision. I was left wondering whether it was possible to provide an answer that explains in intuitively understandable plain language why these two values are not equal.
Ultimately, my answer may be unsatisfyingly circular; but conceptually, the reason max(rnorm(100)) tends to be higher than qnorm(.98) is, in short, because on average the highest of 100 random normally distributed scores will on occasion exceed its expected value. However this distortion is non-symmetrical, since when low scores are drawn they are unlikely to end up being the highest out of the 100 scores. Each independent draw is a new chance to exceed the expected value, or to be ignored because the obtained value isn't the maximum of the 100 drawn values. For a visual demonstration compare the histogram of the maximum of 20 values to the histogram of the maximum of 100 values, the difference in skew, especially in the tails, is stark.
I arrived at this answer indirectly while working through a related problem/question I had asked in the comments. Specifically, if I found that someone's test scores were ranked in the 95th percentile, I'd expect that on average if I put them in a room with 99 other test takers that their rank would average out to be 95. This turns out to be more or less the case (R code)...
for (i in 1:NSIM)
{
rank[i] <- seq(1,100)[order(c(qnorm(.95),rnorm(99)))==1]
}
summary(rank)
As an extension of that logic, I had likewise been expecting that if I took 100 people in a room and selected the person with 95th highest score, then took another 99 people and had them take the same test, that on average the selected person would be ranked 95th in the new group. But this is not the case (R code)...
for (i in 1:NSIM)
{
testtakers <- rnorm(100)
testtakers <- testtakers[order(testtakers)]
testtakers <- testtakers[order(testtakers)]
ranked95 <- testtakers[95]
rank[i] <- seq(1,100)[order(c(ranked95,rnorm(99)))==1]
}
summary(rank)
What makes the first case different from the second case is that in the first case the individual's score places them at exactly the 95th percentile. In the second case their score may turn out to be somewhat higher or lower than the true 95th percentile. Since they can not possibly rank higher than 100, groups that produce a rank 95 score that is actually at the 99th percentile or higher can not offset (in terms of average rank) those cases where the rank 95 score is much lower than the true 90th percentile. If you look at the histograms for the two rank vectors provided in this answer it is easy to see that there is a restriction of range in the upper ends that is a consequence of this process I have been describing. | Why is the average of the highest value from 100 draws from a normal distribution different from the
I asked about why there was a difference between the average of the maximum of 100 draws from a random normal distribution and the 98th percentile of the normal distribution. The answer I received fr |
34,456 | Why is the average of the highest value from 100 draws from a normal distribution different from the 98th percentile of the normal distribution? | There are two issues: one is the skewness in the distribution of the top value which you have identified; the other is that you should not be looking at 98th percentile.
Instead of the mean of the highest value, consider the median. This is easier as it is an order statistic. The probability that all 100 values are less than than the quantile $q$ is $q^{100}$ so the median quantile for the maximum will be when $q^{100}=\frac12$, i.e. $q=\dfrac{1}{2^{1/100}}\approx 0.99309$, rather more than $0.98$. But because of the skewness, you would expect the mean to be higher still.
As an illustration in R
require(matrixStats)
NSIM <- 100001
cases <- 100
set.seed(1)
simmat <- matrix(rnorm(cases*NSIM), ncol=cases)
tops <- rowMaxs(simmat)
c(mean(tops), median(tops), qnorm(1/2^(1/cases)))
c(pnorm(mean(tops)), pnorm(median(tops)), 1/2^(1/cases))
which gives
> c(mean(tops), median(tops), qnorm(1/2^(1/cases)))
[1] 2.508940 2.464794 2.462038
> c(pnorm(mean(tops)), pnorm(median(tops)), 1/2^(1/cases))
[1] 0.9939453 0.9931454 0.9930925 | Why is the average of the highest value from 100 draws from a normal distribution different from the | There are two issues: one is the skewness in the distribution of the top value which you have identified; the other is that you should not be looking at 98th percentile.
Instead of the mean of the hig | Why is the average of the highest value from 100 draws from a normal distribution different from the 98th percentile of the normal distribution?
There are two issues: one is the skewness in the distribution of the top value which you have identified; the other is that you should not be looking at 98th percentile.
Instead of the mean of the highest value, consider the median. This is easier as it is an order statistic. The probability that all 100 values are less than than the quantile $q$ is $q^{100}$ so the median quantile for the maximum will be when $q^{100}=\frac12$, i.e. $q=\dfrac{1}{2^{1/100}}\approx 0.99309$, rather more than $0.98$. But because of the skewness, you would expect the mean to be higher still.
As an illustration in R
require(matrixStats)
NSIM <- 100001
cases <- 100
set.seed(1)
simmat <- matrix(rnorm(cases*NSIM), ncol=cases)
tops <- rowMaxs(simmat)
c(mean(tops), median(tops), qnorm(1/2^(1/cases)))
c(pnorm(mean(tops)), pnorm(median(tops)), 1/2^(1/cases))
which gives
> c(mean(tops), median(tops), qnorm(1/2^(1/cases)))
[1] 2.508940 2.464794 2.462038
> c(pnorm(mean(tops)), pnorm(median(tops)), 1/2^(1/cases))
[1] 0.9939453 0.9931454 0.9930925 | Why is the average of the highest value from 100 draws from a normal distribution different from the
There are two issues: one is the skewness in the distribution of the top value which you have identified; the other is that you should not be looking at 98th percentile.
Instead of the mean of the hig |
34,457 | Why is the average of the highest value from 100 draws from a normal distribution different from the 98th percentile of the normal distribution? | Just to expand on Rob's answer a bit, suppose that we want to know the cumulative distribution function (CDF) of the highest value of $N$ independent draws from a standard normal distribution, $X_1, ..., X_N$. Call this highest value $Y_1$, the first order statistic. Then the CDF is:
$$ \begin{align*}P(Y_1 < x) &= P(\max(X_1, ..., X_N) < x) \\
&= P(X_1 < x, ..., X_N < x)
\\
&= P(X_1 < x) \cdot \cdot \cdot P(X_N < x) \\
&= P(X < x)^{100},
\end{align*} $$
where the second line follows by independence of the draws. We can also write this as
$$F_{Y_1}(x) = F_X(x)^{100},$$
where $F$ represents the CDF and $f$ represents the PDF of the random variable given as a subscript to this function.
Rob uses the standard notation that $\Phi(x)$ is defined as $P(X < x)$ for a standard normal---i.e., $\Phi(x)$ is the standard normal CDF.
The probability density function (PDF) of the first order statistic is just the derivative of the CDF with respect to $X$:
$$f_{Y_1}(x) = 100 \cdot F_X(x)^{99} f_X(x)$$
the CDF at $x$ raised to 99 (that is, $N-1$) times the PDF at $x$ times 100 (that is, $N$). | Why is the average of the highest value from 100 draws from a normal distribution different from the | Just to expand on Rob's answer a bit, suppose that we want to know the cumulative distribution function (CDF) of the highest value of $N$ independent draws from a standard normal distribution, $X_1, . | Why is the average of the highest value from 100 draws from a normal distribution different from the 98th percentile of the normal distribution?
Just to expand on Rob's answer a bit, suppose that we want to know the cumulative distribution function (CDF) of the highest value of $N$ independent draws from a standard normal distribution, $X_1, ..., X_N$. Call this highest value $Y_1$, the first order statistic. Then the CDF is:
$$ \begin{align*}P(Y_1 < x) &= P(\max(X_1, ..., X_N) < x) \\
&= P(X_1 < x, ..., X_N < x)
\\
&= P(X_1 < x) \cdot \cdot \cdot P(X_N < x) \\
&= P(X < x)^{100},
\end{align*} $$
where the second line follows by independence of the draws. We can also write this as
$$F_{Y_1}(x) = F_X(x)^{100},$$
where $F$ represents the CDF and $f$ represents the PDF of the random variable given as a subscript to this function.
Rob uses the standard notation that $\Phi(x)$ is defined as $P(X < x)$ for a standard normal---i.e., $\Phi(x)$ is the standard normal CDF.
The probability density function (PDF) of the first order statistic is just the derivative of the CDF with respect to $X$:
$$f_{Y_1}(x) = 100 \cdot F_X(x)^{99} f_X(x)$$
the CDF at $x$ raised to 99 (that is, $N-1$) times the PDF at $x$ times 100 (that is, $N$). | Why is the average of the highest value from 100 draws from a normal distribution different from the
Just to expand on Rob's answer a bit, suppose that we want to know the cumulative distribution function (CDF) of the highest value of $N$ independent draws from a standard normal distribution, $X_1, . |
34,458 | The combinatorics of the clumsy dishwasher | $\frac{21}{5^5}$ is the probability a pre-identified individual smashed $4$ or $5$ plates (assuming each plate was independently equally likely to be smashed by anybody), and is $P(X\ge 4)$ when $X \sim Bin(5,\frac15)$. As the books seems to say.
$\frac{21}{5^4} = \frac{105}{5^5}$ is five times that and is the probability somebody smashed $4$ or $5$ plates, since it is impossible that two people each smashed $4$ or $5$ of the $5$ smashed plates. As your second attempt seems to say. Note that $5(4{5 \choose 4}+{5 \choose 5})=105$
Your $\frac{125}{5^5}$ looks harder to justify, especially your $p^5_4 =120$ for $4$ plates smashed by somebody and $1$ by someone else. In that case there are $5$ people who could be the big smasher and $4$ other people the little smasher and $5$ possible plates being smashed by the little smasher, so $5\times 4 \times 5=100$ possibilities, to which you later add $5$ to get $105$. | The combinatorics of the clumsy dishwasher | $\frac{21}{5^5}$ is the probability a pre-identified individual smashed $4$ or $5$ plates (assuming each plate was independently equally likely to be smashed by anybody), and is $P(X\ge 4)$ when $X \s | The combinatorics of the clumsy dishwasher
$\frac{21}{5^5}$ is the probability a pre-identified individual smashed $4$ or $5$ plates (assuming each plate was independently equally likely to be smashed by anybody), and is $P(X\ge 4)$ when $X \sim Bin(5,\frac15)$. As the books seems to say.
$\frac{21}{5^4} = \frac{105}{5^5}$ is five times that and is the probability somebody smashed $4$ or $5$ plates, since it is impossible that two people each smashed $4$ or $5$ of the $5$ smashed plates. As your second attempt seems to say. Note that $5(4{5 \choose 4}+{5 \choose 5})=105$
Your $\frac{125}{5^5}$ looks harder to justify, especially your $p^5_4 =120$ for $4$ plates smashed by somebody and $1$ by someone else. In that case there are $5$ people who could be the big smasher and $4$ other people the little smasher and $5$ possible plates being smashed by the little smasher, so $5\times 4 \times 5=100$ possibilities, to which you later add $5$ to get $105$. | The combinatorics of the clumsy dishwasher
$\frac{21}{5^5}$ is the probability a pre-identified individual smashed $4$ or $5$ plates (assuming each plate was independently equally likely to be smashed by anybody), and is $P(X\ge 4)$ when $X \s |
34,459 | The combinatorics of the clumsy dishwasher | I am going to generalise your problem to allow you to deal with any number of dishwashers and broken dishes. (Also, I interpret the problem as being a condtional probability given a fixed number of broken dishes; the answer will be different if you don't condition on this.) I'll show the relevant combinatorial analysis below, but first I'll introduce you to the general distribution you are dealing with and show you some facilities for computing values from this distribution in the general case (i.e., allowing for any number of dishes and dishwashers).
This question requires you to compute a probability from the maxcount distribution (see related question). In general, we can consider a set of observed values $U_1,...,U_n \sim \text{IID U} \{ 1,...,m \}$ and we are interested in the distribution of the maxcount statistic, defined by:
$$M_n \equiv \max_{k=1,...,m} \sum_{i=1}^n \mathbb{I}(U_i = k).$$
In the context of your problem the value $n$ is the number of dishwashers and the number $m$ is the number of broken dishes, and you are seeking the probability $\mathbb{P}(M_n \geqslant 4)$. This can be computed combinatorially (see below) or it can be computing using the general method for computing the probability mass function for the maxcount distribution.
An algorithm to compute the cumulative distribution function of the maxount distribution can be found in Bonetti, Cirillo and Ogay (2019) (pp. 6-7). The algorithm is quite complicated, but fortunately for you, all the relevant probability functions have already been programmed in the occupancy package in R. You can compute the distribution of interest and the specific probability you want using the commands below. The probability of interest is $\mathbb{P}(M_n \geqslant 4) = 0.0336$.
#Compute the maxcount probabilities
library(occupancy)
PROBS <- dmaxcount(0:5, size = 5, space = 5)
names(PROBS) <- 0:5
#Compute the probablity of interest
sum(PROBS[5:6])
[1] 0.0336
#Plot the maxcount probability mass function
barplot(PROBS, col = 'blue',
xlab = 'Maximum number of broken dishes (for a single dishwasher)',
ylab = 'Probability')
Combinatorial analysis: The above allows you to compute values from the maxcount distribution in general. However, in the present case you have $n=m=5$, and so the parameters of the distribution are small enough that it is feasible to compute the probability of interest using a simple combinatorial analysis. There are $5^5 = 3125$ possible allocations of $n=5$ dishwashers to $m=5$ broken dishes. Out of those allocations, we have:
$$\begin{align}
\text{Number of allocations } (M_n = 4)
&= 5 \times 4 \times {5 \choose (4,1,0,0,0) } = 100, \\[12pt]
\text{Number of allocations } (M_n = 5)
&= 5 \times {5 \choose (5,0,0,0,0) } = 5. \\[6pt]
\end{align}$$
This gives the probability:
$$\mathbb{P}(M_n \geqslant 4) = \frac{100+5}{3125} = \frac{105}{3125} = 0.0336.$$ | The combinatorics of the clumsy dishwasher | I am going to generalise your problem to allow you to deal with any number of dishwashers and broken dishes. (Also, I interpret the problem as being a condtional probability given a fixed number of b | The combinatorics of the clumsy dishwasher
I am going to generalise your problem to allow you to deal with any number of dishwashers and broken dishes. (Also, I interpret the problem as being a condtional probability given a fixed number of broken dishes; the answer will be different if you don't condition on this.) I'll show the relevant combinatorial analysis below, but first I'll introduce you to the general distribution you are dealing with and show you some facilities for computing values from this distribution in the general case (i.e., allowing for any number of dishes and dishwashers).
This question requires you to compute a probability from the maxcount distribution (see related question). In general, we can consider a set of observed values $U_1,...,U_n \sim \text{IID U} \{ 1,...,m \}$ and we are interested in the distribution of the maxcount statistic, defined by:
$$M_n \equiv \max_{k=1,...,m} \sum_{i=1}^n \mathbb{I}(U_i = k).$$
In the context of your problem the value $n$ is the number of dishwashers and the number $m$ is the number of broken dishes, and you are seeking the probability $\mathbb{P}(M_n \geqslant 4)$. This can be computed combinatorially (see below) or it can be computing using the general method for computing the probability mass function for the maxcount distribution.
An algorithm to compute the cumulative distribution function of the maxount distribution can be found in Bonetti, Cirillo and Ogay (2019) (pp. 6-7). The algorithm is quite complicated, but fortunately for you, all the relevant probability functions have already been programmed in the occupancy package in R. You can compute the distribution of interest and the specific probability you want using the commands below. The probability of interest is $\mathbb{P}(M_n \geqslant 4) = 0.0336$.
#Compute the maxcount probabilities
library(occupancy)
PROBS <- dmaxcount(0:5, size = 5, space = 5)
names(PROBS) <- 0:5
#Compute the probablity of interest
sum(PROBS[5:6])
[1] 0.0336
#Plot the maxcount probability mass function
barplot(PROBS, col = 'blue',
xlab = 'Maximum number of broken dishes (for a single dishwasher)',
ylab = 'Probability')
Combinatorial analysis: The above allows you to compute values from the maxcount distribution in general. However, in the present case you have $n=m=5$, and so the parameters of the distribution are small enough that it is feasible to compute the probability of interest using a simple combinatorial analysis. There are $5^5 = 3125$ possible allocations of $n=5$ dishwashers to $m=5$ broken dishes. Out of those allocations, we have:
$$\begin{align}
\text{Number of allocations } (M_n = 4)
&= 5 \times 4 \times {5 \choose (4,1,0,0,0) } = 100, \\[12pt]
\text{Number of allocations } (M_n = 5)
&= 5 \times {5 \choose (5,0,0,0,0) } = 5. \\[6pt]
\end{align}$$
This gives the probability:
$$\mathbb{P}(M_n \geqslant 4) = \frac{100+5}{3125} = \frac{105}{3125} = 0.0336.$$ | The combinatorics of the clumsy dishwasher
I am going to generalise your problem to allow you to deal with any number of dishwashers and broken dishes. (Also, I interpret the problem as being a condtional probability given a fixed number of b |
34,460 | The combinatorics of the clumsy dishwasher | Far simpler approach: 1/5
Why?
with 4 breakages due to the same individual.
This means that it is not a random chance for each plate, and how many plates any dishwasher breaks is not distributed in any normal statistical distribution, since we are concerned with a posterior evaluation, aka everything has already happened. Someone already broke at least 4 of those 5 plates.
Any given dishwasher either has broken zero, one, four or five plates, with four or five having the same "value" for us (="true"), as well as zero and one being the same for us: that dishwasher has not broken "4 or more plates". ( a dishwasher breaking 2 or 3 plates is not possible since we know someone broke 4 or more out of the 5 total breaks)
Also, we know that there is a dishwasher who has broken 4 or more plates, so the only question is whether the one dishwasher we're inquiring about is also the one that broke multiple plates, which is a 1 in 5 chance assuming fair distribution.
[I know that this seems too simple, please tell me where I went wrong] | The combinatorics of the clumsy dishwasher | Far simpler approach: 1/5
Why?
with 4 breakages due to the same individual.
This means that it is not a random chance for each plate, and how many plates any dishwasher breaks is not distributed in | The combinatorics of the clumsy dishwasher
Far simpler approach: 1/5
Why?
with 4 breakages due to the same individual.
This means that it is not a random chance for each plate, and how many plates any dishwasher breaks is not distributed in any normal statistical distribution, since we are concerned with a posterior evaluation, aka everything has already happened. Someone already broke at least 4 of those 5 plates.
Any given dishwasher either has broken zero, one, four or five plates, with four or five having the same "value" for us (="true"), as well as zero and one being the same for us: that dishwasher has not broken "4 or more plates". ( a dishwasher breaking 2 or 3 plates is not possible since we know someone broke 4 or more out of the 5 total breaks)
Also, we know that there is a dishwasher who has broken 4 or more plates, so the only question is whether the one dishwasher we're inquiring about is also the one that broke multiple plates, which is a 1 in 5 chance assuming fair distribution.
[I know that this seems too simple, please tell me where I went wrong] | The combinatorics of the clumsy dishwasher
Far simpler approach: 1/5
Why?
with 4 breakages due to the same individual.
This means that it is not a random chance for each plate, and how many plates any dishwasher breaks is not distributed in |
34,461 | Are all log-likelihood functions twice differentiable? | In short: no. Note that, to maximise the log likelihood we frequently use differentiation, but in fact to truly maximise a function we need to consider several types of points
Stationary/turning points (when $\frac{\partial \ell}{\partial \theta} = 0$)
Singular points (e.g. where the function cannot be differentiated)
End points - this only applies on a finite interval $[a,b]$, possibly with one of $a$ or $b$ being infinite in modulus
Of course, that is provided that the parameter of interest is actually continuous.
Let's consider the Laplace distribution with density
$$p(x \mid \mu, b) = \frac{1}{2b} \exp \left\{ -\frac{|x - \mu|}{b} \right\}$$
Then the log-likelihood is, given a sample $\mathbf{x}$ of size $n$
$$ \ell(\mu, b \mid \mathbf{x} ) = -n \log (2b) - \sum_{i=1}^n \frac{|x_i - \mu|}{b}$$
It can be shown that $\hat{b} = \frac{1}{n} \sum_{i=1}^n |x_i - \hat{\mu}|$. The difficult bit is finding $\hat{\mu}$.
Now if we differentiate w.r.t. $\mu$ then we need to differentiate $|x_i - \mu|$. If $\mu \neq x_i$ for any $x_i$ then $\frac{\partial \ell}{\partial \mu} = - \sum_{i=1}^n\text{sign}(x_i - \mu)$ which can be zero only if $n$ is even (but still might be non zero!). At any $\mu \in \mathbf{x}$ the gradient does not exist!.
Now for any $\mu$ that is equal to one of the $x_i$, the log likelihood will not be differentiable at these points. Now assume $n$ is odd, it can be shown that $\hat{\mu}$ is actually the sample median. The sample median will be one of the $x_i$ (the middle $x_i$ when the $x_i$ are in order). Therefore, the m.l.e. is at one of the non-differentiable points - a singular point!
How can we guarantee that the log-likelihood is differentiable? I don't think we can actually force this to be true unless we choose a log-likelihood that is twice differentiable. I'd view this as a modelling choice or an assumption. Rather than something we can guarantee. Other assumptions might imply a twice differentiable log-likelihood, but in general I can't see how we would end up with such a log-likelihood. | Are all log-likelihood functions twice differentiable? | In short: no. Note that, to maximise the log likelihood we frequently use differentiation, but in fact to truly maximise a function we need to consider several types of points
Stationary/turning poin | Are all log-likelihood functions twice differentiable?
In short: no. Note that, to maximise the log likelihood we frequently use differentiation, but in fact to truly maximise a function we need to consider several types of points
Stationary/turning points (when $\frac{\partial \ell}{\partial \theta} = 0$)
Singular points (e.g. where the function cannot be differentiated)
End points - this only applies on a finite interval $[a,b]$, possibly with one of $a$ or $b$ being infinite in modulus
Of course, that is provided that the parameter of interest is actually continuous.
Let's consider the Laplace distribution with density
$$p(x \mid \mu, b) = \frac{1}{2b} \exp \left\{ -\frac{|x - \mu|}{b} \right\}$$
Then the log-likelihood is, given a sample $\mathbf{x}$ of size $n$
$$ \ell(\mu, b \mid \mathbf{x} ) = -n \log (2b) - \sum_{i=1}^n \frac{|x_i - \mu|}{b}$$
It can be shown that $\hat{b} = \frac{1}{n} \sum_{i=1}^n |x_i - \hat{\mu}|$. The difficult bit is finding $\hat{\mu}$.
Now if we differentiate w.r.t. $\mu$ then we need to differentiate $|x_i - \mu|$. If $\mu \neq x_i$ for any $x_i$ then $\frac{\partial \ell}{\partial \mu} = - \sum_{i=1}^n\text{sign}(x_i - \mu)$ which can be zero only if $n$ is even (but still might be non zero!). At any $\mu \in \mathbf{x}$ the gradient does not exist!.
Now for any $\mu$ that is equal to one of the $x_i$, the log likelihood will not be differentiable at these points. Now assume $n$ is odd, it can be shown that $\hat{\mu}$ is actually the sample median. The sample median will be one of the $x_i$ (the middle $x_i$ when the $x_i$ are in order). Therefore, the m.l.e. is at one of the non-differentiable points - a singular point!
How can we guarantee that the log-likelihood is differentiable? I don't think we can actually force this to be true unless we choose a log-likelihood that is twice differentiable. I'd view this as a modelling choice or an assumption. Rather than something we can guarantee. Other assumptions might imply a twice differentiable log-likelihood, but in general I can't see how we would end up with such a log-likelihood. | Are all log-likelihood functions twice differentiable?
In short: no. Note that, to maximise the log likelihood we frequently use differentiation, but in fact to truly maximise a function we need to consider several types of points
Stationary/turning poin |
34,462 | How many standard deviations around the mean do I need to guarantee covering at least one sample | You should use different notation for the sample mean and standard deviation, for example $\bar x$ and $s$. There are no guarantees for the location of sample observations compared to the population mean and standard deviation, just probabilities.
There is a slight issue if your calculation of the sample standard deviation $s$ uses the $\frac1{n-1}$ expression of $s= \sqrt{\frac{1}{n-1}\sum(x_i-\bar x)^2}$ rather than $s= \sqrt{\frac{1}{n}\sum(x_i-\bar x)^2}$, as for $n=1$ the $\frac1{n-1}$ expression will give $\frac00$. When $n=1$, you have the observation equal to the sample mean.
Ignoring that issue and using either expression for $s$, you can say that for all $n>0$, at least one sample observations will be in the interval $[\bar x -s, \bar x +s]$. If none were then you would have $\sum(x_i-\bar x)^2 > \sum_i s^2 = n s^2$, leading to the contradictory $s>s$.
All the sample observations will be in the interval $[\bar x -\sqrt{n}s, \bar x +\sqrt{n}s]$. If any observation $x_j$ was outside that interval you would have $\sum(x_i-\bar x)^2 > (x_j-\bar x)^2 > ns^2$ again leading to the contradictory $s>s$.
Both $[\bar x -s, \bar x +s]$ and $[\bar x -\sqrt{n}s, \bar x +\sqrt{n}s]$ are narrower than $[\bar x -ns, \bar x +ns]$ for $n>0$, with equality only when $n=1$. | How many standard deviations around the mean do I need to guarantee covering at least one sample | You should use different notation for the sample mean and standard deviation, for example $\bar x$ and $s$. There are no guarantees for the location of sample observations compared to the population | How many standard deviations around the mean do I need to guarantee covering at least one sample
You should use different notation for the sample mean and standard deviation, for example $\bar x$ and $s$. There are no guarantees for the location of sample observations compared to the population mean and standard deviation, just probabilities.
There is a slight issue if your calculation of the sample standard deviation $s$ uses the $\frac1{n-1}$ expression of $s= \sqrt{\frac{1}{n-1}\sum(x_i-\bar x)^2}$ rather than $s= \sqrt{\frac{1}{n}\sum(x_i-\bar x)^2}$, as for $n=1$ the $\frac1{n-1}$ expression will give $\frac00$. When $n=1$, you have the observation equal to the sample mean.
Ignoring that issue and using either expression for $s$, you can say that for all $n>0$, at least one sample observations will be in the interval $[\bar x -s, \bar x +s]$. If none were then you would have $\sum(x_i-\bar x)^2 > \sum_i s^2 = n s^2$, leading to the contradictory $s>s$.
All the sample observations will be in the interval $[\bar x -\sqrt{n}s, \bar x +\sqrt{n}s]$. If any observation $x_j$ was outside that interval you would have $\sum(x_i-\bar x)^2 > (x_j-\bar x)^2 > ns^2$ again leading to the contradictory $s>s$.
Both $[\bar x -s, \bar x +s]$ and $[\bar x -\sqrt{n}s, \bar x +\sqrt{n}s]$ are narrower than $[\bar x -ns, \bar x +ns]$ for $n>0$, with equality only when $n=1$. | How many standard deviations around the mean do I need to guarantee covering at least one sample
You should use different notation for the sample mean and standard deviation, for example $\bar x$ and $s$. There are no guarantees for the location of sample observations compared to the population |
34,463 | What do we exactly mean by "density" in Probability Density function (PDF)? [duplicate] | Short answer: Like in physical density, the probability density is probability/volume.
Long answer: For homogeneous objects, density can be defined as you said, $m/V$, with $m$ denoting mass and $V$ its volume. However, if your object is not homogeneous, the density is a function of the space coordinates within the object:
$$
\rho(x, y, z) = \lim_{\Delta V \rightarrow 0} \frac{\Delta m(x, y, z)}{\Delta V}
$$
i.e. the mass inside an infinitesimal volume around the given coordinates, divided by that infinitesimal volume. Think of a plum pudding: The density at the raisins is different from the density at dough.
For probability, it is basically the same:
$$
f(x, y, z) = \lim_{\Delta V \rightarrow 0} \frac{\Delta F(x, y, z)}{\Delta V}
$$
where $f$ is the probability density function (PDF) and $F$ the cumulative density function (CDF), so that $\Delta F$ is the infinitesimal probability in the infinitesimal volume $\Delta V$ in the vicinity of coordinates $(x, y, z)$ in the space over which $F$ is defined.
Now, we happen to live in a physical world with three space dimensions, but we are not limited to defining probabilities just over space. In practice, it is much more common to work with probabilities defined over a single dimension, say, $x$. Then the above simplifies to
$$
f(x) = \lim_{\Delta x \rightarrow 0} \frac{\Delta F(x)}{\Delta x} = \lim_{\Delta x \rightarrow 0} \frac{F(x+\Delta x) - F(x)}{\Delta x}
$$
But, of course, depending on your probability model, $F$ and $f$ can be defined over any number of dimensions. | What do we exactly mean by "density" in Probability Density function (PDF)? [duplicate] | Short answer: Like in physical density, the probability density is probability/volume.
Long answer: For homogeneous objects, density can be defined as you said, $m/V$, with $m$ denoting mass and $V$ i | What do we exactly mean by "density" in Probability Density function (PDF)? [duplicate]
Short answer: Like in physical density, the probability density is probability/volume.
Long answer: For homogeneous objects, density can be defined as you said, $m/V$, with $m$ denoting mass and $V$ its volume. However, if your object is not homogeneous, the density is a function of the space coordinates within the object:
$$
\rho(x, y, z) = \lim_{\Delta V \rightarrow 0} \frac{\Delta m(x, y, z)}{\Delta V}
$$
i.e. the mass inside an infinitesimal volume around the given coordinates, divided by that infinitesimal volume. Think of a plum pudding: The density at the raisins is different from the density at dough.
For probability, it is basically the same:
$$
f(x, y, z) = \lim_{\Delta V \rightarrow 0} \frac{\Delta F(x, y, z)}{\Delta V}
$$
where $f$ is the probability density function (PDF) and $F$ the cumulative density function (CDF), so that $\Delta F$ is the infinitesimal probability in the infinitesimal volume $\Delta V$ in the vicinity of coordinates $(x, y, z)$ in the space over which $F$ is defined.
Now, we happen to live in a physical world with three space dimensions, but we are not limited to defining probabilities just over space. In practice, it is much more common to work with probabilities defined over a single dimension, say, $x$. Then the above simplifies to
$$
f(x) = \lim_{\Delta x \rightarrow 0} \frac{\Delta F(x)}{\Delta x} = \lim_{\Delta x \rightarrow 0} \frac{F(x+\Delta x) - F(x)}{\Delta x}
$$
But, of course, depending on your probability model, $F$ and $f$ can be defined over any number of dimensions. | What do we exactly mean by "density" in Probability Density function (PDF)? [duplicate]
Short answer: Like in physical density, the probability density is probability/volume.
Long answer: For homogeneous objects, density can be defined as you said, $m/V$, with $m$ denoting mass and $V$ i |
34,464 | What do we exactly mean by "density" in Probability Density function (PDF)? [duplicate] | You could see the Radon-Nikodym derivative as a formal definition of a more general notion of density.
It is the ratio of two measures (which have the extensive property, they are additive) defined on the same space.
$$\rho = \frac{d \nu}{d \mu}$$
This ratio makes the one quantity measure $\nu$ of a set $S$ expressible by an integral over the other measure $\mu$ $$\nu(S) = \int_S \rho d \mu$$
Typically the denominator $\mu$ is a measure based on a metric measure like distance, area or volume. This is common for densities in physics like mass density, energy density, charge density, particle density.
With the density of probability the denominator can be more generally another type of variable that does not relate to physical space. Yet, often it is similar in the use of the Euclidean measure or Lebesgue measure. It is just that the variable does not need to be a coordinate in physical space. | What do we exactly mean by "density" in Probability Density function (PDF)? [duplicate] | You could see the Radon-Nikodym derivative as a formal definition of a more general notion of density.
It is the ratio of two measures (which have the extensive property, they are additive) defined on | What do we exactly mean by "density" in Probability Density function (PDF)? [duplicate]
You could see the Radon-Nikodym derivative as a formal definition of a more general notion of density.
It is the ratio of two measures (which have the extensive property, they are additive) defined on the same space.
$$\rho = \frac{d \nu}{d \mu}$$
This ratio makes the one quantity measure $\nu$ of a set $S$ expressible by an integral over the other measure $\mu$ $$\nu(S) = \int_S \rho d \mu$$
Typically the denominator $\mu$ is a measure based on a metric measure like distance, area or volume. This is common for densities in physics like mass density, energy density, charge density, particle density.
With the density of probability the denominator can be more generally another type of variable that does not relate to physical space. Yet, often it is similar in the use of the Euclidean measure or Lebesgue measure. It is just that the variable does not need to be a coordinate in physical space. | What do we exactly mean by "density" in Probability Density function (PDF)? [duplicate]
You could see the Radon-Nikodym derivative as a formal definition of a more general notion of density.
It is the ratio of two measures (which have the extensive property, they are additive) defined on |
34,465 | What do we exactly mean by "density" in Probability Density function (PDF)? [duplicate] | For a single continuous random variable, the value of the pdf at the point $t$ tells you the density of the probability mass, measured in units of probability mass per unit length, at the point $t$ on the real line. The density of the probability mass can be different at different points on the real line; it is not quite as facile as the mass/volume prescription of high-school physics. | What do we exactly mean by "density" in Probability Density function (PDF)? [duplicate] | For a single continuous random variable, the value of the pdf at the point $t$ tells you the density of the probability mass, measured in units of probability mass per unit length, at the point $t$ on | What do we exactly mean by "density" in Probability Density function (PDF)? [duplicate]
For a single continuous random variable, the value of the pdf at the point $t$ tells you the density of the probability mass, measured in units of probability mass per unit length, at the point $t$ on the real line. The density of the probability mass can be different at different points on the real line; it is not quite as facile as the mass/volume prescription of high-school physics. | What do we exactly mean by "density" in Probability Density function (PDF)? [duplicate]
For a single continuous random variable, the value of the pdf at the point $t$ tells you the density of the probability mass, measured in units of probability mass per unit length, at the point $t$ on |
34,466 | Under what circumstances can an improper prior be used in bayesian analysis? | The textbook definition is that an improper prior is a prior probability density that is not integrable, i.e. it does not have a finite integral. A CDF cannot be higher than 1 hence the name "improper". If a prior were integrable to a finite number, one could always divide the prior density to said number making it integrable to 1. Thus, it must be non-finite.
Using an improper prior may lead to an improper posterior, but it does not need to. For example, choosing the uniform prior over $\mathbb{R}$ as $\pi(\theta)=1 \ \forall \ \theta\in\mathbb{R}$ leads to it vanishing (multiplication by 1) in the posterior, thus integration of the likelihood times prior to get the norming constant $f(y)=\int_{-\infty}^{+\infty}f(y|\theta)\pi(\theta)d\theta$ is just integration over the likelihood. Even if this is not the case, for Bayesian simulation we only need the kernel of the posterior, i.e. the part that is proportional to the posterior, not the norming constant, i.e. $\pi(\theta|y) \propto f(y|\theta)\pi(\theta)$. Thus Integration to 1 is not needed for the posterior. The kernel is enough to simulate the posterior, which is most likely the case with Bayesian problems. Of course, if we 'know' the posterior, all inference regarding it is valid*, but some issues arise (see below).
*[EDIT: I've given this some thought and clearly you would not be able to calculate expectations, variances, credibility intervals in some cases of improper posteriors. I found this as an example of a simulation from such a posterior. There are obviously problems with them.]
[Extra content: Interest arises not whether or not improper priors can be used, but when looking at the issues that arise when using improper priors such as 1) the possibility of manipulation of Bayes factors and 2) marginalization paradoxes. Improper priors should best be avoided. Improper priors are used to model uninformativeness, i.e. the fact that we have no prior knowledge of the data. There are many proposals regarding uninformative (diffuse) priors, which need not be improper. To name a few prior proposals: Jeffrey's prior, Haldane's prior, Maximum Entropy prior, Maximal data information prior, empirical Bayes.] | Under what circumstances can an improper prior be used in bayesian analysis? | The textbook definition is that an improper prior is a prior probability density that is not integrable, i.e. it does not have a finite integral. A CDF cannot be higher than 1 hence the name "improper | Under what circumstances can an improper prior be used in bayesian analysis?
The textbook definition is that an improper prior is a prior probability density that is not integrable, i.e. it does not have a finite integral. A CDF cannot be higher than 1 hence the name "improper". If a prior were integrable to a finite number, one could always divide the prior density to said number making it integrable to 1. Thus, it must be non-finite.
Using an improper prior may lead to an improper posterior, but it does not need to. For example, choosing the uniform prior over $\mathbb{R}$ as $\pi(\theta)=1 \ \forall \ \theta\in\mathbb{R}$ leads to it vanishing (multiplication by 1) in the posterior, thus integration of the likelihood times prior to get the norming constant $f(y)=\int_{-\infty}^{+\infty}f(y|\theta)\pi(\theta)d\theta$ is just integration over the likelihood. Even if this is not the case, for Bayesian simulation we only need the kernel of the posterior, i.e. the part that is proportional to the posterior, not the norming constant, i.e. $\pi(\theta|y) \propto f(y|\theta)\pi(\theta)$. Thus Integration to 1 is not needed for the posterior. The kernel is enough to simulate the posterior, which is most likely the case with Bayesian problems. Of course, if we 'know' the posterior, all inference regarding it is valid*, but some issues arise (see below).
*[EDIT: I've given this some thought and clearly you would not be able to calculate expectations, variances, credibility intervals in some cases of improper posteriors. I found this as an example of a simulation from such a posterior. There are obviously problems with them.]
[Extra content: Interest arises not whether or not improper priors can be used, but when looking at the issues that arise when using improper priors such as 1) the possibility of manipulation of Bayes factors and 2) marginalization paradoxes. Improper priors should best be avoided. Improper priors are used to model uninformativeness, i.e. the fact that we have no prior knowledge of the data. There are many proposals regarding uninformative (diffuse) priors, which need not be improper. To name a few prior proposals: Jeffrey's prior, Haldane's prior, Maximum Entropy prior, Maximal data information prior, empirical Bayes.] | Under what circumstances can an improper prior be used in bayesian analysis?
The textbook definition is that an improper prior is a prior probability density that is not integrable, i.e. it does not have a finite integral. A CDF cannot be higher than 1 hence the name "improper |
34,467 | Under what circumstances can an improper prior be used in bayesian analysis? | To add a specific example to PaulG's +1 answer, consider the beta binomial setting.
Consider a prior
$$ \theta \sim Beta\left( 0,1\right) $$
such that
$$\pi \left( \theta \right) =\frac{\Gamma \left( 1\right)}{\Gamma\left(0\right)\Gamma\left(1\right) }\theta
^{-1}\left( 1-\theta \right) ^{1-1} =\frac{1}{\theta} $$
with $\int_0^1\frac{1}{\theta}d\theta=\ln\theta|^1_0=+\infty$. The posterior becomes
$$
\pi(\theta|y) \propto \theta ^{k-1}\left( 1-\theta \right) ^{n-k},
$$
which is a $Beta\left( k,n-k+1\right)$-kernel. This is a proper posterior unless $k=0$.
Similarly, $\theta \sim Beta\left( 1,0\right)$ leads to a $Beta\left( k+1,n-k\right)$-kernel, which is proper unless $k=n$. So, in this particular example, we are safe if $0<k<n$.
Improper priors are a more serious issue when using Bayes factors, and hence posterior odds ratios. As no normalization exists (this also addresses one of your questions - if the prior integrated to any other finite number $d$, we could renormalize by $1/d$ to have a prior that integrates to 1), an improper prior $\pi$ is equivalent to $c\pi$, $c>0$.
Thus we can write the Bayes factor as
$$
\frac{\int f_{1}\left( y|\theta _{1}\right) c_1\pi _{1}\left(\theta_{1}\right) d\theta _{1}}{\int f_{2}\left( y|\theta _{2}\right) c_2\pi_{2}\left( \theta _{2}\right) d\theta _{2}}
$$
Since the $c_i$ are arbitrary, so is the Bayes factor. | Under what circumstances can an improper prior be used in bayesian analysis? | To add a specific example to PaulG's +1 answer, consider the beta binomial setting.
Consider a prior
$$ \theta \sim Beta\left( 0,1\right) $$
such that
$$\pi \left( \theta \right) =\frac{\Gamma \left( | Under what circumstances can an improper prior be used in bayesian analysis?
To add a specific example to PaulG's +1 answer, consider the beta binomial setting.
Consider a prior
$$ \theta \sim Beta\left( 0,1\right) $$
such that
$$\pi \left( \theta \right) =\frac{\Gamma \left( 1\right)}{\Gamma\left(0\right)\Gamma\left(1\right) }\theta
^{-1}\left( 1-\theta \right) ^{1-1} =\frac{1}{\theta} $$
with $\int_0^1\frac{1}{\theta}d\theta=\ln\theta|^1_0=+\infty$. The posterior becomes
$$
\pi(\theta|y) \propto \theta ^{k-1}\left( 1-\theta \right) ^{n-k},
$$
which is a $Beta\left( k,n-k+1\right)$-kernel. This is a proper posterior unless $k=0$.
Similarly, $\theta \sim Beta\left( 1,0\right)$ leads to a $Beta\left( k+1,n-k\right)$-kernel, which is proper unless $k=n$. So, in this particular example, we are safe if $0<k<n$.
Improper priors are a more serious issue when using Bayes factors, and hence posterior odds ratios. As no normalization exists (this also addresses one of your questions - if the prior integrated to any other finite number $d$, we could renormalize by $1/d$ to have a prior that integrates to 1), an improper prior $\pi$ is equivalent to $c\pi$, $c>0$.
Thus we can write the Bayes factor as
$$
\frac{\int f_{1}\left( y|\theta _{1}\right) c_1\pi _{1}\left(\theta_{1}\right) d\theta _{1}}{\int f_{2}\left( y|\theta _{2}\right) c_2\pi_{2}\left( \theta _{2}\right) d\theta _{2}}
$$
Since the $c_i$ are arbitrary, so is the Bayes factor. | Under what circumstances can an improper prior be used in bayesian analysis?
To add a specific example to PaulG's +1 answer, consider the beta binomial setting.
Consider a prior
$$ \theta \sim Beta\left( 0,1\right) $$
such that
$$\pi \left( \theta \right) =\frac{\Gamma \left( |
34,468 | Why "sorting" is needed for simple random sampling [closed] | Sorting a list of objects based on an accompanying set of IID continuous random variables (such as uniform random variables) is equivalent to shuffling those objects into a random order (i.e., by a random permutation). Since the random values are independent continuous random variables, every possible permutation is equally likely, and that is the definition of simple random sampling. This method is used in computer programs that have facilities to create pseudo-random numbers, but do not have an existing sampling function. | Why "sorting" is needed for simple random sampling [closed] | Sorting a list of objects based on an accompanying set of IID continuous random variables (such as uniform random variables) is equivalent to shuffling those objects into a random order (i.e., by a ra | Why "sorting" is needed for simple random sampling [closed]
Sorting a list of objects based on an accompanying set of IID continuous random variables (such as uniform random variables) is equivalent to shuffling those objects into a random order (i.e., by a random permutation). Since the random values are independent continuous random variables, every possible permutation is equally likely, and that is the definition of simple random sampling. This method is used in computer programs that have facilities to create pseudo-random numbers, but do not have an existing sampling function. | Why "sorting" is needed for simple random sampling [closed]
Sorting a list of objects based on an accompanying set of IID continuous random variables (such as uniform random variables) is equivalent to shuffling those objects into a random order (i.e., by a ra |
34,469 | Why "sorting" is needed for simple random sampling [closed] | It should be emphasized that you don't need to sort in order to sample. The method given in the tutorial works, but it is extremely inefficient. It basically does $\Theta(n \log n)$ operations for what can be done in $\Theta(1)$.
If you can sample a random floating point number from 0 to 1, you can sample a random integer from 1 to n. And Excel can give you the value in a list at a specific index. You can use that for sampling.
(Note, though, that Excels tends to re-roll all random values whenever you do anything, so you'll want to copy the value of the random index before proceeding.) | Why "sorting" is needed for simple random sampling [closed] | It should be emphasized that you don't need to sort in order to sample. The method given in the tutorial works, but it is extremely inefficient. It basically does $\Theta(n \log n)$ operations for wha | Why "sorting" is needed for simple random sampling [closed]
It should be emphasized that you don't need to sort in order to sample. The method given in the tutorial works, but it is extremely inefficient. It basically does $\Theta(n \log n)$ operations for what can be done in $\Theta(1)$.
If you can sample a random floating point number from 0 to 1, you can sample a random integer from 1 to n. And Excel can give you the value in a list at a specific index. You can use that for sampling.
(Note, though, that Excels tends to re-roll all random values whenever you do anything, so you'll want to copy the value of the random index before proceeding.) | Why "sorting" is needed for simple random sampling [closed]
It should be emphasized that you don't need to sort in order to sample. The method given in the tutorial works, but it is extremely inefficient. It basically does $\Theta(n \log n)$ operations for wha |
34,470 | Generalized Linear Model and Identity link, what's its benefit? | For a conditional normal distribution, the result would indeed be in line with the normal linear model.
Example in R
# Normal linear model fitted by OLS
summary(lm(Sepal.Length ~ Sepal.Width, data = iris))
# Output
Estimate Std. Error t value Pr(>|t|)
(Intercept) 6.5262 0.4789 13.63 <2e-16 ***
Sepal.Width -0.2234 0.1551 -1.44 0.152
# GLM with conditional normal response and identity link
summary(glm(Sepal.Length ~ Sepal.Width, data = iris))
# Output
Estimate Std. Error t value Pr(>|t|)
(Intercept) 6.5262 0.4789 13.63 <2e-16 ***
Sepal.Width -0.2234 0.1551 -1.44 0.152
For all other distributions in the GLM family (e.g. Gamma, Poisson or Bernoulli), the results would differ, e.g. by taking into account the variance heterogeneity that is implied by the distributional family and also by different numerical techniques (iteratively reweighted least-squares instead of a single least-squares iteration).
So e.g. for the Gamma:
summary(glm(Sepal.Length ~ Sepal.Width, data = iris,
+ family = Gamma(link = "identity")))
# Output
Estimate Std. Error t value Pr(>|t|)
(Intercept) 6.5656 0.4792 13.70 <2e-16 ***
Sepal.Width -0.2362 0.1544 -1.53 0.128
This is an additive model for a response with conditional Gamma distribution, correctly taking into account the non-homogeneity of the variance induced by the Gamma assumption.
While using an identity link with non-normal conditional response might lead to numerical instabilities in certain cases, it is a neat trick to e.g. adjust a difference in two proportions for confounders: to do so, you would run a logistic GLM with identity link. | Generalized Linear Model and Identity link, what's its benefit? | For a conditional normal distribution, the result would indeed be in line with the normal linear model.
Example in R
# Normal linear model fitted by OLS
summary(lm(Sepal.Length ~ Sepal.Width, data = i | Generalized Linear Model and Identity link, what's its benefit?
For a conditional normal distribution, the result would indeed be in line with the normal linear model.
Example in R
# Normal linear model fitted by OLS
summary(lm(Sepal.Length ~ Sepal.Width, data = iris))
# Output
Estimate Std. Error t value Pr(>|t|)
(Intercept) 6.5262 0.4789 13.63 <2e-16 ***
Sepal.Width -0.2234 0.1551 -1.44 0.152
# GLM with conditional normal response and identity link
summary(glm(Sepal.Length ~ Sepal.Width, data = iris))
# Output
Estimate Std. Error t value Pr(>|t|)
(Intercept) 6.5262 0.4789 13.63 <2e-16 ***
Sepal.Width -0.2234 0.1551 -1.44 0.152
For all other distributions in the GLM family (e.g. Gamma, Poisson or Bernoulli), the results would differ, e.g. by taking into account the variance heterogeneity that is implied by the distributional family and also by different numerical techniques (iteratively reweighted least-squares instead of a single least-squares iteration).
So e.g. for the Gamma:
summary(glm(Sepal.Length ~ Sepal.Width, data = iris,
+ family = Gamma(link = "identity")))
# Output
Estimate Std. Error t value Pr(>|t|)
(Intercept) 6.5656 0.4792 13.70 <2e-16 ***
Sepal.Width -0.2362 0.1544 -1.53 0.128
This is an additive model for a response with conditional Gamma distribution, correctly taking into account the non-homogeneity of the variance induced by the Gamma assumption.
While using an identity link with non-normal conditional response might lead to numerical instabilities in certain cases, it is a neat trick to e.g. adjust a difference in two proportions for confounders: to do so, you would run a logistic GLM with identity link. | Generalized Linear Model and Identity link, what's its benefit?
For a conditional normal distribution, the result would indeed be in line with the normal linear model.
Example in R
# Normal linear model fitted by OLS
summary(lm(Sepal.Length ~ Sepal.Width, data = i |
34,471 | Generalized Linear Model and Identity link, what's its benefit? | Without a paper it's impossible to know. It could be simply that they wrote a standard set of scripts using GLM function, and use different links, but in this case they used only identity. The main benefit is that you have smaller code base by not writing specific code for OLS and using the generic code for GLM, it's easy to try different settings in more generic code and probability of bugs is lowered too.
This happens to me sometimes. I have the scripts to run ARIMA, and run ARIMA(0,0,0) for a OLS regression too. This way you have fewer scripts, and less chance of a bug | Generalized Linear Model and Identity link, what's its benefit? | Without a paper it's impossible to know. It could be simply that they wrote a standard set of scripts using GLM function, and use different links, but in this case they used only identity. The main be | Generalized Linear Model and Identity link, what's its benefit?
Without a paper it's impossible to know. It could be simply that they wrote a standard set of scripts using GLM function, and use different links, but in this case they used only identity. The main benefit is that you have smaller code base by not writing specific code for OLS and using the generic code for GLM, it's easy to try different settings in more generic code and probability of bugs is lowered too.
This happens to me sometimes. I have the scripts to run ARIMA, and run ARIMA(0,0,0) for a OLS regression too. This way you have fewer scripts, and less chance of a bug | Generalized Linear Model and Identity link, what's its benefit?
Without a paper it's impossible to know. It could be simply that they wrote a standard set of scripts using GLM function, and use different links, but in this case they used only identity. The main be |
34,472 | "Deep learning removes the need for feature engineering"? | To me, this is a (provocative, and intentionally so) restatement of the universal approximation theorems. Loosely speaking, the universal approximation theorems say that, given enough parameters, a neural network can get as close to a decent function as you want.
In this context, it means that you can let the neural network figure the composition of the feature extraction function and the regression function.
However, if you have insights into the features that would be important, you can give your neural network a break and do some of the work for it. Why make the network figure out that quadratic terms are important when domain knowledge (physics, chemistry, biology, etc) says that you know the quadratic term is important? You can, perhaps, use fewer parameters and put yourself at a lower risk of overfitting. | "Deep learning removes the need for feature engineering"? | To me, this is a (provocative, and intentionally so) restatement of the universal approximation theorems. Loosely speaking, the universal approximation theorems say that, given enough parameters, a ne | "Deep learning removes the need for feature engineering"?
To me, this is a (provocative, and intentionally so) restatement of the universal approximation theorems. Loosely speaking, the universal approximation theorems say that, given enough parameters, a neural network can get as close to a decent function as you want.
In this context, it means that you can let the neural network figure the composition of the feature extraction function and the regression function.
However, if you have insights into the features that would be important, you can give your neural network a break and do some of the work for it. Why make the network figure out that quadratic terms are important when domain knowledge (physics, chemistry, biology, etc) says that you know the quadratic term is important? You can, perhaps, use fewer parameters and put yourself at a lower risk of overfitting. | "Deep learning removes the need for feature engineering"?
To me, this is a (provocative, and intentionally so) restatement of the universal approximation theorems. Loosely speaking, the universal approximation theorems say that, given enough parameters, a ne |
34,473 | "Deep learning removes the need for feature engineering"? | Most deep learning models and their associated calibration processes are able to "perform" some simple feature engineering tasks like variable transformation and variable selection (it's difficult to speak about all models at the same time). Often it's more about how models are built than a specific action. This renders some basic feature engineering task unusefull.
For exemple a vanilla NN on tabular data will mostly be insensible to linear data transformation as each neuron rely on a linear predictor. The variable selection is somewhat done trough the weight calibration (may be with some regularisation) : if all the weights associated to a variable are low or 0, it is equivalent to its removal. Again, generally speaking, models refinements will enhance these properties.
However, for tabular data, I've found simple feature ingineering to be be crucial for the following reasons :
It's important to understand your data. I've found feature engineering to be an important step to have a look at your features, spot data quality problems and deal with them. Generally this will help you build better models. On some occasion understanding the data and building relevant features even lead me to go out of deep learning and build way simpler models.
Full deep learning necessitate a lot of computational ressources (computational power, memory). In general those ressources are limited and you will be better by removing poor predictors beforehand. Overall it may even translate to better performance as you will be able to build more sophisticated models with your restricted ressources. Non linear transformation of your data may also help the convergence of your calibration process by reducing the impact of 'outliers'.
Another point is when the instance are not independant, both in terms of features across instances or in terms of targets. Feature enginnering (mean by group for exemple) allows to build features across many instance. Target encoding / engineering / imputation may help better capture the interdependance of targets. Those are features that can drastically improve the model over 'base' features, as they bring new information to them.
Deep learning model are difficult to explain. Removing non-predictive features and building more predictive features trough feature engineering will often help you in that purpose. Whatever is your explainability solution, feature engineering will probably make it better. (Note that it is not necessarily true for more complex feature engineering steps) | "Deep learning removes the need for feature engineering"? | Most deep learning models and their associated calibration processes are able to "perform" some simple feature engineering tasks like variable transformation and variable selection (it's difficult to | "Deep learning removes the need for feature engineering"?
Most deep learning models and their associated calibration processes are able to "perform" some simple feature engineering tasks like variable transformation and variable selection (it's difficult to speak about all models at the same time). Often it's more about how models are built than a specific action. This renders some basic feature engineering task unusefull.
For exemple a vanilla NN on tabular data will mostly be insensible to linear data transformation as each neuron rely on a linear predictor. The variable selection is somewhat done trough the weight calibration (may be with some regularisation) : if all the weights associated to a variable are low or 0, it is equivalent to its removal. Again, generally speaking, models refinements will enhance these properties.
However, for tabular data, I've found simple feature ingineering to be be crucial for the following reasons :
It's important to understand your data. I've found feature engineering to be an important step to have a look at your features, spot data quality problems and deal with them. Generally this will help you build better models. On some occasion understanding the data and building relevant features even lead me to go out of deep learning and build way simpler models.
Full deep learning necessitate a lot of computational ressources (computational power, memory). In general those ressources are limited and you will be better by removing poor predictors beforehand. Overall it may even translate to better performance as you will be able to build more sophisticated models with your restricted ressources. Non linear transformation of your data may also help the convergence of your calibration process by reducing the impact of 'outliers'.
Another point is when the instance are not independant, both in terms of features across instances or in terms of targets. Feature enginnering (mean by group for exemple) allows to build features across many instance. Target encoding / engineering / imputation may help better capture the interdependance of targets. Those are features that can drastically improve the model over 'base' features, as they bring new information to them.
Deep learning model are difficult to explain. Removing non-predictive features and building more predictive features trough feature engineering will often help you in that purpose. Whatever is your explainability solution, feature engineering will probably make it better. (Note that it is not necessarily true for more complex feature engineering steps) | "Deep learning removes the need for feature engineering"?
Most deep learning models and their associated calibration processes are able to "perform" some simple feature engineering tasks like variable transformation and variable selection (it's difficult to |
34,474 | lme4::glmer : Get the covariance matrix of the fixed and random effect estimates | Unless you've gone out of your way to not compute the Hessian, it's hiding in the output model structure. You can look in lme4:::vcov.merMod to see where these computations come from (what's there is more complicated because it handles a bunch of edge cases; it also extracts just the part of the covariance matrix relevant to the fixed effects ...)
Example:
library(lme4)
object <- glmer(cbind(incidence, size - incidence) ~ period + (1 | herd),
data = cbpp,
family = binomial)
This extracts the Hessian, inverts it, and doubles it (since the Hessian is computed on the (-2 log likelihood) scale. The h+t(h) is a clever way to improve symmetry while doubling (if I recall correctly ...)
h <- object@optinfo$derivs$Hessian
h <- solve(h)
v <- forceSymmetric(h + t(h))
Check that the fixed-effect part agrees (random-effect parameters come first):
all.equal(unname(as.matrix(vcov(object))),
unname(as.matrix(v)[-1,-1])) ## TRUE
Warning: the random effects are parameterized on the Cholesky scale (i.e., the parameters are the lower triangle, in column-major order, of the Cholesky factor of the random effect covariance matrix) ... if you need this in variance-covariance parameterization, or in standard deviation-correlation parameterization, it's going to take more work. (If you only have a single scalar random effect, then the parameter is the standard deviation.) | lme4::glmer : Get the covariance matrix of the fixed and random effect estimates | Unless you've gone out of your way to not compute the Hessian, it's hiding in the output model structure. You can look in lme4:::vcov.merMod to see where these computations come from (what's there is | lme4::glmer : Get the covariance matrix of the fixed and random effect estimates
Unless you've gone out of your way to not compute the Hessian, it's hiding in the output model structure. You can look in lme4:::vcov.merMod to see where these computations come from (what's there is more complicated because it handles a bunch of edge cases; it also extracts just the part of the covariance matrix relevant to the fixed effects ...)
Example:
library(lme4)
object <- glmer(cbind(incidence, size - incidence) ~ period + (1 | herd),
data = cbpp,
family = binomial)
This extracts the Hessian, inverts it, and doubles it (since the Hessian is computed on the (-2 log likelihood) scale. The h+t(h) is a clever way to improve symmetry while doubling (if I recall correctly ...)
h <- object@optinfo$derivs$Hessian
h <- solve(h)
v <- forceSymmetric(h + t(h))
Check that the fixed-effect part agrees (random-effect parameters come first):
all.equal(unname(as.matrix(vcov(object))),
unname(as.matrix(v)[-1,-1])) ## TRUE
Warning: the random effects are parameterized on the Cholesky scale (i.e., the parameters are the lower triangle, in column-major order, of the Cholesky factor of the random effect covariance matrix) ... if you need this in variance-covariance parameterization, or in standard deviation-correlation parameterization, it's going to take more work. (If you only have a single scalar random effect, then the parameter is the standard deviation.) | lme4::glmer : Get the covariance matrix of the fixed and random effect estimates
Unless you've gone out of your way to not compute the Hessian, it's hiding in the output model structure. You can look in lme4:::vcov.merMod to see where these computations come from (what's there is |
34,475 | lme4::glmer : Get the covariance matrix of the fixed and random effect estimates | In the GLMMadaptive package the vcov() method returns the covariance matrix of the maximum likelihood estimates for both the fixed effects coefficients and the parameters of the variance-covariance matrix of the random effects (the later in the log-Cholesky factor scale).
For an example, check here. | lme4::glmer : Get the covariance matrix of the fixed and random effect estimates | In the GLMMadaptive package the vcov() method returns the covariance matrix of the maximum likelihood estimates for both the fixed effects coefficients and the parameters of the variance-covariance ma | lme4::glmer : Get the covariance matrix of the fixed and random effect estimates
In the GLMMadaptive package the vcov() method returns the covariance matrix of the maximum likelihood estimates for both the fixed effects coefficients and the parameters of the variance-covariance matrix of the random effects (the later in the log-Cholesky factor scale).
For an example, check here. | lme4::glmer : Get the covariance matrix of the fixed and random effect estimates
In the GLMMadaptive package the vcov() method returns the covariance matrix of the maximum likelihood estimates for both the fixed effects coefficients and the parameters of the variance-covariance ma |
34,476 | What is a 'true' model? | No, the true model is the data-generating model/process, which is only known ex-ante if you assume the underlying model beforehand (e.g. simulations or theoretical models). If you only observe data, you do not know what the true model is. You try to find a model that explains data the best, which does not mean that it is the true model.
In fact, it is possible that you find a model that "fits" just as good as the true model (if you would have known), even though true model and assumed model are different.
This happens, for instance, when you have hidden variables that you do not know of that you never see. Drawing inference from these is almost impossible. | What is a 'true' model? | No, the true model is the data-generating model/process, which is only known ex-ante if you assume the underlying model beforehand (e.g. simulations or theoretical models). If you only observe data, y | What is a 'true' model?
No, the true model is the data-generating model/process, which is only known ex-ante if you assume the underlying model beforehand (e.g. simulations or theoretical models). If you only observe data, you do not know what the true model is. You try to find a model that explains data the best, which does not mean that it is the true model.
In fact, it is possible that you find a model that "fits" just as good as the true model (if you would have known), even though true model and assumed model are different.
This happens, for instance, when you have hidden variables that you do not know of that you never see. Drawing inference from these is almost impossible. | What is a 'true' model?
No, the true model is the data-generating model/process, which is only known ex-ante if you assume the underlying model beforehand (e.g. simulations or theoretical models). If you only observe data, y |
34,477 | What is a 'true' model? | In a regression context you have variables $(y_i,\mathbf{x}_i)$ and you are seeking to describe the behaviour of the first element conditional on the second element. The model posits a class of possible conditional distributions of $y_i$ given $\mathbf{x}_i$, and the true model is the true conditional distribution. In my view, it is best to avoid equating this to the "data generating process" since that is an additional causal hypothesis, and it brings in a large number of strong assertions that are impossible to prove (e.g., that probability is an embedded metaphysical property of nature, and not just an epistemological tool for reasoning).
Suppose you accept the view that the "true model" is a synonym for the true conditional distribution. It is still nice to be able to give an operational meaning to this (i.e., a meaning framed in terms of observable data), if possible. To do this, suppose you are willing to assume that you have a potentially infinite set of observable data, manifesting in an infinite sequence $\mathscr{R} \equiv \{ (y_i,\mathbf{x}_i) : i \in \mathbb{N} \}$. (In a given problem you will only observe a finite amount of data, but our assumption is that there is no finite limit to the amount of data we could collect in theory.) Define the limiting empirical distribution function $F_\infty: \mathbb{R}^{m+1} \rightarrow [0,1]$ by:
$$F_\infty(y,\mathbf{x}) \equiv \lim_{n \rightarrow \infty} \frac{1}{n} \sum_{i=1}^n \mathbb{I}(y_i \leqslant y, \mathbf{x}_i \leqslant \mathbf{x})
\quad \quad \quad \text{for all } y \in \mathbb{R} \text{ and } \mathbf{x} \in \mathbb{R}^m.$$
If the sequence $\mathscr{R}$ is exchangeable then it follows from the strong law of large numbers that $F_\infty$ is almost surely equal to the true distribution $F$ (i.e., we have $\mathbb{P}(F_\infty = F)=1$). This means that the conditional distribution induces from the limiting empirical distribution of the sequence is the true conditional distribution of $y_i$ given $\mathbf{x}_i$ --- this gives an operational meaning to the "true model". | What is a 'true' model? | In a regression context you have variables $(y_i,\mathbf{x}_i)$ and you are seeking to describe the behaviour of the first element conditional on the second element. The model posits a class of possi | What is a 'true' model?
In a regression context you have variables $(y_i,\mathbf{x}_i)$ and you are seeking to describe the behaviour of the first element conditional on the second element. The model posits a class of possible conditional distributions of $y_i$ given $\mathbf{x}_i$, and the true model is the true conditional distribution. In my view, it is best to avoid equating this to the "data generating process" since that is an additional causal hypothesis, and it brings in a large number of strong assertions that are impossible to prove (e.g., that probability is an embedded metaphysical property of nature, and not just an epistemological tool for reasoning).
Suppose you accept the view that the "true model" is a synonym for the true conditional distribution. It is still nice to be able to give an operational meaning to this (i.e., a meaning framed in terms of observable data), if possible. To do this, suppose you are willing to assume that you have a potentially infinite set of observable data, manifesting in an infinite sequence $\mathscr{R} \equiv \{ (y_i,\mathbf{x}_i) : i \in \mathbb{N} \}$. (In a given problem you will only observe a finite amount of data, but our assumption is that there is no finite limit to the amount of data we could collect in theory.) Define the limiting empirical distribution function $F_\infty: \mathbb{R}^{m+1} \rightarrow [0,1]$ by:
$$F_\infty(y,\mathbf{x}) \equiv \lim_{n \rightarrow \infty} \frac{1}{n} \sum_{i=1}^n \mathbb{I}(y_i \leqslant y, \mathbf{x}_i \leqslant \mathbf{x})
\quad \quad \quad \text{for all } y \in \mathbb{R} \text{ and } \mathbf{x} \in \mathbb{R}^m.$$
If the sequence $\mathscr{R}$ is exchangeable then it follows from the strong law of large numbers that $F_\infty$ is almost surely equal to the true distribution $F$ (i.e., we have $\mathbb{P}(F_\infty = F)=1$). This means that the conditional distribution induces from the limiting empirical distribution of the sequence is the true conditional distribution of $y_i$ given $\mathbf{x}_i$ --- this gives an operational meaning to the "true model". | What is a 'true' model?
In a regression context you have variables $(y_i,\mathbf{x}_i)$ and you are seeking to describe the behaviour of the first element conditional on the second element. The model posits a class of possi |
34,478 | What is a 'true' model? | You're right. It's very hard to find a good discussion of this. My thoughts: The "true" model is not a model of how the data were actually generated but rather a hypothetical "generating model" that generates data with the distribution P(Y|X), where X are the independent variables in your statistical model, and satisfies Gauss-Markov (see Wikipedia), so error (not residuals!) are I.I.D. and mean zero. Omitted variables are irrelevant to these conditions. Literally an infinite number of generating models (with different combinations of causal factors) can generate data with the same P(Y|X). Omitted variable bias is simply not relevant to statistical modeling the way it is described in statistical textbooks. Some of this is in Gelman and Hill. Another good source is Shalizi's draft for a textbook (all googleable). See my comment below for the most comprehensive source I've found that offer's an answer to this question. | What is a 'true' model? | You're right. It's very hard to find a good discussion of this. My thoughts: The "true" model is not a model of how the data were actually generated but rather a hypothetical "generating model" that g | What is a 'true' model?
You're right. It's very hard to find a good discussion of this. My thoughts: The "true" model is not a model of how the data were actually generated but rather a hypothetical "generating model" that generates data with the distribution P(Y|X), where X are the independent variables in your statistical model, and satisfies Gauss-Markov (see Wikipedia), so error (not residuals!) are I.I.D. and mean zero. Omitted variables are irrelevant to these conditions. Literally an infinite number of generating models (with different combinations of causal factors) can generate data with the same P(Y|X). Omitted variable bias is simply not relevant to statistical modeling the way it is described in statistical textbooks. Some of this is in Gelman and Hill. Another good source is Shalizi's draft for a textbook (all googleable). See my comment below for the most comprehensive source I've found that offer's an answer to this question. | What is a 'true' model?
You're right. It's very hard to find a good discussion of this. My thoughts: The "true" model is not a model of how the data were actually generated but rather a hypothetical "generating model" that g |
34,479 | What is a 'true' model? | It seems me that the the position of Gkhan Cebs is correct, true model and data generating process/model are synonym.
The position of JWalker is strange because it sustain that meaning of true model stay only in joint probability distribution but this position is precisely contradicted in the Pearl's paper he cited "Trygve Haavelmo and the Emergence of Causal Calculus".
Honestly Pearl never speak about "true model" and only of "data generating mechanism" but JWalker cited the paper as referee for true model meaning. The reason can be only that he consider true model and data generating process as synonym, and it seems me correct but this fact posed the JWalker answer in contradiction.
However JWalker and RJAL have right when says that the "true model" meaning is very difficult to find and then to understand. In econometrics textbooks the meaning of "true model" is skipped and/or unclear. Sometimes is said that it has theoretical/causal meaning, sometimes only statistical one, sometimes else nothing is said. It seems almost a mystery. This fact produce great confusions.
Maybe in some statistical text something like the "true model" can be used without structural meaning.
However I think that the correct interpretation for the true model in econometrics is like: structural linear causal equation. Like here: linear causal model
These discussions are strongly related:
Regression and causality in econometrics
In regression analysis what's the difference between data-generation process and model? | What is a 'true' model? | It seems me that the the position of Gkhan Cebs is correct, true model and data generating process/model are synonym.
The position of JWalker is strange because it sustain that meaning of true model s | What is a 'true' model?
It seems me that the the position of Gkhan Cebs is correct, true model and data generating process/model are synonym.
The position of JWalker is strange because it sustain that meaning of true model stay only in joint probability distribution but this position is precisely contradicted in the Pearl's paper he cited "Trygve Haavelmo and the Emergence of Causal Calculus".
Honestly Pearl never speak about "true model" and only of "data generating mechanism" but JWalker cited the paper as referee for true model meaning. The reason can be only that he consider true model and data generating process as synonym, and it seems me correct but this fact posed the JWalker answer in contradiction.
However JWalker and RJAL have right when says that the "true model" meaning is very difficult to find and then to understand. In econometrics textbooks the meaning of "true model" is skipped and/or unclear. Sometimes is said that it has theoretical/causal meaning, sometimes only statistical one, sometimes else nothing is said. It seems almost a mystery. This fact produce great confusions.
Maybe in some statistical text something like the "true model" can be used without structural meaning.
However I think that the correct interpretation for the true model in econometrics is like: structural linear causal equation. Like here: linear causal model
These discussions are strongly related:
Regression and causality in econometrics
In regression analysis what's the difference between data-generation process and model? | What is a 'true' model?
It seems me that the the position of Gkhan Cebs is correct, true model and data generating process/model are synonym.
The position of JWalker is strange because it sustain that meaning of true model s |
34,480 | Xgboost and repeated measures | You are correct to worry about using clustered data and then ignoring their inherit clustering. This can lead to information leakage as the cluster/subject-specific variance patterns might dictate patterns that do not generalise to the underlying population, i.e. lead us to over-fit our sample data. To that extent, ignoring the subject information altogether, again does not protect us from over-fitting; our learner might detect subject-specific patterns by itself.
A partial work-around for this issue is relatively straightforward. We do not segment our available data completely at random but instead we design our training and test set in such a way that measurements from the same subject exist either exclusively in the training or exclusively in the test set. This is easy to implement as we simply need to sample subjects instead of raw measurements. We might still over-fit subject specific patterns during training but theoretically these will be penalised during testing and thus lead us to a more universal representation of our learning task. To paraphrase Karpievitch et al. (2009) An Introspective Comparison of Random Forest-Based Classifiers for the Analysis of Cluster-Correlated Data by Way of RF++: this is effectively the idea of growing "each tree on a bootstrap sample (a random sample selected with replacement) at the subject-level rather than at the replicate-level of the training data".
More theoretically, there has been some work particularly on the use of GBMs for clustered data (e.g. Groll & Tutz (2012) Regularization for Generalized Additive Mixed Models by Likelihood-Based Boosting or Miller et al. (2017) Gradient Boosting Machine for Hierarchically Clustered Data) that I think can be insightful for what you want.
The basic idea in these works, is that given some initial estimates for our fixed effects, random effects and variance components (e.g. through lme4::lmer), we compute the estimates for the new fixed and random effects through gradient boosting of the penalized likelihood function. Then considering those fixed, we re-estimate the variance components. We then do this a number of times till satisfactory convergence in an E-M like approach.
A general point is that the difference between fixed and random effects is often a matter of convenience and/or existing nomenclature (see the thread: What is the difference between fixed effect, random effect and mixed effect models? for more details). Depending on the particular task, certain factors can be seen as random or as fixed. I believe that the most important thing is to ensure that we do not make unreasonable assumptions.
Some final blue-sky thoughts: 1. There is one core ML problem that is solved via GBMs and is concerned with clustered data: learning to rank. In that scenario, a query is the unit of analysis and the subsequent metrics (e.g. Mean reciprocal rank or (Normalised) Discounted cumulative gain) are all relevant per unit of analysis. You might be able to get some ideas from there too. 2. There are implementations for regression trees and random forests that are specifically developed for clustered data (at first instance, see Hajjem et al. (2011) Mixed Effects Regression Trees for Clustered Data and Hajjem et al. (2014) Mixed-effects random forest for clustered data respectively). Somewhat simplistically, I assume that if these procedures are used as base-learners in a boosting framework, then the boosting procedure should behave coherently when used with clustered data. | Xgboost and repeated measures | You are correct to worry about using clustered data and then ignoring their inherit clustering. This can lead to information leakage as the cluster/subject-specific variance patterns might dictate pat | Xgboost and repeated measures
You are correct to worry about using clustered data and then ignoring their inherit clustering. This can lead to information leakage as the cluster/subject-specific variance patterns might dictate patterns that do not generalise to the underlying population, i.e. lead us to over-fit our sample data. To that extent, ignoring the subject information altogether, again does not protect us from over-fitting; our learner might detect subject-specific patterns by itself.
A partial work-around for this issue is relatively straightforward. We do not segment our available data completely at random but instead we design our training and test set in such a way that measurements from the same subject exist either exclusively in the training or exclusively in the test set. This is easy to implement as we simply need to sample subjects instead of raw measurements. We might still over-fit subject specific patterns during training but theoretically these will be penalised during testing and thus lead us to a more universal representation of our learning task. To paraphrase Karpievitch et al. (2009) An Introspective Comparison of Random Forest-Based Classifiers for the Analysis of Cluster-Correlated Data by Way of RF++: this is effectively the idea of growing "each tree on a bootstrap sample (a random sample selected with replacement) at the subject-level rather than at the replicate-level of the training data".
More theoretically, there has been some work particularly on the use of GBMs for clustered data (e.g. Groll & Tutz (2012) Regularization for Generalized Additive Mixed Models by Likelihood-Based Boosting or Miller et al. (2017) Gradient Boosting Machine for Hierarchically Clustered Data) that I think can be insightful for what you want.
The basic idea in these works, is that given some initial estimates for our fixed effects, random effects and variance components (e.g. through lme4::lmer), we compute the estimates for the new fixed and random effects through gradient boosting of the penalized likelihood function. Then considering those fixed, we re-estimate the variance components. We then do this a number of times till satisfactory convergence in an E-M like approach.
A general point is that the difference between fixed and random effects is often a matter of convenience and/or existing nomenclature (see the thread: What is the difference between fixed effect, random effect and mixed effect models? for more details). Depending on the particular task, certain factors can be seen as random or as fixed. I believe that the most important thing is to ensure that we do not make unreasonable assumptions.
Some final blue-sky thoughts: 1. There is one core ML problem that is solved via GBMs and is concerned with clustered data: learning to rank. In that scenario, a query is the unit of analysis and the subsequent metrics (e.g. Mean reciprocal rank or (Normalised) Discounted cumulative gain) are all relevant per unit of analysis. You might be able to get some ideas from there too. 2. There are implementations for regression trees and random forests that are specifically developed for clustered data (at first instance, see Hajjem et al. (2011) Mixed Effects Regression Trees for Clustered Data and Hajjem et al. (2014) Mixed-effects random forest for clustered data respectively). Somewhat simplistically, I assume that if these procedures are used as base-learners in a boosting framework, then the boosting procedure should behave coherently when used with clustered data. | Xgboost and repeated measures
You are correct to worry about using clustered data and then ignoring their inherit clustering. This can lead to information leakage as the cluster/subject-specific variance patterns might dictate pat |
34,481 | Xgboost and repeated measures | It is in general not a good idea to simply drop the ID column as you ignore potentially important information. Also, including the ID column as a categorical variable can have drawbacks in some situations: learning is not efficient when there are many categories and a relatively small number of samples per category, and tree algorithms can have problems with high-cardinality categorical variables. To avoid theses issues, you can use a mixed effects model which models the ID using random effects.
The GPBoost library builds on LightGBM and allows for combining tree-boosting and mixed effects models. Simply speaking it is an extension of linear mixed effects models where the fixed-effects are learned using tree-boosting. See this blog post and Sigrist (2020) for further information.
Disclaimer: I am the author of the GPBoost library. | Xgboost and repeated measures | It is in general not a good idea to simply drop the ID column as you ignore potentially important information. Also, including the ID column as a categorical variable can have drawbacks in some situat | Xgboost and repeated measures
It is in general not a good idea to simply drop the ID column as you ignore potentially important information. Also, including the ID column as a categorical variable can have drawbacks in some situations: learning is not efficient when there are many categories and a relatively small number of samples per category, and tree algorithms can have problems with high-cardinality categorical variables. To avoid theses issues, you can use a mixed effects model which models the ID using random effects.
The GPBoost library builds on LightGBM and allows for combining tree-boosting and mixed effects models. Simply speaking it is an extension of linear mixed effects models where the fixed-effects are learned using tree-boosting. See this blog post and Sigrist (2020) for further information.
Disclaimer: I am the author of the GPBoost library. | Xgboost and repeated measures
It is in general not a good idea to simply drop the ID column as you ignore potentially important information. Also, including the ID column as a categorical variable can have drawbacks in some situat |
34,482 | Is it important to make a feature scaling before using Gaussian Mixture Model? | I'm going to assume that you mean , when you say "using a Gaussian Mixture Model", you mean fitting a mixture of (possibly multivariate) Gaussians to some data, for the purposes of clustering.
In this case, provided you use maximum-likelihood as your condition for fitting the model, you don't need to scale your data. If one variable has a higher variance than another, your optimisation procedure will be able to learn this and fit your variances (or covariance matrices in the multivariate case) accordingly.
Only if you include a prior (and are thus doing posterior maximisation) will the scale of your data be important.
To answer why it's important in KMeans and not Gaussian Mixture Models, it's easiest to explain in terms of the soft KMeans algorithm, which KMeans itself is a limiting case of. The soft KMeans algorithm is the same as Gaussian Mixture modelling, if you assume that all of your clusters are generated by Gaussians of the same variance (and no covariance, all features are independent). For that reason, it makes sense to enforce that all your features do have the same variance (but you don't need to centre them, because KMeans allows the distributions to have different centroids, it learns them).
Gaussian Mixture Modelling explicitly relaxes both the assumption of all clusters having the same variance, and the assumption of no correlation of features within a cluster, and that's why you don't need to standardise your features.
To be clear, the real advantage to using Gaussian Mixture Models is that your clusters don't have to be hyper-spherical and of the same radius. The fact that you also don't have to standardise your variables is just a nice bonus | Is it important to make a feature scaling before using Gaussian Mixture Model? | I'm going to assume that you mean , when you say "using a Gaussian Mixture Model", you mean fitting a mixture of (possibly multivariate) Gaussians to some data, for the purposes of clustering.
In this | Is it important to make a feature scaling before using Gaussian Mixture Model?
I'm going to assume that you mean , when you say "using a Gaussian Mixture Model", you mean fitting a mixture of (possibly multivariate) Gaussians to some data, for the purposes of clustering.
In this case, provided you use maximum-likelihood as your condition for fitting the model, you don't need to scale your data. If one variable has a higher variance than another, your optimisation procedure will be able to learn this and fit your variances (or covariance matrices in the multivariate case) accordingly.
Only if you include a prior (and are thus doing posterior maximisation) will the scale of your data be important.
To answer why it's important in KMeans and not Gaussian Mixture Models, it's easiest to explain in terms of the soft KMeans algorithm, which KMeans itself is a limiting case of. The soft KMeans algorithm is the same as Gaussian Mixture modelling, if you assume that all of your clusters are generated by Gaussians of the same variance (and no covariance, all features are independent). For that reason, it makes sense to enforce that all your features do have the same variance (but you don't need to centre them, because KMeans allows the distributions to have different centroids, it learns them).
Gaussian Mixture Modelling explicitly relaxes both the assumption of all clusters having the same variance, and the assumption of no correlation of features within a cluster, and that's why you don't need to standardise your features.
To be clear, the real advantage to using Gaussian Mixture Models is that your clusters don't have to be hyper-spherical and of the same radius. The fact that you also don't have to standardise your variables is just a nice bonus | Is it important to make a feature scaling before using Gaussian Mixture Model?
I'm going to assume that you mean , when you say "using a Gaussian Mixture Model", you mean fitting a mixture of (possibly multivariate) Gaussians to some data, for the purposes of clustering.
In this |
34,483 | Why is regression with Gradient Tree Boosting sometimes impacted by normalization (or scaling)? | A big part of the answer seems to be found in https://github.com/dmlc/xgboost/issues/799#issuecomment-181768076.
By default, base_score is set to 0.5 and this seems a bad choice for regression problems. When the average of the target is much higher or lower than base_score, the first x trees are just trying to catch the average, and less trees are left to solve the real task.
The solution thus seems simple: adjust base_score to the mean of the target to avoid impact from its scale on the regression result.
Especially for objective 'reg:gamma' this indeed seems to be the clue, whereas for 'reg:linear' it provides only a partial improvement:
data = {'reg:linear': [], 'reg:gamma': [], 'reg:linear - base_score': [], 'reg:gamma - base_score': []}
for objective in ['reg:linear', 'reg:gamma']:
for scale in scales:
xgb_model = xgb.XGBRegressor(objective=objective).fit(X, y / scale)
y_predicted = xgb_model.predict(X) * scale
data[objective].append(mean_squared_error(y, y_predicted))
for objective in ['reg:linear', 'reg:gamma']:
for scale in scales:
base_score = (y / scale).mean()
xgb_model = xgb.XGBRegressor(objective=objective, base_score=base_score).fit(X, y / scale)
y_predicted = xgb_model.predict(X) * scale
data[objective + ' - base_score'].append(mean_squared_error(y, y_predicted))
styles = ['g-', 'r-', 'g--', 'r--']
pd.DataFrame(data, index=scales).plot(loglog=True, grid=True, style=styles).set(ylabel='MSE')
So the remaining question reduces to: Why is there still sometimes an impact of scaling the target with objective 'reg:linear', even after adjusting base_score to the mean of the (scaled) target? | Why is regression with Gradient Tree Boosting sometimes impacted by normalization (or scaling)? | A big part of the answer seems to be found in https://github.com/dmlc/xgboost/issues/799#issuecomment-181768076.
By default, base_score is set to 0.5 and this seems a bad choice for regression problem | Why is regression with Gradient Tree Boosting sometimes impacted by normalization (or scaling)?
A big part of the answer seems to be found in https://github.com/dmlc/xgboost/issues/799#issuecomment-181768076.
By default, base_score is set to 0.5 and this seems a bad choice for regression problems. When the average of the target is much higher or lower than base_score, the first x trees are just trying to catch the average, and less trees are left to solve the real task.
The solution thus seems simple: adjust base_score to the mean of the target to avoid impact from its scale on the regression result.
Especially for objective 'reg:gamma' this indeed seems to be the clue, whereas for 'reg:linear' it provides only a partial improvement:
data = {'reg:linear': [], 'reg:gamma': [], 'reg:linear - base_score': [], 'reg:gamma - base_score': []}
for objective in ['reg:linear', 'reg:gamma']:
for scale in scales:
xgb_model = xgb.XGBRegressor(objective=objective).fit(X, y / scale)
y_predicted = xgb_model.predict(X) * scale
data[objective].append(mean_squared_error(y, y_predicted))
for objective in ['reg:linear', 'reg:gamma']:
for scale in scales:
base_score = (y / scale).mean()
xgb_model = xgb.XGBRegressor(objective=objective, base_score=base_score).fit(X, y / scale)
y_predicted = xgb_model.predict(X) * scale
data[objective + ' - base_score'].append(mean_squared_error(y, y_predicted))
styles = ['g-', 'r-', 'g--', 'r--']
pd.DataFrame(data, index=scales).plot(loglog=True, grid=True, style=styles).set(ylabel='MSE')
So the remaining question reduces to: Why is there still sometimes an impact of scaling the target with objective 'reg:linear', even after adjusting base_score to the mean of the (scaled) target? | Why is regression with Gradient Tree Boosting sometimes impacted by normalization (or scaling)?
A big part of the answer seems to be found in https://github.com/dmlc/xgboost/issues/799#issuecomment-181768076.
By default, base_score is set to 0.5 and this seems a bad choice for regression problem |
34,484 | Why is regression with Gradient Tree Boosting sometimes impacted by normalization (or scaling)? | Trees really do not depend on scaling, and a linear boosting algorithm shouldn't either.
However, we have to keep in mind XGBoost is a Gradient Boosting algorithm that tries to optimize a loss function based on the addition of models, through gradient descent.
Why is this important? Gradient descent update rules operate based on the estimation of an optimal direction for updating plus a step length for a step in this direction. The length of this step isn't obvious at all, and in XGBoost it's estimated based on a second-order expansion of the objective function gradient .
I have to investigate it further, but I guess the reason might lie on this optimization. | Why is regression with Gradient Tree Boosting sometimes impacted by normalization (or scaling)? | Trees really do not depend on scaling, and a linear boosting algorithm shouldn't either.
However, we have to keep in mind XGBoost is a Gradient Boosting algorithm that tries to optimize a loss functio | Why is regression with Gradient Tree Boosting sometimes impacted by normalization (or scaling)?
Trees really do not depend on scaling, and a linear boosting algorithm shouldn't either.
However, we have to keep in mind XGBoost is a Gradient Boosting algorithm that tries to optimize a loss function based on the addition of models, through gradient descent.
Why is this important? Gradient descent update rules operate based on the estimation of an optimal direction for updating plus a step length for a step in this direction. The length of this step isn't obvious at all, and in XGBoost it's estimated based on a second-order expansion of the objective function gradient .
I have to investigate it further, but I guess the reason might lie on this optimization. | Why is regression with Gradient Tree Boosting sometimes impacted by normalization (or scaling)?
Trees really do not depend on scaling, and a linear boosting algorithm shouldn't either.
However, we have to keep in mind XGBoost is a Gradient Boosting algorithm that tries to optimize a loss functio |
34,485 | gradient descent and local maximum | If Gradient Descent gets initialized in such a way that it starts at a local maximum (or a saddle point, or a local minimum) with gradient zero, then it will simply stay stuck there. Variations of GD, such as Stochastic GD and Mini-batch GD try to work around this by adding an element of randomness to the search, but even those aren't guaranteed to escape a zero gradient region if the shape of the gradient is weird enough.
In practice the only way to solve this is to reinitialize your search with new weights or parameters that start in a completely new region of the search space. This won't be hard to do, since if you do get stuck in such a zero-gradient area you will notice very quickly that the error in your training isn't changing at all, and you would know that you need to start over. | gradient descent and local maximum | If Gradient Descent gets initialized in such a way that it starts at a local maximum (or a saddle point, or a local minimum) with gradient zero, then it will simply stay stuck there. Variations of GD, | gradient descent and local maximum
If Gradient Descent gets initialized in such a way that it starts at a local maximum (or a saddle point, or a local minimum) with gradient zero, then it will simply stay stuck there. Variations of GD, such as Stochastic GD and Mini-batch GD try to work around this by adding an element of randomness to the search, but even those aren't guaranteed to escape a zero gradient region if the shape of the gradient is weird enough.
In practice the only way to solve this is to reinitialize your search with new weights or parameters that start in a completely new region of the search space. This won't be hard to do, since if you do get stuck in such a zero-gradient area you will notice very quickly that the error in your training isn't changing at all, and you would know that you need to start over. | gradient descent and local maximum
If Gradient Descent gets initialized in such a way that it starts at a local maximum (or a saddle point, or a local minimum) with gradient zero, then it will simply stay stuck there. Variations of GD, |
34,486 | Prove that $t_{n-1, \alpha/2} / \sqrt{n} \rightarrow 0$ as $n \rightarrow \infty$ | Proof with Chebyshev's inequality
Here is a proof using Chebyshev's inequality $Pr(|T|\geq k\sigma) \leq \frac{1}{k^2}$.
If we fill in $\sigma_{t_\nu} = \frac{\nu}{\nu-2}$ and set $1/k^2=\alpha = Pr\left(|T|\geq t_{\nu,\alpha/2}\right)$ then we have a limit
$$Pr\left(|T|\geq \frac{\nu}{\nu-2}\frac{1}{\sqrt{\alpha}}\right) \leq Pr\left(|T|\geq t_{\nu,\alpha/2}\right) $$
thus $t_{\nu,\alpha/2}$ will be bounded above by
$$t_{\nu,\alpha/2} \leq \frac{\nu}{\nu-2}\frac{1}{\sqrt{\alpha}}$$
adding the obvious lower bound and devide by $\sqrt{\nu+1}$
$$0 \leq \frac{t_{n-1,\alpha/2}}{\sqrt{\nu+1}} \leq \frac{\nu}{\sqrt{\nu+1}\left(\nu-2\right)}\frac{1}{\sqrt{\alpha}} $$
which squeezes $t_{n-1,\alpha/2} / \sqrt{n}$ to zero for $n \to \infty$ | Prove that $t_{n-1, \alpha/2} / \sqrt{n} \rightarrow 0$ as $n \rightarrow \infty$ | Proof with Chebyshev's inequality
Here is a proof using Chebyshev's inequality $Pr(|T|\geq k\sigma) \leq \frac{1}{k^2}$.
If we fill in $\sigma_{t_\nu} = \frac{\nu}{\nu-2}$ and set $1/k^2=\alpha = Pr\l | Prove that $t_{n-1, \alpha/2} / \sqrt{n} \rightarrow 0$ as $n \rightarrow \infty$
Proof with Chebyshev's inequality
Here is a proof using Chebyshev's inequality $Pr(|T|\geq k\sigma) \leq \frac{1}{k^2}$.
If we fill in $\sigma_{t_\nu} = \frac{\nu}{\nu-2}$ and set $1/k^2=\alpha = Pr\left(|T|\geq t_{\nu,\alpha/2}\right)$ then we have a limit
$$Pr\left(|T|\geq \frac{\nu}{\nu-2}\frac{1}{\sqrt{\alpha}}\right) \leq Pr\left(|T|\geq t_{\nu,\alpha/2}\right) $$
thus $t_{\nu,\alpha/2}$ will be bounded above by
$$t_{\nu,\alpha/2} \leq \frac{\nu}{\nu-2}\frac{1}{\sqrt{\alpha}}$$
adding the obvious lower bound and devide by $\sqrt{\nu+1}$
$$0 \leq \frac{t_{n-1,\alpha/2}}{\sqrt{\nu+1}} \leq \frac{\nu}{\sqrt{\nu+1}\left(\nu-2\right)}\frac{1}{\sqrt{\alpha}} $$
which squeezes $t_{n-1,\alpha/2} / \sqrt{n}$ to zero for $n \to \infty$ | Prove that $t_{n-1, \alpha/2} / \sqrt{n} \rightarrow 0$ as $n \rightarrow \infty$
Proof with Chebyshev's inequality
Here is a proof using Chebyshev's inequality $Pr(|T|\geq k\sigma) \leq \frac{1}{k^2}$.
If we fill in $\sigma_{t_\nu} = \frac{\nu}{\nu-2}$ and set $1/k^2=\alpha = Pr\l |
34,487 | Prove that $t_{n-1, \alpha/2} / \sqrt{n} \rightarrow 0$ as $n \rightarrow \infty$ | I'm sure there is an easier way to do this, but the result is immediate from the following:
Proposition: Let $F$ be a continuous distribution function and $F_n$ a sequence of distribution functions such that $F_n \to F$ weakly (i.e., in distribution). Then $F_n(x) \to F(x)$ uniformly in $x$.
Proof: Using continuity and monotonicity, for any natural number $m$ we can select $x_0, x_1, \ldots, x_m$ such that $F(x_j) = j/m$ (taking $x_0 = -\infty$ and $x_m = \infty$). By weak convergence and the fact that $F$ is continuous, $F_n(x_j) \to F(x_j)$. For any $y$, find an interval $[x_{j-1}, x_{j}]$ containing $y$ and note that $|F_n(y) - F(y)| \le \sup_j |F_n(x_j) - F(x_j)| + |F(x_j) - F(x_{j-1})| \to \frac{1}{m}$. Hence $\varlimsup_{n \to \infty} \sup_y |F_n(y) - F(y)| \le \frac 1 m$ and because $m$ was arbitrary we get $\sup_y |F_n(y) - F(y)| \to 0$.
Next, it is a well-known application of Slutsky's theorem that the $t_{n-1}$ converges in distribution to a standard normal distribution. The previous result implies that $F_n(t_{n-1,\alpha}) - F(t_{n-1,\alpha}) \to 0$, i.e., $F(t_{n-1,\alpha}) \to \alpha$. Applying the normal quantile function to both sides, we get $t_{n-1,\alpha} \to z_{\alpha}$.
Hence $t_{n-1,\alpha} \to z_{\alpha}$ implying $\frac{t_{n-1,\alpha}}{g(n)} \to 0$ for any $g(n) \to \infty$ (in particular, $g(n) = \sqrt n$). | Prove that $t_{n-1, \alpha/2} / \sqrt{n} \rightarrow 0$ as $n \rightarrow \infty$ | I'm sure there is an easier way to do this, but the result is immediate from the following:
Proposition: Let $F$ be a continuous distribution function and $F_n$ a sequence of distribution functions | Prove that $t_{n-1, \alpha/2} / \sqrt{n} \rightarrow 0$ as $n \rightarrow \infty$
I'm sure there is an easier way to do this, but the result is immediate from the following:
Proposition: Let $F$ be a continuous distribution function and $F_n$ a sequence of distribution functions such that $F_n \to F$ weakly (i.e., in distribution). Then $F_n(x) \to F(x)$ uniformly in $x$.
Proof: Using continuity and monotonicity, for any natural number $m$ we can select $x_0, x_1, \ldots, x_m$ such that $F(x_j) = j/m$ (taking $x_0 = -\infty$ and $x_m = \infty$). By weak convergence and the fact that $F$ is continuous, $F_n(x_j) \to F(x_j)$. For any $y$, find an interval $[x_{j-1}, x_{j}]$ containing $y$ and note that $|F_n(y) - F(y)| \le \sup_j |F_n(x_j) - F(x_j)| + |F(x_j) - F(x_{j-1})| \to \frac{1}{m}$. Hence $\varlimsup_{n \to \infty} \sup_y |F_n(y) - F(y)| \le \frac 1 m$ and because $m$ was arbitrary we get $\sup_y |F_n(y) - F(y)| \to 0$.
Next, it is a well-known application of Slutsky's theorem that the $t_{n-1}$ converges in distribution to a standard normal distribution. The previous result implies that $F_n(t_{n-1,\alpha}) - F(t_{n-1,\alpha}) \to 0$, i.e., $F(t_{n-1,\alpha}) \to \alpha$. Applying the normal quantile function to both sides, we get $t_{n-1,\alpha} \to z_{\alpha}$.
Hence $t_{n-1,\alpha} \to z_{\alpha}$ implying $\frac{t_{n-1,\alpha}}{g(n)} \to 0$ for any $g(n) \to \infty$ (in particular, $g(n) = \sqrt n$). | Prove that $t_{n-1, \alpha/2} / \sqrt{n} \rightarrow 0$ as $n \rightarrow \infty$
I'm sure there is an easier way to do this, but the result is immediate from the following:
Proposition: Let $F$ be a continuous distribution function and $F_n$ a sequence of distribution functions |
34,488 | Prove that $t_{n-1, \alpha/2} / \sqrt{n} \rightarrow 0$ as $n \rightarrow \infty$ | Geometrical proof
Geometrical view
Consider the observed sample as a point in n-dimensional Euclidean space and the estimation of the mean as the projection of an observation $x_1,x_2,...,x_n$ onto the model line $x_1=x_2= ... = x_n = \bar{x}$.
The t-score can be expressed as ratio of two distances in this space
the distance between the projected point and the population mean $$\sqrt{n}(\bar{x}-\mu)$$
the distance between this point and the observation $$\sqrt{\sum_{i=1}^n(\hat{x}-x_i)^2}$$
This is related to the tangent of the angle between the observation and the line on which it is projected.
$$\frac{t}{\sqrt{n-1} } =\frac{\sqrt{n}(\bar{x}-\mu)}{\sqrt{\sum_{i=1}^n(\hat{x}-x_i)^2}} = \frac{1}{\tan{\theta}}$$
Equivalence t-distribution and angle distribution
In this geometrical view the probability of the t-score being higher than some value is equivalent to the probability of the angle being less than some value:
$$Pr(|T|>t_{n-1,\alpha/2}) = 2 Pr(\theta \leq \theta_{\nu,\alpha}) = \alpha$$
Or
$$\frac{t_{n-1,\alpha/2}}{\sqrt{n-1}} = \frac{1}{\tan \theta_{\nu,\alpha}}$$
You could say that the t-score relates to the angle of the observation with the line of the theoretic model. For points outside the confidence interval (then $\mu$ is further away from $\bar{x}$ and the angle will be smaller) the angle will be below some limit $\theta_{\nu,\alpha}$. This limit will change with more observations. If the limit of this angle $\theta_{\nu,\alpha}$ goes to 90 degrees for large $n$ (the cone shape getting more flat, ie less pointy and long) then this means that the size of the confidence interval becomes smaller and approaches zero.
Angle distribution as relative area of the cap of an n-sphere
Due to symmetry of the joint probability distribution of independent normal distributed variables, every direction is equally probable and the probability for the angle to be within a certain region is equal to the relative area of the cap of an n-sphere.
The relative area of this n-cap is found by integrating the area of a n-frustum:
$$\begin{array}{rcl} 2 Pr(\theta \leq \theta_c)& =& 2 \int_{\frac{1}{\sqrt{1+\tan(\theta_c)^2}}}^1 \frac{(1-x^2)^{\frac{n-3}{2}}}{B(\frac{1}{2},\frac{n-1}{2})} dx \\
&=& \int_{\frac{1}{{1+\tan(\theta_c)^2}}}^1 \frac{t^{-0.5}(1-t)^{\frac{n-3}{2}}}{B(\frac{1}{2},\frac{n-1}{2})} dt \\
&=& I_{\frac{1}{{1+\tan(\theta_c)^2}}}\left(\frac{1}{2},\frac{n-1}{2} \right)
\end{array}$$
where $I_x(\cdot,\cdot)$ is the upper regularized incomplete beta function.
Limit of angle
If $\theta_{n,\alpha}$ goes to 90 degrees for $n \to \infty$ then $t_{n-1,\alpha/2}/\sqrt{n}$ goes to zero.
Or an inverse statement: for any angle smaller than 90 degrees the relative area of that angle on a n-sphere, decreases to zero when $n$ goes to infinity.
Intuitively this means that all area of a n-sphere concentrates to the equator as the dimension $n$ increases to infinity.
Quantitatively we can show this by using the expression
$$\int_{a}^1 \frac{t^{-0.5}(1-t)^{\frac{n-3}{2}}}{B(\frac{1}{2},\frac{n-1}{2})} dt < \int_{a}^1 \frac{(1-a)^{\frac{n-3}{2}}}{B(\frac{1}{2},\frac{n-1}{2})} dt = \frac{(1-a)^{\frac{n-1}{2}}}{B(\frac{1}{2},\frac{n-1}{2})} = L(n)$$
and consider the difference between $L(n+2)$ and $L(n)$.
At some point the decrease in the denominator $$\frac{B(\frac{1}{2},x+1)}{B(\frac{1}{2},x)} = \frac{x}{x+\frac{1}{2}}$$ will be taken over by the decrease in the numerator $$\frac{(1-a)^{\frac{n+1}{2}}}{(1-a)^{\frac{n-1}{2}}} = 1-a$$ and the function $L(n)$ decreases to zero for $n$ to infinity. | Prove that $t_{n-1, \alpha/2} / \sqrt{n} \rightarrow 0$ as $n \rightarrow \infty$ | Geometrical proof
Geometrical view
Consider the observed sample as a point in n-dimensional Euclidean space and the estimation of the mean as the projection of an observation $x_1,x_2,...,x_n$ onto th | Prove that $t_{n-1, \alpha/2} / \sqrt{n} \rightarrow 0$ as $n \rightarrow \infty$
Geometrical proof
Geometrical view
Consider the observed sample as a point in n-dimensional Euclidean space and the estimation of the mean as the projection of an observation $x_1,x_2,...,x_n$ onto the model line $x_1=x_2= ... = x_n = \bar{x}$.
The t-score can be expressed as ratio of two distances in this space
the distance between the projected point and the population mean $$\sqrt{n}(\bar{x}-\mu)$$
the distance between this point and the observation $$\sqrt{\sum_{i=1}^n(\hat{x}-x_i)^2}$$
This is related to the tangent of the angle between the observation and the line on which it is projected.
$$\frac{t}{\sqrt{n-1} } =\frac{\sqrt{n}(\bar{x}-\mu)}{\sqrt{\sum_{i=1}^n(\hat{x}-x_i)^2}} = \frac{1}{\tan{\theta}}$$
Equivalence t-distribution and angle distribution
In this geometrical view the probability of the t-score being higher than some value is equivalent to the probability of the angle being less than some value:
$$Pr(|T|>t_{n-1,\alpha/2}) = 2 Pr(\theta \leq \theta_{\nu,\alpha}) = \alpha$$
Or
$$\frac{t_{n-1,\alpha/2}}{\sqrt{n-1}} = \frac{1}{\tan \theta_{\nu,\alpha}}$$
You could say that the t-score relates to the angle of the observation with the line of the theoretic model. For points outside the confidence interval (then $\mu$ is further away from $\bar{x}$ and the angle will be smaller) the angle will be below some limit $\theta_{\nu,\alpha}$. This limit will change with more observations. If the limit of this angle $\theta_{\nu,\alpha}$ goes to 90 degrees for large $n$ (the cone shape getting more flat, ie less pointy and long) then this means that the size of the confidence interval becomes smaller and approaches zero.
Angle distribution as relative area of the cap of an n-sphere
Due to symmetry of the joint probability distribution of independent normal distributed variables, every direction is equally probable and the probability for the angle to be within a certain region is equal to the relative area of the cap of an n-sphere.
The relative area of this n-cap is found by integrating the area of a n-frustum:
$$\begin{array}{rcl} 2 Pr(\theta \leq \theta_c)& =& 2 \int_{\frac{1}{\sqrt{1+\tan(\theta_c)^2}}}^1 \frac{(1-x^2)^{\frac{n-3}{2}}}{B(\frac{1}{2},\frac{n-1}{2})} dx \\
&=& \int_{\frac{1}{{1+\tan(\theta_c)^2}}}^1 \frac{t^{-0.5}(1-t)^{\frac{n-3}{2}}}{B(\frac{1}{2},\frac{n-1}{2})} dt \\
&=& I_{\frac{1}{{1+\tan(\theta_c)^2}}}\left(\frac{1}{2},\frac{n-1}{2} \right)
\end{array}$$
where $I_x(\cdot,\cdot)$ is the upper regularized incomplete beta function.
Limit of angle
If $\theta_{n,\alpha}$ goes to 90 degrees for $n \to \infty$ then $t_{n-1,\alpha/2}/\sqrt{n}$ goes to zero.
Or an inverse statement: for any angle smaller than 90 degrees the relative area of that angle on a n-sphere, decreases to zero when $n$ goes to infinity.
Intuitively this means that all area of a n-sphere concentrates to the equator as the dimension $n$ increases to infinity.
Quantitatively we can show this by using the expression
$$\int_{a}^1 \frac{t^{-0.5}(1-t)^{\frac{n-3}{2}}}{B(\frac{1}{2},\frac{n-1}{2})} dt < \int_{a}^1 \frac{(1-a)^{\frac{n-3}{2}}}{B(\frac{1}{2},\frac{n-1}{2})} dt = \frac{(1-a)^{\frac{n-1}{2}}}{B(\frac{1}{2},\frac{n-1}{2})} = L(n)$$
and consider the difference between $L(n+2)$ and $L(n)$.
At some point the decrease in the denominator $$\frac{B(\frac{1}{2},x+1)}{B(\frac{1}{2},x)} = \frac{x}{x+\frac{1}{2}}$$ will be taken over by the decrease in the numerator $$\frac{(1-a)^{\frac{n+1}{2}}}{(1-a)^{\frac{n-1}{2}}} = 1-a$$ and the function $L(n)$ decreases to zero for $n$ to infinity. | Prove that $t_{n-1, \alpha/2} / \sqrt{n} \rightarrow 0$ as $n \rightarrow \infty$
Geometrical proof
Geometrical view
Consider the observed sample as a point in n-dimensional Euclidean space and the estimation of the mean as the projection of an observation $x_1,x_2,...,x_n$ onto th |
34,489 | Prove that $t_{n-1, \alpha/2} / \sqrt{n} \rightarrow 0$ as $n \rightarrow \infty$ | We have
\begin{align}
\frac{\alpha}{2} &= \int \limits_{t_{n-1, \alpha/2}}^\infty \lim_{n \to \infty}\frac{1}{\sqrt{(n-1) \pi}} \cdot \frac{\Gamma(\tfrac{n}{2})}{\Gamma(\tfrac{n-1}{2})} \Big( 1+ \frac{r^2}{n-1} \Big)^{-n/2} dr \\[10pt]
&= \int \limits_{t_{n-1, \alpha/2}}^\infty \frac{1}{\sqrt{2 \pi}} e^{-\frac{1}{2}r^2} dr \\[10pt]
&= 1-\Phi(t_{n-1, \alpha/2}) \\[10pt]
&\approx 1-\left[\frac{1}{2}+\varphi(t_{n-1, \alpha/2}) \left(t_{n-1, \alpha/2}+\frac{(t_{n-1, \alpha/2})^3}{3}+\frac{(t_{n-1, \alpha/2})^5}{15} + \dots \right) \right]
\end{align}
which implies that the second term in the boxed brackets can be at most $\frac{1}{2}$ since the maximum $\alpha$ can be is $1$. Note that $\varphi(x)$ is the pdf of normal distribution. This approximation is also based on this.
So
$$
0 < \alpha \approx 1+2\varphi(t_{n-1, \alpha/2}) \left(t_{n-1, \alpha/2}+\frac{(t_{n-1, \alpha/2})^3}{3}+\frac{(t_{n-1, \alpha/2})^5}{15} + \dots \right) <1
$$ | Prove that $t_{n-1, \alpha/2} / \sqrt{n} \rightarrow 0$ as $n \rightarrow \infty$ | We have
\begin{align}
\frac{\alpha}{2} &= \int \limits_{t_{n-1, \alpha/2}}^\infty \lim_{n \to \infty}\frac{1}{\sqrt{(n-1) \pi}} \cdot \frac{\Gamma(\tfrac{n}{2})}{\Gamma(\tfrac{n-1}{2})} \Big( 1+ \fr | Prove that $t_{n-1, \alpha/2} / \sqrt{n} \rightarrow 0$ as $n \rightarrow \infty$
We have
\begin{align}
\frac{\alpha}{2} &= \int \limits_{t_{n-1, \alpha/2}}^\infty \lim_{n \to \infty}\frac{1}{\sqrt{(n-1) \pi}} \cdot \frac{\Gamma(\tfrac{n}{2})}{\Gamma(\tfrac{n-1}{2})} \Big( 1+ \frac{r^2}{n-1} \Big)^{-n/2} dr \\[10pt]
&= \int \limits_{t_{n-1, \alpha/2}}^\infty \frac{1}{\sqrt{2 \pi}} e^{-\frac{1}{2}r^2} dr \\[10pt]
&= 1-\Phi(t_{n-1, \alpha/2}) \\[10pt]
&\approx 1-\left[\frac{1}{2}+\varphi(t_{n-1, \alpha/2}) \left(t_{n-1, \alpha/2}+\frac{(t_{n-1, \alpha/2})^3}{3}+\frac{(t_{n-1, \alpha/2})^5}{15} + \dots \right) \right]
\end{align}
which implies that the second term in the boxed brackets can be at most $\frac{1}{2}$ since the maximum $\alpha$ can be is $1$. Note that $\varphi(x)$ is the pdf of normal distribution. This approximation is also based on this.
So
$$
0 < \alpha \approx 1+2\varphi(t_{n-1, \alpha/2}) \left(t_{n-1, \alpha/2}+\frac{(t_{n-1, \alpha/2})^3}{3}+\frac{(t_{n-1, \alpha/2})^5}{15} + \dots \right) <1
$$ | Prove that $t_{n-1, \alpha/2} / \sqrt{n} \rightarrow 0$ as $n \rightarrow \infty$
We have
\begin{align}
\frac{\alpha}{2} &= \int \limits_{t_{n-1, \alpha/2}}^\infty \lim_{n \to \infty}\frac{1}{\sqrt{(n-1) \pi}} \cdot \frac{\Gamma(\tfrac{n}{2})}{\Gamma(\tfrac{n-1}{2})} \Big( 1+ \fr |
34,490 | Prove that $\text{Corr}(X^2,Y^2)=\rho^2$ where $X,Y$ are jointly $N(0,1)$ variables with correlation $\rho$ | Hint:
Let $(X,Y)$ be jointly normal variables with zero means and unit variances and $\text{Corr}(X,Y)=\rho$.
By definition, \begin{align}\text{Corr}(X^2,Y^2)=\frac{\text{Cov}(X^2,Y^2)}{\sqrt{\text{Var}(X^2)\text{Var}(Y^2)}}\end{align}
where $\text{Cov}(X^2,Y^2)=\mathbb E(X^2Y^2)-\mathbb E(X^2)\mathbb E(Y^2)$, and
$\text{Var}(X^2)=\mathbb E(X^4)-(\mathbb E(X^2))^2=\text{Var}(Y^2)$.
For finding $\mathbb E(X^2Y^2)$ quickly, note that $\mathbb E(X^2Y^2)=\mathbb E(\mathbb E(X^2Y^2\mid X))=\mathbb E(X^2\,\mathbb E(Y^2\mid X))$.
And we know that $Y\mid X\sim\mathcal{N}(\rho X,1-\rho^2)$.
So, $\mathbb E(Y^2\mid X)=\text{Var}(Y\mid X)+(\mathbb E(Y\mid X))^2=\cdots$.
I think you can find the moments now. | Prove that $\text{Corr}(X^2,Y^2)=\rho^2$ where $X,Y$ are jointly $N(0,1)$ variables with correlation | Hint:
Let $(X,Y)$ be jointly normal variables with zero means and unit variances and $\text{Corr}(X,Y)=\rho$.
By definition, \begin{align}\text{Corr}(X^2,Y^2)=\frac{\text{Cov}(X^2,Y^2)}{\sqrt{\text{Va | Prove that $\text{Corr}(X^2,Y^2)=\rho^2$ where $X,Y$ are jointly $N(0,1)$ variables with correlation $\rho$
Hint:
Let $(X,Y)$ be jointly normal variables with zero means and unit variances and $\text{Corr}(X,Y)=\rho$.
By definition, \begin{align}\text{Corr}(X^2,Y^2)=\frac{\text{Cov}(X^2,Y^2)}{\sqrt{\text{Var}(X^2)\text{Var}(Y^2)}}\end{align}
where $\text{Cov}(X^2,Y^2)=\mathbb E(X^2Y^2)-\mathbb E(X^2)\mathbb E(Y^2)$, and
$\text{Var}(X^2)=\mathbb E(X^4)-(\mathbb E(X^2))^2=\text{Var}(Y^2)$.
For finding $\mathbb E(X^2Y^2)$ quickly, note that $\mathbb E(X^2Y^2)=\mathbb E(\mathbb E(X^2Y^2\mid X))=\mathbb E(X^2\,\mathbb E(Y^2\mid X))$.
And we know that $Y\mid X\sim\mathcal{N}(\rho X,1-\rho^2)$.
So, $\mathbb E(Y^2\mid X)=\text{Var}(Y\mid X)+(\mathbb E(Y\mid X))^2=\cdots$.
I think you can find the moments now. | Prove that $\text{Corr}(X^2,Y^2)=\rho^2$ where $X,Y$ are jointly $N(0,1)$ variables with correlation
Hint:
Let $(X,Y)$ be jointly normal variables with zero means and unit variances and $\text{Corr}(X,Y)=\rho$.
By definition, \begin{align}\text{Corr}(X^2,Y^2)=\frac{\text{Cov}(X^2,Y^2)}{\sqrt{\text{Va |
34,491 | Prove that $\text{Corr}(X^2,Y^2)=\rho^2$ where $X,Y$ are jointly $N(0,1)$ variables with correlation $\rho$ | You ask how to use the hint. One way is to focus on computing the covariances that go into the correlation formula. There are two. I will do the algebra for you to reduce the problem to simpler calculations requiring a little statistical thought.
The easy covariance calculation (because it involves only one variable at a time and both variables have standard Normal distributions and we know their first four moments are $0,1,0,3$) is $$\operatorname{Var}(X^2) = \operatorname{Var}(Y^2) = E[(Y^2)^2]-E[Y^2]^2=3-1=2.\tag{*}$$
This implies you would like to prove
$$\operatorname{Cov}(X^2,Y^2) = \sqrt{\operatorname{Var}(X^2)}\sqrt{\operatorname{Var}(Y^2)} \operatorname{Cor}(X^2,Y^2) = 2\rho^2.\tag{**}$$
To compute this, let's just blindly apply the hint by making the substitution for $Y,$ expanding $Y^2$ algebraically, and exploiting the linearity of $\operatorname{Cov}$ in its second argument to break the resulting expression into three simpler ones:
$$\eqalign{
\operatorname{Cov}(X^2,Y^2) &= \operatorname{Cov}(X^2, (\rho X + \rho^\prime U)^2) \\
&= \operatorname{Cov}(X^2, \rho^2 X^2 + 2\rho\rho^\prime XU + (\rho^\prime)^2 U^2)\\
&= \rho^2 \operatorname{Cov}(X^2, X^2) + 2\rho\rho^\prime \operatorname{Cov}(X^2, XU) + (\rho^\prime)^2 \operatorname{Cov}(X^2, U^2).
}$$
(To make the patterns clearer to see, I have written $\sqrt{1-\rho^2}=\rho^\prime.$)
That should be good enough, but I'll take you a little closer to the end so you can see where this is all going. We have already found (at $*$) that
$$\operatorname{Cov}(X^2, X^2) = \operatorname{Var}(X^2) = 2.$$
Plugging this value into the preceding expression and comparing it to $(**)$ shows we would like to demonstrate
$$2\rho^2 = \operatorname{Cov}(X^2, Y^2) = 2\rho^2 + 2\rho\rho^\prime \operatorname{Cov}(X^2, XU) + (\rho^\prime)^2 \operatorname{Cov}(X^2, U^2).$$
Evidently, no matter what value $\rho$ might have, the sum of the last two terms needs to be zero. This insight reminds us that $X$ and $U$ are independent. Exploit that fact to show that each of the remaining covariances is zero. Explicitly, prove
$$\operatorname{Cov}(X^2, XU) = 0 = \operatorname{Cov}(X^2, U^2).$$ | Prove that $\text{Corr}(X^2,Y^2)=\rho^2$ where $X,Y$ are jointly $N(0,1)$ variables with correlation | You ask how to use the hint. One way is to focus on computing the covariances that go into the correlation formula. There are two. I will do the algebra for you to reduce the problem to simpler cal | Prove that $\text{Corr}(X^2,Y^2)=\rho^2$ where $X,Y$ are jointly $N(0,1)$ variables with correlation $\rho$
You ask how to use the hint. One way is to focus on computing the covariances that go into the correlation formula. There are two. I will do the algebra for you to reduce the problem to simpler calculations requiring a little statistical thought.
The easy covariance calculation (because it involves only one variable at a time and both variables have standard Normal distributions and we know their first four moments are $0,1,0,3$) is $$\operatorname{Var}(X^2) = \operatorname{Var}(Y^2) = E[(Y^2)^2]-E[Y^2]^2=3-1=2.\tag{*}$$
This implies you would like to prove
$$\operatorname{Cov}(X^2,Y^2) = \sqrt{\operatorname{Var}(X^2)}\sqrt{\operatorname{Var}(Y^2)} \operatorname{Cor}(X^2,Y^2) = 2\rho^2.\tag{**}$$
To compute this, let's just blindly apply the hint by making the substitution for $Y,$ expanding $Y^2$ algebraically, and exploiting the linearity of $\operatorname{Cov}$ in its second argument to break the resulting expression into three simpler ones:
$$\eqalign{
\operatorname{Cov}(X^2,Y^2) &= \operatorname{Cov}(X^2, (\rho X + \rho^\prime U)^2) \\
&= \operatorname{Cov}(X^2, \rho^2 X^2 + 2\rho\rho^\prime XU + (\rho^\prime)^2 U^2)\\
&= \rho^2 \operatorname{Cov}(X^2, X^2) + 2\rho\rho^\prime \operatorname{Cov}(X^2, XU) + (\rho^\prime)^2 \operatorname{Cov}(X^2, U^2).
}$$
(To make the patterns clearer to see, I have written $\sqrt{1-\rho^2}=\rho^\prime.$)
That should be good enough, but I'll take you a little closer to the end so you can see where this is all going. We have already found (at $*$) that
$$\operatorname{Cov}(X^2, X^2) = \operatorname{Var}(X^2) = 2.$$
Plugging this value into the preceding expression and comparing it to $(**)$ shows we would like to demonstrate
$$2\rho^2 = \operatorname{Cov}(X^2, Y^2) = 2\rho^2 + 2\rho\rho^\prime \operatorname{Cov}(X^2, XU) + (\rho^\prime)^2 \operatorname{Cov}(X^2, U^2).$$
Evidently, no matter what value $\rho$ might have, the sum of the last two terms needs to be zero. This insight reminds us that $X$ and $U$ are independent. Exploit that fact to show that each of the remaining covariances is zero. Explicitly, prove
$$\operatorname{Cov}(X^2, XU) = 0 = \operatorname{Cov}(X^2, U^2).$$ | Prove that $\text{Corr}(X^2,Y^2)=\rho^2$ where $X,Y$ are jointly $N(0,1)$ variables with correlation
You ask how to use the hint. One way is to focus on computing the covariances that go into the correlation formula. There are two. I will do the algebra for you to reduce the problem to simpler cal |
34,492 | QQ plot and $x = y$ line | The linearity of the QQ-plot only suggests that your sample follows a normal distribution (or more specifically, it's quantile function is the probit function). The slope is determined by the standard deviation (for sd=1, we get the popular $x=y$ line).
An S-shaped plot, something which seems symmetrical across 180-degree rotation is indicative of a symmetric distribution.
An intuitive reasoning for the shape is thus; to get a straight line, you need a similar scaling of the spacing of the quantiles around the mean. Meaning that if say $x^{th}$ quantile is some proportion of distance from the mean when compared to $y^{th}$ quantile, the proportion is conserved, which is only conserved in case of a normal distribution. The slope is more indicative of the absolute magnitude of this proportion, hence depends on the sd. Different shapes can be reasoned out in a similar way, by looking at this proportion at different places along the distribution.
Here are some visualisations.
Note: I am plotting the sample on the Y-axis as is the norm, and I am assuming that the way you have plotted puts the sample on the x axis.
R-code:
# Creating different distributions with mean 0
library(rmutil)
set.seed(12345)
normald<-rnorm(10000,sd=2)
normald<-(normald-mean(normald))/sd(normald)
sharperpeak<-rlaplace(10000) #using Laplace distribution
sharperpeak<-(sharperpeak-mean(sharperpeak))/sd(sharperpeak)
heavytail<-rt(10000,5) #using t-distribution
heavytail<-(heavytail-mean(heavytail))/sd(heavytail)
positiveskew<-rlnorm(10000) #using lognormal distribution
positiveskew<-(positiveskew-mean(positiveskew))/sd(positiveskew)
negativeskew<-positiveskew*(-1) #shortcut
negativeskew<-(negativeskew-mean(negativeskew))/sd(negativeskew)
library(ggplot2)
library(gridExtra)
#normal plot
p1<-ggplot(data.frame(dt=normald))+geom_density(aes(x=dt),fill='green',alpha=0.6)+xlab('Normal Distribution')+geom_vline(xintercept=quantile(normald,c(0.25,0.75),color='red',alpha=0.3))
p2<-ggplot(data.frame(dt=normald))+geom_qq(aes(sample=dt))+geom_abline(slope=1,intercept = 0)
grid.arrange(p1,p2,nrow=1)
#sharppeak plot
p1<-ggplot(data.frame(dt=sharperpeak))+geom_density(aes(x=dt),fill='green',alpha=0.6)+xlab('Sharper-peaks')+geom_vline(xintercept=quantile(sharperpeak,c(0.25,0.75),color='red',alpha=0.3))
p2<-ggplot(data.frame(dt=sharperpeak))+geom_qq(aes(sample=dt))+geom_abline(slope=1,intercept = 0)
grid.arrange(p1,p2,nrow=1)
#heaviertails plot
p1<-ggplot(data.frame(dt=heavytail))+geom_density(aes(x=dt),fill='green',alpha=0.6)+xlab('Heavy Tails')+geom_vline(xintercept=quantile(heavytail,c(0.25,0.75),color='red',alpha=0.3))
p2<-ggplot(data.frame(dt=heavytail))+geom_qq(aes(sample=dt))+geom_abline(slope=1,intercept = 0)
grid.arrange(p1,p2,nrow=1)
#positiveskew plot
p1<-ggplot(data.frame(dt=positiveskew))+geom_density(aes(x=dt),fill='green',alpha=0.6)+xlab('Positively skewed Distribution')+geom_vline(xintercept=quantile(positiveskew,c(0.25,0.75),color='red',alpha=0.3))+xlim(-1.5,5)
p2<-ggplot(data.frame(dt=positiveskew))+geom_qq(aes(sample=dt))+geom_abline(slope=1,intercept = 0)
grid.arrange(p1,p2,nrow=1)
#negative skew plot
p1<-ggplot(data.frame(dt=negativeskew))+geom_density(aes(x=dt),fill='green',alpha=0.6)+xlab('Negatively skewed Distribution')+geom_vline(xintercept=quantile(negativeskew,c(0.25,0.75),color='red',alpha=0.3))+xlim(-5,1.5)
p2<-ggplot(data.frame(dt=negativeskew))+geom_qq(aes(sample=dt))+geom_abline(slope=1,intercept = 0)
grid.arrange(p1,p2,nrow=1)
# Normal distributions with different sds
normal1<-rnorm(3000,sd=2)
normal2<-rnorm(3000,sd=4)
normal3<-rnorm(3000,sd=0.5)
normal4<-rnorm(3000,sd=0.25)
final<-c(normal1,normal2,normal3,normal4)
ggplot(data.frame(dt=final,sds=factor(rep(c('2','4','0.5','0.25'),each=3000))),aes(sample=dt,color=sds))+geom_qq()+geom_abline(slope=1,intercept=0) | QQ plot and $x = y$ line | The linearity of the QQ-plot only suggests that your sample follows a normal distribution (or more specifically, it's quantile function is the probit function). The slope is determined by the standard | QQ plot and $x = y$ line
The linearity of the QQ-plot only suggests that your sample follows a normal distribution (or more specifically, it's quantile function is the probit function). The slope is determined by the standard deviation (for sd=1, we get the popular $x=y$ line).
An S-shaped plot, something which seems symmetrical across 180-degree rotation is indicative of a symmetric distribution.
An intuitive reasoning for the shape is thus; to get a straight line, you need a similar scaling of the spacing of the quantiles around the mean. Meaning that if say $x^{th}$ quantile is some proportion of distance from the mean when compared to $y^{th}$ quantile, the proportion is conserved, which is only conserved in case of a normal distribution. The slope is more indicative of the absolute magnitude of this proportion, hence depends on the sd. Different shapes can be reasoned out in a similar way, by looking at this proportion at different places along the distribution.
Here are some visualisations.
Note: I am plotting the sample on the Y-axis as is the norm, and I am assuming that the way you have plotted puts the sample on the x axis.
R-code:
# Creating different distributions with mean 0
library(rmutil)
set.seed(12345)
normald<-rnorm(10000,sd=2)
normald<-(normald-mean(normald))/sd(normald)
sharperpeak<-rlaplace(10000) #using Laplace distribution
sharperpeak<-(sharperpeak-mean(sharperpeak))/sd(sharperpeak)
heavytail<-rt(10000,5) #using t-distribution
heavytail<-(heavytail-mean(heavytail))/sd(heavytail)
positiveskew<-rlnorm(10000) #using lognormal distribution
positiveskew<-(positiveskew-mean(positiveskew))/sd(positiveskew)
negativeskew<-positiveskew*(-1) #shortcut
negativeskew<-(negativeskew-mean(negativeskew))/sd(negativeskew)
library(ggplot2)
library(gridExtra)
#normal plot
p1<-ggplot(data.frame(dt=normald))+geom_density(aes(x=dt),fill='green',alpha=0.6)+xlab('Normal Distribution')+geom_vline(xintercept=quantile(normald,c(0.25,0.75),color='red',alpha=0.3))
p2<-ggplot(data.frame(dt=normald))+geom_qq(aes(sample=dt))+geom_abline(slope=1,intercept = 0)
grid.arrange(p1,p2,nrow=1)
#sharppeak plot
p1<-ggplot(data.frame(dt=sharperpeak))+geom_density(aes(x=dt),fill='green',alpha=0.6)+xlab('Sharper-peaks')+geom_vline(xintercept=quantile(sharperpeak,c(0.25,0.75),color='red',alpha=0.3))
p2<-ggplot(data.frame(dt=sharperpeak))+geom_qq(aes(sample=dt))+geom_abline(slope=1,intercept = 0)
grid.arrange(p1,p2,nrow=1)
#heaviertails plot
p1<-ggplot(data.frame(dt=heavytail))+geom_density(aes(x=dt),fill='green',alpha=0.6)+xlab('Heavy Tails')+geom_vline(xintercept=quantile(heavytail,c(0.25,0.75),color='red',alpha=0.3))
p2<-ggplot(data.frame(dt=heavytail))+geom_qq(aes(sample=dt))+geom_abline(slope=1,intercept = 0)
grid.arrange(p1,p2,nrow=1)
#positiveskew plot
p1<-ggplot(data.frame(dt=positiveskew))+geom_density(aes(x=dt),fill='green',alpha=0.6)+xlab('Positively skewed Distribution')+geom_vline(xintercept=quantile(positiveskew,c(0.25,0.75),color='red',alpha=0.3))+xlim(-1.5,5)
p2<-ggplot(data.frame(dt=positiveskew))+geom_qq(aes(sample=dt))+geom_abline(slope=1,intercept = 0)
grid.arrange(p1,p2,nrow=1)
#negative skew plot
p1<-ggplot(data.frame(dt=negativeskew))+geom_density(aes(x=dt),fill='green',alpha=0.6)+xlab('Negatively skewed Distribution')+geom_vline(xintercept=quantile(negativeskew,c(0.25,0.75),color='red',alpha=0.3))+xlim(-5,1.5)
p2<-ggplot(data.frame(dt=negativeskew))+geom_qq(aes(sample=dt))+geom_abline(slope=1,intercept = 0)
grid.arrange(p1,p2,nrow=1)
# Normal distributions with different sds
normal1<-rnorm(3000,sd=2)
normal2<-rnorm(3000,sd=4)
normal3<-rnorm(3000,sd=0.5)
normal4<-rnorm(3000,sd=0.25)
final<-c(normal1,normal2,normal3,normal4)
ggplot(data.frame(dt=final,sds=factor(rep(c('2','4','0.5','0.25'),each=3000))),aes(sample=dt,color=sds))+geom_qq()+geom_abline(slope=1,intercept=0) | QQ plot and $x = y$ line
The linearity of the QQ-plot only suggests that your sample follows a normal distribution (or more specifically, it's quantile function is the probit function). The slope is determined by the standard |
34,493 | QQ plot and $x = y$ line | Due to the lack of data in your question, I use the gaussian distribution vs. a sample in my answer below (instead of Laplace distribution vs. your sample data).
As far as the two first moments are concerned, the interpretation of what you see in the qq-plot is the following:
If the distributions are identical, you expect a line $x = y$:
x <- rnorm(1000)
qqnorm(x)
abline(0, 1, col = 'red')
If the means are different, you expect an intercept $a \neq 0$, meaning it will above or bellow the $x=y$ line:
x <- rnorm(1000)
qqnorm(x + 1)
abline(0, 1, col = 'red')
If the standard deviations are different, you expect a slope $b \neq 1$:
x <- rnorm(1000)
qqnorm(x * 1.5)
abline(0, 1, col = 'red')
To get the intuition of this, you can simply plot the CDFs in the same plot. For example, taking the last one:
lines(seq(-7, 7, by = 0.01), pnorm(seq(-7, 7, by = 0.01)), col = 'red')
Let's take for example 3 points in the y-axis: $CDF(q) = 0.2$, $0.5$, $0.8$ and see what value of $q$ (quantile) gives us each CDF value.
You can see that:
$$\begin{aligned}
F^{-1}_{red}(0.2) &> F^{-1}_X(0.2) \text{ (quantile around -1)} \\
F^{-1}_{red}(0.5) &= F^{-1}_X(0.5) \text{ (quantile = 0)}\\
F^{-1}_{red}(0.8) &< F^{-1}_X(0.8) \text{ (quantile around 1)}
\end{aligned}$$
Which is what's shown by the qq-plot. | QQ plot and $x = y$ line | Due to the lack of data in your question, I use the gaussian distribution vs. a sample in my answer below (instead of Laplace distribution vs. your sample data).
As far as the two first moments are co | QQ plot and $x = y$ line
Due to the lack of data in your question, I use the gaussian distribution vs. a sample in my answer below (instead of Laplace distribution vs. your sample data).
As far as the two first moments are concerned, the interpretation of what you see in the qq-plot is the following:
If the distributions are identical, you expect a line $x = y$:
x <- rnorm(1000)
qqnorm(x)
abline(0, 1, col = 'red')
If the means are different, you expect an intercept $a \neq 0$, meaning it will above or bellow the $x=y$ line:
x <- rnorm(1000)
qqnorm(x + 1)
abline(0, 1, col = 'red')
If the standard deviations are different, you expect a slope $b \neq 1$:
x <- rnorm(1000)
qqnorm(x * 1.5)
abline(0, 1, col = 'red')
To get the intuition of this, you can simply plot the CDFs in the same plot. For example, taking the last one:
lines(seq(-7, 7, by = 0.01), pnorm(seq(-7, 7, by = 0.01)), col = 'red')
Let's take for example 3 points in the y-axis: $CDF(q) = 0.2$, $0.5$, $0.8$ and see what value of $q$ (quantile) gives us each CDF value.
You can see that:
$$\begin{aligned}
F^{-1}_{red}(0.2) &> F^{-1}_X(0.2) \text{ (quantile around -1)} \\
F^{-1}_{red}(0.5) &= F^{-1}_X(0.5) \text{ (quantile = 0)}\\
F^{-1}_{red}(0.8) &< F^{-1}_X(0.8) \text{ (quantile around 1)}
\end{aligned}$$
Which is what's shown by the qq-plot. | QQ plot and $x = y$ line
Due to the lack of data in your question, I use the gaussian distribution vs. a sample in my answer below (instead of Laplace distribution vs. your sample data).
As far as the two first moments are co |
34,494 | If Mean Squared Error = Variance + Bias^2. Then How can the Mean Squared Error be lower than the Variance | That's called overfitting. The apparent MSE on the training data is lower than the variance, but this was only achieved by making a model overly complicated so that it could follow random fluctuations art individual data points ("chasing noise"). Once you try to predict on new data MSE is much worse. I.e. the real MSE of predictions from the model is not lower than the variance. | If Mean Squared Error = Variance + Bias^2. Then How can the Mean Squared Error be lower than the Var | That's called overfitting. The apparent MSE on the training data is lower than the variance, but this was only achieved by making a model overly complicated so that it could follow random fluctuations | If Mean Squared Error = Variance + Bias^2. Then How can the Mean Squared Error be lower than the Variance
That's called overfitting. The apparent MSE on the training data is lower than the variance, but this was only achieved by making a model overly complicated so that it could follow random fluctuations art individual data points ("chasing noise"). Once you try to predict on new data MSE is much worse. I.e. the real MSE of predictions from the model is not lower than the variance. | If Mean Squared Error = Variance + Bias^2. Then How can the Mean Squared Error be lower than the Var
That's called overfitting. The apparent MSE on the training data is lower than the variance, but this was only achieved by making a model overly complicated so that it could follow random fluctuations |
34,495 | If Mean Squared Error = Variance + Bias^2. Then How can the Mean Squared Error be lower than the Variance | The formula reproduced in the question is exact and hence not compatible with an "MSE lower than the Variance". When you mention one observes an "MSE lower than the Variance" on the provided graph (assuming the minimum MSE is the model variance), it is because you consider empirical MSE and variances, rather than the theoretical quantities, which are expectations against the model distribution. | If Mean Squared Error = Variance + Bias^2. Then How can the Mean Squared Error be lower than the Var | The formula reproduced in the question is exact and hence not compatible with an "MSE lower than the Variance". When you mention one observes an "MSE lower than the Variance" on the provided graph (as | If Mean Squared Error = Variance + Bias^2. Then How can the Mean Squared Error be lower than the Variance
The formula reproduced in the question is exact and hence not compatible with an "MSE lower than the Variance". When you mention one observes an "MSE lower than the Variance" on the provided graph (assuming the minimum MSE is the model variance), it is because you consider empirical MSE and variances, rather than the theoretical quantities, which are expectations against the model distribution. | If Mean Squared Error = Variance + Bias^2. Then How can the Mean Squared Error be lower than the Var
The formula reproduced in the question is exact and hence not compatible with an "MSE lower than the Variance". When you mention one observes an "MSE lower than the Variance" on the provided graph (as |
34,496 | If Mean Squared Error = Variance + Bias^2. Then How can the Mean Squared Error be lower than the Variance | You seem to think that there is a case showing the variance being larger than the MSE, but it is far from clear how you are seeing that. In machine learning, Y is modeled as being equal to some function of X, plus a random error term. That error is, as it is in this example, often represented with an epsilon, $\epsilon$. In this model, an estimator function equal to the "real" dependency of Y on X will have an MSE equal to the variance of $\epsilon$. An estimator other than the "real" dependency will have an MSE equal to the variance of $\epsilon$, plus the variance between the "real" dependency and the estimator used. Thus, the MSE of the estimator will be greater than or equal to the variance $\underline{\text{of }}\underline{\epsilon}$. It can be, and any decent estimator will be, less than the variance $\underline{\text{of Y}}$. If the MSE of an estimator were greater than the variance of Y, then ignoring X completely and just predicting that Y will be equal to the mean of Y would be a better estimator. | If Mean Squared Error = Variance + Bias^2. Then How can the Mean Squared Error be lower than the Var | You seem to think that there is a case showing the variance being larger than the MSE, but it is far from clear how you are seeing that. In machine learning, Y is modeled as being equal to some functi | If Mean Squared Error = Variance + Bias^2. Then How can the Mean Squared Error be lower than the Variance
You seem to think that there is a case showing the variance being larger than the MSE, but it is far from clear how you are seeing that. In machine learning, Y is modeled as being equal to some function of X, plus a random error term. That error is, as it is in this example, often represented with an epsilon, $\epsilon$. In this model, an estimator function equal to the "real" dependency of Y on X will have an MSE equal to the variance of $\epsilon$. An estimator other than the "real" dependency will have an MSE equal to the variance of $\epsilon$, plus the variance between the "real" dependency and the estimator used. Thus, the MSE of the estimator will be greater than or equal to the variance $\underline{\text{of }}\underline{\epsilon}$. It can be, and any decent estimator will be, less than the variance $\underline{\text{of Y}}$. If the MSE of an estimator were greater than the variance of Y, then ignoring X completely and just predicting that Y will be equal to the mean of Y would be a better estimator. | If Mean Squared Error = Variance + Bias^2. Then How can the Mean Squared Error be lower than the Var
You seem to think that there is a case showing the variance being larger than the MSE, but it is far from clear how you are seeing that. In machine learning, Y is modeled as being equal to some functi |
34,497 | Cross validation with time series [duplicate] | Cross-validation is great! You can and should use cross-validation for this purpose. The trick is to perform cross-validation correctly for your data, and k-fold is too naive to deal with the autocorrelation.
You've correctly identified the fact that sequential data (like time series) will be subject to autocorrelation. In other words, the traditional supervised learning assumption of i.i.d. observations doesn't hold in this case.
In fact, most cross validation schemes appear to rely on having i.i.d. data because the training-test splits do not take time indices into account. For example, 5-fold cross validation applied naively over 5 time periods would ignore the sequential nature of time, mixing up past, present & future:
This would be wrong because
Your autoregressive models require a contiguous block of data, since they rely on the presence of autocorrelations at predefined lags (instead of having training sets split into 2 parts). Indeed, this is roughly the purpose of models like ARIMA - to capture autocorrelation in a way that many other models don't.
You should not train models on future data anyway, to avoid look-ahead bias
Hyndman (who has already commented on your question to post 2 great links), has lots of good examples of using a rolling or sliding window approach to cross validation to avoid this issue. For 5 time periods, you would split the sets as follows:
Another approach is to use an expanding window, though this may not be appropriate in your case:
Both of these schemes deal with the issues we identified earlier, and shouldn't be too hard to code up. | Cross validation with time series [duplicate] | Cross-validation is great! You can and should use cross-validation for this purpose. The trick is to perform cross-validation correctly for your data, and k-fold is too naive to deal with the autocorr | Cross validation with time series [duplicate]
Cross-validation is great! You can and should use cross-validation for this purpose. The trick is to perform cross-validation correctly for your data, and k-fold is too naive to deal with the autocorrelation.
You've correctly identified the fact that sequential data (like time series) will be subject to autocorrelation. In other words, the traditional supervised learning assumption of i.i.d. observations doesn't hold in this case.
In fact, most cross validation schemes appear to rely on having i.i.d. data because the training-test splits do not take time indices into account. For example, 5-fold cross validation applied naively over 5 time periods would ignore the sequential nature of time, mixing up past, present & future:
This would be wrong because
Your autoregressive models require a contiguous block of data, since they rely on the presence of autocorrelations at predefined lags (instead of having training sets split into 2 parts). Indeed, this is roughly the purpose of models like ARIMA - to capture autocorrelation in a way that many other models don't.
You should not train models on future data anyway, to avoid look-ahead bias
Hyndman (who has already commented on your question to post 2 great links), has lots of good examples of using a rolling or sliding window approach to cross validation to avoid this issue. For 5 time periods, you would split the sets as follows:
Another approach is to use an expanding window, though this may not be appropriate in your case:
Both of these schemes deal with the issues we identified earlier, and shouldn't be too hard to code up. | Cross validation with time series [duplicate]
Cross-validation is great! You can and should use cross-validation for this purpose. The trick is to perform cross-validation correctly for your data, and k-fold is too naive to deal with the autocorr |
34,498 | How important is basis expansion for deep nets? | The idea of deep neural network is it can do the feature engineering automatically for us. (See the first chapter of the deep learning book.) I would strongly recommend you to read the first chapter.
Doing basis expansion is not really necessary and uncommonly used. Keep in mind that, the deep net usually takes raw features as inputs, for images that have (at least) thousands of pixels, it is also not possible to do the basis expansion (say higher order polynomial expansion) effectively before feeding to the neural network.
In fact, there are some operations in deep neural network can be viewed as basis expansion.
Convolution layer can be viewed as doing feature engineering in Fourier basis expansion. See my question: What is the intuition behind convolutional neural network?
The ReLU can be viewed as doing piecewise linear fit (spline basis). | How important is basis expansion for deep nets? | The idea of deep neural network is it can do the feature engineering automatically for us. (See the first chapter of the deep learning book.) I would strongly recommend you to read the first chapter. | How important is basis expansion for deep nets?
The idea of deep neural network is it can do the feature engineering automatically for us. (See the first chapter of the deep learning book.) I would strongly recommend you to read the first chapter.
Doing basis expansion is not really necessary and uncommonly used. Keep in mind that, the deep net usually takes raw features as inputs, for images that have (at least) thousands of pixels, it is also not possible to do the basis expansion (say higher order polynomial expansion) effectively before feeding to the neural network.
In fact, there are some operations in deep neural network can be viewed as basis expansion.
Convolution layer can be viewed as doing feature engineering in Fourier basis expansion. See my question: What is the intuition behind convolutional neural network?
The ReLU can be viewed as doing piecewise linear fit (spline basis). | How important is basis expansion for deep nets?
The idea of deep neural network is it can do the feature engineering automatically for us. (See the first chapter of the deep learning book.) I would strongly recommend you to read the first chapter. |
34,499 | How important is basis expansion for deep nets? | Many deep learning models learn their own features from the raw input data during training (e.g., 2D Convolutional Neural Networks for images). So in many cases, you don't even have to worry about passing variables explicitly to your model.
In some other cases, you still need features, but only core features (e.g., words in NLP). These features are represented as vectors in an embedding space that captures similarity (e.g., that 'president' is close to 'Obama'). The embedding space either comes from unsupervised pre-training (word2vec, glove) or is initialized randomly, and the vectors are tuned during training via backpropagation. The architecture of the network is responsible for learning feature combinations, like the difference between 'not bad, quite good' and 'not good, quite bad'.
The 'Feature combinations' paragraph of Section 3 of Goldberg, Y. (2015). A primer on neural network models for natural language processing. Journal of Artificial Intelligence Research, 57, 345-420. very well explains this (I really recommend reading the whole Section 3, it is excellent):
The combination features are crucial in linear models because they introduce more
dimensions to the input, transforming it into a space where the data-points are closer to
being linearly separable. On the other hand, the space of possible combinations is very
large, and the feature designer has to spend a lot of time coming up with an effective
set of feature combinations. One of the promises of the non-linear neural network models
is that one needs to define only the core features. The non-linearity of the classifier, as
defined by the network structure, is expected to take care of finding the indicative feature
combinations, alleviating the need for feature combination engineering. | How important is basis expansion for deep nets? | Many deep learning models learn their own features from the raw input data during training (e.g., 2D Convolutional Neural Networks for images). So in many cases, you don't even have to worry about pas | How important is basis expansion for deep nets?
Many deep learning models learn their own features from the raw input data during training (e.g., 2D Convolutional Neural Networks for images). So in many cases, you don't even have to worry about passing variables explicitly to your model.
In some other cases, you still need features, but only core features (e.g., words in NLP). These features are represented as vectors in an embedding space that captures similarity (e.g., that 'president' is close to 'Obama'). The embedding space either comes from unsupervised pre-training (word2vec, glove) or is initialized randomly, and the vectors are tuned during training via backpropagation. The architecture of the network is responsible for learning feature combinations, like the difference between 'not bad, quite good' and 'not good, quite bad'.
The 'Feature combinations' paragraph of Section 3 of Goldberg, Y. (2015). A primer on neural network models for natural language processing. Journal of Artificial Intelligence Research, 57, 345-420. very well explains this (I really recommend reading the whole Section 3, it is excellent):
The combination features are crucial in linear models because they introduce more
dimensions to the input, transforming it into a space where the data-points are closer to
being linearly separable. On the other hand, the space of possible combinations is very
large, and the feature designer has to spend a lot of time coming up with an effective
set of feature combinations. One of the promises of the non-linear neural network models
is that one needs to define only the core features. The non-linearity of the classifier, as
defined by the network structure, is expected to take care of finding the indicative feature
combinations, alleviating the need for feature combination engineering. | How important is basis expansion for deep nets?
Many deep learning models learn their own features from the raw input data during training (e.g., 2D Convolutional Neural Networks for images). So in many cases, you don't even have to worry about pas |
34,500 | Kolmogorov Smirnov Z vs Mann Whitney U small sample size n= 15? | If the original statement doesn't limit the conditions under which it applies pretty substantially, Field is just wrong on this.
Responding to the quoted section:
In effect, this means it does much the same as the Mann–Whitney test!
No, it really doesn't. They really test for different kinds of things. As one example, if two close-to-symmetric distributions differ in spread but don't differ in location, the Kolmogorov-Smirnov can identify that kind of difference (in large enough samples relative to the effect) but the Wilcoxon-Mann-Whitney can't.
This is because they're designed for different purposes.
"However, this test tends to have better power than the Mann–Whitney test when sample sizes are less than about 25 per group, and so is worth selecting if that’s the case."
As a general claim, this is nonsense. Against the things the Mann-Whitney doesn't test it has better power, but against the things the Mann-Whitney is meant for, it doesn't. This doesn't change when $n<25$.
[There may be some situation where the claim is true; if Field doesn't explain what context his claim applies in, I'm not likely to be able to guess it.]
Here's a power curve for n=20 per group. The significance level is a bit over 3% for each test (in fact the achievable significance level for the KS is slightly higher and I have not attempted to use a randomized test to adjust for that difference so it's been given a small advantage in this comparison):
As we see, in this case (the first one I tried) the Wilcoxon-Mann-Whitney is clearly more powerful.
At n=5, the Kolmogorov-Smirnov remains less powerful for this situation. [So what the heck is he talking about? Is he comparing power for some situation not mentioned in the quote? I don't know, but going just on what's quoted here we should not take that claim at face value. It was wrong in the first thing I checked, and - based on a broader familiarity with the two tests, I would readily bet it's wrong for a bunch of other situations.]
At sample sizes of 4 and 11 for shift alternatives (and normal populations), again, the Wilcoxon-Mann-Whitney does better.
With the variable you're looking at, a suitable alternative is probably something more like a scale shift; but if some power (like a square root or a cube root say or better still a log) of your data aren't too non-normal looking these results I mention should be relevant. If you have discrete or zero-inflated data that may make some difference, but my bet would be that the Kolmogorov-Smirnov doesn't overtake the Wilcoxon-Mann-Whitney then either. [I won't pursue this at present because it's not clear if it's relevant for your situation.]
In addition, the attainable significance levels with the Kolmogorov-Smirnov are very gappy at small sample sizes. You often can't get tests close to the usual significance levels you are likely to want. (The WMW does much better than the KS in relation to available test sizes. There is a neat way way to dramatically improve this gappiness of levels situation without losing either the nonparametric or the rank based nature of tests like these - that also doesn't involve randomized testing - but it seems to be very rarely used for some reason.)
Note that I carefully chose examples that made the levels of the two tests close to comparable. If you're just choosing $\alpha=0.05$ every time without regard to the available levels and comparing a p-value to that, then the gappiness of the Kolmogorov-Smirnov's attainable levels is going to make its power much worse in general (though will very occasionally help it a little as here -- these advantage will not generally be much though and probably not enough to help it beat the WMW at the task it's suited for).
If you're in a situation where the Wilcoxon-Mann-Whitney tests what you want to test, I would definitely not recommend using the Kolmogorov-Smirnov instead. I'd use each test for what they're designed to test, which is where they tend to do fairly well.
The best way to figure out what's best is to try some simulations in situations that would be realistic for the kind of data you will have. Then you can see when it does what.
Also when reporting the intakes along with the p values, should I use mean and standard deviation or median and IQR as data is non- parametric?
Data are just data. They're neither parametric nor nonparametric -- that's a property of models and inferential procedures that we use which rely on them (estimation, testing, intervals). Parametric means "defined up to a fixed, finite number of parameters", which is not an attribute of data but of models. If you can't just give both sets of values (which would be my preference) and must instead choose one or the other, which is more relevant scientifically or in relation to your question of interest?
[Note that the Wilcoxon-Mann-Whitney doesn't compare either means or medians (unless you add some assumptions I bet don't come close to applying in this case). Nor does the Kolmogorov-Smirnov.]
Also when reporting the intakes along with the p values, should I use mean and standard deviation or median and IQR
My general advice is to report what makes sense to report for that variable (without worrying very much about what its distribution might be); if you want to know something about the population mean, the sample mean generally makes sense to report, similarly for the population median. Personally I rarely look at only one summary statistic and when reading a paper, I am interested in more than one.
Neither sample means nor sample medians will correspond to what either of the tests here are comparing. | Kolmogorov Smirnov Z vs Mann Whitney U small sample size n= 15? | If the original statement doesn't limit the conditions under which it applies pretty substantially, Field is just wrong on this.
Responding to the quoted section:
In effect, this means it does much t | Kolmogorov Smirnov Z vs Mann Whitney U small sample size n= 15?
If the original statement doesn't limit the conditions under which it applies pretty substantially, Field is just wrong on this.
Responding to the quoted section:
In effect, this means it does much the same as the Mann–Whitney test!
No, it really doesn't. They really test for different kinds of things. As one example, if two close-to-symmetric distributions differ in spread but don't differ in location, the Kolmogorov-Smirnov can identify that kind of difference (in large enough samples relative to the effect) but the Wilcoxon-Mann-Whitney can't.
This is because they're designed for different purposes.
"However, this test tends to have better power than the Mann–Whitney test when sample sizes are less than about 25 per group, and so is worth selecting if that’s the case."
As a general claim, this is nonsense. Against the things the Mann-Whitney doesn't test it has better power, but against the things the Mann-Whitney is meant for, it doesn't. This doesn't change when $n<25$.
[There may be some situation where the claim is true; if Field doesn't explain what context his claim applies in, I'm not likely to be able to guess it.]
Here's a power curve for n=20 per group. The significance level is a bit over 3% for each test (in fact the achievable significance level for the KS is slightly higher and I have not attempted to use a randomized test to adjust for that difference so it's been given a small advantage in this comparison):
As we see, in this case (the first one I tried) the Wilcoxon-Mann-Whitney is clearly more powerful.
At n=5, the Kolmogorov-Smirnov remains less powerful for this situation. [So what the heck is he talking about? Is he comparing power for some situation not mentioned in the quote? I don't know, but going just on what's quoted here we should not take that claim at face value. It was wrong in the first thing I checked, and - based on a broader familiarity with the two tests, I would readily bet it's wrong for a bunch of other situations.]
At sample sizes of 4 and 11 for shift alternatives (and normal populations), again, the Wilcoxon-Mann-Whitney does better.
With the variable you're looking at, a suitable alternative is probably something more like a scale shift; but if some power (like a square root or a cube root say or better still a log) of your data aren't too non-normal looking these results I mention should be relevant. If you have discrete or zero-inflated data that may make some difference, but my bet would be that the Kolmogorov-Smirnov doesn't overtake the Wilcoxon-Mann-Whitney then either. [I won't pursue this at present because it's not clear if it's relevant for your situation.]
In addition, the attainable significance levels with the Kolmogorov-Smirnov are very gappy at small sample sizes. You often can't get tests close to the usual significance levels you are likely to want. (The WMW does much better than the KS in relation to available test sizes. There is a neat way way to dramatically improve this gappiness of levels situation without losing either the nonparametric or the rank based nature of tests like these - that also doesn't involve randomized testing - but it seems to be very rarely used for some reason.)
Note that I carefully chose examples that made the levels of the two tests close to comparable. If you're just choosing $\alpha=0.05$ every time without regard to the available levels and comparing a p-value to that, then the gappiness of the Kolmogorov-Smirnov's attainable levels is going to make its power much worse in general (though will very occasionally help it a little as here -- these advantage will not generally be much though and probably not enough to help it beat the WMW at the task it's suited for).
If you're in a situation where the Wilcoxon-Mann-Whitney tests what you want to test, I would definitely not recommend using the Kolmogorov-Smirnov instead. I'd use each test for what they're designed to test, which is where they tend to do fairly well.
The best way to figure out what's best is to try some simulations in situations that would be realistic for the kind of data you will have. Then you can see when it does what.
Also when reporting the intakes along with the p values, should I use mean and standard deviation or median and IQR as data is non- parametric?
Data are just data. They're neither parametric nor nonparametric -- that's a property of models and inferential procedures that we use which rely on them (estimation, testing, intervals). Parametric means "defined up to a fixed, finite number of parameters", which is not an attribute of data but of models. If you can't just give both sets of values (which would be my preference) and must instead choose one or the other, which is more relevant scientifically or in relation to your question of interest?
[Note that the Wilcoxon-Mann-Whitney doesn't compare either means or medians (unless you add some assumptions I bet don't come close to applying in this case). Nor does the Kolmogorov-Smirnov.]
Also when reporting the intakes along with the p values, should I use mean and standard deviation or median and IQR
My general advice is to report what makes sense to report for that variable (without worrying very much about what its distribution might be); if you want to know something about the population mean, the sample mean generally makes sense to report, similarly for the population median. Personally I rarely look at only one summary statistic and when reading a paper, I am interested in more than one.
Neither sample means nor sample medians will correspond to what either of the tests here are comparing. | Kolmogorov Smirnov Z vs Mann Whitney U small sample size n= 15?
If the original statement doesn't limit the conditions under which it applies pretty substantially, Field is just wrong on this.
Responding to the quoted section:
In effect, this means it does much t |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.