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 |
|---|---|---|---|---|---|---|
36,501 | How to distinguish between two biased coins | Say the odds of getting $C_1$ over $C_2$ are, in principle, $1:1$. Then, you flip the coin $n$ times and get $x$ heads. If we call the probabilities of heads $p_1=0.95$ and $p_2=0.01$, then the probability that each coin gives $x$ heads is:
$$P(x|C_1)=p_1^x(1-p_1)^{n-x}$$
$$P(x|C_2)=p_2^x(1-p_2)^{n-x}$$
If we use Bayes theorem, we get the odds that the coin is $C_1$ including the information from the coin tosses:
$$\begin{align}
\frac{P(C_1|x)}{P(C_2|x)}&=\frac{P(C_1)\cdot p_1^x(1-p_1)^{n-x}}{P(C_2)\cdot p_2^x(1-p_2)^{n-x}}\\
&=\frac{p_1^x(1-p_1)^{n-x}}{p_2^x(1-p_2)^{n-x}}\\
&=\left(\frac{p_1}{p_2}\right)^x\left(\frac{1-p_1}{1-p_2}\right)^{n-x}
\end{align}$$
For example, if you tossed the coin 3 times and had 2 heads, you would have:
$$\frac{P(C_1|x)}{P(C_2|x)}=\left(\frac{0.95}{0.01}\right)^{2}\left(\frac{0.05}{0.99}\right)^{1}\approx456$$
That means the odds that the coin is $C_1$ are $456:1$, which is equivalent to a probability of $\frac{456}{456+1}\approx99.8\%$. That looks like a huge value for such a low number of trials, and the reason is that the probabilities $95\%$ and $1\%$ are very different. If the coins had closer probabilities, the odds would not be so dramatic. | How to distinguish between two biased coins | Say the odds of getting $C_1$ over $C_2$ are, in principle, $1:1$. Then, you flip the coin $n$ times and get $x$ heads. If we call the probabilities of heads $p_1=0.95$ and $p_2=0.01$, then the probab | How to distinguish between two biased coins
Say the odds of getting $C_1$ over $C_2$ are, in principle, $1:1$. Then, you flip the coin $n$ times and get $x$ heads. If we call the probabilities of heads $p_1=0.95$ and $p_2=0.01$, then the probability that each coin gives $x$ heads is:
$$P(x|C_1)=p_1^x(1-p_1)^{n-x}$$
$$P(x|C_2)=p_2^x(1-p_2)^{n-x}$$
If we use Bayes theorem, we get the odds that the coin is $C_1$ including the information from the coin tosses:
$$\begin{align}
\frac{P(C_1|x)}{P(C_2|x)}&=\frac{P(C_1)\cdot p_1^x(1-p_1)^{n-x}}{P(C_2)\cdot p_2^x(1-p_2)^{n-x}}\\
&=\frac{p_1^x(1-p_1)^{n-x}}{p_2^x(1-p_2)^{n-x}}\\
&=\left(\frac{p_1}{p_2}\right)^x\left(\frac{1-p_1}{1-p_2}\right)^{n-x}
\end{align}$$
For example, if you tossed the coin 3 times and had 2 heads, you would have:
$$\frac{P(C_1|x)}{P(C_2|x)}=\left(\frac{0.95}{0.01}\right)^{2}\left(\frac{0.05}{0.99}\right)^{1}\approx456$$
That means the odds that the coin is $C_1$ are $456:1$, which is equivalent to a probability of $\frac{456}{456+1}\approx99.8\%$. That looks like a huge value for such a low number of trials, and the reason is that the probabilities $95\%$ and $1\%$ are very different. If the coins had closer probabilities, the odds would not be so dramatic. | How to distinguish between two biased coins
Say the odds of getting $C_1$ over $C_2$ are, in principle, $1:1$. Then, you flip the coin $n$ times and get $x$ heads. If we call the probabilities of heads $p_1=0.95$ and $p_2=0.01$, then the probab |
36,502 | How do we handle a confounder which is collinear with the exposure? | Multicollinearity will only be a problem if the correlation between X and Z is 1. In that case, X and Z can be combined into a single variable which will provide an unbiased estimate. We can see this with a simple simulation
> set.seed(1)
> N <- 100
> Z <- rnorm(N)
> X <- Z # perfect collinearity
> Y <- 4 + X + Z + rnorm(N)
> lm(Y ~ X) %>% summary()
Call:
lm(formula = Y ~ X)
Residuals:
Min 1Q Median 3Q Max
-1.8768 -0.6138 -0.1395 0.5394 2.3462
Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) 3.96231 0.09699 40.85 <2e-16 ***
X 1.99894 0.10773 18.56 <2e-16 ***
which is biased. But adjusting for Z will not work due to perfect collinearity:
lm(Y ~ X + Z) %>% summary()
Call:
lm(formula = Y ~ X + Z)
Residuals:
Min 1Q Median 3Q Max
-1.8768 -0.6138 -0.1395 0.5394 2.3462
Coefficients: (1 not defined because of singularities)
Estimate Std. Error t value Pr(>|t|)
(Intercept) 3.96231 0.09699 40.85 <2e-16 ***
X 1.99894 0.10773 18.56 <2e-16 ***
Z NA NA NA NA
So we combine X and Z into a new variable, W, and condition on W only:
> W <- X + Z
> lm(Y ~ W) %>% summary()
Call:
lm(formula = Y ~ W)
Residuals:
Min 1Q Median 3Q Max
-1.8768 -0.6138 -0.1395 0.5394 2.3462
Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) 3.96231 0.09699 40.85 <2e-16 ***
W 0.99947 0.05386 18.56 <2e-16 ***
and we obtain an unbiased estimate.
Regarding your point:
this model causes the b coefficient of x to be smaller or close to zero?
No, that should not be the case. If the correlation is high, the estimate may lose some precision, but should still be unbiased. Again we can see that with a simulation:
> nsim <- 1000
> vec.X <- numeric(nsim)
> vec.cor <- numeric(nsim)
> #
> set.seed(1)
> for (i in 1:nsim) {
+
+ Z <- rnorm(N)
+ X <- Z + rnorm(N, 0, 0.3) # high collinearity
+ vec.cor[i] <- cor(X, Z)
+ Y <- 4 + X + Z + rnorm(N)
+ m0 <- lm(Y ~ X + Z)
+ vec.X[i] <- coef(m0)[2]
+
+ }
> mean(vec.X)
[1] 1.00914
> mean(vec.cor)
[1] 0.9577407
Note that, in the first example above we knew that data generating process and because we knew that X and Z had equal influence so that a simple sum of both variables worked. However in practice we won't know the data generating process, and therefore, if we do have perfect collinearity (not likely in practice of course) then we could use the same approach as in the 2nd smulation above and add some small random error to Z which will uncover the unbiased estimate for X.
Does your approach differ is the correlation is moderate, weak?
If the correlation is moderate or week there should be no problem in conditioning on Z | How do we handle a confounder which is collinear with the exposure? | Multicollinearity will only be a problem if the correlation between X and Z is 1. In that case, X and Z can be combined into a single variable which will provide an unbiased estimate. We can see this | How do we handle a confounder which is collinear with the exposure?
Multicollinearity will only be a problem if the correlation between X and Z is 1. In that case, X and Z can be combined into a single variable which will provide an unbiased estimate. We can see this with a simple simulation
> set.seed(1)
> N <- 100
> Z <- rnorm(N)
> X <- Z # perfect collinearity
> Y <- 4 + X + Z + rnorm(N)
> lm(Y ~ X) %>% summary()
Call:
lm(formula = Y ~ X)
Residuals:
Min 1Q Median 3Q Max
-1.8768 -0.6138 -0.1395 0.5394 2.3462
Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) 3.96231 0.09699 40.85 <2e-16 ***
X 1.99894 0.10773 18.56 <2e-16 ***
which is biased. But adjusting for Z will not work due to perfect collinearity:
lm(Y ~ X + Z) %>% summary()
Call:
lm(formula = Y ~ X + Z)
Residuals:
Min 1Q Median 3Q Max
-1.8768 -0.6138 -0.1395 0.5394 2.3462
Coefficients: (1 not defined because of singularities)
Estimate Std. Error t value Pr(>|t|)
(Intercept) 3.96231 0.09699 40.85 <2e-16 ***
X 1.99894 0.10773 18.56 <2e-16 ***
Z NA NA NA NA
So we combine X and Z into a new variable, W, and condition on W only:
> W <- X + Z
> lm(Y ~ W) %>% summary()
Call:
lm(formula = Y ~ W)
Residuals:
Min 1Q Median 3Q Max
-1.8768 -0.6138 -0.1395 0.5394 2.3462
Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) 3.96231 0.09699 40.85 <2e-16 ***
W 0.99947 0.05386 18.56 <2e-16 ***
and we obtain an unbiased estimate.
Regarding your point:
this model causes the b coefficient of x to be smaller or close to zero?
No, that should not be the case. If the correlation is high, the estimate may lose some precision, but should still be unbiased. Again we can see that with a simulation:
> nsim <- 1000
> vec.X <- numeric(nsim)
> vec.cor <- numeric(nsim)
> #
> set.seed(1)
> for (i in 1:nsim) {
+
+ Z <- rnorm(N)
+ X <- Z + rnorm(N, 0, 0.3) # high collinearity
+ vec.cor[i] <- cor(X, Z)
+ Y <- 4 + X + Z + rnorm(N)
+ m0 <- lm(Y ~ X + Z)
+ vec.X[i] <- coef(m0)[2]
+
+ }
> mean(vec.X)
[1] 1.00914
> mean(vec.cor)
[1] 0.9577407
Note that, in the first example above we knew that data generating process and because we knew that X and Z had equal influence so that a simple sum of both variables worked. However in practice we won't know the data generating process, and therefore, if we do have perfect collinearity (not likely in practice of course) then we could use the same approach as in the 2nd smulation above and add some small random error to Z which will uncover the unbiased estimate for X.
Does your approach differ is the correlation is moderate, weak?
If the correlation is moderate or week there should be no problem in conditioning on Z | How do we handle a confounder which is collinear with the exposure?
Multicollinearity will only be a problem if the correlation between X and Z is 1. In that case, X and Z can be combined into a single variable which will provide an unbiased estimate. We can see this |
36,503 | Relationship between distribution and data generating process | The probability distribution is the actual mathematical function $P({\bf x}; \theta)$ that can assign a probability to each possible vector ${\bf x}$. It is given by the parameter vector $\theta$.
The data generating process is the causal (deterministic or stochastic) mechanism from where the data originate.
The population is the total number of data items at all available.
$
\begin{split}
\\
\\
\\
\end{split}
$
The probabilistic model
Define a data-generating process ${\cal P}$ as follows
$
\begin{split}
&{\cal P} \mapsto {\cal E} \\
&{\cal P} = f(\,{\cal S}\,; \; {\cal E}\,; \; \{{\cal C} \Rightarrow^* {\cal A}\})
\end{split}
$
with the set ${\cal S}$ the complete state description, the set ${\cal E}$ the possible events to occur and the set $\{{\cal C} \Rightarrow^* {\cal A}\}$, the (cause $\rightarrow$ action) relationships that may be evoked given ${\cal S}$. The asterisk in $\Rightarrow^*$ indicates that an intrinsic stochastic-causal mechanism may be at play, just like in quantum mechanics. The data generating process maps to the (future) event space ${\cal E}$.
Define a random variable $X$ as a function from the event space ${\cal E}$ to the set of real numbers $\Re$ [Evans], $\;X\,:\; {\cal E} \, \mapsto \, \Re$ .
The distribution of $X$ is the collection of probabilities $P(X \in {\cal B})$ for all subsets ${\cal B}$ of the real numbers. ${\cal B}$ is a Borel subset [Evans].
Based on the distribution of $X$, a parametrized probability distribution is defined as $P({\bf x}; {\bf \theta})$. Now we talk about a statistical model. This model $P$ has the the parameter vector ${\bf \theta}$.
In general $P({\bf x}; {\bf \theta})$ will specify probability outcomes of possible events ${\cal E}$, and the inner working of $P({\bf x}; {\bf \theta})$ will always be an abstraction of the underlying data-generating process ${\cal P}$.
Example
These three concepts are illustrated by examples below.
Probability distribution
For a binomially distributed value $i$, the probability distribution is
$
P(i ; p) = \binom{n}{i} \; p^i \, (1-p)^{(n-i)}
$
where $i$ is the number of '1's in a sample of $n$ draws, $i \leq n$ and $\theta=p$ is the probability of a '1' in each individual draw.
Data generating process
The mechanism that is responsible for generating the data, that can be deterministic or stochastic. Even at the smallest level in our world, stochastic mechanisms apply namely the in quantum mechanics. In a number of cases, the underlying mechanism is deterministic but way too complex to model. And so a stochastic model based on assumptions and abstraction is built. Think for example of a macro econometric model that can simulate the economic interactions between Miljons of citizens.
Population
The population can be all voters in an election in a complete country. The frequently performed polls take samples from this population to see what will be voted for at the coming elections.
Michael J. Evans, Jeffrey S. Rosenthal. Probabilities and Statistics - the Science of Uncertainty, W.H. Freeman and Company, New York, 2004. | Relationship between distribution and data generating process | The probability distribution is the actual mathematical function $P({\bf x}; \theta)$ that can assign a probability to each possible vector ${\bf x}$. It is given by the parameter vector $\theta$.
The | Relationship between distribution and data generating process
The probability distribution is the actual mathematical function $P({\bf x}; \theta)$ that can assign a probability to each possible vector ${\bf x}$. It is given by the parameter vector $\theta$.
The data generating process is the causal (deterministic or stochastic) mechanism from where the data originate.
The population is the total number of data items at all available.
$
\begin{split}
\\
\\
\\
\end{split}
$
The probabilistic model
Define a data-generating process ${\cal P}$ as follows
$
\begin{split}
&{\cal P} \mapsto {\cal E} \\
&{\cal P} = f(\,{\cal S}\,; \; {\cal E}\,; \; \{{\cal C} \Rightarrow^* {\cal A}\})
\end{split}
$
with the set ${\cal S}$ the complete state description, the set ${\cal E}$ the possible events to occur and the set $\{{\cal C} \Rightarrow^* {\cal A}\}$, the (cause $\rightarrow$ action) relationships that may be evoked given ${\cal S}$. The asterisk in $\Rightarrow^*$ indicates that an intrinsic stochastic-causal mechanism may be at play, just like in quantum mechanics. The data generating process maps to the (future) event space ${\cal E}$.
Define a random variable $X$ as a function from the event space ${\cal E}$ to the set of real numbers $\Re$ [Evans], $\;X\,:\; {\cal E} \, \mapsto \, \Re$ .
The distribution of $X$ is the collection of probabilities $P(X \in {\cal B})$ for all subsets ${\cal B}$ of the real numbers. ${\cal B}$ is a Borel subset [Evans].
Based on the distribution of $X$, a parametrized probability distribution is defined as $P({\bf x}; {\bf \theta})$. Now we talk about a statistical model. This model $P$ has the the parameter vector ${\bf \theta}$.
In general $P({\bf x}; {\bf \theta})$ will specify probability outcomes of possible events ${\cal E}$, and the inner working of $P({\bf x}; {\bf \theta})$ will always be an abstraction of the underlying data-generating process ${\cal P}$.
Example
These three concepts are illustrated by examples below.
Probability distribution
For a binomially distributed value $i$, the probability distribution is
$
P(i ; p) = \binom{n}{i} \; p^i \, (1-p)^{(n-i)}
$
where $i$ is the number of '1's in a sample of $n$ draws, $i \leq n$ and $\theta=p$ is the probability of a '1' in each individual draw.
Data generating process
The mechanism that is responsible for generating the data, that can be deterministic or stochastic. Even at the smallest level in our world, stochastic mechanisms apply namely the in quantum mechanics. In a number of cases, the underlying mechanism is deterministic but way too complex to model. And so a stochastic model based on assumptions and abstraction is built. Think for example of a macro econometric model that can simulate the economic interactions between Miljons of citizens.
Population
The population can be all voters in an election in a complete country. The frequently performed polls take samples from this population to see what will be voted for at the coming elections.
Michael J. Evans, Jeffrey S. Rosenthal. Probabilities and Statistics - the Science of Uncertainty, W.H. Freeman and Company, New York, 2004. | Relationship between distribution and data generating process
The probability distribution is the actual mathematical function $P({\bf x}; \theta)$ that can assign a probability to each possible vector ${\bf x}$. It is given by the parameter vector $\theta$.
The |
36,504 | The importance of a correct interpretation of a confidence interval | I'll be honest there: I don't think the actual distinction is all that important. Yes, saying that "the probability of the estimated parameter being included in the confidence interval is 95%" is incorrect, for the precise reason you give. However, I do not think it is a major problem. (I would be interested in any other point of view. Has this incorrect manner of writing ever led to "real" problems?)
If you run a single experiment and get a single CI, then yes, it either contains or does not contain the true value of the parameter:
As you write, there is no probability involved any more. The correct interpretation of a CI only comes in if we (explicitly or implicitly) run precisely the same experiment many times and collect all CIs:
And here, we see that (approximately) 95% of the CIs do contain the correct parameter. (The CI from the single experiment pictured above is the one at the bottom in this second plot.)
Yes, it would be better if everyone used the correct nomenclature, or at least had the correct interpretation involving many re-runs of the experiment in the back of their head while they were writing sloppily. But people don't.
And I honestly don't think this is a truly big deal.
R code:
set.seed(1)
n_population <- 1e6
xx_population <- runif(n_population)
param <- 0.5
yy_population <- 2+param*xx_population+rnorm(n_population,0,0.5)
n_analyses <- 100
n_sample <- 30
CIs <- matrix(NA,nrow=n_analyses,ncol=3)
for ( ii in 1:n_analyses ) {
index <- sample(1:n_population,n_sample)
model <- lm(yy_population[index]~xx_population[index])
CIs[ii,] <- c(confint(model)[2,1],coef(model)[2],confint(model)[2,2])
}
opar <- par(mai=c(.5,.1,.1,.1))
ii <- 1
plot(range(CIs),c(ii,ii),type="n",xlab="",ylab="",yaxt="n")
lines(CIs[ii,c(1,3)],rep(ii,2),col=2-(CIs[ii,1]<param¶m<CIs[ii,3]))
points(CIs[ii,2],ii,pch=19,col=2-(CIs[ii,1]<0.5&0.5<CIs[ii,3]))
abline(v=param,lty=2,lwd=2)
plot(range(CIs),c(1,n_analyses),type="n",xlab="",ylab="",yaxt="n")
sapply(1:n_analyses,function(ii)lines(CIs[ii,c(1,3)],rep(ii,2),col=2-(CIs[ii,1]<param¶m<CIs[ii,3])))
points(CIs[,2],1:n_analyses,pch=19,col=2-(CIs[,1]<0.5&0.5<CIs[,3]))
abline(v=param,lty=2,lwd=2) | The importance of a correct interpretation of a confidence interval | I'll be honest there: I don't think the actual distinction is all that important. Yes, saying that "the probability of the estimated parameter being included in the confidence interval is 95%" is inco | The importance of a correct interpretation of a confidence interval
I'll be honest there: I don't think the actual distinction is all that important. Yes, saying that "the probability of the estimated parameter being included in the confidence interval is 95%" is incorrect, for the precise reason you give. However, I do not think it is a major problem. (I would be interested in any other point of view. Has this incorrect manner of writing ever led to "real" problems?)
If you run a single experiment and get a single CI, then yes, it either contains or does not contain the true value of the parameter:
As you write, there is no probability involved any more. The correct interpretation of a CI only comes in if we (explicitly or implicitly) run precisely the same experiment many times and collect all CIs:
And here, we see that (approximately) 95% of the CIs do contain the correct parameter. (The CI from the single experiment pictured above is the one at the bottom in this second plot.)
Yes, it would be better if everyone used the correct nomenclature, or at least had the correct interpretation involving many re-runs of the experiment in the back of their head while they were writing sloppily. But people don't.
And I honestly don't think this is a truly big deal.
R code:
set.seed(1)
n_population <- 1e6
xx_population <- runif(n_population)
param <- 0.5
yy_population <- 2+param*xx_population+rnorm(n_population,0,0.5)
n_analyses <- 100
n_sample <- 30
CIs <- matrix(NA,nrow=n_analyses,ncol=3)
for ( ii in 1:n_analyses ) {
index <- sample(1:n_population,n_sample)
model <- lm(yy_population[index]~xx_population[index])
CIs[ii,] <- c(confint(model)[2,1],coef(model)[2],confint(model)[2,2])
}
opar <- par(mai=c(.5,.1,.1,.1))
ii <- 1
plot(range(CIs),c(ii,ii),type="n",xlab="",ylab="",yaxt="n")
lines(CIs[ii,c(1,3)],rep(ii,2),col=2-(CIs[ii,1]<param¶m<CIs[ii,3]))
points(CIs[ii,2],ii,pch=19,col=2-(CIs[ii,1]<0.5&0.5<CIs[ii,3]))
abline(v=param,lty=2,lwd=2)
plot(range(CIs),c(1,n_analyses),type="n",xlab="",ylab="",yaxt="n")
sapply(1:n_analyses,function(ii)lines(CIs[ii,c(1,3)],rep(ii,2),col=2-(CIs[ii,1]<param¶m<CIs[ii,3])))
points(CIs[,2],1:n_analyses,pch=19,col=2-(CIs[,1]<0.5&0.5<CIs[,3]))
abline(v=param,lty=2,lwd=2) | The importance of a correct interpretation of a confidence interval
I'll be honest there: I don't think the actual distinction is all that important. Yes, saying that "the probability of the estimated parameter being included in the confidence interval is 95%" is inco |
36,505 | The importance of a correct interpretation of a confidence interval | Suppose you are estimating the price of a house using some given features. So when someone says to find out the $95$% confidence interval of the price, given some features. So you are basically finding an interval $[x, y]$ so that the probability of your price lying in this interval $[x,y]$ is $0.95$ (i.e $95$%).
I hope this helps. | The importance of a correct interpretation of a confidence interval | Suppose you are estimating the price of a house using some given features. So when someone says to find out the $95$% confidence interval of the price, given some features. So you are basically findin | The importance of a correct interpretation of a confidence interval
Suppose you are estimating the price of a house using some given features. So when someone says to find out the $95$% confidence interval of the price, given some features. So you are basically finding an interval $[x, y]$ so that the probability of your price lying in this interval $[x,y]$ is $0.95$ (i.e $95$%).
I hope this helps. | The importance of a correct interpretation of a confidence interval
Suppose you are estimating the price of a house using some given features. So when someone says to find out the $95$% confidence interval of the price, given some features. So you are basically findin |
36,506 | How can I calculate the probability for multiple trials with different probabilities? | Suppose you conduct the first trial $n$ times and (independently) second one $m$ times, and that the chances of success are $p$ and $q$ respectively. Let $A$ be the total number of successes in the first instance, $B$ the total in the second, and $X=A+B$ be the total number of successes. Obviously $X$ is an integer between $0$ and $m+n$ (inclusive). For any such integer $x,$ let's find an expression for the chance that $X=x.$
One such expression exploits the probability axiom that says the chance of an event is the sum of the chances of mutually disjoint events of which it is comprised. Here, the event $X=x$ is comprised of the events $A=a, B=x-a$ where $a$ ranges over all possible counts (of successes of $A$).
The independence of $A$ and $B$ implies the chance an event $A=a,B=x-a$ is the product of the component chances. Since $A$ and $B$ have Binomial distributions, we have immediately
$$\Pr(A=a,B=x-a) = \left(\binom{n}{a} p^a(1-p)^{n-a}\right)\left(\binom{m}{x-a} q^{x-a}(1-q)^{m-(x-a)}\right).$$
Summing these over $a$ and doing a little algebraic simplification yields
$$\eqalign{\Pr(X=x) &= (1-p)^n q^x(1-q)^{m-x}\,\sum_{a=0}^x \binom{n}{a}\binom{m}{x-a} \left(\frac{p(1-q)}{(1-p)q}\right)^a \\
&= \phi^x (1-p)^n (1-q)^{m}\,\sum_{a=0}^x \binom{n}{a}\binom{m}{x-a} t^a \\
&= \phi^x (1-p)^n (1-q)^{m}\binom{m}{x}\,\sum_{a=0}^\infty \frac{(-n)^a (-x)^a }{a! (m-x+1)^a} (-1)^{2a}t^a \\
&= \phi^x (1-p)^n(1-q)^{m}\binom{m}{x}\,_2F_1(-n,-x;m-x+1;t)
}$$
where
$$\phi = \frac{q}{1-q}$$
is the odds for $B,$
$$t = \frac{p}{1-p}\,/\,\frac{q}{1-q}$$
is the odds ratio for $A$ relative to $B,$
$$(z)^s = z(z+1)\cdots(z+s-1)$$
is the "rising factorial" (or Pochhammer symbol), and $\,_2F_1$ is the Riemann hypergeometric function (which, in this case, obviously reduces to a polynomial in $t$ of degree no greater than $x$).
Find the chance of the event $X\ge x$ (as in the question) by summing over the individual possibilities of $x$ or, when $x$ is small, by computing the chance of its complement,
$$\Pr(X \ge x) = 1 - \Pr(X \lt x) = 1 - \sum_{y=0}^{x-1} \Pr(X = y).$$
For tiny values of $x$ this won't be too bad; for larger values, you will want a good software library for computing values of the hypergeometric function.
Remarks
Convolution of the two binomial distributions (using the Fast Fourier Transform) is an attractive option for precise calculation.
When both of $np+mq$ and $n(1-p)+m(1-q)$ are not small (exceeding $5$ is often considered ok), the Normal approximation to the Binomial distributions will give a good approximation. Specifically, the approximating Normal distribution will have mean
$$\mu= np + mq,$$
variance
$$\sigma^2 = np(1-p) + mq(1-q),$$
and the chance is therefore approximated (using a continuity correction) by
$$\Pr(X \ge x) \approx \Phi\left(\frac{\mu - x + 1/2}{\sigma}\right)$$
where $\Phi$ is the CDF of the standard Normal distribution. If you're brave, you can also approximate the individual probabilities as
$$\eqalign{
\Pr(X = x) &= \Pr(X \ge x) - \Pr(X \ge x+1) \\
&\approx \Phi\left(\frac{\mu-x+1/2}{\sigma}\right) - \Phi\left(\frac{\mu-x-1/2}{\sigma}\right).}$$
As an example, with $n=6,$ $p=0.40,$ $m=10,$ and $q=0.25$ (the chances in the question, with the minimal numbers of trials for the approximation to hold), a simulation of 100,000 values of $X$ (shown by the line heights) is pretty well reproduced by the approximation (shown by the dots):
This R code produced the figure.
n <- 6
m <- 10
p <- 0.4
q <- 0.25
#
# Simulate X.
#
n.sim <- 1e5
A <- rbinom(n.sim, n, p)
B <- rbinom(n.sim, m, q)
X <- A+B
#
# Plot the simulation.
#
plot(0:(n+m), tabulate(X+1, n+m+1)/n.sim, type="h", ylab="Relative frequency", xlab="x")
#
# Plot the Normal approximation.
#
f <- function(x, n, p, m, q) {
mu <- n * p + m * q
sigma <- sqrt(n * p * (1-p) + m * q * (1-q))
pnorm((x + 1/2 - mu) / sigma) - pnorm((x-1 + 1/2 - mu) / sigma)
}
points(0:(n+m), f(0:(n+m), n, p, m, q), pch=21, bg="#e0000080") | How can I calculate the probability for multiple trials with different probabilities? | Suppose you conduct the first trial $n$ times and (independently) second one $m$ times, and that the chances of success are $p$ and $q$ respectively. Let $A$ be the total number of successes in the f | How can I calculate the probability for multiple trials with different probabilities?
Suppose you conduct the first trial $n$ times and (independently) second one $m$ times, and that the chances of success are $p$ and $q$ respectively. Let $A$ be the total number of successes in the first instance, $B$ the total in the second, and $X=A+B$ be the total number of successes. Obviously $X$ is an integer between $0$ and $m+n$ (inclusive). For any such integer $x,$ let's find an expression for the chance that $X=x.$
One such expression exploits the probability axiom that says the chance of an event is the sum of the chances of mutually disjoint events of which it is comprised. Here, the event $X=x$ is comprised of the events $A=a, B=x-a$ where $a$ ranges over all possible counts (of successes of $A$).
The independence of $A$ and $B$ implies the chance an event $A=a,B=x-a$ is the product of the component chances. Since $A$ and $B$ have Binomial distributions, we have immediately
$$\Pr(A=a,B=x-a) = \left(\binom{n}{a} p^a(1-p)^{n-a}\right)\left(\binom{m}{x-a} q^{x-a}(1-q)^{m-(x-a)}\right).$$
Summing these over $a$ and doing a little algebraic simplification yields
$$\eqalign{\Pr(X=x) &= (1-p)^n q^x(1-q)^{m-x}\,\sum_{a=0}^x \binom{n}{a}\binom{m}{x-a} \left(\frac{p(1-q)}{(1-p)q}\right)^a \\
&= \phi^x (1-p)^n (1-q)^{m}\,\sum_{a=0}^x \binom{n}{a}\binom{m}{x-a} t^a \\
&= \phi^x (1-p)^n (1-q)^{m}\binom{m}{x}\,\sum_{a=0}^\infty \frac{(-n)^a (-x)^a }{a! (m-x+1)^a} (-1)^{2a}t^a \\
&= \phi^x (1-p)^n(1-q)^{m}\binom{m}{x}\,_2F_1(-n,-x;m-x+1;t)
}$$
where
$$\phi = \frac{q}{1-q}$$
is the odds for $B,$
$$t = \frac{p}{1-p}\,/\,\frac{q}{1-q}$$
is the odds ratio for $A$ relative to $B,$
$$(z)^s = z(z+1)\cdots(z+s-1)$$
is the "rising factorial" (or Pochhammer symbol), and $\,_2F_1$ is the Riemann hypergeometric function (which, in this case, obviously reduces to a polynomial in $t$ of degree no greater than $x$).
Find the chance of the event $X\ge x$ (as in the question) by summing over the individual possibilities of $x$ or, when $x$ is small, by computing the chance of its complement,
$$\Pr(X \ge x) = 1 - \Pr(X \lt x) = 1 - \sum_{y=0}^{x-1} \Pr(X = y).$$
For tiny values of $x$ this won't be too bad; for larger values, you will want a good software library for computing values of the hypergeometric function.
Remarks
Convolution of the two binomial distributions (using the Fast Fourier Transform) is an attractive option for precise calculation.
When both of $np+mq$ and $n(1-p)+m(1-q)$ are not small (exceeding $5$ is often considered ok), the Normal approximation to the Binomial distributions will give a good approximation. Specifically, the approximating Normal distribution will have mean
$$\mu= np + mq,$$
variance
$$\sigma^2 = np(1-p) + mq(1-q),$$
and the chance is therefore approximated (using a continuity correction) by
$$\Pr(X \ge x) \approx \Phi\left(\frac{\mu - x + 1/2}{\sigma}\right)$$
where $\Phi$ is the CDF of the standard Normal distribution. If you're brave, you can also approximate the individual probabilities as
$$\eqalign{
\Pr(X = x) &= \Pr(X \ge x) - \Pr(X \ge x+1) \\
&\approx \Phi\left(\frac{\mu-x+1/2}{\sigma}\right) - \Phi\left(\frac{\mu-x-1/2}{\sigma}\right).}$$
As an example, with $n=6,$ $p=0.40,$ $m=10,$ and $q=0.25$ (the chances in the question, with the minimal numbers of trials for the approximation to hold), a simulation of 100,000 values of $X$ (shown by the line heights) is pretty well reproduced by the approximation (shown by the dots):
This R code produced the figure.
n <- 6
m <- 10
p <- 0.4
q <- 0.25
#
# Simulate X.
#
n.sim <- 1e5
A <- rbinom(n.sim, n, p)
B <- rbinom(n.sim, m, q)
X <- A+B
#
# Plot the simulation.
#
plot(0:(n+m), tabulate(X+1, n+m+1)/n.sim, type="h", ylab="Relative frequency", xlab="x")
#
# Plot the Normal approximation.
#
f <- function(x, n, p, m, q) {
mu <- n * p + m * q
sigma <- sqrt(n * p * (1-p) + m * q * (1-q))
pnorm((x + 1/2 - mu) / sigma) - pnorm((x-1 + 1/2 - mu) / sigma)
}
points(0:(n+m), f(0:(n+m), n, p, m, q), pch=21, bg="#e0000080") | How can I calculate the probability for multiple trials with different probabilities?
Suppose you conduct the first trial $n$ times and (independently) second one $m$ times, and that the chances of success are $p$ and $q$ respectively. Let $A$ be the total number of successes in the f |
36,507 | How can I calculate the probability for multiple trials with different probabilities? | The sum of independent non-identically distributed Bernoulli trials is called a Poisson-Binomial distribution. The probabilities can be easily calculated with an R package called poibin.
For the example in the OP's description (3 trials with 40% chance of success and 2 trials with 25% chance of success), the following code will find the pmf:
library(poibin)
p_success <- c(rep(0.4,3),rep(0.25,2))
kk <- 0:5
pmf <- dpoibin(pp=p_success,kk=kk)
pmf
Here is the output, which matches what the OP found for the probability of zero successes and gives the probabilities for 1-5 successes as well:
[1] 0.1215 0.3240 0.3375 0.1710 0.0420 0.0040 | How can I calculate the probability for multiple trials with different probabilities? | The sum of independent non-identically distributed Bernoulli trials is called a Poisson-Binomial distribution. The probabilities can be easily calculated with an R package called poibin.
For the exam | How can I calculate the probability for multiple trials with different probabilities?
The sum of independent non-identically distributed Bernoulli trials is called a Poisson-Binomial distribution. The probabilities can be easily calculated with an R package called poibin.
For the example in the OP's description (3 trials with 40% chance of success and 2 trials with 25% chance of success), the following code will find the pmf:
library(poibin)
p_success <- c(rep(0.4,3),rep(0.25,2))
kk <- 0:5
pmf <- dpoibin(pp=p_success,kk=kk)
pmf
Here is the output, which matches what the OP found for the probability of zero successes and gives the probabilities for 1-5 successes as well:
[1] 0.1215 0.3240 0.3375 0.1710 0.0420 0.0040 | How can I calculate the probability for multiple trials with different probabilities?
The sum of independent non-identically distributed Bernoulli trials is called a Poisson-Binomial distribution. The probabilities can be easily calculated with an R package called poibin.
For the exam |
36,508 | How can I calculate the probability for multiple trials with different probabilities? | For at least two successes, we can calculate the probability of no success and only one success, sum them and subtract from $1$. You've already done the first. For one success, the cases are
1 success for A, 0 success for B $\rightarrow {3\choose 1}p_a(1-p_a)^2(1-p_b)^2$
0 success for A, 1 success for B $\rightarrow (1-p_a)^3{2\choose 1}p_b(1-p_b)$
This was a simple situation and the general case is harder as pointed out int the comments. | How can I calculate the probability for multiple trials with different probabilities? | For at least two successes, we can calculate the probability of no success and only one success, sum them and subtract from $1$. You've already done the first. For one success, the cases are
1 succes | How can I calculate the probability for multiple trials with different probabilities?
For at least two successes, we can calculate the probability of no success and only one success, sum them and subtract from $1$. You've already done the first. For one success, the cases are
1 success for A, 0 success for B $\rightarrow {3\choose 1}p_a(1-p_a)^2(1-p_b)^2$
0 success for A, 1 success for B $\rightarrow (1-p_a)^3{2\choose 1}p_b(1-p_b)$
This was a simple situation and the general case is harder as pointed out int the comments. | How can I calculate the probability for multiple trials with different probabilities?
For at least two successes, we can calculate the probability of no success and only one success, sum them and subtract from $1$. You've already done the first. For one success, the cases are
1 succes |
36,509 | What is the name of a chart that visualizes the inclusion and exclusion of patients in a cohort? | This is a CONSORT 2010 Flow Diagram.
CONSORT stands for Consolidated Standards of Reporting Trials and encompasses various initiatives developed by the CONSORT Group to alleviate the problems arising from inadequate reporting of randomized controlled trials.
You can download a template for the flowchart, along with supplementary information, at the CONSORT statement website. If you decide to use such a flow chart when reporting your study (which I would consider extremely good practice), it would probably be best to cite the original CONSORT statement (BMJ, 2010;340:c332). You could argue that your original source should have done so. And if you want to read up on the chart, you could search for papers that cite this original BMJ paper. | What is the name of a chart that visualizes the inclusion and exclusion of patients in a cohort? | This is a CONSORT 2010 Flow Diagram.
CONSORT stands for Consolidated Standards of Reporting Trials and encompasses various initiatives developed by the CONSORT Group to alleviate the problems arisin | What is the name of a chart that visualizes the inclusion and exclusion of patients in a cohort?
This is a CONSORT 2010 Flow Diagram.
CONSORT stands for Consolidated Standards of Reporting Trials and encompasses various initiatives developed by the CONSORT Group to alleviate the problems arising from inadequate reporting of randomized controlled trials.
You can download a template for the flowchart, along with supplementary information, at the CONSORT statement website. If you decide to use such a flow chart when reporting your study (which I would consider extremely good practice), it would probably be best to cite the original CONSORT statement (BMJ, 2010;340:c332). You could argue that your original source should have done so. And if you want to read up on the chart, you could search for papers that cite this original BMJ paper. | What is the name of a chart that visualizes the inclusion and exclusion of patients in a cohort?
This is a CONSORT 2010 Flow Diagram.
CONSORT stands for Consolidated Standards of Reporting Trials and encompasses various initiatives developed by the CONSORT Group to alleviate the problems arisin |
36,510 | Why do we use random sample with replacement while implementing random forest? | Random forests are based on the concept of bootstrap aggregation (aka bagging). This is a theoretical foundation that shows that sampling with replacement and then building an ensemble reduces the variance of the forest without increasing the bias.
The same theoretical property is not true if you sample without replacement, because sampling without a replacement would lead to pretty high variance.
Let say we’re building a random forest with 1,000 trees, and our training set is 2,000 examples. If we sample without replacement we would train on 2 examples per tree. This is obviously impractical.
Hope this helps. | Why do we use random sample with replacement while implementing random forest? | Random forests are based on the concept of bootstrap aggregation (aka bagging). This is a theoretical foundation that shows that sampling with replacement and then building an ensemble reduces the var | Why do we use random sample with replacement while implementing random forest?
Random forests are based on the concept of bootstrap aggregation (aka bagging). This is a theoretical foundation that shows that sampling with replacement and then building an ensemble reduces the variance of the forest without increasing the bias.
The same theoretical property is not true if you sample without replacement, because sampling without a replacement would lead to pretty high variance.
Let say we’re building a random forest with 1,000 trees, and our training set is 2,000 examples. If we sample without replacement we would train on 2 examples per tree. This is obviously impractical.
Hope this helps. | Why do we use random sample with replacement while implementing random forest?
Random forests are based on the concept of bootstrap aggregation (aka bagging). This is a theoretical foundation that shows that sampling with replacement and then building an ensemble reduces the var |
36,511 | Is initializing the weights of autoencoders still a difficult problem? | These layerwise pretraining procedures are mostly not needed anymore, for a few reasons:
Better initialization schemes, e.g. Xavier / Glorot initialization (the same thing, named after Xavier Glorot) as shimao noted. These help avoid the problems of exploding or vanishing gradients where, essentially, multiplying many numbers significantly more than one gives a huge result, or where multiplying many numbers significantly less than one gives a tiny result. These initialization schemes keep the gradient norms closer to one.
The switch to non-saturating activation functions, like $\operatorname{LReLU}_{0.1}(x) = \begin{cases}x & x \ge 0 \\ 0.1 \, x & x < 0\end{cases}$, rather than saturating ones like $\operatorname{sigmoid}(x) = \frac{1}{1 + \exp(-x)} \in (0, 1)$ that were previously popular. Sigmoids only have useful signal for $x$ in a fairly tight set of inputs; too large or too small and the function becomes quite flat. Leaky ReLU has useful signal everywhere, and regular ReLU has useful signal for any positive input.
Batch normalization, and related schemes like weight/layer/spectral/... normalization, also help keep activations in a "nice" regime if you use them.
Architectural innovations like ResNets allow for very deep networks that can still be effectively trained.
There may be more of a trend now (as opposed to 2006) of using fairly wide hidden layers; this very-overparameterized regime has been shown over the last few years to be amenable to gradient descent optimization.
Adaptive optimizers, like Adam, may do a better job optimizing than previous algorithms.
There are still occasional settings where you see people doing layerwise training for one reason or another, but the vast majority of the time, it's not necessary anymore. | Is initializing the weights of autoencoders still a difficult problem? | These layerwise pretraining procedures are mostly not needed anymore, for a few reasons:
Better initialization schemes, e.g. Xavier / Glorot initialization (the same thing, named after Xavier Glorot) | Is initializing the weights of autoencoders still a difficult problem?
These layerwise pretraining procedures are mostly not needed anymore, for a few reasons:
Better initialization schemes, e.g. Xavier / Glorot initialization (the same thing, named after Xavier Glorot) as shimao noted. These help avoid the problems of exploding or vanishing gradients where, essentially, multiplying many numbers significantly more than one gives a huge result, or where multiplying many numbers significantly less than one gives a tiny result. These initialization schemes keep the gradient norms closer to one.
The switch to non-saturating activation functions, like $\operatorname{LReLU}_{0.1}(x) = \begin{cases}x & x \ge 0 \\ 0.1 \, x & x < 0\end{cases}$, rather than saturating ones like $\operatorname{sigmoid}(x) = \frac{1}{1 + \exp(-x)} \in (0, 1)$ that were previously popular. Sigmoids only have useful signal for $x$ in a fairly tight set of inputs; too large or too small and the function becomes quite flat. Leaky ReLU has useful signal everywhere, and regular ReLU has useful signal for any positive input.
Batch normalization, and related schemes like weight/layer/spectral/... normalization, also help keep activations in a "nice" regime if you use them.
Architectural innovations like ResNets allow for very deep networks that can still be effectively trained.
There may be more of a trend now (as opposed to 2006) of using fairly wide hidden layers; this very-overparameterized regime has been shown over the last few years to be amenable to gradient descent optimization.
Adaptive optimizers, like Adam, may do a better job optimizing than previous algorithms.
There are still occasional settings where you see people doing layerwise training for one reason or another, but the vast majority of the time, it's not necessary anymore. | Is initializing the weights of autoencoders still a difficult problem?
These layerwise pretraining procedures are mostly not needed anymore, for a few reasons:
Better initialization schemes, e.g. Xavier / Glorot initialization (the same thing, named after Xavier Glorot) |
36,512 | Intuitive Understanding of Expected Improvement for Gaussian Process | My question is are we searching for the point in the Gaussian Process model whose expected value (determined by mean and confidence) shall be decreased the most if sampled at that point?
No. At any iteration, you've observed some inputs, and one of those inputs ($x^*$) is the current optimum with a function value $f(x^*)$.
In expected improvement, what we want to do is calculate, for every possible input, how much its function value can be expected to improve over our current optimum. This is expressed in your post by the equation:
$$I(x) = max(f^* - Y, 0)$$
I think it's clearer to write this as:
$$I(x) = max(f(x^*) - f(x), 0)$$
In words, this means that the improvement for any input $x$ is how much better lower its function value f(x) is than the current lowest function value found $f(x^*)$. If $f(x)$ is greater than $f(x^*)$, then there's no improvement, so $I(x) = 0$.
Under a GP posterior, $f(x)$ is a random variable, which means that $I(x)$ is also a random variable, and so we want to calculate the expected value of $I(x)$. We do this for every possible $x$, and pick the one that gives the greatest expected improvement. After observing that point, we add its function value to our GP posterior and repeat. | Intuitive Understanding of Expected Improvement for Gaussian Process | My question is are we searching for the point in the Gaussian Process model whose expected value (determined by mean and confidence) shall be decreased the most if sampled at that point?
No. At any i | Intuitive Understanding of Expected Improvement for Gaussian Process
My question is are we searching for the point in the Gaussian Process model whose expected value (determined by mean and confidence) shall be decreased the most if sampled at that point?
No. At any iteration, you've observed some inputs, and one of those inputs ($x^*$) is the current optimum with a function value $f(x^*)$.
In expected improvement, what we want to do is calculate, for every possible input, how much its function value can be expected to improve over our current optimum. This is expressed in your post by the equation:
$$I(x) = max(f^* - Y, 0)$$
I think it's clearer to write this as:
$$I(x) = max(f(x^*) - f(x), 0)$$
In words, this means that the improvement for any input $x$ is how much better lower its function value f(x) is than the current lowest function value found $f(x^*)$. If $f(x)$ is greater than $f(x^*)$, then there's no improvement, so $I(x) = 0$.
Under a GP posterior, $f(x)$ is a random variable, which means that $I(x)$ is also a random variable, and so we want to calculate the expected value of $I(x)$. We do this for every possible $x$, and pick the one that gives the greatest expected improvement. After observing that point, we add its function value to our GP posterior and repeat. | Intuitive Understanding of Expected Improvement for Gaussian Process
My question is are we searching for the point in the Gaussian Process model whose expected value (determined by mean and confidence) shall be decreased the most if sampled at that point?
No. At any i |
36,513 | Intuitive Understanding of Expected Improvement for Gaussian Process | As far as I know, in practice, the first observations in Bayesian optimization are random before the Gaussian processes take over. After the initial observations, the expected improvement can be calculated for a data point x. By doing so, we want to select the value for x that is expected to improve the results of our objective function the most. | Intuitive Understanding of Expected Improvement for Gaussian Process | As far as I know, in practice, the first observations in Bayesian optimization are random before the Gaussian processes take over. After the initial observations, the expected improvement can be calcu | Intuitive Understanding of Expected Improvement for Gaussian Process
As far as I know, in practice, the first observations in Bayesian optimization are random before the Gaussian processes take over. After the initial observations, the expected improvement can be calculated for a data point x. By doing so, we want to select the value for x that is expected to improve the results of our objective function the most. | Intuitive Understanding of Expected Improvement for Gaussian Process
As far as I know, in practice, the first observations in Bayesian optimization are random before the Gaussian processes take over. After the initial observations, the expected improvement can be calcu |
36,514 | How to understand the vertical bar (pipe) in R formulas [closed] | Assume there are only two groups: group 1 and group 2. The gls() call you specified fits two sub-models to your $y$ observations - one sub-model for the $y$ observations in the first group and another sub-model for the $y$ observations in the second group.
The sub-model for the observations $y$ in group 1 postulates that $y = \beta_0 + \epsilon$, where $\epsilon$ denotes a random error term coming from a normal distribution with mean 0 and unknown variance $\sigma_1^2$. In other words, these observations are grouped about the true group mean $\beta_0$, with their spread about this true group mean being captured by $\sigma_1^2$.
The sub-model for the observations y in group 2 postulates that $y = \beta_0 + \beta_1 + \epsilon$, where $\epsilon$ denotes a random error term coming from a normal distribution with mean 0 and unknown variance $\sigma_2^2$. In other words, these observations are grouped about the true group mean $\beta_0 + \beta_1$, with their spread about this true group mean being captured by $\sigma_2^2$.
The gls() call you provided allows the spread (or variability) of the y values in the two groups about their respective true group means to be different across groups (that is, it allows $\sigma_1^2$ to be different from $\sigma_2^2$) via the option weights=varIdent(form = ~ 1 | group). | How to understand the vertical bar (pipe) in R formulas [closed] | Assume there are only two groups: group 1 and group 2. The gls() call you specified fits two sub-models to your $y$ observations - one sub-model for the $y$ observations in the first group and anothe | How to understand the vertical bar (pipe) in R formulas [closed]
Assume there are only two groups: group 1 and group 2. The gls() call you specified fits two sub-models to your $y$ observations - one sub-model for the $y$ observations in the first group and another sub-model for the $y$ observations in the second group.
The sub-model for the observations $y$ in group 1 postulates that $y = \beta_0 + \epsilon$, where $\epsilon$ denotes a random error term coming from a normal distribution with mean 0 and unknown variance $\sigma_1^2$. In other words, these observations are grouped about the true group mean $\beta_0$, with their spread about this true group mean being captured by $\sigma_1^2$.
The sub-model for the observations y in group 2 postulates that $y = \beta_0 + \beta_1 + \epsilon$, where $\epsilon$ denotes a random error term coming from a normal distribution with mean 0 and unknown variance $\sigma_2^2$. In other words, these observations are grouped about the true group mean $\beta_0 + \beta_1$, with their spread about this true group mean being captured by $\sigma_2^2$.
The gls() call you provided allows the spread (or variability) of the y values in the two groups about their respective true group means to be different across groups (that is, it allows $\sigma_1^2$ to be different from $\sigma_2^2$) via the option weights=varIdent(form = ~ 1 | group). | How to understand the vertical bar (pipe) in R formulas [closed]
Assume there are only two groups: group 1 and group 2. The gls() call you specified fits two sub-models to your $y$ observations - one sub-model for the $y$ observations in the first group and anothe |
36,515 | Spatial Point Process: Does an inhomogeneous first order intensity function affect the second order dependence? | First order intensity and second order intensity measure different aspects of a process that can be almost independently varied. In particular, not every point process can be regarded as an inhomogeneous Poisson process.
Let's deal with that last issue first. Consider a homogeneous Poisson process on the interval $[0,1].$ The gaps will tend to follow an exponential distribution. Let's compare it with a process that tends to maintain a more even spacing, a "stratified random" process. It is created by dividing the interval into a thousand non-overlapping bins and selecting one uniformly random point within each bin. They have the same first order intensities, as suggested by these estimates from a single realization of each process:
These processes are readily distinguished by examining the intervals between successive values:
It is indeed the case that certain forms of "clustering" can be characterized by the second order intensity--but not all. Clustering can mean any combination of two things:
"First order" clustering near a location $s$ just means there tend to be more points in a neighborhood of $s$ across all realizations.
"Second order" clustering near a location $s$ means the appearance of a point close to $s$ is associated with the appearance of points at other locations near $s.$
This sounds subtle, so let's contrast some examples. I have generated realizations of two processes: one that is simply inhomogeneous, having an intensity five times greater on the interval $(0,1/2]$ than on the interval $(1/2,1]$; and another that is similarly inhomogeneous but clustered in the interval $(0,1/2]$. To generate the latter, I created a sequence of iid exponential variates $dX_i$, multiplied every fifth one of them by $100,$ and computed their cumulative sum $X_i,$ finally dividing by twice their sum to place them within the range $(0,1/2].$ The process in the interval $(1/2,1]$ is a homogeneous Poisson process, just as before. This created a process in which there tend to be tight groups of four points, all widely separated from each other. Because the intervening gaps between those points are random, though, the locations where those clusters occur tend not to be the same from one realization to another. When you have the opportunity to view multiple realizations of a process, this is one way to distinguish inhomogeneity (which will persist from one realization to the next) from clustering (which may occur anywhere, not necessarily at fixed locations).
The realization of each process appears as a rug plot at the bottom. The points are a scatterplot of the $(X_i, dX_i)$ pairs: that is, the heights graph the gaps to the next point at the right. The scatterplots clearly distinguish the two processes. | Spatial Point Process: Does an inhomogeneous first order intensity function affect the second order | First order intensity and second order intensity measure different aspects of a process that can be almost independently varied. In particular, not every point process can be regarded as an inhomogen | Spatial Point Process: Does an inhomogeneous first order intensity function affect the second order dependence?
First order intensity and second order intensity measure different aspects of a process that can be almost independently varied. In particular, not every point process can be regarded as an inhomogeneous Poisson process.
Let's deal with that last issue first. Consider a homogeneous Poisson process on the interval $[0,1].$ The gaps will tend to follow an exponential distribution. Let's compare it with a process that tends to maintain a more even spacing, a "stratified random" process. It is created by dividing the interval into a thousand non-overlapping bins and selecting one uniformly random point within each bin. They have the same first order intensities, as suggested by these estimates from a single realization of each process:
These processes are readily distinguished by examining the intervals between successive values:
It is indeed the case that certain forms of "clustering" can be characterized by the second order intensity--but not all. Clustering can mean any combination of two things:
"First order" clustering near a location $s$ just means there tend to be more points in a neighborhood of $s$ across all realizations.
"Second order" clustering near a location $s$ means the appearance of a point close to $s$ is associated with the appearance of points at other locations near $s.$
This sounds subtle, so let's contrast some examples. I have generated realizations of two processes: one that is simply inhomogeneous, having an intensity five times greater on the interval $(0,1/2]$ than on the interval $(1/2,1]$; and another that is similarly inhomogeneous but clustered in the interval $(0,1/2]$. To generate the latter, I created a sequence of iid exponential variates $dX_i$, multiplied every fifth one of them by $100,$ and computed their cumulative sum $X_i,$ finally dividing by twice their sum to place them within the range $(0,1/2].$ The process in the interval $(1/2,1]$ is a homogeneous Poisson process, just as before. This created a process in which there tend to be tight groups of four points, all widely separated from each other. Because the intervening gaps between those points are random, though, the locations where those clusters occur tend not to be the same from one realization to another. When you have the opportunity to view multiple realizations of a process, this is one way to distinguish inhomogeneity (which will persist from one realization to the next) from clustering (which may occur anywhere, not necessarily at fixed locations).
The realization of each process appears as a rug plot at the bottom. The points are a scatterplot of the $(X_i, dX_i)$ pairs: that is, the heights graph the gaps to the next point at the right. The scatterplots clearly distinguish the two processes. | Spatial Point Process: Does an inhomogeneous first order intensity function affect the second order
First order intensity and second order intensity measure different aspects of a process that can be almost independently varied. In particular, not every point process can be regarded as an inhomogen |
36,516 | Spatial Point Process: Does an inhomogeneous first order intensity function affect the second order dependence? | In broad terms your understanding sounds right. In particular, you are right that it is basically impossible to distinguish "first order inhomogeneity" and "second order clustering due to interactions between points" based on a single point pattern. | Spatial Point Process: Does an inhomogeneous first order intensity function affect the second order | In broad terms your understanding sounds right. In particular, you are right that it is basically impossible to distinguish "first order inhomogeneity" and "second order clustering due to interactions | Spatial Point Process: Does an inhomogeneous first order intensity function affect the second order dependence?
In broad terms your understanding sounds right. In particular, you are right that it is basically impossible to distinguish "first order inhomogeneity" and "second order clustering due to interactions between points" based on a single point pattern. | Spatial Point Process: Does an inhomogeneous first order intensity function affect the second order
In broad terms your understanding sounds right. In particular, you are right that it is basically impossible to distinguish "first order inhomogeneity" and "second order clustering due to interactions |
36,517 | Why is random sampling a non-differentiable operation? | Gregory Gundersen wrote a blog post about this in 2018. He explictly answers the questions:
What does a “random node” mean and what does it mean for backprop to “flow” or not flow through such a node?
The following excerpt should answer your questions:
Undifferentiable expectations
Let’s say we want to take the gradient w.r.t. $\theta$ of the following expectation, $$\mathbb{E}_{p(z)}[f_{\theta}(z)]$$ where $p$ is a density. Provided we can differentiate $f_{\theta}(x)$, we can easily compute the gradient:
$$ \begin{align} \nabla_{\theta} \mathbb{E}_{p(z)}[f_{\theta}(z)]
&= \nabla_{\theta} \Big[ \int_{z} p(z) f_{\theta}(z) dz \Big] \\
&= \int_{z} p(z) \Big[\nabla_{\theta} f_{\theta}(z) \Big] dz \\
&= \mathbb{E}_{p(z)} \Big[\nabla_{\theta} f_{\theta}(z) \Big] \end{align}
$$
In words, the gradient of the expectation is equal to the expectation of the gradient. But what happens if our density $p$ is also parameterized by $\theta$?
$$ \begin{align} \nabla_{\theta} \mathbb{E}_{p_{\theta}(z)}[f_{\theta}(z)] &= \nabla_{\theta} \Big[ \int_{z} p_{\theta}(z) f_{\theta}(z) dz \Big] \\ &= \int_{z} \nabla_{\theta} \Big[ p_{\theta}(z) f_{\theta}(z) \Big] dz \\ &= \int_{z} f_{\theta}(z) \nabla_{\theta} p_{\theta}(z)dz + \int_{z} p_{\theta}(z) \nabla_{\theta} f_{\theta}(z)dz \\ &= \underbrace{\int_{z} f_{\theta}(z) \nabla_{\theta} p_{\theta}(z)}_{\text{What about this?}}dz + \mathbb{E}_{p_{\theta}(z)} \Big[\nabla_{\theta}f_{\theta}(z)\Big] \end{align}$$
The first term of the last equation is not guaranteed to be an expectation. Monte Carlo methods require that we can sample from $p_{\theta}(z)$, but not that we can take its gradient. This is not a problem if we have an analytic solution to $\nabla_{\theta}p_{\theta}(z)$, but this is not true in general. 1 | Why is random sampling a non-differentiable operation? | Gregory Gundersen wrote a blog post about this in 2018. He explictly answers the questions:
What does a “random node” mean and what does it mean for backprop to “flow” or not flow through such a node | Why is random sampling a non-differentiable operation?
Gregory Gundersen wrote a blog post about this in 2018. He explictly answers the questions:
What does a “random node” mean and what does it mean for backprop to “flow” or not flow through such a node?
The following excerpt should answer your questions:
Undifferentiable expectations
Let’s say we want to take the gradient w.r.t. $\theta$ of the following expectation, $$\mathbb{E}_{p(z)}[f_{\theta}(z)]$$ where $p$ is a density. Provided we can differentiate $f_{\theta}(x)$, we can easily compute the gradient:
$$ \begin{align} \nabla_{\theta} \mathbb{E}_{p(z)}[f_{\theta}(z)]
&= \nabla_{\theta} \Big[ \int_{z} p(z) f_{\theta}(z) dz \Big] \\
&= \int_{z} p(z) \Big[\nabla_{\theta} f_{\theta}(z) \Big] dz \\
&= \mathbb{E}_{p(z)} \Big[\nabla_{\theta} f_{\theta}(z) \Big] \end{align}
$$
In words, the gradient of the expectation is equal to the expectation of the gradient. But what happens if our density $p$ is also parameterized by $\theta$?
$$ \begin{align} \nabla_{\theta} \mathbb{E}_{p_{\theta}(z)}[f_{\theta}(z)] &= \nabla_{\theta} \Big[ \int_{z} p_{\theta}(z) f_{\theta}(z) dz \Big] \\ &= \int_{z} \nabla_{\theta} \Big[ p_{\theta}(z) f_{\theta}(z) \Big] dz \\ &= \int_{z} f_{\theta}(z) \nabla_{\theta} p_{\theta}(z)dz + \int_{z} p_{\theta}(z) \nabla_{\theta} f_{\theta}(z)dz \\ &= \underbrace{\int_{z} f_{\theta}(z) \nabla_{\theta} p_{\theta}(z)}_{\text{What about this?}}dz + \mathbb{E}_{p_{\theta}(z)} \Big[\nabla_{\theta}f_{\theta}(z)\Big] \end{align}$$
The first term of the last equation is not guaranteed to be an expectation. Monte Carlo methods require that we can sample from $p_{\theta}(z)$, but not that we can take its gradient. This is not a problem if we have an analytic solution to $\nabla_{\theta}p_{\theta}(z)$, but this is not true in general. 1 | Why is random sampling a non-differentiable operation?
Gregory Gundersen wrote a blog post about this in 2018. He explictly answers the questions:
What does a “random node” mean and what does it mean for backprop to “flow” or not flow through such a node |
36,518 | Why is random sampling a non-differentiable operation? | It'd be easier to see with sampling from a categorical distribution. Say you have categorical distribution
$$\pi_1, \pi_2,...,\pi_K, \pi_i \ge 0, \sum_{i=1}^K \pi_i = 1$$
with $p(x=i|\pi) = \pi_i$. To draw a sample $x$ from this distribution, a standard way is to do:
$$
u \sim U(0,1) \\
x = \arg\min_i \sum_{j=1}^i \pi_j \ge u
$$
That is, we draw a value from a uniform distribution and check which "bin" it falls into the CDF of the categorical distribution. The operation "check which "bin" it falls into the CDF of the categorical distribution. " is not differentiable | Why is random sampling a non-differentiable operation? | It'd be easier to see with sampling from a categorical distribution. Say you have categorical distribution
$$\pi_1, \pi_2,...,\pi_K, \pi_i \ge 0, \sum_{i=1}^K \pi_i = 1$$
with $p(x=i|\pi) = \pi_i$. To | Why is random sampling a non-differentiable operation?
It'd be easier to see with sampling from a categorical distribution. Say you have categorical distribution
$$\pi_1, \pi_2,...,\pi_K, \pi_i \ge 0, \sum_{i=1}^K \pi_i = 1$$
with $p(x=i|\pi) = \pi_i$. To draw a sample $x$ from this distribution, a standard way is to do:
$$
u \sim U(0,1) \\
x = \arg\min_i \sum_{j=1}^i \pi_j \ge u
$$
That is, we draw a value from a uniform distribution and check which "bin" it falls into the CDF of the categorical distribution. The operation "check which "bin" it falls into the CDF of the categorical distribution. " is not differentiable | Why is random sampling a non-differentiable operation?
It'd be easier to see with sampling from a categorical distribution. Say you have categorical distribution
$$\pi_1, \pi_2,...,\pi_K, \pi_i \ge 0, \sum_{i=1}^K \pi_i = 1$$
with $p(x=i|\pi) = \pi_i$. To |
36,519 | Why aren't auto-encoders also considered generative models? | My answer to this question would be the following:
A generative model, as defined on the Wikipedia link you provided, aims to estimate the joint distribution of your data and some latent (random) variables usually $p(\textbf{x},\textbf{z})$. Particularly, in the case of the VAE you have that the data (usually $\textbf{x}$) are the images, text, audio or whatever you are modeling and the latent variable (usually $\textbf{z}$) is a multivariate normal (you can relax this). In the AE you cannot make this analogy, you have your data, you map it to a space which lies on a smaller dimension than your original image, and you try to decode this lower dimensional data into your original data. This means, there are no distributional assumptions of how your data is generated. In probabilistic reasoning lingo, there are no assumptions on the data generation process.
When I started studying VAEs I thought of them as "just" probabilistic AEs but now I really don't like that way of looking at them. The intuition I have built around VAEs and the use of neural networks is the following: you build your model on a data generation process, particularly, you think that there is a latent variable per observation, estimating each latent variable per observation can be extremely expensive in classical variational inference so you use a function approximator (this is where the neural networks come in) and approximate the distribution of each latent variable using the observation itself. So the use of neural networks in probabilistic reasoning comes because of its approximating capabilities. Contrary to thinking that VAEs are just probabilistic extensions of neural networks.
Similarly, other models have been developed around the same intuition I tried to explain. For example deep Kalman filters, structural VAEs, etc.
EDIT:
Note that my definition of generative model is a bit reductionist. There is a family of models called "auto-regressive" generative models that don't include a latent variable. In this case, you would be looking at a joint distribution of your variables as a factorization of the individual distributions conditional on the rest of the (previous) variables. Mathematically:
\begin{align}
p(\textbf{x}) = p(x_{0}, x_{1},...,x_{N}) \\
&= \prod_{i=0}^{N}p(x_{i}|\textbf{x}_{i<}) \\
&= p(x_{N}|x_{N-1}, x_{N-2},...x_{0})p(x_{N-1}|x_{N-2}, x_{N-3},...x_{0})...p(x_{o})
\end{align} | Why aren't auto-encoders also considered generative models? | My answer to this question would be the following:
A generative model, as defined on the Wikipedia link you provided, aims to estimate the joint distribution of your data and some latent (random) vari | Why aren't auto-encoders also considered generative models?
My answer to this question would be the following:
A generative model, as defined on the Wikipedia link you provided, aims to estimate the joint distribution of your data and some latent (random) variables usually $p(\textbf{x},\textbf{z})$. Particularly, in the case of the VAE you have that the data (usually $\textbf{x}$) are the images, text, audio or whatever you are modeling and the latent variable (usually $\textbf{z}$) is a multivariate normal (you can relax this). In the AE you cannot make this analogy, you have your data, you map it to a space which lies on a smaller dimension than your original image, and you try to decode this lower dimensional data into your original data. This means, there are no distributional assumptions of how your data is generated. In probabilistic reasoning lingo, there are no assumptions on the data generation process.
When I started studying VAEs I thought of them as "just" probabilistic AEs but now I really don't like that way of looking at them. The intuition I have built around VAEs and the use of neural networks is the following: you build your model on a data generation process, particularly, you think that there is a latent variable per observation, estimating each latent variable per observation can be extremely expensive in classical variational inference so you use a function approximator (this is where the neural networks come in) and approximate the distribution of each latent variable using the observation itself. So the use of neural networks in probabilistic reasoning comes because of its approximating capabilities. Contrary to thinking that VAEs are just probabilistic extensions of neural networks.
Similarly, other models have been developed around the same intuition I tried to explain. For example deep Kalman filters, structural VAEs, etc.
EDIT:
Note that my definition of generative model is a bit reductionist. There is a family of models called "auto-regressive" generative models that don't include a latent variable. In this case, you would be looking at a joint distribution of your variables as a factorization of the individual distributions conditional on the rest of the (previous) variables. Mathematically:
\begin{align}
p(\textbf{x}) = p(x_{0}, x_{1},...,x_{N}) \\
&= \prod_{i=0}^{N}p(x_{i}|\textbf{x}_{i<}) \\
&= p(x_{N}|x_{N-1}, x_{N-2},...x_{0})p(x_{N-1}|x_{N-2}, x_{N-3},...x_{0})...p(x_{o})
\end{align} | Why aren't auto-encoders also considered generative models?
My answer to this question would be the following:
A generative model, as defined on the Wikipedia link you provided, aims to estimate the joint distribution of your data and some latent (random) vari |
36,520 | Can't understand why rejection sampling works | First off you need your $x$ and $y$ distributed between $-1$ and $1$ ($[0,1]$ gives you a quarter of a circle since you're only looking at $y \ge 0$ and $x \ge0$ ).
Then you realise, that you've two lists of randomly distributed variables along the $X$ and $Y$ axis - two lines with a random distribution of points. Combine these and you've a square of randomly distributed points.
You then reject the bits of the square that don't lie within a circle centered at $(0,0)$ - hence the $x^{2}+y^{2}\le1$ - and all the points that satisfy this inequality will lie on the disc and, since the points on the square were uniformly distributed so too will those on the disc. | Can't understand why rejection sampling works | First off you need your $x$ and $y$ distributed between $-1$ and $1$ ($[0,1]$ gives you a quarter of a circle since you're only looking at $y \ge 0$ and $x \ge0$ ).
Then you realise, that you've two l | Can't understand why rejection sampling works
First off you need your $x$ and $y$ distributed between $-1$ and $1$ ($[0,1]$ gives you a quarter of a circle since you're only looking at $y \ge 0$ and $x \ge0$ ).
Then you realise, that you've two lists of randomly distributed variables along the $X$ and $Y$ axis - two lines with a random distribution of points. Combine these and you've a square of randomly distributed points.
You then reject the bits of the square that don't lie within a circle centered at $(0,0)$ - hence the $x^{2}+y^{2}\le1$ - and all the points that satisfy this inequality will lie on the disc and, since the points on the square were uniformly distributed so too will those on the disc. | Can't understand why rejection sampling works
First off you need your $x$ and $y$ distributed between $-1$ and $1$ ($[0,1]$ gives you a quarter of a circle since you're only looking at $y \ge 0$ and $x \ge0$ ).
Then you realise, that you've two l |
36,521 | Can't understand why rejection sampling works | In general, to sample from a distribution with density $f(x,y)$ on support $\mathcal{S}$, if using a proposal distribution with density $h(x,y)$, we need to find $M$ such that
$$\sup_{(x,y) \in\mathcal{S}} \dfrac{f(x,y)}{h(x,y)} \leq M, $$
so that we can accept a proposed value with probability
$$\alpha = \dfrac{f(x,y)}{Mh(x,y)}\,. $$
Accepting with $\alpha$ is equivaluent to drawing $U \sim U[0,1]$ and accepting if $U < \alpha$.
I am assuming you understand this general premise of rejection sampling. So in this example of drawing samples from the circle using a uniform square proposal,
$$f(x,y) = \dfrac{1}{\pi} \cdot I(\underbrace{x^2 + y^2 <1}_{=\mathcal{S}}) \quad \text{ and }\quad h(x,y) = \dfrac{1}{4} I(-1 < x,y < 1)\,. $$
First, let's find $M$. In the support of $f$,
$$\sup_{x^2 + y^2 \leq 1} \dfrac{f(x,y)}{h(x,y)} = \sup_{x^2 + y^2 \leq 1} \dfrac{ I(x^2 + y^2 \leq 1)/ \pi}{1/4} = \dfrac{4}{\pi} := M\,. $$
So any proposed value from the square will be expected with probability
$$ \dfrac{f(x,y)}{M{h(x,y)}} = \dfrac{I(x^2 + y^2 \leq 1)/\pi}{M/{4}} = I(x^2 + y^2 \leq 1)\,.$$
So for any value proposed in the support of $f$, $U\sim U[0,1]$ will always be less than $1$, so we will always accept. There is thus, no need to sample from a $U$, and whenever the sampled point is inside the circle, we can accept it straightaway. | Can't understand why rejection sampling works | In general, to sample from a distribution with density $f(x,y)$ on support $\mathcal{S}$, if using a proposal distribution with density $h(x,y)$, we need to find $M$ such that
$$\sup_{(x,y) \in\mathca | Can't understand why rejection sampling works
In general, to sample from a distribution with density $f(x,y)$ on support $\mathcal{S}$, if using a proposal distribution with density $h(x,y)$, we need to find $M$ such that
$$\sup_{(x,y) \in\mathcal{S}} \dfrac{f(x,y)}{h(x,y)} \leq M, $$
so that we can accept a proposed value with probability
$$\alpha = \dfrac{f(x,y)}{Mh(x,y)}\,. $$
Accepting with $\alpha$ is equivaluent to drawing $U \sim U[0,1]$ and accepting if $U < \alpha$.
I am assuming you understand this general premise of rejection sampling. So in this example of drawing samples from the circle using a uniform square proposal,
$$f(x,y) = \dfrac{1}{\pi} \cdot I(\underbrace{x^2 + y^2 <1}_{=\mathcal{S}}) \quad \text{ and }\quad h(x,y) = \dfrac{1}{4} I(-1 < x,y < 1)\,. $$
First, let's find $M$. In the support of $f$,
$$\sup_{x^2 + y^2 \leq 1} \dfrac{f(x,y)}{h(x,y)} = \sup_{x^2 + y^2 \leq 1} \dfrac{ I(x^2 + y^2 \leq 1)/ \pi}{1/4} = \dfrac{4}{\pi} := M\,. $$
So any proposed value from the square will be expected with probability
$$ \dfrac{f(x,y)}{M{h(x,y)}} = \dfrac{I(x^2 + y^2 \leq 1)/\pi}{M/{4}} = I(x^2 + y^2 \leq 1)\,.$$
So for any value proposed in the support of $f$, $U\sim U[0,1]$ will always be less than $1$, so we will always accept. There is thus, no need to sample from a $U$, and whenever the sampled point is inside the circle, we can accept it straightaway. | Can't understand why rejection sampling works
In general, to sample from a distribution with density $f(x,y)$ on support $\mathcal{S}$, if using a proposal distribution with density $h(x,y)$, we need to find $M$ such that
$$\sup_{(x,y) \in\mathca |
36,522 | Can't understand why rejection sampling works | You have chosen any point in [0,1]x[0,1] with equal probability. Then you removed all of those who are outside the circle.
This does not alter the probability of being selected for each individual point inside the circle (ie: any point inside the circle has still the same probability of being chosen as any other) | Can't understand why rejection sampling works | You have chosen any point in [0,1]x[0,1] with equal probability. Then you removed all of those who are outside the circle.
This does not alter the probability of being selected for each individual poi | Can't understand why rejection sampling works
You have chosen any point in [0,1]x[0,1] with equal probability. Then you removed all of those who are outside the circle.
This does not alter the probability of being selected for each individual point inside the circle (ie: any point inside the circle has still the same probability of being chosen as any other) | Can't understand why rejection sampling works
You have chosen any point in [0,1]x[0,1] with equal probability. Then you removed all of those who are outside the circle.
This does not alter the probability of being selected for each individual poi |
36,523 | verifying a posterior is proper | For $𝑘=1$, you can see directly from your equation for the likelihood that the posterior density $𝑝(𝛼,𝛽|𝑦_1,𝑥_1)$ will be constant along parallell lines at which $𝛼+𝛽𝑥_𝑖$ takes constant values. So the posterior is indeed improper and has the shape of a ridge for $𝑘=1$. Basically, any regression line fitting the observed response at $𝑥_1$ will do equally well.
Next, suppose we have $k=2$ observations. Consider the reparameterization given by
\begin{align}
\eta_1 &= \alpha + \beta x_1 \\
\eta_2 &= \alpha + \beta x_2
\end{align}
Since this is a linear transformation of $\alpha,\beta$ with a constant determinant the prior for $\eta_1,\eta_2$ is also uniform over $\mathbb{R}^2$, provided that $x_1\neq x_2$. Consider the further reparameterization, the inverse logit transformation
\begin{align}
p_i = \frac1{1+e^{-\eta_i}},
\end{align}
for $i=1,2$. Clearly, $p_1,p_2$ are also a priori independent with densities given by
$$
\pi(p_i)=\pi(\eta_i)\Big|\frac{d\eta_i}{dp_i}\Big|\propto \frac d{dp_i}\ln\frac{p_i}{1-p_i} = \frac1{(1-p_i)p_i}
$$
These are so called improper Haldane priors, that can be interpreted as a certain form of limit of the density of a Beta distribution with both parameters approaching zero. Conditional on the data $y_1,y_2$, provided that $0<y_i<n$, the posterior marginal density for each $p_i$ are proper Beta distributions with parameters $y_i,n-y_i$. Backtransforming, the posterior distributions of $(\eta_1,\eta_2)$ and $(\alpha,\beta)$ must also be proper. This holds except in special cases such as one $y_i$ taking a value of 0 or $n$ in which case the normalising beta function $B(y_i,n-y_i)$ is infinite and the posterior of $p_i$ (and hence the posterior of $\alpha$ and $\beta$) is improper.
For $k>2$ observations, the posterior must also be proper since the non-normalized posterior density of $\alpha,\beta$ is bounded by the posterior based on the first $k=2$ observations. | verifying a posterior is proper | For $𝑘=1$, you can see directly from your equation for the likelihood that the posterior density $𝑝(𝛼,𝛽|𝑦_1,𝑥_1)$ will be constant along parallell lines at which $𝛼+𝛽𝑥_𝑖$ takes constant values. So the | verifying a posterior is proper
For $𝑘=1$, you can see directly from your equation for the likelihood that the posterior density $𝑝(𝛼,𝛽|𝑦_1,𝑥_1)$ will be constant along parallell lines at which $𝛼+𝛽𝑥_𝑖$ takes constant values. So the posterior is indeed improper and has the shape of a ridge for $𝑘=1$. Basically, any regression line fitting the observed response at $𝑥_1$ will do equally well.
Next, suppose we have $k=2$ observations. Consider the reparameterization given by
\begin{align}
\eta_1 &= \alpha + \beta x_1 \\
\eta_2 &= \alpha + \beta x_2
\end{align}
Since this is a linear transformation of $\alpha,\beta$ with a constant determinant the prior for $\eta_1,\eta_2$ is also uniform over $\mathbb{R}^2$, provided that $x_1\neq x_2$. Consider the further reparameterization, the inverse logit transformation
\begin{align}
p_i = \frac1{1+e^{-\eta_i}},
\end{align}
for $i=1,2$. Clearly, $p_1,p_2$ are also a priori independent with densities given by
$$
\pi(p_i)=\pi(\eta_i)\Big|\frac{d\eta_i}{dp_i}\Big|\propto \frac d{dp_i}\ln\frac{p_i}{1-p_i} = \frac1{(1-p_i)p_i}
$$
These are so called improper Haldane priors, that can be interpreted as a certain form of limit of the density of a Beta distribution with both parameters approaching zero. Conditional on the data $y_1,y_2$, provided that $0<y_i<n$, the posterior marginal density for each $p_i$ are proper Beta distributions with parameters $y_i,n-y_i$. Backtransforming, the posterior distributions of $(\eta_1,\eta_2)$ and $(\alpha,\beta)$ must also be proper. This holds except in special cases such as one $y_i$ taking a value of 0 or $n$ in which case the normalising beta function $B(y_i,n-y_i)$ is infinite and the posterior of $p_i$ (and hence the posterior of $\alpha$ and $\beta$) is improper.
For $k>2$ observations, the posterior must also be proper since the non-normalized posterior density of $\alpha,\beta$ is bounded by the posterior based on the first $k=2$ observations. | verifying a posterior is proper
For $𝑘=1$, you can see directly from your equation for the likelihood that the posterior density $𝑝(𝛼,𝛽|𝑦_1,𝑥_1)$ will be constant along parallell lines at which $𝛼+𝛽𝑥_𝑖$ takes constant values. So the |
36,524 | verifying a posterior is proper | It's improper, I believe. I only need to prove that $$\int\limits_{\alpha \in \mathbb{R} \\ \beta>0} p(y \mid \alpha, \beta, x) = +\infty.$$
Denote function $$\sigma = \mathrm{invlogit}$$
Now that $\sigma$ is a monotonically increasing function, when $\beta > 0$, we have $$\mathrm{\sigma}(\alpha + \beta x_i) > \mathrm{\sigma}(\alpha - \beta \max |x_i|) > 0,$$ $$1 - \mathrm{\sigma}(\alpha + \beta x_i) > 1 - \mathrm{\sigma}(\alpha + \beta \max |x_i|) > 0.$$
Thus the the integral
$$\begin{aligned}
\int\limits_{\alpha \in \mathbb{R} \\ \beta>0} p(y \mid \alpha, \beta, x) >& \int\limits_{\alpha \in \mathbb{R} \\ \beta>0} \prod \left[ \mathrm{\sigma}(\alpha - \beta \max |x_i|) \right]^{y_i} \left[ 1 - \mathrm{\sigma}(\alpha + \beta \max |x_i|) \right]^{n_i - y_i} \\
>& \int\limits_{\alpha \in \mathbb{R} \\ \beta>0} \prod \left[ \mathrm{\sigma}(\alpha - \beta \max |x_i|) \right]^{\max n_i} \left[ 1 - \mathrm{\sigma}(\alpha + \beta \max |x_i|) \right]^{\max n_i} \\
>& \int\limits_{\alpha \in \mathbb{R} \\ \beta>0} \left[ \mathrm{\sigma}(\alpha - \beta \max |x_i|) \right]^{k\max n_i} \left[ 1 - \mathrm{\sigma}(\alpha + \beta \max |x_i|) \right]^{k\max n_i} \\
\end{aligned}$$
More properties about $\sigma$ are needed:
$$\left( \sigma(x) \right)^N = \frac{1}{(1+e^{-x})^N} > \dfrac{1}{2^N (\max\{1,e^{-x}\}) ^N} = \dfrac{1}{2^N (\max\{1,e^{-Nx}\})} > \dfrac{1}{2^N}\sigma(Nx)$$
Let $\xi = \alpha - \beta \max |x_i|$, $\eta = \alpha + \beta \max |x_i|, N=k\max n_i$, then
\begin{aligned}
\int\limits_{\alpha \in \mathbb{R} \\ \beta>0} p(y \mid \alpha, \beta, x)
>& \int\limits_{\alpha \in \mathbb{R} \\ \beta>0} \left[ \mathrm{\sigma}(\alpha - \beta \max |x_i|) \right]^{N} \left[ 1 - \mathrm{\sigma}(\alpha + \beta \max |x_i|) \right]^{N} \\
\propto& \int\limits_{-\infty < \xi < \eta < +\infty} \left[ \mathrm{\sigma}(\xi) \right]^{N} \left[ \mathrm{\sigma}(-\eta) \right]^{N}\\
>& \frac{1}{2^{2N}}\int\limits_{\xi}^{+\infty} \Big( \int\limits_{-\infty}^{+\infty} \mathrm{\sigma}(N\xi) \mathrm{d}\xi \Big) ~ \mathrm{\sigma}(- N\eta) \mathrm{d}\eta \\
=& +\infty
\end{aligned} | verifying a posterior is proper | It's improper, I believe. I only need to prove that $$\int\limits_{\alpha \in \mathbb{R} \\ \beta>0} p(y \mid \alpha, \beta, x) = +\infty.$$
Denote function $$\sigma = \mathrm{invlogit}$$
Now that $\s | verifying a posterior is proper
It's improper, I believe. I only need to prove that $$\int\limits_{\alpha \in \mathbb{R} \\ \beta>0} p(y \mid \alpha, \beta, x) = +\infty.$$
Denote function $$\sigma = \mathrm{invlogit}$$
Now that $\sigma$ is a monotonically increasing function, when $\beta > 0$, we have $$\mathrm{\sigma}(\alpha + \beta x_i) > \mathrm{\sigma}(\alpha - \beta \max |x_i|) > 0,$$ $$1 - \mathrm{\sigma}(\alpha + \beta x_i) > 1 - \mathrm{\sigma}(\alpha + \beta \max |x_i|) > 0.$$
Thus the the integral
$$\begin{aligned}
\int\limits_{\alpha \in \mathbb{R} \\ \beta>0} p(y \mid \alpha, \beta, x) >& \int\limits_{\alpha \in \mathbb{R} \\ \beta>0} \prod \left[ \mathrm{\sigma}(\alpha - \beta \max |x_i|) \right]^{y_i} \left[ 1 - \mathrm{\sigma}(\alpha + \beta \max |x_i|) \right]^{n_i - y_i} \\
>& \int\limits_{\alpha \in \mathbb{R} \\ \beta>0} \prod \left[ \mathrm{\sigma}(\alpha - \beta \max |x_i|) \right]^{\max n_i} \left[ 1 - \mathrm{\sigma}(\alpha + \beta \max |x_i|) \right]^{\max n_i} \\
>& \int\limits_{\alpha \in \mathbb{R} \\ \beta>0} \left[ \mathrm{\sigma}(\alpha - \beta \max |x_i|) \right]^{k\max n_i} \left[ 1 - \mathrm{\sigma}(\alpha + \beta \max |x_i|) \right]^{k\max n_i} \\
\end{aligned}$$
More properties about $\sigma$ are needed:
$$\left( \sigma(x) \right)^N = \frac{1}{(1+e^{-x})^N} > \dfrac{1}{2^N (\max\{1,e^{-x}\}) ^N} = \dfrac{1}{2^N (\max\{1,e^{-Nx}\})} > \dfrac{1}{2^N}\sigma(Nx)$$
Let $\xi = \alpha - \beta \max |x_i|$, $\eta = \alpha + \beta \max |x_i|, N=k\max n_i$, then
\begin{aligned}
\int\limits_{\alpha \in \mathbb{R} \\ \beta>0} p(y \mid \alpha, \beta, x)
>& \int\limits_{\alpha \in \mathbb{R} \\ \beta>0} \left[ \mathrm{\sigma}(\alpha - \beta \max |x_i|) \right]^{N} \left[ 1 - \mathrm{\sigma}(\alpha + \beta \max |x_i|) \right]^{N} \\
\propto& \int\limits_{-\infty < \xi < \eta < +\infty} \left[ \mathrm{\sigma}(\xi) \right]^{N} \left[ \mathrm{\sigma}(-\eta) \right]^{N}\\
>& \frac{1}{2^{2N}}\int\limits_{\xi}^{+\infty} \Big( \int\limits_{-\infty}^{+\infty} \mathrm{\sigma}(N\xi) \mathrm{d}\xi \Big) ~ \mathrm{\sigma}(- N\eta) \mathrm{d}\eta \\
=& +\infty
\end{aligned} | verifying a posterior is proper
It's improper, I believe. I only need to prove that $$\int\limits_{\alpha \in \mathbb{R} \\ \beta>0} p(y \mid \alpha, \beta, x) = +\infty.$$
Denote function $$\sigma = \mathrm{invlogit}$$
Now that $\s |
36,525 | verifying a posterior is proper | I've already accepted an answer, but I did want to point out that the posterior isn't proper for all possible data sets. The posterior is proportional to the likelihood, which is
$$\prod_{i=1}^k [\text{invlogit}(\alpha + \beta x_i)]^{y_i}[1-\text{invlogit}(\alpha + \beta x_i)]^{n-y_i}.
$$
If $y_1 = y_2 = \cdots = y_k = n$, then this simplifies to
$$
\prod_{i=1}^k [\text{invlogit}(\alpha + \beta x_i)]^n,
$$
and we can see that
\begin{align*}
&\int_{-\infty}^{\infty}\int_{-\infty}^{\infty} \prod_{i=1}^k [\text{invlogit}(\alpha + \beta x_i)]^n \text{d}\alpha \text{d}\beta\\
&\ge \int_0^{\infty}\int_{-\infty}^{\infty} \prod_{i=1}^k [\text{invlogit}(\alpha + \beta x_i)]^n \text{d}\alpha \text{d}\beta \\
&\ge \int_0^{\infty}\int_{-\infty}^{\infty} [\text{invlogit}(\alpha + \beta x_{(1)})]^{nk} \text{d}\alpha \text{d}\beta \\
&\ge \int_0^{\infty}\int_{-\infty}^{\infty} [\text{invlogit}(r_1)]^{nk} \text{d}r_1 \text{d}r_2 \\
&= \infty.
\end{align*} | verifying a posterior is proper | I've already accepted an answer, but I did want to point out that the posterior isn't proper for all possible data sets. The posterior is proportional to the likelihood, which is
$$\prod_{i=1}^k [\tex | verifying a posterior is proper
I've already accepted an answer, but I did want to point out that the posterior isn't proper for all possible data sets. The posterior is proportional to the likelihood, which is
$$\prod_{i=1}^k [\text{invlogit}(\alpha + \beta x_i)]^{y_i}[1-\text{invlogit}(\alpha + \beta x_i)]^{n-y_i}.
$$
If $y_1 = y_2 = \cdots = y_k = n$, then this simplifies to
$$
\prod_{i=1}^k [\text{invlogit}(\alpha + \beta x_i)]^n,
$$
and we can see that
\begin{align*}
&\int_{-\infty}^{\infty}\int_{-\infty}^{\infty} \prod_{i=1}^k [\text{invlogit}(\alpha + \beta x_i)]^n \text{d}\alpha \text{d}\beta\\
&\ge \int_0^{\infty}\int_{-\infty}^{\infty} \prod_{i=1}^k [\text{invlogit}(\alpha + \beta x_i)]^n \text{d}\alpha \text{d}\beta \\
&\ge \int_0^{\infty}\int_{-\infty}^{\infty} [\text{invlogit}(\alpha + \beta x_{(1)})]^{nk} \text{d}\alpha \text{d}\beta \\
&\ge \int_0^{\infty}\int_{-\infty}^{\infty} [\text{invlogit}(r_1)]^{nk} \text{d}r_1 \text{d}r_2 \\
&= \infty.
\end{align*} | verifying a posterior is proper
I've already accepted an answer, but I did want to point out that the posterior isn't proper for all possible data sets. The posterior is proportional to the likelihood, which is
$$\prod_{i=1}^k [\tex |
36,526 | Elbow Test using AIC/BIC for identifying number of clusters using GMM | Welcome to CV!
This plot shows how the AIC and BIC change as a function of the number of clusters. While the AIC continues to decrease with a larger number of clusters, you can see that the BIC stops decreasing after $k=6$ clusters. For this reason, you could choose $k = 6$.
Another way to choose the 'best' number of clusters is by considering the elbow(s) of the figure. The elbow of a function is a point after which the decrease becomes notably smaller. An elbow is a heuristic, so there is no exact way to determine which value best describes this point. For example, one could argue that the AIC & BIC both stop decreasing as much after $k = 5$ clusters, while someone else might argue that this is after $k = 6$ clusters. You could even argue that the biggest decrease has already happened after $k = 2$ clusters.
Lastly, you don't have to choose any number of clusters just because AIC/BIC/whatever suggested you do so. If you have some a priori reason to assume that there should be $k = 3$ clusters, then that might be a better choice.
In short: An elbow in this context is a heuristic guide to decide the number of clusters if you have no other reason to assume a certain number of clusters. | Elbow Test using AIC/BIC for identifying number of clusters using GMM | Welcome to CV!
This plot shows how the AIC and BIC change as a function of the number of clusters. While the AIC continues to decrease with a larger number of clusters, you can see that the BIC stops | Elbow Test using AIC/BIC for identifying number of clusters using GMM
Welcome to CV!
This plot shows how the AIC and BIC change as a function of the number of clusters. While the AIC continues to decrease with a larger number of clusters, you can see that the BIC stops decreasing after $k=6$ clusters. For this reason, you could choose $k = 6$.
Another way to choose the 'best' number of clusters is by considering the elbow(s) of the figure. The elbow of a function is a point after which the decrease becomes notably smaller. An elbow is a heuristic, so there is no exact way to determine which value best describes this point. For example, one could argue that the AIC & BIC both stop decreasing as much after $k = 5$ clusters, while someone else might argue that this is after $k = 6$ clusters. You could even argue that the biggest decrease has already happened after $k = 2$ clusters.
Lastly, you don't have to choose any number of clusters just because AIC/BIC/whatever suggested you do so. If you have some a priori reason to assume that there should be $k = 3$ clusters, then that might be a better choice.
In short: An elbow in this context is a heuristic guide to decide the number of clusters if you have no other reason to assume a certain number of clusters. | Elbow Test using AIC/BIC for identifying number of clusters using GMM
Welcome to CV!
This plot shows how the AIC and BIC change as a function of the number of clusters. While the AIC continues to decrease with a larger number of clusters, you can see that the BIC stops |
36,527 | How is the family of distributions with PDF proportional to $(1+ax^2)^{-1/a}$ called? | It's simply a particular scaled $t$-distribution -- a $t$-distribution with a different variance to the standard $t$-distribution.
Let $\nu = \frac{2}{\alpha}-1$. Let $\sigma= \frac{\sqrt{2-\alpha}}{\alpha}$.
Then (if I did it right) $Y=X/\sigma$ is a standard $t$ with $\nu$ d.f.
Here's how my reasoning went:
$$f_Y(y)= c\cdot \frac{1}{(1+\frac{y^2}{\nu})^{(\nu+1)/2}}$$ is a standard $t$-density.
We get the scale family by letting $X/\sigma=Y$, in which case $$f_X(x) = \frac{1}{\sigma}f_Y\Big(\frac{x}{\sigma}\Big) = \frac{c}{\sigma}\cdot \frac{1}{(1+\frac{x^2}{\sigma^2\nu})^{(\nu+1)/2}}$$ is a scaled $t$-density.
Just equate the coefficients in your density to this, and solve for $\nu$ and $\sigma$.
Recognizing that a scale parameter will take up whatever isn't "right" in $\alpha x^2$ (given that $\nu$ is already defined by equating powers) was all that was needed to see it's scaled $t$; algebra wasn't required until it came time to actually find the parameters of the $t$.
[Final note: In case it's not obvious that a scale family has the form $f_X(x) = \frac{1}{\sigma}f_Y\Big(\frac{x}{\sigma}\Big)$, take the probability statement $F_X(x) = F_Y\Big(\frac{x}{\sigma}\Big)$ (noting that the event $X/\sigma\leq t$ is identical to the event $Y\leq t$) and differentiate.] | How is the family of distributions with PDF proportional to $(1+ax^2)^{-1/a}$ called? | It's simply a particular scaled $t$-distribution -- a $t$-distribution with a different variance to the standard $t$-distribution.
Let $\nu = \frac{2}{\alpha}-1$. Let $\sigma= \frac{\sqrt{2-\alpha}}{\ | How is the family of distributions with PDF proportional to $(1+ax^2)^{-1/a}$ called?
It's simply a particular scaled $t$-distribution -- a $t$-distribution with a different variance to the standard $t$-distribution.
Let $\nu = \frac{2}{\alpha}-1$. Let $\sigma= \frac{\sqrt{2-\alpha}}{\alpha}$.
Then (if I did it right) $Y=X/\sigma$ is a standard $t$ with $\nu$ d.f.
Here's how my reasoning went:
$$f_Y(y)= c\cdot \frac{1}{(1+\frac{y^2}{\nu})^{(\nu+1)/2}}$$ is a standard $t$-density.
We get the scale family by letting $X/\sigma=Y$, in which case $$f_X(x) = \frac{1}{\sigma}f_Y\Big(\frac{x}{\sigma}\Big) = \frac{c}{\sigma}\cdot \frac{1}{(1+\frac{x^2}{\sigma^2\nu})^{(\nu+1)/2}}$$ is a scaled $t$-density.
Just equate the coefficients in your density to this, and solve for $\nu$ and $\sigma$.
Recognizing that a scale parameter will take up whatever isn't "right" in $\alpha x^2$ (given that $\nu$ is already defined by equating powers) was all that was needed to see it's scaled $t$; algebra wasn't required until it came time to actually find the parameters of the $t$.
[Final note: In case it's not obvious that a scale family has the form $f_X(x) = \frac{1}{\sigma}f_Y\Big(\frac{x}{\sigma}\Big)$, take the probability statement $F_X(x) = F_Y\Big(\frac{x}{\sigma}\Big)$ (noting that the event $X/\sigma\leq t$ is identical to the event $Y\leq t$) and differentiate.] | How is the family of distributions with PDF proportional to $(1+ax^2)^{-1/a}$ called?
It's simply a particular scaled $t$-distribution -- a $t$-distribution with a different variance to the standard $t$-distribution.
Let $\nu = \frac{2}{\alpha}-1$. Let $\sigma= \frac{\sqrt{2-\alpha}}{\ |
36,528 | How Ridge or Lasso regression really work? | Because your "penalty" represenation of the minimization problem is just the langrange form of a constraint optimization problem:
Assume centered variables.
In both cases, lasso and ridge, your unconstrained target function is then the usual sum of squared residuals; i.e. given $p$ regressors you minimize:
$$RSS(\boldsymbol{\beta}) = \sum_{i=1}^n (y_i-(x_{i,1}\beta_1 +\dots +x_{i,p}\beta_p))^2.$$
over all $\boldsymbol{\beta} =(\beta_1,\dots, \beta_p)$.
Now, in the case of a ridge regression you minimize $RSS(\boldsymbol{\beta})$ such that $$\sum_{i=1}^p\beta_p^2 \leq t_{ridge},$$
for some value of $t_{ridge}\geq 0$. For small values of $t_{ridge}$ it will be impossible to derive the same solution as in standard least square scenario in which case you only minimize $RSS(\boldsymbol{\beta})$ -- Think about $t_{ridge}=0$ then the only possible solution can be $\beta_1\equiv \dots \equiv \beta_p = 0$.
On the other hand, in the case of the lasso, you minimize $RSS(\boldsymbol{\beta})$ under the constraint
$$\sum_{i=1}^p|\beta_p| \leq t_{lasso},$$
for some value of $t_{lasso}\geq 0$.
Both constrained optimization problems can be equivalently forumlated in terms of an unconstrained optimization problem, i.e. for the lasso: you can equivalently minimize
$$\sum_{i=1}^n (y_i-(x_{i,1}\beta_1 +\dots +x_{i,p}\beta_p))^2 + \lambda_{lasso}\sum_{i=1}^p|\beta_p|.$$ | How Ridge or Lasso regression really work? | Because your "penalty" represenation of the minimization problem is just the langrange form of a constraint optimization problem:
Assume centered variables.
In both cases, lasso and ridge, your uncon | How Ridge or Lasso regression really work?
Because your "penalty" represenation of the minimization problem is just the langrange form of a constraint optimization problem:
Assume centered variables.
In both cases, lasso and ridge, your unconstrained target function is then the usual sum of squared residuals; i.e. given $p$ regressors you minimize:
$$RSS(\boldsymbol{\beta}) = \sum_{i=1}^n (y_i-(x_{i,1}\beta_1 +\dots +x_{i,p}\beta_p))^2.$$
over all $\boldsymbol{\beta} =(\beta_1,\dots, \beta_p)$.
Now, in the case of a ridge regression you minimize $RSS(\boldsymbol{\beta})$ such that $$\sum_{i=1}^p\beta_p^2 \leq t_{ridge},$$
for some value of $t_{ridge}\geq 0$. For small values of $t_{ridge}$ it will be impossible to derive the same solution as in standard least square scenario in which case you only minimize $RSS(\boldsymbol{\beta})$ -- Think about $t_{ridge}=0$ then the only possible solution can be $\beta_1\equiv \dots \equiv \beta_p = 0$.
On the other hand, in the case of the lasso, you minimize $RSS(\boldsymbol{\beta})$ under the constraint
$$\sum_{i=1}^p|\beta_p| \leq t_{lasso},$$
for some value of $t_{lasso}\geq 0$.
Both constrained optimization problems can be equivalently forumlated in terms of an unconstrained optimization problem, i.e. for the lasso: you can equivalently minimize
$$\sum_{i=1}^n (y_i-(x_{i,1}\beta_1 +\dots +x_{i,p}\beta_p))^2 + \lambda_{lasso}\sum_{i=1}^p|\beta_p|.$$ | How Ridge or Lasso regression really work?
Because your "penalty" represenation of the minimization problem is just the langrange form of a constraint optimization problem:
Assume centered variables.
In both cases, lasso and ridge, your uncon |
36,529 | The distribution of the initial point of an AR process | Time-series processes defined only by a recursive equation are not fully specified, since they depend on specification of a "starting distribution". Unless there is some additional restriction you are required to meet, you can use any starting distribution you like, and you will still have an AR model that conforms with the specified recursive equation. However, having said this, it is usually the case that we want to specify a stationary AR model, which imposes an additional restriction beyond the recursive equation. If you would like your AR model to be stationary, then you require $|\alpha|<1$ and you also need to choose the marginal distribution of the initial value to be equal to the asymptotic distribution of the process.
To obtain the marginal distribution required for a stationary model, you set the variance for the marginal distribution by setting its variance to $\sigma_X^2 = \mathbb{V}(X_t) = \mathbb{V}(X_{t-1})$. From the recursive equation defining your AR process you have:
$$\begin{equation} \begin{aligned}
\sigma_X^2 = \mathbb{V}(X_t)
&= \mathbb{V}(\alpha X_{t-1} + e_t) \\[6pt]
&= \alpha^2 \mathbb{V}(X_{t-1}) + \mathbb{V}(e_t) \\[6pt]
&= \alpha^2 \sigma_X^2 + \sigma^2. \\[6pt]
\end{aligned} \end{equation}$$
Solving for $\sigma_X$ yields:
$$\sigma_X^2 = \frac{\sigma^2}{1-\alpha^2}.$$
Hence, in order to obtain a (strongly) stationary AR model (with zero mean), you would use the starting distribution:
$$X_i \sim \text{N} \Big( 0, \frac{\sigma^2}{1-\alpha^2} \Big).$$
Using this starting distribution ensures that the time-series values all have that same marginal distribution, which gives you a stationary process. You will notice from this result that the marginal variance of the series is larger if the absolute value of the auto-correlation parameter is closer to one. That is because such processes have high auto-correlation, which leads to large swings in the process, leading to higher (marginal) variance.
One more thing to note here is that you do not have a mean term in your AR model, so it has an asymptotic mean of zero, and so we have used a mean of zero in the starting distribution. You could generalise your model to have a mean parameter if you wanted to, but that would change the recursive equation slightly. I have discussed this issue for the more general AR model in another answer to a similar question here, and I recommend you read that answer to supplement this one. | The distribution of the initial point of an AR process | Time-series processes defined only by a recursive equation are not fully specified, since they depend on specification of a "starting distribution". Unless there is some additional restriction you ar | The distribution of the initial point of an AR process
Time-series processes defined only by a recursive equation are not fully specified, since they depend on specification of a "starting distribution". Unless there is some additional restriction you are required to meet, you can use any starting distribution you like, and you will still have an AR model that conforms with the specified recursive equation. However, having said this, it is usually the case that we want to specify a stationary AR model, which imposes an additional restriction beyond the recursive equation. If you would like your AR model to be stationary, then you require $|\alpha|<1$ and you also need to choose the marginal distribution of the initial value to be equal to the asymptotic distribution of the process.
To obtain the marginal distribution required for a stationary model, you set the variance for the marginal distribution by setting its variance to $\sigma_X^2 = \mathbb{V}(X_t) = \mathbb{V}(X_{t-1})$. From the recursive equation defining your AR process you have:
$$\begin{equation} \begin{aligned}
\sigma_X^2 = \mathbb{V}(X_t)
&= \mathbb{V}(\alpha X_{t-1} + e_t) \\[6pt]
&= \alpha^2 \mathbb{V}(X_{t-1}) + \mathbb{V}(e_t) \\[6pt]
&= \alpha^2 \sigma_X^2 + \sigma^2. \\[6pt]
\end{aligned} \end{equation}$$
Solving for $\sigma_X$ yields:
$$\sigma_X^2 = \frac{\sigma^2}{1-\alpha^2}.$$
Hence, in order to obtain a (strongly) stationary AR model (with zero mean), you would use the starting distribution:
$$X_i \sim \text{N} \Big( 0, \frac{\sigma^2}{1-\alpha^2} \Big).$$
Using this starting distribution ensures that the time-series values all have that same marginal distribution, which gives you a stationary process. You will notice from this result that the marginal variance of the series is larger if the absolute value of the auto-correlation parameter is closer to one. That is because such processes have high auto-correlation, which leads to large swings in the process, leading to higher (marginal) variance.
One more thing to note here is that you do not have a mean term in your AR model, so it has an asymptotic mean of zero, and so we have used a mean of zero in the starting distribution. You could generalise your model to have a mean parameter if you wanted to, but that would change the recursive equation slightly. I have discussed this issue for the more general AR model in another answer to a similar question here, and I recommend you read that answer to supplement this one. | The distribution of the initial point of an AR process
Time-series processes defined only by a recursive equation are not fully specified, since they depend on specification of a "starting distribution". Unless there is some additional restriction you ar |
36,530 | Intuition (geometric or other) of $Var(X) = Var(E[X|Y]) + E[Var(X|Y)]$ | To get some simple intuition, we will compare with a two-way analysis of variance. Let $Y_{ij} = \mu_i +\epsilon_{ij}$ where the $\epsilon_{ij}$ are iid with expectation zero and common variance $\sigma^2$, $i=1,\dotsc,k; j=1,\dotsc,n_i$.
Then we have the decomposition
$$
\sum_{i=1}^k\sum_{j=1}^{n_i} (Y_{ij}-\overline{\overline{Y}})^2 = \sum_{i=1}^k\sum_{j=1}^{n_i} (Y_{ij}-\overline{Y_i})^2 + \sum_{i=1}^k n_i((\overline{Y_{i}}-\overline{\overline{Y}})^2
$$
where the first term on the right measures within-group variance (and can be used to estimate the common within-group variance $\sigma^2$), the second term measures between-group variance, and can be used to estimate $\sigma^2$ only under the hypothesis that all the $\mu_i$ have a common value. Otherwise, it will contain an extra component, the "variance of the $\mu_i$'s". This has the same form as the law of total variance!
Formally, let group membership be the random variable $G$. Then we get
$$
Var Y = E Var (Y | G) + Var E (Y | G)
$$
and we can read this as "variance of $Y$ is the expected value of within-group variance plus the variance of group expectations." That is the same as our interpretation of the ANOVA decomposition above. Looking closer at the derivation (which we didn't give here) you can see that it is really a version of the Pythagorean theorem. For that point of view see Law of total variance as Pythagorean theorem | Intuition (geometric or other) of $Var(X) = Var(E[X|Y]) + E[Var(X|Y)]$ | To get some simple intuition, we will compare with a two-way analysis of variance. Let $Y_{ij} = \mu_i +\epsilon_{ij}$ where the $\epsilon_{ij}$ are iid with expectation zero and common variance $\sig | Intuition (geometric or other) of $Var(X) = Var(E[X|Y]) + E[Var(X|Y)]$
To get some simple intuition, we will compare with a two-way analysis of variance. Let $Y_{ij} = \mu_i +\epsilon_{ij}$ where the $\epsilon_{ij}$ are iid with expectation zero and common variance $\sigma^2$, $i=1,\dotsc,k; j=1,\dotsc,n_i$.
Then we have the decomposition
$$
\sum_{i=1}^k\sum_{j=1}^{n_i} (Y_{ij}-\overline{\overline{Y}})^2 = \sum_{i=1}^k\sum_{j=1}^{n_i} (Y_{ij}-\overline{Y_i})^2 + \sum_{i=1}^k n_i((\overline{Y_{i}}-\overline{\overline{Y}})^2
$$
where the first term on the right measures within-group variance (and can be used to estimate the common within-group variance $\sigma^2$), the second term measures between-group variance, and can be used to estimate $\sigma^2$ only under the hypothesis that all the $\mu_i$ have a common value. Otherwise, it will contain an extra component, the "variance of the $\mu_i$'s". This has the same form as the law of total variance!
Formally, let group membership be the random variable $G$. Then we get
$$
Var Y = E Var (Y | G) + Var E (Y | G)
$$
and we can read this as "variance of $Y$ is the expected value of within-group variance plus the variance of group expectations." That is the same as our interpretation of the ANOVA decomposition above. Looking closer at the derivation (which we didn't give here) you can see that it is really a version of the Pythagorean theorem. For that point of view see Law of total variance as Pythagorean theorem | Intuition (geometric or other) of $Var(X) = Var(E[X|Y]) + E[Var(X|Y)]$
To get some simple intuition, we will compare with a two-way analysis of variance. Let $Y_{ij} = \mu_i +\epsilon_{ij}$ where the $\epsilon_{ij}$ are iid with expectation zero and common variance $\sig |
36,531 | How to do dimension reduction with sparse data | This depends on the goal of clustering.
t-SNE as well as various clustering methods (like hierarchical clustering) can work on distance matrices. And it's your job to construct a distance measure that captures what you wish to achieve. A few examples below.
Example 1
If you want to group the students based on their ability to get good grades the simplest solution would be to ignore the missing classes and simply compare the average grades they achieved. So the distance between two students might simply be the difference of their average grades.
A good additional idea here would be to weight each class according to how hard it was (based for example on the average grades students get in that class)
Example 2
If students are free to choose their classes you might want to group them by their interests. In this case the interests would be reflected by the type of classes they actually chose. In this scenario you would ignore all of their marks and simply code the missing classes as 0 and attended classes as 1. Then compute a distance measure between students based on how many classes they overlap at.
Example 3
Another possible scenario is if you wish to group students based on their ability on various subjects. Here you would have to incorporate both the grades as well as the selection of subjects. A simple (read dumb) solution would be to replace all missing entries for each student with their average ability. Or with the average ability for every student on that subject.
The idea is that when the student didn't take the class - your best guess that he is average at that class.
But you could possibly construct better metrics after some reflection. Just need to think about what the similarity should be between students when none of their classes overlap.
t-SNE and clustering
The examples above show some ways how one could construct a distance matrix between students. After that you can use that matrix for both t-SNE and clustering. | How to do dimension reduction with sparse data | This depends on the goal of clustering.
t-SNE as well as various clustering methods (like hierarchical clustering) can work on distance matrices. And it's your job to construct a distance measure that | How to do dimension reduction with sparse data
This depends on the goal of clustering.
t-SNE as well as various clustering methods (like hierarchical clustering) can work on distance matrices. And it's your job to construct a distance measure that captures what you wish to achieve. A few examples below.
Example 1
If you want to group the students based on their ability to get good grades the simplest solution would be to ignore the missing classes and simply compare the average grades they achieved. So the distance between two students might simply be the difference of their average grades.
A good additional idea here would be to weight each class according to how hard it was (based for example on the average grades students get in that class)
Example 2
If students are free to choose their classes you might want to group them by their interests. In this case the interests would be reflected by the type of classes they actually chose. In this scenario you would ignore all of their marks and simply code the missing classes as 0 and attended classes as 1. Then compute a distance measure between students based on how many classes they overlap at.
Example 3
Another possible scenario is if you wish to group students based on their ability on various subjects. Here you would have to incorporate both the grades as well as the selection of subjects. A simple (read dumb) solution would be to replace all missing entries for each student with their average ability. Or with the average ability for every student on that subject.
The idea is that when the student didn't take the class - your best guess that he is average at that class.
But you could possibly construct better metrics after some reflection. Just need to think about what the similarity should be between students when none of their classes overlap.
t-SNE and clustering
The examples above show some ways how one could construct a distance matrix between students. After that you can use that matrix for both t-SNE and clustering. | How to do dimension reduction with sparse data
This depends on the goal of clustering.
t-SNE as well as various clustering methods (like hierarchical clustering) can work on distance matrices. And it's your job to construct a distance measure that |
36,532 | How to do dimension reduction with sparse data | Singular value decomposition is a very common strategy for dimension reduction applied to sparse data types. This is because you can leverage specialized sparse SVD solvers (e.g. ARPACK), and for SVD the inputs do not have to be manipulated in any special way which could disrupt sparsity. | How to do dimension reduction with sparse data | Singular value decomposition is a very common strategy for dimension reduction applied to sparse data types. This is because you can leverage specialized sparse SVD solvers (e.g. ARPACK), and for SVD | How to do dimension reduction with sparse data
Singular value decomposition is a very common strategy for dimension reduction applied to sparse data types. This is because you can leverage specialized sparse SVD solvers (e.g. ARPACK), and for SVD the inputs do not have to be manipulated in any special way which could disrupt sparsity. | How to do dimension reduction with sparse data
Singular value decomposition is a very common strategy for dimension reduction applied to sparse data types. This is because you can leverage specialized sparse SVD solvers (e.g. ARPACK), and for SVD |
36,533 | Ms. A selects a number $X$ randomly from the uniform distribution on $[0, 1]$. Then Mr. B repeatedly, and independently, draws numbers | Although, you didn't include self-study tag, I first give you two hints and then full solution. You may stop reading after first or second hint and try youself.
Hint 1:
For $a \in (0,1)$ we have $$\sum_{m=0}^{\infty} ma^m = \frac{a}{(1-a)^2}$$
Hint 2:
Let $K$ be number of numbers drawn by Mr. B. And let your "target variable", $E(Y_1+\ldots+Y_K | X=x)$ be denoted by $Z$. Notice, this is a random variable, not a real number (since $K$ is a random variable). Then, by the law of total expectation, $E(Z) = E(E(Z|K))$.
Full solution:
$K$ follows, as you mentioned, geometric distribution with probability of success $p=1-\frac{x}{2}$. So
$$E(Z) = E(E(Z|K)) = \sum_{k=1}^{\infty} E(Z|K=k)P(K=k)$$
and $$P(K=k)=(1-p)^{k-1}p = \left(\frac x2\right)^{k-1}\left(1-\frac x2\right)$$.
Let's focus on $E(Z|K=k)$. It is now $E(Y_1+\ldots+Y_k | X=x, K=k)$. Notice lower case $k$ here!!! Since $Y$'s are independent this equals
$$E(Y_1 | X=x, K=k)+\ldots+E(Y_k | X=x, K=k)$$.
Conditioning on $X=x$ and $K=k$ means that $Y_1, \ldots, Y_{k-1}$ are drawn uniformly from $\left[0,\frac x2\right)$ and $Y_k$ is drawn uniformly from $\left(\frac x2, 1\right]$.
So $$E(Y_1 | X=x, K=k)=\ldots= E(Y_{k-1} | X=x, K=k) = \frac x4$$
and $$E(Y_k | X=x, K=k) = \frac{1+\frac x2}{2} = \frac{2+x}4$$
Putting all this together:
$$ E(Z|K=k) = (k-1)\frac x4 + \frac{2+x}4$$
And
$$E(Z) = \sum_{k=1}^{\infty} \left( (k-1)\frac x4 + \frac{2+x}4 \right) P(K=k) = \sum_{k=1}^{\infty} (k-1)\frac x4 P(K=k) + \sum_{k=1}^{\infty} \frac{2+x}4 P(K=k)$$
Second part is easy (last equality uses the fact that sum of probability mass function adds up to 1):
$$\sum_{k=1}^{\infty} \frac{2+x}4 P(K=k) = \frac{2+x}4\sum_{k=1}^{\infty} P(K=k)= \frac{2+x}4 $$
To get this, you can also use the fact, that Mr. B always draws one last number from $\left(\frac x2, 1\right]$, no matter what value of $K$ took.
First part is only a bit harder:
$$ \sum_{k=1}^{\infty} (k-1)\frac x4 P(K=k) = \sum_{k=1}^{\infty} (k-1)\frac x4 \left(\frac x2\right)^{k-1}\left(1-\frac x2\right)$$
Move everything that do not depend on $k$ in fornt of sum to get: $$ \frac x4 \left(1-\frac x2\right)\sum_{k=1}^{\infty} (k-1) \left(\frac x2\right)^{k-1}$$
Introduce $m=k-1$:
$$ \frac x4 \left(1-\frac x2\right)\sum_{m=0}^{\infty} m \left(\frac x2\right)^m$$
Use hint 1 with $a=\frac x2$:
$$ \frac x4 \left(1-\frac x2\right)\frac{\frac x2}{(1-\frac x2)^2}$$
To finally get
$$ \frac {x^2}{8(1-\frac x2)} =\frac {x^2}{8(\frac {2-x}2)} =\frac {x^2}{4(2-x)} $$
And add second part (the easy one):
$$ \frac {x^2}{4(2-x)} + \frac{2+x}4 = \frac {x^2}{4(2-x)} + \frac{(2+x)(2-x)}{4(2-x)} = \frac {x^2 + (4-x^2)}{4(2-x)} = \frac 4{4(2-x)} = \frac 1{2-x}$$
WHOAH!!!! | Ms. A selects a number $X$ randomly from the uniform distribution on $[0, 1]$. Then Mr. B repeatedly | Although, you didn't include self-study tag, I first give you two hints and then full solution. You may stop reading after first or second hint and try youself.
Hint 1:
For $a \in (0,1)$ we have $$\su | Ms. A selects a number $X$ randomly from the uniform distribution on $[0, 1]$. Then Mr. B repeatedly, and independently, draws numbers
Although, you didn't include self-study tag, I first give you two hints and then full solution. You may stop reading after first or second hint and try youself.
Hint 1:
For $a \in (0,1)$ we have $$\sum_{m=0}^{\infty} ma^m = \frac{a}{(1-a)^2}$$
Hint 2:
Let $K$ be number of numbers drawn by Mr. B. And let your "target variable", $E(Y_1+\ldots+Y_K | X=x)$ be denoted by $Z$. Notice, this is a random variable, not a real number (since $K$ is a random variable). Then, by the law of total expectation, $E(Z) = E(E(Z|K))$.
Full solution:
$K$ follows, as you mentioned, geometric distribution with probability of success $p=1-\frac{x}{2}$. So
$$E(Z) = E(E(Z|K)) = \sum_{k=1}^{\infty} E(Z|K=k)P(K=k)$$
and $$P(K=k)=(1-p)^{k-1}p = \left(\frac x2\right)^{k-1}\left(1-\frac x2\right)$$.
Let's focus on $E(Z|K=k)$. It is now $E(Y_1+\ldots+Y_k | X=x, K=k)$. Notice lower case $k$ here!!! Since $Y$'s are independent this equals
$$E(Y_1 | X=x, K=k)+\ldots+E(Y_k | X=x, K=k)$$.
Conditioning on $X=x$ and $K=k$ means that $Y_1, \ldots, Y_{k-1}$ are drawn uniformly from $\left[0,\frac x2\right)$ and $Y_k$ is drawn uniformly from $\left(\frac x2, 1\right]$.
So $$E(Y_1 | X=x, K=k)=\ldots= E(Y_{k-1} | X=x, K=k) = \frac x4$$
and $$E(Y_k | X=x, K=k) = \frac{1+\frac x2}{2} = \frac{2+x}4$$
Putting all this together:
$$ E(Z|K=k) = (k-1)\frac x4 + \frac{2+x}4$$
And
$$E(Z) = \sum_{k=1}^{\infty} \left( (k-1)\frac x4 + \frac{2+x}4 \right) P(K=k) = \sum_{k=1}^{\infty} (k-1)\frac x4 P(K=k) + \sum_{k=1}^{\infty} \frac{2+x}4 P(K=k)$$
Second part is easy (last equality uses the fact that sum of probability mass function adds up to 1):
$$\sum_{k=1}^{\infty} \frac{2+x}4 P(K=k) = \frac{2+x}4\sum_{k=1}^{\infty} P(K=k)= \frac{2+x}4 $$
To get this, you can also use the fact, that Mr. B always draws one last number from $\left(\frac x2, 1\right]$, no matter what value of $K$ took.
First part is only a bit harder:
$$ \sum_{k=1}^{\infty} (k-1)\frac x4 P(K=k) = \sum_{k=1}^{\infty} (k-1)\frac x4 \left(\frac x2\right)^{k-1}\left(1-\frac x2\right)$$
Move everything that do not depend on $k$ in fornt of sum to get: $$ \frac x4 \left(1-\frac x2\right)\sum_{k=1}^{\infty} (k-1) \left(\frac x2\right)^{k-1}$$
Introduce $m=k-1$:
$$ \frac x4 \left(1-\frac x2\right)\sum_{m=0}^{\infty} m \left(\frac x2\right)^m$$
Use hint 1 with $a=\frac x2$:
$$ \frac x4 \left(1-\frac x2\right)\frac{\frac x2}{(1-\frac x2)^2}$$
To finally get
$$ \frac {x^2}{8(1-\frac x2)} =\frac {x^2}{8(\frac {2-x}2)} =\frac {x^2}{4(2-x)} $$
And add second part (the easy one):
$$ \frac {x^2}{4(2-x)} + \frac{2+x}4 = \frac {x^2}{4(2-x)} + \frac{(2+x)(2-x)}{4(2-x)} = \frac {x^2 + (4-x^2)}{4(2-x)} = \frac 4{4(2-x)} = \frac 1{2-x}$$
WHOAH!!!! | Ms. A selects a number $X$ randomly from the uniform distribution on $[0, 1]$. Then Mr. B repeatedly
Although, you didn't include self-study tag, I first give you two hints and then full solution. You may stop reading after first or second hint and try youself.
Hint 1:
For $a \in (0,1)$ we have $$\su |
36,534 | Ms. A selects a number $X$ randomly from the uniform distribution on $[0, 1]$. Then Mr. B repeatedly, and independently, draws numbers | Another angle of solution (summing not with P(K=k) but P(K>=k)):
$$\begin{array}\\
E(\sum Y_k) = \sum E(Y_k) & = \sum_{k=1}^\infty E(Y_k|K>=k) \cdot P(K>=k) \\
& = \sum_{k=0}^\infty \frac{1}{2} \cdot \left(\frac{x}{2} \right)^k \\
& = \frac{1}{2-x}
\end{array}$$ | Ms. A selects a number $X$ randomly from the uniform distribution on $[0, 1]$. Then Mr. B repeatedly | Another angle of solution (summing not with P(K=k) but P(K>=k)):
$$\begin{array}\\
E(\sum Y_k) = \sum E(Y_k) & = \sum_{k=1}^\infty E(Y_k|K>=k) \cdot P(K>=k) \\
& = \sum_{k=0}^\infty \frac{1}{2} \c | Ms. A selects a number $X$ randomly from the uniform distribution on $[0, 1]$. Then Mr. B repeatedly, and independently, draws numbers
Another angle of solution (summing not with P(K=k) but P(K>=k)):
$$\begin{array}\\
E(\sum Y_k) = \sum E(Y_k) & = \sum_{k=1}^\infty E(Y_k|K>=k) \cdot P(K>=k) \\
& = \sum_{k=0}^\infty \frac{1}{2} \cdot \left(\frac{x}{2} \right)^k \\
& = \frac{1}{2-x}
\end{array}$$ | Ms. A selects a number $X$ randomly from the uniform distribution on $[0, 1]$. Then Mr. B repeatedly
Another angle of solution (summing not with P(K=k) but P(K>=k)):
$$\begin{array}\\
E(\sum Y_k) = \sum E(Y_k) & = \sum_{k=1}^\infty E(Y_k|K>=k) \cdot P(K>=k) \\
& = \sum_{k=0}^\infty \frac{1}{2} \c |
36,535 | Alternate (?) definition of sample variance [duplicate] | Using symmetry, your double sum can be written as
$$
s^2 = \text{ave}_{i < j} f(x_i, x_j)
$$
with $f(x, y) := \frac{1}{2} (x - y)^2$ and as such is a U-statistic of degree 2 with kernel $f$ for the estimation of the parameter $\theta = E(f(X, Y)) = \ldots = \text{Var}(X)$, $X$, $Y$ iid. It is actually one of the most prominent, non-trivial examples of a U-statistic and shines accordingly in theoretical math stats classes.
Being a U-statistic is nice because e.g.
a U-statistic is automatically "optimal" in the sense of being U-nbiased with minimum variance (bye-bye Rao-Blackwell theorem) and
there is a (more or less explicit) formula for its variance and thus its standard error.
Nevertheless, this alternative representation of the sample variance $s^2$ is rarely used in practice although, as you mentioned, it seems to highlight a different aspect of variation ("typical squared difference between two random picks" instead of "typical squared difference between random pick and mean").
The U-statistics representation of $s^2$ always reminds me of Gini impurity used in decision tree learning where that often plays the role of variance for categorical responses. For a discrete random variable $Z$ with levels $z_1, \dots, z_m$ and $\text{Pr}(Z = z_j) = p_j$, it is defined as
$$
I(Z) = 1 - \sum_{j = 1}^m p_i^2 = \sum_{i}\sum_{j \ne i} p_i p_j,
$$
and as such is the probability of two random picks not being equal (again something like a typical difference between two random picks). | Alternate (?) definition of sample variance [duplicate] | Using symmetry, your double sum can be written as
$$
s^2 = \text{ave}_{i < j} f(x_i, x_j)
$$
with $f(x, y) := \frac{1}{2} (x - y)^2$ and as such is a U-statistic of degree 2 with kernel $f$ for the | Alternate (?) definition of sample variance [duplicate]
Using symmetry, your double sum can be written as
$$
s^2 = \text{ave}_{i < j} f(x_i, x_j)
$$
with $f(x, y) := \frac{1}{2} (x - y)^2$ and as such is a U-statistic of degree 2 with kernel $f$ for the estimation of the parameter $\theta = E(f(X, Y)) = \ldots = \text{Var}(X)$, $X$, $Y$ iid. It is actually one of the most prominent, non-trivial examples of a U-statistic and shines accordingly in theoretical math stats classes.
Being a U-statistic is nice because e.g.
a U-statistic is automatically "optimal" in the sense of being U-nbiased with minimum variance (bye-bye Rao-Blackwell theorem) and
there is a (more or less explicit) formula for its variance and thus its standard error.
Nevertheless, this alternative representation of the sample variance $s^2$ is rarely used in practice although, as you mentioned, it seems to highlight a different aspect of variation ("typical squared difference between two random picks" instead of "typical squared difference between random pick and mean").
The U-statistics representation of $s^2$ always reminds me of Gini impurity used in decision tree learning where that often plays the role of variance for categorical responses. For a discrete random variable $Z$ with levels $z_1, \dots, z_m$ and $\text{Pr}(Z = z_j) = p_j$, it is defined as
$$
I(Z) = 1 - \sum_{j = 1}^m p_i^2 = \sum_{i}\sum_{j \ne i} p_i p_j,
$$
and as such is the probability of two random picks not being equal (again something like a typical difference between two random picks). | Alternate (?) definition of sample variance [duplicate]
Using symmetry, your double sum can be written as
$$
s^2 = \text{ave}_{i < j} f(x_i, x_j)
$$
with $f(x, y) := \frac{1}{2} (x - y)^2$ and as such is a U-statistic of degree 2 with kernel $f$ for the |
36,536 | What is the difference between using random intercepts and slopes instead of separate regressions per subject? | There are two major differences, related to each other.
Running separate regressions for each subject takes up many more degrees of freedom, since you have an intercept and slope to estimate for every subject.
Mixed models make use of partial pooling; random effects are shrunk towards the mean. This basically means that the data from other subjects informs your best estimate of the parameters for any particular subject. If you fit your regressions separately (or via fixed effects for each subject), you will likely get more extreme values than if you make use of random effects. Note that the utility of this approach relies on the assumption that the random effects are drawn from a normal distribution, though I believe that it is robust to deviations from it. This is generally a reasonable assumption, but it could be useful to consider whether it is likely to be true in your case. If you have good reasonable to believe a different distribution would be better for your case, you could specify this in a Bayesian hierarchical model instead of a standard mixed model. | What is the difference between using random intercepts and slopes instead of separate regressions pe | There are two major differences, related to each other.
Running separate regressions for each subject takes up many more degrees of freedom, since you have an intercept and slope to estimate for ever | What is the difference between using random intercepts and slopes instead of separate regressions per subject?
There are two major differences, related to each other.
Running separate regressions for each subject takes up many more degrees of freedom, since you have an intercept and slope to estimate for every subject.
Mixed models make use of partial pooling; random effects are shrunk towards the mean. This basically means that the data from other subjects informs your best estimate of the parameters for any particular subject. If you fit your regressions separately (or via fixed effects for each subject), you will likely get more extreme values than if you make use of random effects. Note that the utility of this approach relies on the assumption that the random effects are drawn from a normal distribution, though I believe that it is robust to deviations from it. This is generally a reasonable assumption, but it could be useful to consider whether it is likely to be true in your case. If you have good reasonable to believe a different distribution would be better for your case, you could specify this in a Bayesian hierarchical model instead of a standard mixed model. | What is the difference between using random intercepts and slopes instead of separate regressions pe
There are two major differences, related to each other.
Running separate regressions for each subject takes up many more degrees of freedom, since you have an intercept and slope to estimate for ever |
36,537 | Using $R^2$ to evaluate out-of-sample performance | The coefficient of determination, $R^2$, value can be calculated as
$$R^2 = 1 - SS_{res}/SS_{tot}$$ where the total sum of squares is
$$SS_{tot} = \sum_{i}(y_i - \bar{y})^2$$
and the residual sum of squares is
$$SS_{res} = \sum_{i}(y_i-\hat{y_i})^2 = \sum_{i}e_i^2$$
To apply the above equations to out-of-sample predictions you could use $y_i$ and mean $\bar{y}$ from your test data. This seems like the most obvious way of calculating out-of-sample $R^2$.
If the model prediction is better than simply assuming a constant fit equal to the mean, then the $R^2$ will be greater than zero. As $SS_{res}$ goes to zero, the $R^2$ would approach one. Not that mean squared prediction error (MSPE) would also go to zero as $SS_{res}$ goes to zero. Therefore, if there is low MSPE we would expect high values of $R^2$. The $R^2$ value can also be interpreted as one minus the ratio of MSPE to variance.
$$ R^2 = 1 - MSPE/Var(y) = 1 - \frac{\frac{1}{N}\sum_{i}(y_i-\hat{y_i})^2}{\frac{1}{N}\sum_{i}(y_i-\bar{y})^2} $$
One of the main criticisms of $R^2$, that would apply to out-of-sample as well, is that if the data is very noisy the $R^2$ may be low even if the model fits the data well. Also, the $R^2$ could be high even if the functional form of the model is different than that of process that generated the data (e.g., a linear fit to a quadratic function). | Using $R^2$ to evaluate out-of-sample performance | The coefficient of determination, $R^2$, value can be calculated as
$$R^2 = 1 - SS_{res}/SS_{tot}$$ where the total sum of squares is
$$SS_{tot} = \sum_{i}(y_i - \bar{y})^2$$
and the residual sum of | Using $R^2$ to evaluate out-of-sample performance
The coefficient of determination, $R^2$, value can be calculated as
$$R^2 = 1 - SS_{res}/SS_{tot}$$ where the total sum of squares is
$$SS_{tot} = \sum_{i}(y_i - \bar{y})^2$$
and the residual sum of squares is
$$SS_{res} = \sum_{i}(y_i-\hat{y_i})^2 = \sum_{i}e_i^2$$
To apply the above equations to out-of-sample predictions you could use $y_i$ and mean $\bar{y}$ from your test data. This seems like the most obvious way of calculating out-of-sample $R^2$.
If the model prediction is better than simply assuming a constant fit equal to the mean, then the $R^2$ will be greater than zero. As $SS_{res}$ goes to zero, the $R^2$ would approach one. Not that mean squared prediction error (MSPE) would also go to zero as $SS_{res}$ goes to zero. Therefore, if there is low MSPE we would expect high values of $R^2$. The $R^2$ value can also be interpreted as one minus the ratio of MSPE to variance.
$$ R^2 = 1 - MSPE/Var(y) = 1 - \frac{\frac{1}{N}\sum_{i}(y_i-\hat{y_i})^2}{\frac{1}{N}\sum_{i}(y_i-\bar{y})^2} $$
One of the main criticisms of $R^2$, that would apply to out-of-sample as well, is that if the data is very noisy the $R^2$ may be low even if the model fits the data well. Also, the $R^2$ could be high even if the functional form of the model is different than that of process that generated the data (e.g., a linear fit to a quadratic function). | Using $R^2$ to evaluate out-of-sample performance
The coefficient of determination, $R^2$, value can be calculated as
$$R^2 = 1 - SS_{res}/SS_{tot}$$ where the total sum of squares is
$$SS_{tot} = \sum_{i}(y_i - \bar{y})^2$$
and the residual sum of |
36,538 | Clarification on how to perform nested cross-validation | I gave a general answer to this question, and here is what applies to your question:
Train and Validation Split:
First split the input into train and validation; but I'd also take the domain knowledge into account. In your case, I would take that year parameter into account and take the last few years of the data (not sure how many years your have, let say 2 out of 10, if you have 10) and assume that portion of the data as your validation set.
Nested Cross Validation and Parameter Search:
Now you can do what you explain in your diagram. Assume you have a method, which takes the input data, and the parameters (e.g. a parameter defining to use a GAM with a poisson family or a GAM with a negative binomial), and fit the corresponding model on the data. Let's call the set of all these parameters you're considering, a parameter grid.
Now for each of those outer folds, you do a whole grid search using the inner folds, to get a score for each parameter set. Then train your model using that best parameter set on the whole data given to you in the inner loop, and get its performance on the test portion of the outer loop.
Assume your parameter grid has 3 values in total (e.g. a GAM with a poisson family or a GAM with a negative binomial, and a [not regularized] linear model), and there's no other parameter involved. Then you'd do these many trainings:
$5 [\text{outer loop}] \times \left(3[\text{parameter grid}] \times 4[\text{inner loop}] + 1[\text{best parameters}]\right)$
Talking in code, here's how it'd look like:
parameter_grid = {'param1: ['binomial', 'poisson'],
'smoothing': ['yes', 'no']}
scores = []
for train, test in outer_folds:
model = GridSearchCV(estimator=my_custom_model,
param_grid=parameter_grid,
refit=True,
cv=4)
model.fit(train.X, train.y)
scores.append(model.score(test.X, test.y))
score = mean(scores)
For simplicity, I'm diverging from the actual API, so the above code is more like a psuedocode, but it gives you the idea.
This gives you an idea about how your parameter grid would perform on your data. Then you may think you'd like to add a regularization parameter to your linear model, or exclude one of your GAMs, etc. You do all the manipulations on your parameter set at this stage.
Final Evaluation:
Once you're done finding a parameter grid you're comfortable with, you'd then apply that on your whole train data. You can do a grid search on your whole train data with a normal 5 fold cross validation WITHOUT manipulating your parameter grid to find the pest parameter set, train a model with those parameters on your whole train data, and then get its performance on your validation set. That result would be your final performance and if you want your results to be as valid as thy can be, you should not go back to optimize any parameters at this point.
To clarify the parameter search at this stage, I'm getting help from scikit-learn API in Python:
parameter_grid = {'param1: ['binomial', 'poisson'],
'smoothing': ['yes', 'no']}
model = GridSearchCV(estimator=my_custom_model,
param_grid=parameter_grid,
refit=True,
cv=5)
model.fit(X_train, y_train)
model.score(X_validation, y_validation)
The above code does (model.fit(...)) a 5 fold cross validation (cv=5) on your training data, fits the best model on the whole data (refit=True), and finally gives your the score on the validation set (model.score(...)).
Deciding on what to out in your parameter_grid in this stage is what you do in the previous stage. You can include/exclude all the parameters you mention in there and experiment and evaluate. Once you're certain about your choice of parameter grid, then you move on to the validation stage. | Clarification on how to perform nested cross-validation | I gave a general answer to this question, and here is what applies to your question:
Train and Validation Split:
First split the input into train and validation; but I'd also take the domain knowledge | Clarification on how to perform nested cross-validation
I gave a general answer to this question, and here is what applies to your question:
Train and Validation Split:
First split the input into train and validation; but I'd also take the domain knowledge into account. In your case, I would take that year parameter into account and take the last few years of the data (not sure how many years your have, let say 2 out of 10, if you have 10) and assume that portion of the data as your validation set.
Nested Cross Validation and Parameter Search:
Now you can do what you explain in your diagram. Assume you have a method, which takes the input data, and the parameters (e.g. a parameter defining to use a GAM with a poisson family or a GAM with a negative binomial), and fit the corresponding model on the data. Let's call the set of all these parameters you're considering, a parameter grid.
Now for each of those outer folds, you do a whole grid search using the inner folds, to get a score for each parameter set. Then train your model using that best parameter set on the whole data given to you in the inner loop, and get its performance on the test portion of the outer loop.
Assume your parameter grid has 3 values in total (e.g. a GAM with a poisson family or a GAM with a negative binomial, and a [not regularized] linear model), and there's no other parameter involved. Then you'd do these many trainings:
$5 [\text{outer loop}] \times \left(3[\text{parameter grid}] \times 4[\text{inner loop}] + 1[\text{best parameters}]\right)$
Talking in code, here's how it'd look like:
parameter_grid = {'param1: ['binomial', 'poisson'],
'smoothing': ['yes', 'no']}
scores = []
for train, test in outer_folds:
model = GridSearchCV(estimator=my_custom_model,
param_grid=parameter_grid,
refit=True,
cv=4)
model.fit(train.X, train.y)
scores.append(model.score(test.X, test.y))
score = mean(scores)
For simplicity, I'm diverging from the actual API, so the above code is more like a psuedocode, but it gives you the idea.
This gives you an idea about how your parameter grid would perform on your data. Then you may think you'd like to add a regularization parameter to your linear model, or exclude one of your GAMs, etc. You do all the manipulations on your parameter set at this stage.
Final Evaluation:
Once you're done finding a parameter grid you're comfortable with, you'd then apply that on your whole train data. You can do a grid search on your whole train data with a normal 5 fold cross validation WITHOUT manipulating your parameter grid to find the pest parameter set, train a model with those parameters on your whole train data, and then get its performance on your validation set. That result would be your final performance and if you want your results to be as valid as thy can be, you should not go back to optimize any parameters at this point.
To clarify the parameter search at this stage, I'm getting help from scikit-learn API in Python:
parameter_grid = {'param1: ['binomial', 'poisson'],
'smoothing': ['yes', 'no']}
model = GridSearchCV(estimator=my_custom_model,
param_grid=parameter_grid,
refit=True,
cv=5)
model.fit(X_train, y_train)
model.score(X_validation, y_validation)
The above code does (model.fit(...)) a 5 fold cross validation (cv=5) on your training data, fits the best model on the whole data (refit=True), and finally gives your the score on the validation set (model.score(...)).
Deciding on what to out in your parameter_grid in this stage is what you do in the previous stage. You can include/exclude all the parameters you mention in there and experiment and evaluate. Once you're certain about your choice of parameter grid, then you move on to the validation stage. | Clarification on how to perform nested cross-validation
I gave a general answer to this question, and here is what applies to your question:
Train and Validation Split:
First split the input into train and validation; but I'd also take the domain knowledge |
36,539 | Clarification on how to perform nested cross-validation | What are you wanting to achieve by selecting knots? As a means of determining the complexity of the smooth terms in the model?
Generally there's not much to be gained from choosing knots in modern GAM theory; thin plate splines for example are the default in mgcv and have a knot at each unique data location (the subsequent basis is then eigen decomposed to give a lower rank approximation), and smoothness selection via ML or REML strategies typically works well enough to avoid over fitting. If not using thin plate splines, just spread the $k-1$ cubic regression spline knots evenly over the data interval or at $k-1$ evenly spaced quantiles of the data. If you are using other bases, such a p splines, it may not even make sense to choose knot locations beyond evenly spacing them over the interval of the data.
The key user choice is to select a sufficiently large basis dimension for each smooth, but there are tools to test for that. The penalty on wiggliness typically does the rest assuming the initial basis expansion is sufficient large/rich enough to either include the true function or a close approximation to it.
The GLM is a special case of the GAM where all terms are perfectly smooth (linear). Hence you could fit the GAM with smoothness selection and if linear effects are appropriate the smoothness penalty should become large (greater penalty on wiggliness). Alternatively, you could formulate the GAM as follows
gam(y ~ x + s(x, bs = "tp", m = c(2, 0)))
where the smooth term is specifically testing for a smooth effect of x in addition to the linear effect already included.
As for choosing the family, model diagnostics could motivate this also, as can the estimate for the parameter informing the extra variation of the Negative binomial over the Poisson distribution.
For the random effect, yuo can fit this as a random effect smoother in gam() or bam() via bs = "re" and then use the summary() output to decide if this smooth is required — the test there has good properties for random effect terms. I also believe AIC as implemented in recent mgcv versions is suitable for use with simple random effect terms such as this.
Interactions can be tested using inference via a ANOVA-like decomposition into "main effects" and "interaction" via ti() terms:
y ~ ti(x) + ti(z) + ti(x, z)
where one would focus on the ti(x, z) to determine whether the interaction was required or not.
As for the factor-smooth question; fit both models using all the data (one with and one without that factor-level smooth) and compare the model fits via AIC and the Wald-like tests reported in the summary() output.
My general point here is that it may be better when fitting GAMs, which learn from the data, to use all the data to inform the estimates of the smooths. Then use statistical inference to decide which terms are needed.
Or just fit the most complex model and include extra penalties (via select = TRUE with method = "REML" or method = "ML") to do the selection for you. | Clarification on how to perform nested cross-validation | What are you wanting to achieve by selecting knots? As a means of determining the complexity of the smooth terms in the model?
Generally there's not much to be gained from choosing knots in modern GAM | Clarification on how to perform nested cross-validation
What are you wanting to achieve by selecting knots? As a means of determining the complexity of the smooth terms in the model?
Generally there's not much to be gained from choosing knots in modern GAM theory; thin plate splines for example are the default in mgcv and have a knot at each unique data location (the subsequent basis is then eigen decomposed to give a lower rank approximation), and smoothness selection via ML or REML strategies typically works well enough to avoid over fitting. If not using thin plate splines, just spread the $k-1$ cubic regression spline knots evenly over the data interval or at $k-1$ evenly spaced quantiles of the data. If you are using other bases, such a p splines, it may not even make sense to choose knot locations beyond evenly spacing them over the interval of the data.
The key user choice is to select a sufficiently large basis dimension for each smooth, but there are tools to test for that. The penalty on wiggliness typically does the rest assuming the initial basis expansion is sufficient large/rich enough to either include the true function or a close approximation to it.
The GLM is a special case of the GAM where all terms are perfectly smooth (linear). Hence you could fit the GAM with smoothness selection and if linear effects are appropriate the smoothness penalty should become large (greater penalty on wiggliness). Alternatively, you could formulate the GAM as follows
gam(y ~ x + s(x, bs = "tp", m = c(2, 0)))
where the smooth term is specifically testing for a smooth effect of x in addition to the linear effect already included.
As for choosing the family, model diagnostics could motivate this also, as can the estimate for the parameter informing the extra variation of the Negative binomial over the Poisson distribution.
For the random effect, yuo can fit this as a random effect smoother in gam() or bam() via bs = "re" and then use the summary() output to decide if this smooth is required — the test there has good properties for random effect terms. I also believe AIC as implemented in recent mgcv versions is suitable for use with simple random effect terms such as this.
Interactions can be tested using inference via a ANOVA-like decomposition into "main effects" and "interaction" via ti() terms:
y ~ ti(x) + ti(z) + ti(x, z)
where one would focus on the ti(x, z) to determine whether the interaction was required or not.
As for the factor-smooth question; fit both models using all the data (one with and one without that factor-level smooth) and compare the model fits via AIC and the Wald-like tests reported in the summary() output.
My general point here is that it may be better when fitting GAMs, which learn from the data, to use all the data to inform the estimates of the smooths. Then use statistical inference to decide which terms are needed.
Or just fit the most complex model and include extra penalties (via select = TRUE with method = "REML" or method = "ML") to do the selection for you. | Clarification on how to perform nested cross-validation
What are you wanting to achieve by selecting knots? As a means of determining the complexity of the smooth terms in the model?
Generally there's not much to be gained from choosing knots in modern GAM |
36,540 | Clarification on how to perform nested cross-validation | Let me add some points complementing the adready exisiting good answers:
About the nested cross validation I've come for myself to a description that I find makes it easy to get the calculations right while (by) not describing the situation as nested at all.
The basic idea is that I need two things: a way of training my model as function of my data that takes care of all autotuning/selection/hyperparameter optimization train_tuned_model (training_data) and a validation/verification of the model obtained by train_tuned_model (training_data). The latter may be done by a simple straightforward cross validation. And internally, train_tuned_model (training_data) may use another out-of-bootstrap or cross validation or whatever heuristic I deem suitable.
This way, I still get the correct calculations the same way I get them with nested cross validation, but conceptually, I can describe the whole thing by easier and commonly available building blocks. Incidentally, this also answers the question, whether the final model trained from the whole data set should use the optimized hyperparameter set found inside the nested cross validation or whether hyperparameters should be optimized again (my answer: yes).
Regarding whether you do:
a) outer CV loop - hyperparameter loop - inner CV loop or
b) outer CV loop - inner CV loop - hyperparameter loop:
Both are sensible. b) is a paired design and a) is its unpaired analogon. So as the paired design is possible, this may give a little bit more power to your optimization.
One point that has not yet been mentioned: the success of the cross validations (both of them) depends crucially on your splits generating independent subsets of your data. Your data has a much more complicated structure than a simple "rows are [assumed to be] independent". And you know a lot about this structure. Do take this structure into account:
"calendar year. Do I need special care when shuffling the data?" As always: this depends.
There are data/models where year is de facto a random factor (This year's harvest data doesn't help at all predicting next year's harvest, and the model will be used for unknown future years). In that case, you need to make sure that test years are independent of training years.
Other data/models may be longitudinal in nature (i.e. knowing the last years helps predicting the next year(s)) and the production use scenario always has the last $n$ years available. In this case you need to split so that training is always the last n years before test year. (Same principle may needed for spatial data)
With calender year I'm running out of fantasy formulating a scenario where year is a normal fixed factor. Maybe an approximation would be that you find that it is best to recognise whether the year was cold-wet, wet-hot or dry-hot. You do not need to take any special precaution for fixed factors.
In general, splitting needs to make sure random factor levels in test data do not occur in the training data.
Fixed factors to not need special care in the splitting,
but you need to be careful and make sure the factor is really fixed wrt. your prediction scenario. Fixed factors in data collection may be random factors in prediction scenarios (see above).
Factors can be quite deeply nested: in that case, correct splitting at the uppermost random factor will automatically lead to correct splitting for the lower levels.
If random factors are crossed, splitting into independent levels for training and testing implies that some data is excluded from both training and testing for this split. | Clarification on how to perform nested cross-validation | Let me add some points complementing the adready exisiting good answers:
About the nested cross validation I've come for myself to a description that I find makes it easy to get the calculations righ | Clarification on how to perform nested cross-validation
Let me add some points complementing the adready exisiting good answers:
About the nested cross validation I've come for myself to a description that I find makes it easy to get the calculations right while (by) not describing the situation as nested at all.
The basic idea is that I need two things: a way of training my model as function of my data that takes care of all autotuning/selection/hyperparameter optimization train_tuned_model (training_data) and a validation/verification of the model obtained by train_tuned_model (training_data). The latter may be done by a simple straightforward cross validation. And internally, train_tuned_model (training_data) may use another out-of-bootstrap or cross validation or whatever heuristic I deem suitable.
This way, I still get the correct calculations the same way I get them with nested cross validation, but conceptually, I can describe the whole thing by easier and commonly available building blocks. Incidentally, this also answers the question, whether the final model trained from the whole data set should use the optimized hyperparameter set found inside the nested cross validation or whether hyperparameters should be optimized again (my answer: yes).
Regarding whether you do:
a) outer CV loop - hyperparameter loop - inner CV loop or
b) outer CV loop - inner CV loop - hyperparameter loop:
Both are sensible. b) is a paired design and a) is its unpaired analogon. So as the paired design is possible, this may give a little bit more power to your optimization.
One point that has not yet been mentioned: the success of the cross validations (both of them) depends crucially on your splits generating independent subsets of your data. Your data has a much more complicated structure than a simple "rows are [assumed to be] independent". And you know a lot about this structure. Do take this structure into account:
"calendar year. Do I need special care when shuffling the data?" As always: this depends.
There are data/models where year is de facto a random factor (This year's harvest data doesn't help at all predicting next year's harvest, and the model will be used for unknown future years). In that case, you need to make sure that test years are independent of training years.
Other data/models may be longitudinal in nature (i.e. knowing the last years helps predicting the next year(s)) and the production use scenario always has the last $n$ years available. In this case you need to split so that training is always the last n years before test year. (Same principle may needed for spatial data)
With calender year I'm running out of fantasy formulating a scenario where year is a normal fixed factor. Maybe an approximation would be that you find that it is best to recognise whether the year was cold-wet, wet-hot or dry-hot. You do not need to take any special precaution for fixed factors.
In general, splitting needs to make sure random factor levels in test data do not occur in the training data.
Fixed factors to not need special care in the splitting,
but you need to be careful and make sure the factor is really fixed wrt. your prediction scenario. Fixed factors in data collection may be random factors in prediction scenarios (see above).
Factors can be quite deeply nested: in that case, correct splitting at the uppermost random factor will automatically lead to correct splitting for the lower levels.
If random factors are crossed, splitting into independent levels for training and testing implies that some data is excluded from both training and testing for this split. | Clarification on how to perform nested cross-validation
Let me add some points complementing the adready exisiting good answers:
About the nested cross validation I've come for myself to a description that I find makes it easy to get the calculations righ |
36,541 | Is there a version of the Mahalanobis distance for matrices? | No. There are metrics that try to build on a similar concept using Wishart distribution. I have seen papers in MRI imaging that use the metrics. See p.16 in this slide deck: https://earth.esa.int/c/document_library/get_file?folderId=409343&name=DLFE-5593.pdf
There's a distance called Riemannian metric for positive definite matrices, that I used in the past to measure the distance of covariance matrices. For instance, look at Eq.13 here: https://hal.archives-ouvertes.fr/hal-00820475/document "Classification of covariance matrices using a Riemannian-based kernel for BCI applications", Alexandre Barachant, Stéphane Bonnet, Marco Congedo, Christian Jutten. I just grabbed the first link in Google, this is not the reference paper on the subject | Is there a version of the Mahalanobis distance for matrices? | No. There are metrics that try to build on a similar concept using Wishart distribution. I have seen papers in MRI imaging that use the metrics. See p.16 in this slide deck: https://earth.esa.int/c/do | Is there a version of the Mahalanobis distance for matrices?
No. There are metrics that try to build on a similar concept using Wishart distribution. I have seen papers in MRI imaging that use the metrics. See p.16 in this slide deck: https://earth.esa.int/c/document_library/get_file?folderId=409343&name=DLFE-5593.pdf
There's a distance called Riemannian metric for positive definite matrices, that I used in the past to measure the distance of covariance matrices. For instance, look at Eq.13 here: https://hal.archives-ouvertes.fr/hal-00820475/document "Classification of covariance matrices using a Riemannian-based kernel for BCI applications", Alexandre Barachant, Stéphane Bonnet, Marco Congedo, Christian Jutten. I just grabbed the first link in Google, this is not the reference paper on the subject | Is there a version of the Mahalanobis distance for matrices?
No. There are metrics that try to build on a similar concept using Wishart distribution. I have seen papers in MRI imaging that use the metrics. See p.16 in this slide deck: https://earth.esa.int/c/do |
36,542 | Is there a version of the Mahalanobis distance for matrices? | I'm working on a computer vision problem and I want to use the Mahalanobis distance to cluster image patches (2D matrices having the same dimensions). I haven't been able to find any generalisation up to this point and would prefer not to vectorise my patches and end-up with a huge covariance matrix.
If your "image patches" are what I think they are (i.e. 2D arrays of samples), then mathematically they are vectors, not matrices.
In linear algebra, a vector represents a position or a distance in multidimensional space, such as an array of samples, while a matrix represents a linear map from one vector space to another (or possibly the same one). The fact that vectors are commonly written as one-dimensional arrays, and matrices as two-dimensional arrays, is really more of an arbitrary historical convention.
It's not completely arbitrary, since a vector does of course need to be at least one-dimensional, while a matrix, being essentially a vector of vectors, is naturally represented as an array with twice as many dimensions as a vector. But there are plenty of situations, such as when working with 2D image data, where one does end up with vectors that would be most naturally represented as 2D arrays (implying that matrices mapping such "2D vectors" to other "2D vectors" really should be four-dimensional arrays).
The standard way of handling such situations is to flatten the "2D vectors" into ordinary one-dimensional vectors, and any matrices applied to them into two-dimensional block matrices, and then work with them using ordinary linear algebra. This does tend to yield large and awkward-looking expressions if you try to print them out without first transforming them back into a form better suited for the structure of your data, but that's kind of unavoidable when working with such data.
In any case, the question you should ask yourself is whether your 2D "image patches" somehow represent linear transformations between one-dimensional vectors. If not, then they're not matrices, and any attempt to treat them as matrices will probably end up producing nonsense. Instead, you should treat them as what they are, i.e. presumably as vectors of samples.
And yes, if your patches are large, then covariance matrices (which really are matrices in the linear algebra sense!) between them will probably end up being huge and hard to visualize. Which isn't really that surprising, given that they're fundamentally representing a four-dimensional data set, and humans aren't very good at visualizing 4D data. | Is there a version of the Mahalanobis distance for matrices? | I'm working on a computer vision problem and I want to use the Mahalanobis distance to cluster image patches (2D matrices having the same dimensions). I haven't been able to find any generalisation up | Is there a version of the Mahalanobis distance for matrices?
I'm working on a computer vision problem and I want to use the Mahalanobis distance to cluster image patches (2D matrices having the same dimensions). I haven't been able to find any generalisation up to this point and would prefer not to vectorise my patches and end-up with a huge covariance matrix.
If your "image patches" are what I think they are (i.e. 2D arrays of samples), then mathematically they are vectors, not matrices.
In linear algebra, a vector represents a position or a distance in multidimensional space, such as an array of samples, while a matrix represents a linear map from one vector space to another (or possibly the same one). The fact that vectors are commonly written as one-dimensional arrays, and matrices as two-dimensional arrays, is really more of an arbitrary historical convention.
It's not completely arbitrary, since a vector does of course need to be at least one-dimensional, while a matrix, being essentially a vector of vectors, is naturally represented as an array with twice as many dimensions as a vector. But there are plenty of situations, such as when working with 2D image data, where one does end up with vectors that would be most naturally represented as 2D arrays (implying that matrices mapping such "2D vectors" to other "2D vectors" really should be four-dimensional arrays).
The standard way of handling such situations is to flatten the "2D vectors" into ordinary one-dimensional vectors, and any matrices applied to them into two-dimensional block matrices, and then work with them using ordinary linear algebra. This does tend to yield large and awkward-looking expressions if you try to print them out without first transforming them back into a form better suited for the structure of your data, but that's kind of unavoidable when working with such data.
In any case, the question you should ask yourself is whether your 2D "image patches" somehow represent linear transformations between one-dimensional vectors. If not, then they're not matrices, and any attempt to treat them as matrices will probably end up producing nonsense. Instead, you should treat them as what they are, i.e. presumably as vectors of samples.
And yes, if your patches are large, then covariance matrices (which really are matrices in the linear algebra sense!) between them will probably end up being huge and hard to visualize. Which isn't really that surprising, given that they're fundamentally representing a four-dimensional data set, and humans aren't very good at visualizing 4D data. | Is there a version of the Mahalanobis distance for matrices?
I'm working on a computer vision problem and I want to use the Mahalanobis distance to cluster image patches (2D matrices having the same dimensions). I haven't been able to find any generalisation up |
36,543 | Metropolis-Within-Gibbs sampling with only marginal distribution known for a subset of variables | In an ideal world, sampling from $p_1(x_1)$ and then from $p_{1|2}(x_2|x_1)$ is a correct way to simulate from the joint. In case one of these distributions is unavailable, simulating a single step of Metropolis-Within-Gibbs targeting $p_{1|2}(\cdot|x_1^{(t-1)})$ and a single step of Metropolis-Within-Gibbs targeting $p_{2|1}(\cdot|x_2^{(t)})$ is correct. Note that since $p_1(\cdot)$ is available, the MCMC chain starts at stationarity. Note also that, if $p_1(\cdot)$ is available and $p_{2|1}(\cdot|x_1^{(t-1)})$ is available, then (a) $p_{1|2}(\cdot|x_2^{(t)})$ is available up to a constant and (b) $p_1(\cdot)$ can be used as a proposal in the Metropolis-Within-Gibbs step.
In the event where $p_1(\cdot)$ is not available but generational [simulations can be produced from $p_1(\cdot)$] and $p_{1|2}(\cdot|x_1^{(t-1)})$ is available, then making Metropolis proposals $x_1'$ from $p_1(\cdot)$ and accepting these with Metropolis acceptance rate
$$\dfrac{p_{1|2}(x_1'|x_2^{(t)})}{p_{1|2}(x_1^{(t-1)}|x_2^{(t)})}
\dfrac{p_{1}(x_1^{(t-1)})}{p_{1}(x_1')}=\dfrac{p_{2|1}(x_2^{(t)}|x_1')}{p_{2|1}(x_2^{(t)}|x_1^{(t-1)})}$$
can be implemented. | Metropolis-Within-Gibbs sampling with only marginal distribution known for a subset of variables | In an ideal world, sampling from $p_1(x_1)$ and then from $p_{1|2}(x_2|x_1)$ is a correct way to simulate from the joint. In case one of these distributions is unavailable, simulating a single step of | Metropolis-Within-Gibbs sampling with only marginal distribution known for a subset of variables
In an ideal world, sampling from $p_1(x_1)$ and then from $p_{1|2}(x_2|x_1)$ is a correct way to simulate from the joint. In case one of these distributions is unavailable, simulating a single step of Metropolis-Within-Gibbs targeting $p_{1|2}(\cdot|x_1^{(t-1)})$ and a single step of Metropolis-Within-Gibbs targeting $p_{2|1}(\cdot|x_2^{(t)})$ is correct. Note that since $p_1(\cdot)$ is available, the MCMC chain starts at stationarity. Note also that, if $p_1(\cdot)$ is available and $p_{2|1}(\cdot|x_1^{(t-1)})$ is available, then (a) $p_{1|2}(\cdot|x_2^{(t)})$ is available up to a constant and (b) $p_1(\cdot)$ can be used as a proposal in the Metropolis-Within-Gibbs step.
In the event where $p_1(\cdot)$ is not available but generational [simulations can be produced from $p_1(\cdot)$] and $p_{1|2}(\cdot|x_1^{(t-1)})$ is available, then making Metropolis proposals $x_1'$ from $p_1(\cdot)$ and accepting these with Metropolis acceptance rate
$$\dfrac{p_{1|2}(x_1'|x_2^{(t)})}{p_{1|2}(x_1^{(t-1)}|x_2^{(t)})}
\dfrac{p_{1}(x_1^{(t-1)})}{p_{1}(x_1')}=\dfrac{p_{2|1}(x_2^{(t)}|x_1')}{p_{2|1}(x_2^{(t)}|x_1^{(t-1)})}$$
can be implemented. | Metropolis-Within-Gibbs sampling with only marginal distribution known for a subset of variables
In an ideal world, sampling from $p_1(x_1)$ and then from $p_{1|2}(x_2|x_1)$ is a correct way to simulate from the joint. In case one of these distributions is unavailable, simulating a single step of |
36,544 | Final layer of neural network responsible for overfitting | With sample size $N=30\times10^6$ and 500 features, you already tried (most of) the usual regularization tricks, thus it doesn't look like there's much left to do at this point.
However, maybe the problem here is upstream. You haven't told us what's your dataset, exactly (what are the observations? What are the features?) and what are you trying to classify. You also don't describe in detail your architecture (how many neurons do you have? which activation functions are you using? What rule do you use to convert the output layer result into a class choice?). I will proceed under the assumptions that:
you have 512 units in input layer, 512 units in each of the hidden layers and 2 units in the output layer. corresponding to $p=525312$ parameters. In this case, your data set seems large enough to learn all weights.
you're using One-Hot Encoding to perform classification.
Correct me if my assumptions are wrong. Now:
if you have structured data (this means you're not doing image classification), maybe there's just nothing you can do. Usually XGboost just beats DNNs on structured data classification. Have a look the Kaggle competitions: you'll see that for structured data, usually the winning teams use ensembles of extreme gradient boosted trees, not Deep Neural Networks.
if you have unstructured data, then something's weird: usually DNNs dominate XGboost here. If you're doing image classification, don't use an MLP. Mostly everyone now uses a CNN. Also, be sure you don't use sigmoid activation functions, but stuff such as ReLU.
You didn't try early stopping and learning rate decay. Early stopping usually "plays nice" with most other regularization methods and it's easy to implement, so that's the first thing I'd try, if I were in you. In case you're not familiar with early stopping, read this nice answer:
Early stopping vs cross validation
If nothing else helps, you should check for errors in your code. Can you try to write unit tests? If you're using Tensorflow, Theano or MXNet, can you switch to an high level API such as Keras or PyTorch? One might expect that using an high level API, where less customization is possible, would drive your test error up, not down. However, often the opposite happens, because the higher level API allows you to do the same work with much less code, and thus much less opportunity for mistakes. At the very least, you can be sure your high test error isn't due to coding bugs....
Finally, I didn't add anything about dealing with class imbalance because you seem quite knowledgeable, so I assume you used the usual methods to deal with class imbalance. In case I'm wrong, let me know and I'll add a couple tricks, citing questions dealing specifically with class imbalance if needed. | Final layer of neural network responsible for overfitting | With sample size $N=30\times10^6$ and 500 features, you already tried (most of) the usual regularization tricks, thus it doesn't look like there's much left to do at this point.
However, maybe the pr | Final layer of neural network responsible for overfitting
With sample size $N=30\times10^6$ and 500 features, you already tried (most of) the usual regularization tricks, thus it doesn't look like there's much left to do at this point.
However, maybe the problem here is upstream. You haven't told us what's your dataset, exactly (what are the observations? What are the features?) and what are you trying to classify. You also don't describe in detail your architecture (how many neurons do you have? which activation functions are you using? What rule do you use to convert the output layer result into a class choice?). I will proceed under the assumptions that:
you have 512 units in input layer, 512 units in each of the hidden layers and 2 units in the output layer. corresponding to $p=525312$ parameters. In this case, your data set seems large enough to learn all weights.
you're using One-Hot Encoding to perform classification.
Correct me if my assumptions are wrong. Now:
if you have structured data (this means you're not doing image classification), maybe there's just nothing you can do. Usually XGboost just beats DNNs on structured data classification. Have a look the Kaggle competitions: you'll see that for structured data, usually the winning teams use ensembles of extreme gradient boosted trees, not Deep Neural Networks.
if you have unstructured data, then something's weird: usually DNNs dominate XGboost here. If you're doing image classification, don't use an MLP. Mostly everyone now uses a CNN. Also, be sure you don't use sigmoid activation functions, but stuff such as ReLU.
You didn't try early stopping and learning rate decay. Early stopping usually "plays nice" with most other regularization methods and it's easy to implement, so that's the first thing I'd try, if I were in you. In case you're not familiar with early stopping, read this nice answer:
Early stopping vs cross validation
If nothing else helps, you should check for errors in your code. Can you try to write unit tests? If you're using Tensorflow, Theano or MXNet, can you switch to an high level API such as Keras or PyTorch? One might expect that using an high level API, where less customization is possible, would drive your test error up, not down. However, often the opposite happens, because the higher level API allows you to do the same work with much less code, and thus much less opportunity for mistakes. At the very least, you can be sure your high test error isn't due to coding bugs....
Finally, I didn't add anything about dealing with class imbalance because you seem quite knowledgeable, so I assume you used the usual methods to deal with class imbalance. In case I'm wrong, let me know and I'll add a couple tricks, citing questions dealing specifically with class imbalance if needed. | Final layer of neural network responsible for overfitting
With sample size $N=30\times10^6$ and 500 features, you already tried (most of) the usual regularization tricks, thus it doesn't look like there's much left to do at this point.
However, maybe the pr |
36,545 | Final layer of neural network responsible for overfitting | A few years late but: What optimizer are you using? Adam will usually do a pretty good job without much tuning effort. However, recent work seems to show that SGD performs better than adaptive methods in many cases, so it's also probably worth exploring. Make sure to tune both your initial learning rate as well as your learning rate schedule. This last point might explain why your training loss stagnates at some point, if you drop the learning rate, you should see your loss continue to decrease. You might also try clipping gradients to deal with heavy tailed noise: https://arxiv.org/pdf/1905.11881.pdf | Final layer of neural network responsible for overfitting | A few years late but: What optimizer are you using? Adam will usually do a pretty good job without much tuning effort. However, recent work seems to show that SGD performs better than adaptive methods | Final layer of neural network responsible for overfitting
A few years late but: What optimizer are you using? Adam will usually do a pretty good job without much tuning effort. However, recent work seems to show that SGD performs better than adaptive methods in many cases, so it's also probably worth exploring. Make sure to tune both your initial learning rate as well as your learning rate schedule. This last point might explain why your training loss stagnates at some point, if you drop the learning rate, you should see your loss continue to decrease. You might also try clipping gradients to deal with heavy tailed noise: https://arxiv.org/pdf/1905.11881.pdf | Final layer of neural network responsible for overfitting
A few years late but: What optimizer are you using? Adam will usually do a pretty good job without much tuning effort. However, recent work seems to show that SGD performs better than adaptive methods |
36,546 | Dynamic Bayesian Network library in Python [closed] | Try pgmpy.
You can also create something on your own by using more generic tools for Graphical Probabilistic Models such as PyJaggs or Edward. | Dynamic Bayesian Network library in Python [closed] | Try pgmpy.
You can also create something on your own by using more generic tools for Graphical Probabilistic Models such as PyJaggs or Edward. | Dynamic Bayesian Network library in Python [closed]
Try pgmpy.
You can also create something on your own by using more generic tools for Graphical Probabilistic Models such as PyJaggs or Edward. | Dynamic Bayesian Network library in Python [closed]
Try pgmpy.
You can also create something on your own by using more generic tools for Graphical Probabilistic Models such as PyJaggs or Edward. |
36,547 | Gap Statistic in plain English? | Since I'm looking into the gap statistics just now, I'll try to answer this old question.
$\newcommand{\Gap}{{\rm Gap}}$
Once you have partitioned your datapoints into $k$ clusters using e.g., k-means, you want some metric that describes how compact the clusters are. One way of doing this is to compute all the pairwise distances between points within a cluster and average these distances. Do this for all clusters, sum these average distances and take the log. This is $\log(W_{k})$ in Tibshirani et al. 2001.
If clusters are real and very compact, $W_{k}$ will be low. However, we need some baseline reference to tell what "low" means. For this we ask what $W_{k}$ values we can expect from a dataset similar to the one we have but where there are no clusters at all. The largest the difference between the observed $W_{k}$ and the "null" $W_{k}$ the more confident we are that the number of clusters is correct.
Say our dataset has $n$ datapoints in $d$ dimensions. Tibshirani et al. show that such reference dataset can be obtained by taking $n$ datapoints where the coordinate of each datapoint is drawn from a uniform distribution. The minimum and maximum of the uniform distribution in each dimension is given by the min and max of the observed datapoints in that dimension.
Then cluster this reference dataset using the same strategy you used for the real dataset (e.g., k-means with $k$ clusters), calculate its $W_{k}$, and compute the difference between observed $\log(W_{k})$ and reference $\log{W_k}$. Of course, one randomly drawn dataset is not a reliable reference. Instead you draw several datasets and average the resulting $\log(W_{k})$'s. This is $E^{*}\{\log(W_{k})\}$ and the difference $E^{*}\{\log(W_{k})\} - \log(W_{k})$ is the gap statistic.
Tibshirani et al. also show that it is even better to rotate the dataset and remap the datapoints on the principal component axes and use this rotated dataset to draw the reference null datasets. This gives better results since the original variables (dimensions) may be correlated to each other. After rotation, the correlation has been eliminated.
Here's an example using simulation in R. First I produce an example dataset with 2 dimensions and 3 real clusters of 20 observations each.
library(data.table)
options(digits= 3)
set.seed(1234)
K <- 3
ksize <- 20
M <- rbind(
mvrnorm(n= ksize, mu= c( 5, 5), Sigma= diag(c(1,1))),
mvrnorm(n= ksize, mu= c( 5, 10), Sigma= diag(c(1,1))),
mvrnorm(n= ksize, mu= c(10, 10), Sigma= diag(c(1,1)))
)
data <- data.table(M, cluster= rep(LETTERS[1:K], each= ksize), observation= 1:nrow(M))
plot(data$V1, data$V2, col= rep(1:K, each= ksize), pch= 19, xlab= 'Dim 1', ylab= 'Dim 2')
# 60 observations in 2 dimensions
M
[,1] [,2]
[1,] 4.87 3.79
[2,] 5.49 5.28
[3,] 5.44 6.08
[4,] 4.54 2.65
...
[57,] 11.24 8.87
[58,] 9.83 10.88
[59,] 9.33 10.97
[60,] 10.03 12.12
This is a convenience function that given the observations X calculates all the pairwise Euclidean squared distances, and averages them (as per Tibshirani et al).
avg.dist2 <- function(X) {
dist2 <- dist(X)^2
avg <- sum(dist2)/(2 * nrow(X))
return(avg)
}
Here I cluster the dataset using k-means and compute $\log(W_{k})$:
k <- 3
km <- kmeans(M, centers= k)
data[, cluster := km$cluster]
logW <- log(sum(data[, list(d2= avg.dist2(X= cbind(V1, V2))), by= cluster]$d2))
Now I produce the reference datasets. First I rotate the observed data by centering its columns (i.e, subtract from each value the mean of its column), and multiplying it by its eigenvectors (eigenvectors obtained from singular value decomposition):
M_cent <- scale(M, center= TRUE, scale= FALSE)
M_rot <- M %*% svd(M_cent)$v
plot(M_rot[,1], M_rot[,2], col= rep(1:K, each= ksize), pch= 19, xlab= 'PC 1', ylab= 'PC 2')
Now I can draw the reference datasets, cluster them, compute $W_{k}$ for each randomly drawn datasets - the same as for the real data. Note the use of runif(..., min= min(M_rot[,v]), max= max(M_rot[,v])) to create new datapoints.
B <- 500
null_logW <- rep(NA, B)
for(i in 1:length(null_logW)){
null_M <- matrix(data= NA, ncol= ncol(M_rot), nrow= nrow(M_rot))
for(v in 1:ncol(M_rot)){
null_M[,v] <- runif(n= nrow(M_rot), min= min(M_rot[,v]), max= max(M_rot[,v]))
}
null_km <- kmeans(null_M, centers= k)
null_M <- as.data.table(null_M)
null_M[, cluster := null_km$cluster]
null_logW[i] <- log(sum(null_M[, list(d2= avg.dist2(X= cbind(V1, V2))), by= cluster]$d2))
}
plot(null_M$V1, null_M$V2, col= null_M$cluster, pch= 19, xlab= 'Dim 1', ylab= 'Dim 2')
This is an example of one of the random datasets:
Finally, average the null $\log(W_{k})$ and compute the gap statistics. As suggested by Tibshirani et al we should compute also the standard deviation of the null distribution to guide the choice of best number of clusters:
ElogW <- mean(null_logW) # 4.88
sdk <- sqrt((1 + 1/B) * sum((null_logW - mean(null_logW))^2)/B) # 0.0988
gap <- ElogW - logW # 1.04
Now, by replacing k <- 3 with e.g. k <- 2 or 4, 5 etc you can find the optimal number of clusters according to the gap statistics. I.e., the k so that $\Gap(k)\ge \Gap(k+1)-sd_{k+1} $.
Credit: I found the code here the-gap-statistic quite handy to understand myself. | Gap Statistic in plain English? | Since I'm looking into the gap statistics just now, I'll try to answer this old question.
$\newcommand{\Gap}{{\rm Gap}}$
Once you have partitioned your datapoints into $k$ clusters using e.g., k-means | Gap Statistic in plain English?
Since I'm looking into the gap statistics just now, I'll try to answer this old question.
$\newcommand{\Gap}{{\rm Gap}}$
Once you have partitioned your datapoints into $k$ clusters using e.g., k-means, you want some metric that describes how compact the clusters are. One way of doing this is to compute all the pairwise distances between points within a cluster and average these distances. Do this for all clusters, sum these average distances and take the log. This is $\log(W_{k})$ in Tibshirani et al. 2001.
If clusters are real and very compact, $W_{k}$ will be low. However, we need some baseline reference to tell what "low" means. For this we ask what $W_{k}$ values we can expect from a dataset similar to the one we have but where there are no clusters at all. The largest the difference between the observed $W_{k}$ and the "null" $W_{k}$ the more confident we are that the number of clusters is correct.
Say our dataset has $n$ datapoints in $d$ dimensions. Tibshirani et al. show that such reference dataset can be obtained by taking $n$ datapoints where the coordinate of each datapoint is drawn from a uniform distribution. The minimum and maximum of the uniform distribution in each dimension is given by the min and max of the observed datapoints in that dimension.
Then cluster this reference dataset using the same strategy you used for the real dataset (e.g., k-means with $k$ clusters), calculate its $W_{k}$, and compute the difference between observed $\log(W_{k})$ and reference $\log{W_k}$. Of course, one randomly drawn dataset is not a reliable reference. Instead you draw several datasets and average the resulting $\log(W_{k})$'s. This is $E^{*}\{\log(W_{k})\}$ and the difference $E^{*}\{\log(W_{k})\} - \log(W_{k})$ is the gap statistic.
Tibshirani et al. also show that it is even better to rotate the dataset and remap the datapoints on the principal component axes and use this rotated dataset to draw the reference null datasets. This gives better results since the original variables (dimensions) may be correlated to each other. After rotation, the correlation has been eliminated.
Here's an example using simulation in R. First I produce an example dataset with 2 dimensions and 3 real clusters of 20 observations each.
library(data.table)
options(digits= 3)
set.seed(1234)
K <- 3
ksize <- 20
M <- rbind(
mvrnorm(n= ksize, mu= c( 5, 5), Sigma= diag(c(1,1))),
mvrnorm(n= ksize, mu= c( 5, 10), Sigma= diag(c(1,1))),
mvrnorm(n= ksize, mu= c(10, 10), Sigma= diag(c(1,1)))
)
data <- data.table(M, cluster= rep(LETTERS[1:K], each= ksize), observation= 1:nrow(M))
plot(data$V1, data$V2, col= rep(1:K, each= ksize), pch= 19, xlab= 'Dim 1', ylab= 'Dim 2')
# 60 observations in 2 dimensions
M
[,1] [,2]
[1,] 4.87 3.79
[2,] 5.49 5.28
[3,] 5.44 6.08
[4,] 4.54 2.65
...
[57,] 11.24 8.87
[58,] 9.83 10.88
[59,] 9.33 10.97
[60,] 10.03 12.12
This is a convenience function that given the observations X calculates all the pairwise Euclidean squared distances, and averages them (as per Tibshirani et al).
avg.dist2 <- function(X) {
dist2 <- dist(X)^2
avg <- sum(dist2)/(2 * nrow(X))
return(avg)
}
Here I cluster the dataset using k-means and compute $\log(W_{k})$:
k <- 3
km <- kmeans(M, centers= k)
data[, cluster := km$cluster]
logW <- log(sum(data[, list(d2= avg.dist2(X= cbind(V1, V2))), by= cluster]$d2))
Now I produce the reference datasets. First I rotate the observed data by centering its columns (i.e, subtract from each value the mean of its column), and multiplying it by its eigenvectors (eigenvectors obtained from singular value decomposition):
M_cent <- scale(M, center= TRUE, scale= FALSE)
M_rot <- M %*% svd(M_cent)$v
plot(M_rot[,1], M_rot[,2], col= rep(1:K, each= ksize), pch= 19, xlab= 'PC 1', ylab= 'PC 2')
Now I can draw the reference datasets, cluster them, compute $W_{k}$ for each randomly drawn datasets - the same as for the real data. Note the use of runif(..., min= min(M_rot[,v]), max= max(M_rot[,v])) to create new datapoints.
B <- 500
null_logW <- rep(NA, B)
for(i in 1:length(null_logW)){
null_M <- matrix(data= NA, ncol= ncol(M_rot), nrow= nrow(M_rot))
for(v in 1:ncol(M_rot)){
null_M[,v] <- runif(n= nrow(M_rot), min= min(M_rot[,v]), max= max(M_rot[,v]))
}
null_km <- kmeans(null_M, centers= k)
null_M <- as.data.table(null_M)
null_M[, cluster := null_km$cluster]
null_logW[i] <- log(sum(null_M[, list(d2= avg.dist2(X= cbind(V1, V2))), by= cluster]$d2))
}
plot(null_M$V1, null_M$V2, col= null_M$cluster, pch= 19, xlab= 'Dim 1', ylab= 'Dim 2')
This is an example of one of the random datasets:
Finally, average the null $\log(W_{k})$ and compute the gap statistics. As suggested by Tibshirani et al we should compute also the standard deviation of the null distribution to guide the choice of best number of clusters:
ElogW <- mean(null_logW) # 4.88
sdk <- sqrt((1 + 1/B) * sum((null_logW - mean(null_logW))^2)/B) # 0.0988
gap <- ElogW - logW # 1.04
Now, by replacing k <- 3 with e.g. k <- 2 or 4, 5 etc you can find the optimal number of clusters according to the gap statistics. I.e., the k so that $\Gap(k)\ge \Gap(k+1)-sd_{k+1} $.
Credit: I found the code here the-gap-statistic quite handy to understand myself. | Gap Statistic in plain English?
Since I'm looking into the gap statistics just now, I'll try to answer this old question.
$\newcommand{\Gap}{{\rm Gap}}$
Once you have partitioned your datapoints into $k$ clusters using e.g., k-means |
36,548 | How do we incorporate new information into a Dirichlet prior distribution? | Dirichlet prior is an appropriate prior, and is the conjugate prior to a multinomial distribution. However, it seems a bit tricky to apply this to the output of a multinomial logistic regression, since such a regression has a softmax as the output, not a multinomial distribution. However, what we can do is sample from a multinomial, whose probabilities are given by the softmax.
If we draw this as a neural network model, it looks like:
We can easily sample from this, in the forwards direction. How to handle backwards direction? We can use the reparameterization trick, from Kingma's 'Auto-encoding variational Bayes' paper, https://arxiv.org/abs/1312.6114 , in other words, we model the multinomial draw as a deterministic mapping, given the input probability distribution, and a draw from a standard Gaussian random variable:
$$
x_{\text{out}} = g(\mathbf{\mathbf{x}_{\text{in}}}, \mathbf{\epsilon})
$$
where: $\mathbf{\epsilon} \sim \mathcal{N}(0, 1)$
So, our network becomes:
So, we can forward propagate mini-batches of data examples, draws from the standard normal distribution, and back-propagate through the network. This is fairly standard and widely used, eg the Kingma VAE paper above.
A slight nuance is, we are drawing discrete values from a multinomial distribution, but the VAE paper only handles the case of continuous real outputs. However, there is a recent paper, the Gumbel trick, https://casmls.github.io/general/2017/02/01/GumbelSoftmax.html , ie https://arxiv.org/pdf/1611.01144v1.pdf ,and https://arxiv.org/abs/1611.00712 , which allows draws from discrete multinomial papers.
The Gumbel trick formulae gives the following output distribution:
$$
p_{\alpha, \lambda}(x) = (n-1)! \lambda^{n-1} \prod_{k=1}^n \left(
\frac{\alpha_k x_k^{-\lambda-1}}
{\sum_{i=1}^n \alpha_i x_i^{-\lambda}}
\right)
$$
The $\alpha_k$ here are prior probabilities for the various categories, which you can tweak, to push your initial distribution towards how you think the distribution could be distributed initially.
Thus we have a model that:
contains a multinomial logistic regression (the linear layer followed by the softmax)
adds a multinomial sampling step at the end
which includes a prior distribution over the probabilities
can be trained, using Stochastic Gradient Descent, or similar
Edit:
So, the question asks:
"is it possible to apply this kind of technique when we have multiple predictions (and each prediction can be a softmax, like above) for a single sample (from an ensemble of learners)." (see comments below)
So: yes :). It is. Using something like multi-task learning, eg http://www.cs.cornell.edu/~caruana/mlj97.pdf and https://en.wikipedia.org/wiki/Multi-task_learning . Except multi-task learning has a single network, and multiple heads. We will have multiple networks, and a single head.
The 'head' comprises an extract layer, which handles 'mixing' between the nets. Note that you'll need a non-linearity between your 'learners' and the 'mixing' layer, eg ReLU or tanh.
You hint at giving each 'learn' its own multinomial draw, or at least, softmax. On the whole, I think it will be more standard to have the mixing layer first, followed by a single softmax and multinomial draw. This will give the least variance, since fewer draws. (for example, you can look at 'variational dropout' paper, https://arxiv.org/abs/1506.02557 , which explicitly merges multiple random draws, to reduce variance, a technique they call 'local reparameterization')
Such a network will look something like:
This then has the following characteristics:
can include one or more independent learners, each with their own parameters
can include a prior over the distribution of the output classes
will learn to mix across the various learners
Note in passing that this is not the only way of combining the learners. We could also combine them in more of a 'highway' type fashion, somewhat like boosting, something like:
In this last network, each learner learns to fix any issues caused by the network so far, rather than creating its own relatively independent prediction. Such an approach can work quite well, ie Boosting, etc. | How do we incorporate new information into a Dirichlet prior distribution? | Dirichlet prior is an appropriate prior, and is the conjugate prior to a multinomial distribution. However, it seems a bit tricky to apply this to the output of a multinomial logistic regression, sinc | How do we incorporate new information into a Dirichlet prior distribution?
Dirichlet prior is an appropriate prior, and is the conjugate prior to a multinomial distribution. However, it seems a bit tricky to apply this to the output of a multinomial logistic regression, since such a regression has a softmax as the output, not a multinomial distribution. However, what we can do is sample from a multinomial, whose probabilities are given by the softmax.
If we draw this as a neural network model, it looks like:
We can easily sample from this, in the forwards direction. How to handle backwards direction? We can use the reparameterization trick, from Kingma's 'Auto-encoding variational Bayes' paper, https://arxiv.org/abs/1312.6114 , in other words, we model the multinomial draw as a deterministic mapping, given the input probability distribution, and a draw from a standard Gaussian random variable:
$$
x_{\text{out}} = g(\mathbf{\mathbf{x}_{\text{in}}}, \mathbf{\epsilon})
$$
where: $\mathbf{\epsilon} \sim \mathcal{N}(0, 1)$
So, our network becomes:
So, we can forward propagate mini-batches of data examples, draws from the standard normal distribution, and back-propagate through the network. This is fairly standard and widely used, eg the Kingma VAE paper above.
A slight nuance is, we are drawing discrete values from a multinomial distribution, but the VAE paper only handles the case of continuous real outputs. However, there is a recent paper, the Gumbel trick, https://casmls.github.io/general/2017/02/01/GumbelSoftmax.html , ie https://arxiv.org/pdf/1611.01144v1.pdf ,and https://arxiv.org/abs/1611.00712 , which allows draws from discrete multinomial papers.
The Gumbel trick formulae gives the following output distribution:
$$
p_{\alpha, \lambda}(x) = (n-1)! \lambda^{n-1} \prod_{k=1}^n \left(
\frac{\alpha_k x_k^{-\lambda-1}}
{\sum_{i=1}^n \alpha_i x_i^{-\lambda}}
\right)
$$
The $\alpha_k$ here are prior probabilities for the various categories, which you can tweak, to push your initial distribution towards how you think the distribution could be distributed initially.
Thus we have a model that:
contains a multinomial logistic regression (the linear layer followed by the softmax)
adds a multinomial sampling step at the end
which includes a prior distribution over the probabilities
can be trained, using Stochastic Gradient Descent, or similar
Edit:
So, the question asks:
"is it possible to apply this kind of technique when we have multiple predictions (and each prediction can be a softmax, like above) for a single sample (from an ensemble of learners)." (see comments below)
So: yes :). It is. Using something like multi-task learning, eg http://www.cs.cornell.edu/~caruana/mlj97.pdf and https://en.wikipedia.org/wiki/Multi-task_learning . Except multi-task learning has a single network, and multiple heads. We will have multiple networks, and a single head.
The 'head' comprises an extract layer, which handles 'mixing' between the nets. Note that you'll need a non-linearity between your 'learners' and the 'mixing' layer, eg ReLU or tanh.
You hint at giving each 'learn' its own multinomial draw, or at least, softmax. On the whole, I think it will be more standard to have the mixing layer first, followed by a single softmax and multinomial draw. This will give the least variance, since fewer draws. (for example, you can look at 'variational dropout' paper, https://arxiv.org/abs/1506.02557 , which explicitly merges multiple random draws, to reduce variance, a technique they call 'local reparameterization')
Such a network will look something like:
This then has the following characteristics:
can include one or more independent learners, each with their own parameters
can include a prior over the distribution of the output classes
will learn to mix across the various learners
Note in passing that this is not the only way of combining the learners. We could also combine them in more of a 'highway' type fashion, somewhat like boosting, something like:
In this last network, each learner learns to fix any issues caused by the network so far, rather than creating its own relatively independent prediction. Such an approach can work quite well, ie Boosting, etc. | How do we incorporate new information into a Dirichlet prior distribution?
Dirichlet prior is an appropriate prior, and is the conjugate prior to a multinomial distribution. However, it seems a bit tricky to apply this to the output of a multinomial logistic regression, sinc |
36,549 | Overfitting on the loss graph, but not the accuracy graph | Accuracy is not a great way to report machine learning results. (I've never found a need to report accuracy, except when explaining my results to a non-technical audience.) Accuracy only compares a predicted score $t$ to some cutoff $c$, which is not a proper scoring rule and conceals important information about model fitness.
I assume you're using some sort of proper loss function in the "loss" graph, such as cross-entropy loss. Cross-entropy loss is more useful than accuracy because it is sensitive to "how wrong" its results are: if the label is $1$ but $t=0.9$, the cross-entropy is lower than when the label is $1$ but $t=0.1$.
The phenomenon you're seeing when comparing these two graphs -- accuracy is flat but loss is increasing -- happens because $t>c$ is satisfied in the accuracy graph, but the predicted scores are poorly aligned to their labels.
This is intimately related to this similar issue with AUC: Why is AUC higher for a classifier that is less accurate than for one that is more accurate? | Overfitting on the loss graph, but not the accuracy graph | Accuracy is not a great way to report machine learning results. (I've never found a need to report accuracy, except when explaining my results to a non-technical audience.) Accuracy only compares a pr | Overfitting on the loss graph, but not the accuracy graph
Accuracy is not a great way to report machine learning results. (I've never found a need to report accuracy, except when explaining my results to a non-technical audience.) Accuracy only compares a predicted score $t$ to some cutoff $c$, which is not a proper scoring rule and conceals important information about model fitness.
I assume you're using some sort of proper loss function in the "loss" graph, such as cross-entropy loss. Cross-entropy loss is more useful than accuracy because it is sensitive to "how wrong" its results are: if the label is $1$ but $t=0.9$, the cross-entropy is lower than when the label is $1$ but $t=0.1$.
The phenomenon you're seeing when comparing these two graphs -- accuracy is flat but loss is increasing -- happens because $t>c$ is satisfied in the accuracy graph, but the predicted scores are poorly aligned to their labels.
This is intimately related to this similar issue with AUC: Why is AUC higher for a classifier that is less accurate than for one that is more accurate? | Overfitting on the loss graph, but not the accuracy graph
Accuracy is not a great way to report machine learning results. (I've never found a need to report accuracy, except when explaining my results to a non-technical audience.) Accuracy only compares a pr |
36,550 | Regression Using Continuous Variable with Nulls | By the way, the problem you have right now is the "missing data" problem. It can be such an issue that that's one of the reasons they do redundant checkups on you for like 5 things everytime you go to the doctor regardless of whether or not you feel it's related. No one wants to deal with the NULL monster.
It can be frustrating to deal with, but there are many options available...some more complex than others....some very, very complex....tons of books written on the subject too...it's not too bad though.
First, consider what your goal is....do you really need all the people whom have never made a visit in the model? They can really cause problems (probably because they likely have other data that is NULL as well...just a guess) if they arn't relevant to the information you're really seeking and especially if they have multiple NULL values...then I'd actually just delete them and perform a complex different regression/analysis with them. I'm going to assume you feel that they are important though as otherwise you would not have asked the question here including them.
As you have already recognized by asking the question...but I'm going to reiterate:
Null values or the lack of data should never be interpreted as a 0...it's a literal lack of information...it's a blank...if you were to measure something and it was "0" then that's data....that's information. If you weren't able to measure anything, there's no data or information.
1st) I have never heard of setting their values to +/- infinity. Maybe it's a technique I'm not aware of, but seems like it mess up alot of stuff.
2nd) I would DEFINITELY have a binary variable that indicates whether or not they have ever even visited. This is super important. The regression algorithm will likely assign some sort of weight via a coeffient * (1) or (0) to balance out the people who never visited to the ones who did. In fact, you may find that it is one of your most significant variables.
Although you could separate everything into buckets like you mention (it'd be easier seemingly)...but this would probably confuse the regressional alogrithm with the bucket containing the never-shows. You're also unnecessarily eliminating information by doing summarizing unique values into buckets. You're just throwing it all away...but anyways, here's what I'd do pending a few things:
You feel you have enough other data, say, in other columns, about these no shows which you'll be using in your regression. To be honest though, if they are no shows, then you likely have many more columns with the no shows's corresponding Null value for the matching...Null cells...if you do, then at this point this is over my head and I would just move them into a separate regression you study.
Null and measurement recorded are as if they are from different worlds. I would even study the Nulls on their own...if it mattered...depends on the context. Although NULL means a lack of data for a particular parameter, it may (likely) also be related to the value of many other values you have for them...
They are special cases.
Anyways, here's the start of the fancier and likely much better approach.
Depending upon the statistics software you're using, it may already have a function where it does something like this...or does it more robustly...or uses a different method.
Regressional Imputation
By doing this, you're just allowing your regressional algorithm to perform better. You're not adding any value or additional information - which is something to keep in mind. You do incur a penalty though in terms of your margin of error...because you're not using real data...it's ...simulated...
So, you set the column where the cases exist with NULL as the explanatory value to your Y. You then run a regression with all the other cases and get a formula which you could then use to predict what their NULL value "would have been" if "it was there."
This only allows your regressional algorithm to function correctly and accurately though. If you do this, you definitely afterwards then need that additional column of a binary variable representing if they are a no show or not when you perform the "final regression."
For a fancier man...
Multiple Regressional Imputation
You can also get fancier by 1st) predicting the NULL values by setting them to your Y and doing as explained above...and then you have a complete data set.
You take that complete data set and run a bunch of tests over it....such as a correspondance analysis and then other types that check how "complete" your data is...I'll link you to the site I'm referencing in a second..been a while since I did one of these.
I believe you actually make multiple data sets with your new simulated values in different ways (ie. using different variables each time you perform it yielding a different prediction value)
Then after measuring all your new data sets...you run tests which explains to you an analysis of your data...you then combine all of this data testing your none null data with the simulated data and hopefully figure out any, if which, other x variables/situations you can use to most accurately predict what the value would actually be.
This gets you closer than just a single regressional imputation as you're trying to adjust for the error penalty you're incurring by studying relationships to the NULL.
Yeah, so it can get messy.
Here is a nice summary of all the techniques for treating NULL values as well as how to recognize the TYPE of null value you have and what to do with that then...https://www.ncbi.nlm.nih.gov/pmc/articles/PMC3668100/ | Regression Using Continuous Variable with Nulls | By the way, the problem you have right now is the "missing data" problem. It can be such an issue that that's one of the reasons they do redundant checkups on you for like 5 things everytime you go t | Regression Using Continuous Variable with Nulls
By the way, the problem you have right now is the "missing data" problem. It can be such an issue that that's one of the reasons they do redundant checkups on you for like 5 things everytime you go to the doctor regardless of whether or not you feel it's related. No one wants to deal with the NULL monster.
It can be frustrating to deal with, but there are many options available...some more complex than others....some very, very complex....tons of books written on the subject too...it's not too bad though.
First, consider what your goal is....do you really need all the people whom have never made a visit in the model? They can really cause problems (probably because they likely have other data that is NULL as well...just a guess) if they arn't relevant to the information you're really seeking and especially if they have multiple NULL values...then I'd actually just delete them and perform a complex different regression/analysis with them. I'm going to assume you feel that they are important though as otherwise you would not have asked the question here including them.
As you have already recognized by asking the question...but I'm going to reiterate:
Null values or the lack of data should never be interpreted as a 0...it's a literal lack of information...it's a blank...if you were to measure something and it was "0" then that's data....that's information. If you weren't able to measure anything, there's no data or information.
1st) I have never heard of setting their values to +/- infinity. Maybe it's a technique I'm not aware of, but seems like it mess up alot of stuff.
2nd) I would DEFINITELY have a binary variable that indicates whether or not they have ever even visited. This is super important. The regression algorithm will likely assign some sort of weight via a coeffient * (1) or (0) to balance out the people who never visited to the ones who did. In fact, you may find that it is one of your most significant variables.
Although you could separate everything into buckets like you mention (it'd be easier seemingly)...but this would probably confuse the regressional alogrithm with the bucket containing the never-shows. You're also unnecessarily eliminating information by doing summarizing unique values into buckets. You're just throwing it all away...but anyways, here's what I'd do pending a few things:
You feel you have enough other data, say, in other columns, about these no shows which you'll be using in your regression. To be honest though, if they are no shows, then you likely have many more columns with the no shows's corresponding Null value for the matching...Null cells...if you do, then at this point this is over my head and I would just move them into a separate regression you study.
Null and measurement recorded are as if they are from different worlds. I would even study the Nulls on their own...if it mattered...depends on the context. Although NULL means a lack of data for a particular parameter, it may (likely) also be related to the value of many other values you have for them...
They are special cases.
Anyways, here's the start of the fancier and likely much better approach.
Depending upon the statistics software you're using, it may already have a function where it does something like this...or does it more robustly...or uses a different method.
Regressional Imputation
By doing this, you're just allowing your regressional algorithm to perform better. You're not adding any value or additional information - which is something to keep in mind. You do incur a penalty though in terms of your margin of error...because you're not using real data...it's ...simulated...
So, you set the column where the cases exist with NULL as the explanatory value to your Y. You then run a regression with all the other cases and get a formula which you could then use to predict what their NULL value "would have been" if "it was there."
This only allows your regressional algorithm to function correctly and accurately though. If you do this, you definitely afterwards then need that additional column of a binary variable representing if they are a no show or not when you perform the "final regression."
For a fancier man...
Multiple Regressional Imputation
You can also get fancier by 1st) predicting the NULL values by setting them to your Y and doing as explained above...and then you have a complete data set.
You take that complete data set and run a bunch of tests over it....such as a correspondance analysis and then other types that check how "complete" your data is...I'll link you to the site I'm referencing in a second..been a while since I did one of these.
I believe you actually make multiple data sets with your new simulated values in different ways (ie. using different variables each time you perform it yielding a different prediction value)
Then after measuring all your new data sets...you run tests which explains to you an analysis of your data...you then combine all of this data testing your none null data with the simulated data and hopefully figure out any, if which, other x variables/situations you can use to most accurately predict what the value would actually be.
This gets you closer than just a single regressional imputation as you're trying to adjust for the error penalty you're incurring by studying relationships to the NULL.
Yeah, so it can get messy.
Here is a nice summary of all the techniques for treating NULL values as well as how to recognize the TYPE of null value you have and what to do with that then...https://www.ncbi.nlm.nih.gov/pmc/articles/PMC3668100/ | Regression Using Continuous Variable with Nulls
By the way, the problem you have right now is the "missing data" problem. It can be such an issue that that's one of the reasons they do redundant checkups on you for like 5 things everytime you go t |
36,551 | Regression Using Continuous Variable with Nulls | This sounds like you have a predictor which is only relevant for part of the population. My advice is to (conceptually) split your population into two groups. Then write down equations for what your linear predictor should look like for each group. Then consider if these can merged back together into one model, or if you need separate models.
Using the example given, the groups are NULL vs not. Now supposing this is the only variable (for simplicity) with null values, and you have other variable, so your predictor looks like $\eta_i^{NULL} =x_i^T\beta $ or $\eta_i^{not NULL} =x_i^T\beta + z_i\alpha $ where we have $z_i$ is the days since last visit (or transformation of this), $x_i $ is the other predictors in the model. Now if I set the value of $z_i=0$ in this model - both groups have the same linear predictor. This might be good or bad, it depends on the model (though probably bad in your case). What you may also want is for the parameters to vary, so we have $\beta_{NULL} $ or possibly a subset different so you have
$\eta_i^{NULL} =x_{1,i}^T\beta_{1,NULL}+x_{2,i}^T\beta_2 $ or $\eta_i^{not NULL} =x_{1,i}^T\beta_{1,not NULL}+x_{2,i}^T\beta_2 + z_i\alpha $
What this ultimately boils down to is having an indicator variable for NULL being included in your model, and deciding which other variables it should and shouldn't interact with. Once you have this, setting the NULL values to zero is appropriate. (FYI: in the above model, there is an interaction term between the null dummy and $x_1$) | Regression Using Continuous Variable with Nulls | This sounds like you have a predictor which is only relevant for part of the population. My advice is to (conceptually) split your population into two groups. Then write down equations for what your l | Regression Using Continuous Variable with Nulls
This sounds like you have a predictor which is only relevant for part of the population. My advice is to (conceptually) split your population into two groups. Then write down equations for what your linear predictor should look like for each group. Then consider if these can merged back together into one model, or if you need separate models.
Using the example given, the groups are NULL vs not. Now supposing this is the only variable (for simplicity) with null values, and you have other variable, so your predictor looks like $\eta_i^{NULL} =x_i^T\beta $ or $\eta_i^{not NULL} =x_i^T\beta + z_i\alpha $ where we have $z_i$ is the days since last visit (or transformation of this), $x_i $ is the other predictors in the model. Now if I set the value of $z_i=0$ in this model - both groups have the same linear predictor. This might be good or bad, it depends on the model (though probably bad in your case). What you may also want is for the parameters to vary, so we have $\beta_{NULL} $ or possibly a subset different so you have
$\eta_i^{NULL} =x_{1,i}^T\beta_{1,NULL}+x_{2,i}^T\beta_2 $ or $\eta_i^{not NULL} =x_{1,i}^T\beta_{1,not NULL}+x_{2,i}^T\beta_2 + z_i\alpha $
What this ultimately boils down to is having an indicator variable for NULL being included in your model, and deciding which other variables it should and shouldn't interact with. Once you have this, setting the NULL values to zero is appropriate. (FYI: in the above model, there is an interaction term between the null dummy and $x_1$) | Regression Using Continuous Variable with Nulls
This sounds like you have a predictor which is only relevant for part of the population. My advice is to (conceptually) split your population into two groups. Then write down equations for what your l |
36,552 | Why is it desirable to have linear separability in SVM? | Well, that is the whole idea behind support vector machines! svm are searching for a hyperplane that separates the classes (why the name), and that can of course be done most effectively it the points are linearly separable (that's not a deep point, it is a summary of the full idea). In the example you show, point lie on concentric annular rings, which cannot be separated by any plane, but by introducing a new variable RADIUS---distance from center---you get complete linear separation. | Why is it desirable to have linear separability in SVM? | Well, that is the whole idea behind support vector machines! svm are searching for a hyperplane that separates the classes (why the name), and that can of course be done most effectively it the points | Why is it desirable to have linear separability in SVM?
Well, that is the whole idea behind support vector machines! svm are searching for a hyperplane that separates the classes (why the name), and that can of course be done most effectively it the points are linearly separable (that's not a deep point, it is a summary of the full idea). In the example you show, point lie on concentric annular rings, which cannot be separated by any plane, but by introducing a new variable RADIUS---distance from center---you get complete linear separation. | Why is it desirable to have linear separability in SVM?
Well, that is the whole idea behind support vector machines! svm are searching for a hyperplane that separates the classes (why the name), and that can of course be done most effectively it the points |
36,553 | Why is it desirable to have linear separability in SVM? | Why is it desirable to have linear separability in SVM?
SVCs are inherently a linear technique. They find linear boundaries separating (as best possible) different classes. If there is no natural linear boundary for the problem, the choices are either to use a different technique, or to use SVCs with transformed features into a space where there indeed is a linear boundary.
Ref to above image, clearly a circle can separate the two classes(left image). Why then take so much pain to map it to a function to make it linearly separable (right image) ?
This is a classic example. The data classes are separated by a circle, but an SVC cannot find circles directly. However, if the data are transformed using a radial basis function, then in the resulting space, the classes are separated by a linear boundary. | Why is it desirable to have linear separability in SVM? | Why is it desirable to have linear separability in SVM?
SVCs are inherently a linear technique. They find linear boundaries separating (as best possible) different classes. If there is no natural lin | Why is it desirable to have linear separability in SVM?
Why is it desirable to have linear separability in SVM?
SVCs are inherently a linear technique. They find linear boundaries separating (as best possible) different classes. If there is no natural linear boundary for the problem, the choices are either to use a different technique, or to use SVCs with transformed features into a space where there indeed is a linear boundary.
Ref to above image, clearly a circle can separate the two classes(left image). Why then take so much pain to map it to a function to make it linearly separable (right image) ?
This is a classic example. The data classes are separated by a circle, but an SVC cannot find circles directly. However, if the data are transformed using a radial basis function, then in the resulting space, the classes are separated by a linear boundary. | Why is it desirable to have linear separability in SVM?
Why is it desirable to have linear separability in SVM?
SVCs are inherently a linear technique. They find linear boundaries separating (as best possible) different classes. If there is no natural lin |
36,554 | Why is it desirable to have linear separability in SVM? | Not directly answer your question but,
It is important to keep in mind the difference between basis expansion and Kernel method / SVM.
We can "expand data" using basis expansion in different ways. For example, polynomial expansion, splines, Fourier series, etc. These basis expansion have little to do with SVM, kernel trick.
SVM with polynomial kernel provides use a "computational effect" ways to do polynomial basis expansion. Search Kernel trick for details. | Why is it desirable to have linear separability in SVM? | Not directly answer your question but,
It is important to keep in mind the difference between basis expansion and Kernel method / SVM.
We can "expand data" using basis expansion in different ways. Fo | Why is it desirable to have linear separability in SVM?
Not directly answer your question but,
It is important to keep in mind the difference between basis expansion and Kernel method / SVM.
We can "expand data" using basis expansion in different ways. For example, polynomial expansion, splines, Fourier series, etc. These basis expansion have little to do with SVM, kernel trick.
SVM with polynomial kernel provides use a "computational effect" ways to do polynomial basis expansion. Search Kernel trick for details. | Why is it desirable to have linear separability in SVM?
Not directly answer your question but,
It is important to keep in mind the difference between basis expansion and Kernel method / SVM.
We can "expand data" using basis expansion in different ways. Fo |
36,555 | Why is it desirable to have linear separability in SVM? | SVCs were originally defined to be linear classifiers which tried to find maximum margin hyperplanes. The optimization problem is derived starting with an equation of a plane and calculating the distance of points from it, and finding out its parameter matrix w. See here for details. In a 2 dimensional case(left figure) a 1D hyperplane i.e. a straight line clearly can't separate the two classes, but with careful projection of data into 3rd dimension, support vectors are easily separated by a 2D hyperplane, as for these points x^2 + y^2 is near constant. | Why is it desirable to have linear separability in SVM? | SVCs were originally defined to be linear classifiers which tried to find maximum margin hyperplanes. The optimization problem is derived starting with an equation of a plane and calculating the dista | Why is it desirable to have linear separability in SVM?
SVCs were originally defined to be linear classifiers which tried to find maximum margin hyperplanes. The optimization problem is derived starting with an equation of a plane and calculating the distance of points from it, and finding out its parameter matrix w. See here for details. In a 2 dimensional case(left figure) a 1D hyperplane i.e. a straight line clearly can't separate the two classes, but with careful projection of data into 3rd dimension, support vectors are easily separated by a 2D hyperplane, as for these points x^2 + y^2 is near constant. | Why is it desirable to have linear separability in SVM?
SVCs were originally defined to be linear classifiers which tried to find maximum margin hyperplanes. The optimization problem is derived starting with an equation of a plane and calculating the dista |
36,556 | Why is it desirable to have linear separability in SVM? | You are correct. When the field says "linearly separable", they mean that the data should be "differentiable": that there exists some filtering function that you can overlay onto the dataset to create two or more distinct groupings (with some small error tolerance).
That's all. But you should point out to the academics to clean up thier language. | Why is it desirable to have linear separability in SVM? | You are correct. When the field says "linearly separable", they mean that the data should be "differentiable": that there exists some filtering function that you can overlay onto the dataset to creat | Why is it desirable to have linear separability in SVM?
You are correct. When the field says "linearly separable", they mean that the data should be "differentiable": that there exists some filtering function that you can overlay onto the dataset to create two or more distinct groupings (with some small error tolerance).
That's all. But you should point out to the academics to clean up thier language. | Why is it desirable to have linear separability in SVM?
You are correct. When the field says "linearly separable", they mean that the data should be "differentiable": that there exists some filtering function that you can overlay onto the dataset to creat |
36,557 | The unit of Root Mean Square Error (RMSE) | Let's say you have a model represented by the function $f(x)$ and you calculate the RMSE of the outcomes compared with the training set outcomes $y$. Let's also assume the outcome has some arbitrary unit $u$.
The RMSE is
$$RMSE(y)=\frac{1}{N^2}\sqrt{\sum_i{(f(x_i) - y_i)^2}}$$
or expressing the units explicitly
$$RMSE(y)=\frac{1}{N^2}\sqrt{\sum_i{(f(x_i)[u] - y_i[u])^2}}$$
developing this equation you get (treat u as a unitary constant that holds the units)
$$RMSE(y)=\frac{1}{N^2}\sqrt{\sum_i{((f(x_i) - y_i)[u])^2}}$$
$$RMSE(y)=\frac{1}{N^2}\sqrt{\sum_i{((f(x_i) - y_i))^2 [u]^2}}$$
$$RMSE(y)=\frac{1}{N^2}\sqrt{[u]^2\sum_i{((f(x_i) - y_i))^2}}$$
$$RMSE(y)=\frac{1}{N^2}[u]\sqrt{\sum_i{((f(x_i) - y_i))^2}}$$
$$RMSE(y)={[u]}\times{\frac{1}{N^2}\sqrt{\sum_i{((f(x_i) - y_i))^2}}}$$
Notice that the part on the right is a dimensionless variable multiplied by the constant representing the arbitrary unit. So, as @Gregor said, its units are the same as those of the outcome. | The unit of Root Mean Square Error (RMSE) | Let's say you have a model represented by the function $f(x)$ and you calculate the RMSE of the outcomes compared with the training set outcomes $y$. Let's also assume the outcome has some arbitrary u | The unit of Root Mean Square Error (RMSE)
Let's say you have a model represented by the function $f(x)$ and you calculate the RMSE of the outcomes compared with the training set outcomes $y$. Let's also assume the outcome has some arbitrary unit $u$.
The RMSE is
$$RMSE(y)=\frac{1}{N^2}\sqrt{\sum_i{(f(x_i) - y_i)^2}}$$
or expressing the units explicitly
$$RMSE(y)=\frac{1}{N^2}\sqrt{\sum_i{(f(x_i)[u] - y_i[u])^2}}$$
developing this equation you get (treat u as a unitary constant that holds the units)
$$RMSE(y)=\frac{1}{N^2}\sqrt{\sum_i{((f(x_i) - y_i)[u])^2}}$$
$$RMSE(y)=\frac{1}{N^2}\sqrt{\sum_i{((f(x_i) - y_i))^2 [u]^2}}$$
$$RMSE(y)=\frac{1}{N^2}\sqrt{[u]^2\sum_i{((f(x_i) - y_i))^2}}$$
$$RMSE(y)=\frac{1}{N^2}[u]\sqrt{\sum_i{((f(x_i) - y_i))^2}}$$
$$RMSE(y)={[u]}\times{\frac{1}{N^2}\sqrt{\sum_i{((f(x_i) - y_i))^2}}}$$
Notice that the part on the right is a dimensionless variable multiplied by the constant representing the arbitrary unit. So, as @Gregor said, its units are the same as those of the outcome. | The unit of Root Mean Square Error (RMSE)
Let's say you have a model represented by the function $f(x)$ and you calculate the RMSE of the outcomes compared with the training set outcomes $y$. Let's also assume the outcome has some arbitrary u |
36,558 | Motivation for gamma distribution with a non-integer parameter | It seems you are asking for "real-life" examples where gamma distributions are used to model some real-world observables represented by random variables. There are many such examples. Take the Erlang distribution you mention first: The integer parameter case follows from some theoretical probability model for waiting times, but for modelling directly real-world waiting times, the gamma family with non-integer parameter will give better flexibility. Some other examples can be found here: Real-life examples of common distributions
Gamma distributions can model positive random variables, precipitation insurance (A quote from that paper Climatologists prefer the gamma distribution because it is sufficiently flexible to adequately characterize cumulative precipitation over time periods of varying length and link to a freely accessible version).
Other insurance use of gamma regression, in hydrology for modeling rainfall or floods, ... Inventory control use of the Gamma distribution, quote from that paper: In the field of inventory control of finished goods we find that the observed frequency distributions of demand have the following general characteristics:
they exist only for non-negative values of demand
as the mean demand of items increases the observed distributions change
from:
(a) monotonic decreasing to
(b) unimodal distributions heavily skewed to the right, and finally to
(c) normal type distributions (truncated at zero)
... and they then observe that the Gamma family of distributions matches nicely this qualitative behavior. This is an important point in modeling, we are not only interested in how a certain individual distribution matches a particular dataset, we are interested in the general behavior of a family of distributions.
The classic McCullagh/Nelder chapter 8 "Models for data with constant coefficient of variation" mostly uses the gamma distribution, gamma regression. | Motivation for gamma distribution with a non-integer parameter | It seems you are asking for "real-life" examples where gamma distributions are used to model some real-world observables represented by random variables. There are many such examples. Take the Erlang | Motivation for gamma distribution with a non-integer parameter
It seems you are asking for "real-life" examples where gamma distributions are used to model some real-world observables represented by random variables. There are many such examples. Take the Erlang distribution you mention first: The integer parameter case follows from some theoretical probability model for waiting times, but for modelling directly real-world waiting times, the gamma family with non-integer parameter will give better flexibility. Some other examples can be found here: Real-life examples of common distributions
Gamma distributions can model positive random variables, precipitation insurance (A quote from that paper Climatologists prefer the gamma distribution because it is sufficiently flexible to adequately characterize cumulative precipitation over time periods of varying length and link to a freely accessible version).
Other insurance use of gamma regression, in hydrology for modeling rainfall or floods, ... Inventory control use of the Gamma distribution, quote from that paper: In the field of inventory control of finished goods we find that the observed frequency distributions of demand have the following general characteristics:
they exist only for non-negative values of demand
as the mean demand of items increases the observed distributions change
from:
(a) monotonic decreasing to
(b) unimodal distributions heavily skewed to the right, and finally to
(c) normal type distributions (truncated at zero)
... and they then observe that the Gamma family of distributions matches nicely this qualitative behavior. This is an important point in modeling, we are not only interested in how a certain individual distribution matches a particular dataset, we are interested in the general behavior of a family of distributions.
The classic McCullagh/Nelder chapter 8 "Models for data with constant coefficient of variation" mostly uses the gamma distribution, gamma regression. | Motivation for gamma distribution with a non-integer parameter
It seems you are asking for "real-life" examples where gamma distributions are used to model some real-world observables represented by random variables. There are many such examples. Take the Erlang |
36,559 | Motivation for gamma distribution with a non-integer parameter | Given a radioactive sample with unknown emission rate $\lambda$, the likelihood on $\lambda$ induced by observations of emissions is gamma distributed.
Given a normal process with known mean, but unknown precision, the induced likelihood on the precision is gamma distributed.
And similarly for Pareto and gamma models. | Motivation for gamma distribution with a non-integer parameter | Given a radioactive sample with unknown emission rate $\lambda$, the likelihood on $\lambda$ induced by observations of emissions is gamma distributed.
Given a normal process with known mean, but unkn | Motivation for gamma distribution with a non-integer parameter
Given a radioactive sample with unknown emission rate $\lambda$, the likelihood on $\lambda$ induced by observations of emissions is gamma distributed.
Given a normal process with known mean, but unknown precision, the induced likelihood on the precision is gamma distributed.
And similarly for Pareto and gamma models. | Motivation for gamma distribution with a non-integer parameter
Given a radioactive sample with unknown emission rate $\lambda$, the likelihood on $\lambda$ induced by observations of emissions is gamma distributed.
Given a normal process with known mean, but unkn |
36,560 | Interpreting parametric and non-parametric testing | This is a welcome opportunity to discuss and clarify what statistical models mean and how we ought to think about them. Let's begin with definitions, so that the scope of this answer is in no doubt, and move on from there. To keep this post short, I will limit the examples and forgo all illustrations, trusting the reader to be able to supply them from experience.
Definitions
It looks possible to understand "test" in a very general sense as meaning any kind of statistical procedure: not only a null hypothesis test, but also estimation, prediction, and decision making, in either a Frequentist or Bayesian framework. That is because the distinction between "parametric" and "non-parametric" is separate from distinctions between types of procedures or distinctions between these frameworks.
In any event, what makes a procedure statistical is that it models the world with probability distributions whose characteristics are not fully known. Quite abstractly, we conceive of data $X$ as arising by numerically coding the values of objects $\omega\in\Omega$; the particular data we are using correspond to a particular $\omega$; and there is a probability law $F$ that somehow determined the $\omega$ we actually have.
This probability law is assumed to belong to some set $\Theta$. In a parametric setting, the elements $F\in\Theta$ correspond to finite collections of numbers $\theta(F)$, the parameters. In a non-parametric setting, there is no such correspondence. This usually is because we are unwilling to make strong assumptions about $F$.
The Nature of Models
It seems useful to make a further distinction that is rarely discussed. In some circumstances, $F$ is sure to be a fully accurate model for the data. Rather than define what I mean by "fully accurate," let me give an example. Take a survey of a finite, well-defined population in which the observations are binary, none will be missing, and there is no possibility of measurement error. An example might be destructive testing of a random sample of objects coming off an assembly line, for instance. The control we have over this situation--knowing the population and being able to select the sample truly randomly--assures the correctness of a Binomial model for the resulting counts.
In many--perhaps most--other cases, $\Theta$ is not "fully accurate." For instance, many analyses assume (either implicitly or explicitly) that $F$ is a Normal distribution. That's always physically impossible, because any actual measurement is subject to physical constraints on its possible range, whereas there are no such constraints on Normal distributions. We know at the outset that Normal assumptions are wrong!
To what extent is a not-fully-accurate model a problem? Consider what good physicists do. When a physicist uses Newtonian mechanics to solve a problem, it is because she knows that at this particular scale--these masses, these distances, these speeds--Newtonian mechanics is more than accurate enough to work. She will elect to complicate her analysis by considering quantum or relativistic effects (or both) only when the problem requires it. She is familiar with theorems that show, quantitatively, how Newtonian mechanics is a limiting case of quantum mechanics and of special relativity. Those theorems help her understand which theory to choose. This selection is usually not documented or even defended; it may even occur unconsciously: the choice is obvious.
A good statistician always has comparable considerations in mind. When she selects a procedure whose justification relies on a Normality assumption, for instance, she is weighing the extent to which the actual $F$ might depart from Normal behavior and how that could affect the procedure. In many cases the likely effect is so small that it needn't even be quantified: she "assumes Normality." In other cases the likely effect is unknown. In such circumstances she will run diagnostic tests to evaluate the departures from Normality and their effects on the results.
Consequences
It's starting to sound like the not-fully-accurate setting is hardly distinct from the nonparametric one: is there really any difference between assuming a parametric model and evaluating how reality departs from it, one the one hand, and assuming a non-parametric model on the other hand? Deep down, both are non-parametric.
In light of this discussion, let's reconsider conventional distinctions between parametric and non-parametric procedures.
"Non-parametric procedures are robust." So, to some extent, must all procedures be. The issue is not of robustness vs non-robustness, but how robust any procedure is. Just how much, and in what ways, does the true $F$ depart from the distributions in the assumed $\Theta$? As a function of those departures, how much are the test results affected? These are basic questions that apply in any setting, parametric or not.
"Non-parametric procedures don't require goodness-of-fit testing or distributional testing." This isn't generally true. "Non-parametric" is often mistakenly characterized as "distribution-free," in the sense of allowing $F$ to be literally any distribution, but this is almost never the case. Almost all non-parametric procedures do make assumptions that restrict $\Theta$. For instance, $X$ might be split into two sets for comparison, with a distribution $F_0$ governing one set and another distribution $F_1$ governing the other. Perhaps no assumption is made at all about $F_0$, but $F_1$ is assumed to be translated version of $F_0$. That's what many comparisons of central tendency assume. The point is that there is a definite assumption made about $F$ in such tests and it deserves to be checked just as much as any parametric assumption might be.
"Non-parametric procedures don't make assumptions." We have seen that they do. They only tend to make less-constraining assumptions than parametric procedures.
An undue focus on parametric vs non-parametric might be a counterproductive approach. It overlooks the main objective of statistical procedures, which is to improve understanding, make good decisions, or take appropriate action. Statistical procedures are selected based on how well they can be expected to perform in the problem context, in light of all other information and assumptions about the problem, and with regard to the consequences to all stakeholders in the outcome.
The answer to "do these distinctions matter" would therefore appear to be "not really." | Interpreting parametric and non-parametric testing | This is a welcome opportunity to discuss and clarify what statistical models mean and how we ought to think about them. Let's begin with definitions, so that the scope of this answer is in no doubt, | Interpreting parametric and non-parametric testing
This is a welcome opportunity to discuss and clarify what statistical models mean and how we ought to think about them. Let's begin with definitions, so that the scope of this answer is in no doubt, and move on from there. To keep this post short, I will limit the examples and forgo all illustrations, trusting the reader to be able to supply them from experience.
Definitions
It looks possible to understand "test" in a very general sense as meaning any kind of statistical procedure: not only a null hypothesis test, but also estimation, prediction, and decision making, in either a Frequentist or Bayesian framework. That is because the distinction between "parametric" and "non-parametric" is separate from distinctions between types of procedures or distinctions between these frameworks.
In any event, what makes a procedure statistical is that it models the world with probability distributions whose characteristics are not fully known. Quite abstractly, we conceive of data $X$ as arising by numerically coding the values of objects $\omega\in\Omega$; the particular data we are using correspond to a particular $\omega$; and there is a probability law $F$ that somehow determined the $\omega$ we actually have.
This probability law is assumed to belong to some set $\Theta$. In a parametric setting, the elements $F\in\Theta$ correspond to finite collections of numbers $\theta(F)$, the parameters. In a non-parametric setting, there is no such correspondence. This usually is because we are unwilling to make strong assumptions about $F$.
The Nature of Models
It seems useful to make a further distinction that is rarely discussed. In some circumstances, $F$ is sure to be a fully accurate model for the data. Rather than define what I mean by "fully accurate," let me give an example. Take a survey of a finite, well-defined population in which the observations are binary, none will be missing, and there is no possibility of measurement error. An example might be destructive testing of a random sample of objects coming off an assembly line, for instance. The control we have over this situation--knowing the population and being able to select the sample truly randomly--assures the correctness of a Binomial model for the resulting counts.
In many--perhaps most--other cases, $\Theta$ is not "fully accurate." For instance, many analyses assume (either implicitly or explicitly) that $F$ is a Normal distribution. That's always physically impossible, because any actual measurement is subject to physical constraints on its possible range, whereas there are no such constraints on Normal distributions. We know at the outset that Normal assumptions are wrong!
To what extent is a not-fully-accurate model a problem? Consider what good physicists do. When a physicist uses Newtonian mechanics to solve a problem, it is because she knows that at this particular scale--these masses, these distances, these speeds--Newtonian mechanics is more than accurate enough to work. She will elect to complicate her analysis by considering quantum or relativistic effects (or both) only when the problem requires it. She is familiar with theorems that show, quantitatively, how Newtonian mechanics is a limiting case of quantum mechanics and of special relativity. Those theorems help her understand which theory to choose. This selection is usually not documented or even defended; it may even occur unconsciously: the choice is obvious.
A good statistician always has comparable considerations in mind. When she selects a procedure whose justification relies on a Normality assumption, for instance, she is weighing the extent to which the actual $F$ might depart from Normal behavior and how that could affect the procedure. In many cases the likely effect is so small that it needn't even be quantified: she "assumes Normality." In other cases the likely effect is unknown. In such circumstances she will run diagnostic tests to evaluate the departures from Normality and their effects on the results.
Consequences
It's starting to sound like the not-fully-accurate setting is hardly distinct from the nonparametric one: is there really any difference between assuming a parametric model and evaluating how reality departs from it, one the one hand, and assuming a non-parametric model on the other hand? Deep down, both are non-parametric.
In light of this discussion, let's reconsider conventional distinctions between parametric and non-parametric procedures.
"Non-parametric procedures are robust." So, to some extent, must all procedures be. The issue is not of robustness vs non-robustness, but how robust any procedure is. Just how much, and in what ways, does the true $F$ depart from the distributions in the assumed $\Theta$? As a function of those departures, how much are the test results affected? These are basic questions that apply in any setting, parametric or not.
"Non-parametric procedures don't require goodness-of-fit testing or distributional testing." This isn't generally true. "Non-parametric" is often mistakenly characterized as "distribution-free," in the sense of allowing $F$ to be literally any distribution, but this is almost never the case. Almost all non-parametric procedures do make assumptions that restrict $\Theta$. For instance, $X$ might be split into two sets for comparison, with a distribution $F_0$ governing one set and another distribution $F_1$ governing the other. Perhaps no assumption is made at all about $F_0$, but $F_1$ is assumed to be translated version of $F_0$. That's what many comparisons of central tendency assume. The point is that there is a definite assumption made about $F$ in such tests and it deserves to be checked just as much as any parametric assumption might be.
"Non-parametric procedures don't make assumptions." We have seen that they do. They only tend to make less-constraining assumptions than parametric procedures.
An undue focus on parametric vs non-parametric might be a counterproductive approach. It overlooks the main objective of statistical procedures, which is to improve understanding, make good decisions, or take appropriate action. Statistical procedures are selected based on how well they can be expected to perform in the problem context, in light of all other information and assumptions about the problem, and with regard to the consequences to all stakeholders in the outcome.
The answer to "do these distinctions matter" would therefore appear to be "not really." | Interpreting parametric and non-parametric testing
This is a welcome opportunity to discuss and clarify what statistical models mean and how we ought to think about them. Let's begin with definitions, so that the scope of this answer is in no doubt, |
36,561 | Most well-known set-similarity measures? | Other measures are:
Overlap Coefficient: $\frac{|A \cap B|}{min(|A|,|B|)}$
Tversky index: $|A\cap B| + \alpha|A\setminus B| + \beta|B \setminus A|$ where $\alpha$ and $\beta$ are positive numbers. | Most well-known set-similarity measures? | Other measures are:
Overlap Coefficient: $\frac{|A \cap B|}{min(|A|,|B|)}$
Tversky index: $|A\cap B| + \alpha|A\setminus B| + \beta|B \setminus A|$ where $\alpha$ and $\beta$ are positive numbers. | Most well-known set-similarity measures?
Other measures are:
Overlap Coefficient: $\frac{|A \cap B|}{min(|A|,|B|)}$
Tversky index: $|A\cap B| + \alpha|A\setminus B| + \beta|B \setminus A|$ where $\alpha$ and $\beta$ are positive numbers. | Most well-known set-similarity measures?
Other measures are:
Overlap Coefficient: $\frac{|A \cap B|}{min(|A|,|B|)}$
Tversky index: $|A\cap B| + \alpha|A\setminus B| + \beta|B \setminus A|$ where $\alpha$ and $\beta$ are positive numbers. |
36,562 | Why do we assume the exponential family in the GLM context? | When I discovered GLM I also wondered why it was always based on the exponential family. I have never answered to that question clearly. But...
I call $h$ the reciprocal of the link function. $\beta$ the parameter.
When I first learned about Generalized Linear Models I thought that
the assumption that the dependent variable follows some distribution
from the exponential family was made to simplify calculations.
Yes. I used it with stochastic gradient descent (SGD), and the update rule of SGD (the gradient) is made especially simple in the canonical GLM case. See http://proceedings.mlr.press/v32/toulis14.pdf prop 3.1 and paragraph 3.1. Finally it all works in a way that is similar to least squares (minimize average $(Y-h(\beta X))^2$) but even simpler. The interpretation of the update rule is made quite simple. For some sample $(x,y)$ :
compute what you expect as a mean for $y$ (that is $h(\beta x)$)
compare it with real observed $y$,
correct you parameter $\beta$ proportionality to the difference (and $x$)
Without the exp family and canonical link, the error would be multiplied by something dependant on $x$ (and maybe $y$). It would be a sort of refinement of the basic idea : varying the intensity of the correction. It gives different weights to the samples. With least square, you have to multiply by $h'(\beta x)$. Some practical tests of mine in a case with a lot of data showed it was less good (for reasons I'm incapable of explaining).
Thus, it is enough to specify the link function to uniquely specify
the distribution.
Yes again.
Also pre-existing logistic regression and Poisson regression fit into the canonical GLM framework. Probably one more (historical) explanation of using the exp family + canonical link.
Maybe, "why assume the exp family in GLM" is similar to "why assume a normal noise in linear regression". For theoretical good properties and simple calculations... But does it always matter so much in practice ? Real data rarely have normal noise in cases when linear regression still works very well.
What was fundamentally useful (for me) about GLM is the difference with transformed linear regression :
Transformed linear regression : $E(h^{-1}(Y))=\beta X$
GLM : $E(Y)=h(\beta X)$
This changes everything :
Transformed linear regression : the estimation of the mean of $h^{-1}(Y)$ (conditionally to any function of $X$) is unbiased.
GLM : the estimation of the mean of $Y$ (conditionally to any function of $X$) is unbiased.
I'm not familiar with VGLM so I can't answer about it. | Why do we assume the exponential family in the GLM context? | When I discovered GLM I also wondered why it was always based on the exponential family. I have never answered to that question clearly. But...
I call $h$ the reciprocal of the link function. $\beta$ | Why do we assume the exponential family in the GLM context?
When I discovered GLM I also wondered why it was always based on the exponential family. I have never answered to that question clearly. But...
I call $h$ the reciprocal of the link function. $\beta$ the parameter.
When I first learned about Generalized Linear Models I thought that
the assumption that the dependent variable follows some distribution
from the exponential family was made to simplify calculations.
Yes. I used it with stochastic gradient descent (SGD), and the update rule of SGD (the gradient) is made especially simple in the canonical GLM case. See http://proceedings.mlr.press/v32/toulis14.pdf prop 3.1 and paragraph 3.1. Finally it all works in a way that is similar to least squares (minimize average $(Y-h(\beta X))^2$) but even simpler. The interpretation of the update rule is made quite simple. For some sample $(x,y)$ :
compute what you expect as a mean for $y$ (that is $h(\beta x)$)
compare it with real observed $y$,
correct you parameter $\beta$ proportionality to the difference (and $x$)
Without the exp family and canonical link, the error would be multiplied by something dependant on $x$ (and maybe $y$). It would be a sort of refinement of the basic idea : varying the intensity of the correction. It gives different weights to the samples. With least square, you have to multiply by $h'(\beta x)$. Some practical tests of mine in a case with a lot of data showed it was less good (for reasons I'm incapable of explaining).
Thus, it is enough to specify the link function to uniquely specify
the distribution.
Yes again.
Also pre-existing logistic regression and Poisson regression fit into the canonical GLM framework. Probably one more (historical) explanation of using the exp family + canonical link.
Maybe, "why assume the exp family in GLM" is similar to "why assume a normal noise in linear regression". For theoretical good properties and simple calculations... But does it always matter so much in practice ? Real data rarely have normal noise in cases when linear regression still works very well.
What was fundamentally useful (for me) about GLM is the difference with transformed linear regression :
Transformed linear regression : $E(h^{-1}(Y))=\beta X$
GLM : $E(Y)=h(\beta X)$
This changes everything :
Transformed linear regression : the estimation of the mean of $h^{-1}(Y)$ (conditionally to any function of $X$) is unbiased.
GLM : the estimation of the mean of $Y$ (conditionally to any function of $X$) is unbiased.
I'm not familiar with VGLM so I can't answer about it. | Why do we assume the exponential family in the GLM context?
When I discovered GLM I also wondered why it was always based on the exponential family. I have never answered to that question clearly. But...
I call $h$ the reciprocal of the link function. $\beta$ |
36,563 | Why is selection of one amongst the group of highly correlated variables by lasso is stated as its disadvantage? | Principal Components Analysis (PCA) doesn't select among the original features unless the features are orthogonal. It lowers the dimension of the feature space by ignoring PCs (linear combinations of potentially all the predictors) that explain little of the feature-set variance, but in general it does not remove any of the original features from the problem.
Some find the ability of LASSO to choose among several correlated features to be a strength rather than a weakness, particularly when the number of features greatly exceeds the number of cases. Yes, LASSO's choice among correlated features can be highly sample dependent. Nevertheless, as LASSO penalizes the coefficients for the retained variables it can still be useful for developing prediction models. The "disadvantage" is when one tries to interpret the selection by LASSO in terms of "variable importance" for inference.
The issues raised in this question point out a potential advantage of ridge regression, which is effectively PCA with varying weights among the PCs rather than simple 0/1 weights. (See page 79 of ESLII.) Try both LASSO and ridge regression on multiple bootstrap samples of a data set having correlated predictors. The particular features selected by LASSO may change dramatically among the bootstrap samples. This illustrates the mistake of interpreting choices by LASSO in terms of an underlying true "variable importance." The coefficients of correlated predictors in ridge regression may be variable among bootstrap samples but the ridge models will contain all the features. | Why is selection of one amongst the group of highly correlated variables by lasso is stated as its d | Principal Components Analysis (PCA) doesn't select among the original features unless the features are orthogonal. It lowers the dimension of the feature space by ignoring PCs (linear combinations of | Why is selection of one amongst the group of highly correlated variables by lasso is stated as its disadvantage?
Principal Components Analysis (PCA) doesn't select among the original features unless the features are orthogonal. It lowers the dimension of the feature space by ignoring PCs (linear combinations of potentially all the predictors) that explain little of the feature-set variance, but in general it does not remove any of the original features from the problem.
Some find the ability of LASSO to choose among several correlated features to be a strength rather than a weakness, particularly when the number of features greatly exceeds the number of cases. Yes, LASSO's choice among correlated features can be highly sample dependent. Nevertheless, as LASSO penalizes the coefficients for the retained variables it can still be useful for developing prediction models. The "disadvantage" is when one tries to interpret the selection by LASSO in terms of "variable importance" for inference.
The issues raised in this question point out a potential advantage of ridge regression, which is effectively PCA with varying weights among the PCs rather than simple 0/1 weights. (See page 79 of ESLII.) Try both LASSO and ridge regression on multiple bootstrap samples of a data set having correlated predictors. The particular features selected by LASSO may change dramatically among the bootstrap samples. This illustrates the mistake of interpreting choices by LASSO in terms of an underlying true "variable importance." The coefficients of correlated predictors in ridge regression may be variable among bootstrap samples but the ridge models will contain all the features. | Why is selection of one amongst the group of highly correlated variables by lasso is stated as its d
Principal Components Analysis (PCA) doesn't select among the original features unless the features are orthogonal. It lowers the dimension of the feature space by ignoring PCs (linear combinations of |
36,564 | Why is selection of one amongst the group of highly correlated variables by lasso is stated as its disadvantage? | Using PCA to do feature selection is different than using LASSO because PCA does not consider the response variable, but only check the variance in features.
See my answers here, with graphical illustration (logistic regression case / linear method without regularization).
How to decide between PCA and logistic regression? | Why is selection of one amongst the group of highly correlated variables by lasso is stated as its d | Using PCA to do feature selection is different than using LASSO because PCA does not consider the response variable, but only check the variance in features.
See my answers here, with graphical illust | Why is selection of one amongst the group of highly correlated variables by lasso is stated as its disadvantage?
Using PCA to do feature selection is different than using LASSO because PCA does not consider the response variable, but only check the variance in features.
See my answers here, with graphical illustration (logistic regression case / linear method without regularization).
How to decide between PCA and logistic regression? | Why is selection of one amongst the group of highly correlated variables by lasso is stated as its d
Using PCA to do feature selection is different than using LASSO because PCA does not consider the response variable, but only check the variance in features.
See my answers here, with graphical illust |
36,565 | Generate simulated data with predefined partial correlation structure | Why not just create data following your causal model? If the model is $X \leftarrow Z \rightarrow Y$, then just create random $Z$, and build $X$ as some function of $Z$ plus noise (same for $Y$). (I left error SD=1, but just set it higher to get more realistic significance.)
> set.seed(100)
> z = rnorm(500)
> x = z + rnorm(500, 0, 1)
> y = z + rnorm(500, 0, 1)
In the uncontrolled model, you will get fake association between $X$ and $Y$, as requested:
> summary(lm(y ~ x))
Call:
lm(formula = y ~ x)
Residuals:
Min 1Q Median 3Q Max
-3.1534 -0.8674 0.0423 0.8893 4.0521
Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) -0.06574 0.05513 -1.192 0.234
x 0.49819 0.03809 13.081 <2e-16 ***
---
Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
Residual standard error: 1.233 on 498 degrees of freedom
Multiple R-squared: 0.2557, Adjusted R-squared: 0.2542
F-statistic: 171.1 on 1 and 498 DF, p-value: < 2.2e-16
Association with $X$ disappears upon proper controlling:
> summary(lm(y ~ x + z))
Call:
lm(formula = y ~ x + z)
Residuals:
Min 1Q Median 3Q Max
-3.03113 -0.70603 0.04694 0.62110 2.89843
Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) -0.01238 0.04464 -0.277 0.782
x 0.02431 0.04228 0.575 0.566
z 0.99553 0.06095 16.334 <2e-16 ***
---
Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
Residual standard error: 0.9952 on 497 degrees of freedom
Multiple R-squared: 0.5157, Adjusted R-squared: 0.5138
F-statistic: 264.6 on 2 and 497 DF, p-value: < 2.2e-16 | Generate simulated data with predefined partial correlation structure | Why not just create data following your causal model? If the model is $X \leftarrow Z \rightarrow Y$, then just create random $Z$, and build $X$ as some function of $Z$ plus noise (same for $Y$). (I l | Generate simulated data with predefined partial correlation structure
Why not just create data following your causal model? If the model is $X \leftarrow Z \rightarrow Y$, then just create random $Z$, and build $X$ as some function of $Z$ plus noise (same for $Y$). (I left error SD=1, but just set it higher to get more realistic significance.)
> set.seed(100)
> z = rnorm(500)
> x = z + rnorm(500, 0, 1)
> y = z + rnorm(500, 0, 1)
In the uncontrolled model, you will get fake association between $X$ and $Y$, as requested:
> summary(lm(y ~ x))
Call:
lm(formula = y ~ x)
Residuals:
Min 1Q Median 3Q Max
-3.1534 -0.8674 0.0423 0.8893 4.0521
Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) -0.06574 0.05513 -1.192 0.234
x 0.49819 0.03809 13.081 <2e-16 ***
---
Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
Residual standard error: 1.233 on 498 degrees of freedom
Multiple R-squared: 0.2557, Adjusted R-squared: 0.2542
F-statistic: 171.1 on 1 and 498 DF, p-value: < 2.2e-16
Association with $X$ disappears upon proper controlling:
> summary(lm(y ~ x + z))
Call:
lm(formula = y ~ x + z)
Residuals:
Min 1Q Median 3Q Max
-3.03113 -0.70603 0.04694 0.62110 2.89843
Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) -0.01238 0.04464 -0.277 0.782
x 0.02431 0.04228 0.575 0.566
z 0.99553 0.06095 16.334 <2e-16 ***
---
Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
Residual standard error: 0.9952 on 497 degrees of freedom
Multiple R-squared: 0.5157, Adjusted R-squared: 0.5138
F-statistic: 264.6 on 2 and 497 DF, p-value: < 2.2e-16 | Generate simulated data with predefined partial correlation structure
Why not just create data following your causal model? If the model is $X \leftarrow Z \rightarrow Y$, then just create random $Z$, and build $X$ as some function of $Z$ plus noise (same for $Y$). (I l |
36,566 | Meaning of low power in neuroscience after combining results of many meta-analyses (Button et al 2013) | I'm not familiar with this particular study but am familiar with estimating the power of an area of research using a meta-analysis. Your statement that "post hoc power is always inherently associated to the achieved p-values" suggests to me that you are assuming that the post hoc power for each individual study contributing to a single meta-analysis is based on the assumption that the observed effect equals the true population effect. Only with that assumption will the post hoc power be related to the p-value (I personally find this form of post hoc power analysis to be pointless, but that is a bit off topic).
What I believe the authors of this paper are doing, given that it is what is typically done, is to assume that the meta-analytic mean is the true population effect and to estimate power for the studies contributing to that mean using that value, not each study's observed effect. Thus, the mean power within a meta-analysis is a function of the overall meta-analytic mean effect and the sample sizes (or standard errors) of the individual studies. They did this for each meta-analysis and computed the median power across them. | Meaning of low power in neuroscience after combining results of many meta-analyses (Button et al 201 | I'm not familiar with this particular study but am familiar with estimating the power of an area of research using a meta-analysis. Your statement that "post hoc power is always inherently associated | Meaning of low power in neuroscience after combining results of many meta-analyses (Button et al 2013)
I'm not familiar with this particular study but am familiar with estimating the power of an area of research using a meta-analysis. Your statement that "post hoc power is always inherently associated to the achieved p-values" suggests to me that you are assuming that the post hoc power for each individual study contributing to a single meta-analysis is based on the assumption that the observed effect equals the true population effect. Only with that assumption will the post hoc power be related to the p-value (I personally find this form of post hoc power analysis to be pointless, but that is a bit off topic).
What I believe the authors of this paper are doing, given that it is what is typically done, is to assume that the meta-analytic mean is the true population effect and to estimate power for the studies contributing to that mean using that value, not each study's observed effect. Thus, the mean power within a meta-analysis is a function of the overall meta-analytic mean effect and the sample sizes (or standard errors) of the individual studies. They did this for each meta-analysis and computed the median power across them. | Meaning of low power in neuroscience after combining results of many meta-analyses (Button et al 201
I'm not familiar with this particular study but am familiar with estimating the power of an area of research using a meta-analysis. Your statement that "post hoc power is always inherently associated |
36,567 | Convergence concept for MonteCarlo(?) simulation of a tournament | Is this a Monte Carlo simulation / a naive way of drawing from a distribution?
Yes, this is a Monte Carlo simulation. There's nothing wrong with this tactic.
What is the relevant convergence concept that tells me that as the number of draws goes to infinity, my draws converge in (say) distribution to the true distribution?
You're looking for the Law of Large Numbers, which says that for any individual event $E_i$ and its probability $p_i$, the estimator $\hat p_i \equiv x_i/n_i$ converges to the true value ($x_i$=number of trials where $E_i$ occurs, $n_i$ = number of trials total).
The variance of your estimator is $p_i (1-p_i) / n$. A few more useful convergence results:
The Central Limit Theorem says your estimator is asymptotically Gaussian with that variance. (Since the variance goes to 0, it's more precise to say that $\sqrt n\hat p_i$ has a limiting distribution that is Gaussian with variance $p_i (1-p_i)$.)
The Continuous Mapping Theorem says you can plug your estimate $\hat p_i$ into the variance expression above (in place of $p_i$) and it will converge to the correct variance.
Slutsky's Theorem says that you can combine those two results to calculate asymptotic 95% confidence intervals for your estimates as $\hat p_i \pm 1.96*\hat\sigma_n$, where $\hat \sigma_n = \sqrt{\hat p_i (1-\hat p_i) / n}$.
What are the assumptions needed for convergence? What in this setup would make this simulation not converge?
These convergence results are only approximations: in real life, we don't have infinite samples. This might become a practical problem for you if you have rare events (e.g. if the probability team A wins the tournament is 0.00000001). After 100k runs, your estimate will be zero and your confidence interval will have zero width. This is a huge relative error.
When you're working with binary data, these results are guaranteed to apply. If you were dealing with quantitative variables, it would be possible to run into situations where the asymptotic results "kick in" slowly or not at all.
Here's a scaffold for how to do the calculations exactly. You have teams A, B, C, D and six games $G_1 ... G_6$. Each game is binary, so you have only 64 possible outcomes. Let $E_j, q_j$ be the event and probability that game $G_j$ goes to the team earlier in the alphabet. The games are independent, so the probability of a particular outcome $E_1 \land E_2 \land \lnot E_3 \dots $ is just the product $q_1q_2(1-q_3)\dots$ et cetera. For a bigger event such as "A wins the tournament", compute a dataframe with one row for every possible tournament outcome. You can use eight columns: one each for the outcomes of the six games, one for the probability, and one for "Did Team A win? (0 if no, 1 if yes)." Then take a dot product of the last two columns (equivalently, sum up the probabilities of the potential tournaments where A wins). | Convergence concept for MonteCarlo(?) simulation of a tournament | Is this a Monte Carlo simulation / a naive way of drawing from a distribution?
Yes, this is a Monte Carlo simulation. There's nothing wrong with this tactic.
What is the relevant convergence concept t | Convergence concept for MonteCarlo(?) simulation of a tournament
Is this a Monte Carlo simulation / a naive way of drawing from a distribution?
Yes, this is a Monte Carlo simulation. There's nothing wrong with this tactic.
What is the relevant convergence concept that tells me that as the number of draws goes to infinity, my draws converge in (say) distribution to the true distribution?
You're looking for the Law of Large Numbers, which says that for any individual event $E_i$ and its probability $p_i$, the estimator $\hat p_i \equiv x_i/n_i$ converges to the true value ($x_i$=number of trials where $E_i$ occurs, $n_i$ = number of trials total).
The variance of your estimator is $p_i (1-p_i) / n$. A few more useful convergence results:
The Central Limit Theorem says your estimator is asymptotically Gaussian with that variance. (Since the variance goes to 0, it's more precise to say that $\sqrt n\hat p_i$ has a limiting distribution that is Gaussian with variance $p_i (1-p_i)$.)
The Continuous Mapping Theorem says you can plug your estimate $\hat p_i$ into the variance expression above (in place of $p_i$) and it will converge to the correct variance.
Slutsky's Theorem says that you can combine those two results to calculate asymptotic 95% confidence intervals for your estimates as $\hat p_i \pm 1.96*\hat\sigma_n$, where $\hat \sigma_n = \sqrt{\hat p_i (1-\hat p_i) / n}$.
What are the assumptions needed for convergence? What in this setup would make this simulation not converge?
These convergence results are only approximations: in real life, we don't have infinite samples. This might become a practical problem for you if you have rare events (e.g. if the probability team A wins the tournament is 0.00000001). After 100k runs, your estimate will be zero and your confidence interval will have zero width. This is a huge relative error.
When you're working with binary data, these results are guaranteed to apply. If you were dealing with quantitative variables, it would be possible to run into situations where the asymptotic results "kick in" slowly or not at all.
Here's a scaffold for how to do the calculations exactly. You have teams A, B, C, D and six games $G_1 ... G_6$. Each game is binary, so you have only 64 possible outcomes. Let $E_j, q_j$ be the event and probability that game $G_j$ goes to the team earlier in the alphabet. The games are independent, so the probability of a particular outcome $E_1 \land E_2 \land \lnot E_3 \dots $ is just the product $q_1q_2(1-q_3)\dots$ et cetera. For a bigger event such as "A wins the tournament", compute a dataframe with one row for every possible tournament outcome. You can use eight columns: one each for the outcomes of the six games, one for the probability, and one for "Did Team A win? (0 if no, 1 if yes)." Then take a dot product of the last two columns (equivalently, sum up the probabilities of the potential tournaments where A wins). | Convergence concept for MonteCarlo(?) simulation of a tournament
Is this a Monte Carlo simulation / a naive way of drawing from a distribution?
Yes, this is a Monte Carlo simulation. There's nothing wrong with this tactic.
What is the relevant convergence concept t |
36,568 | Why don't we consider nonlinear estimators for the parameters of linear regression models? | In mathematics rarely things are developed in the way they're presented in textbooks. That's the real reason. Here's the explanation.
First, someone came up with a problem to fit $$y=X\beta+\varepsilon$$, i.e. find the "best" in some respect set of parameters $\beta$. Whoever did this didn't think that the solution would be a liner combination of $y$'s. He simply thought about what would be the criterion to pick the "best" solution, and came up with minimizing the sum of squared errors $\varepsilon'\varepsilon$. This is a very reasonable criterion for many people. So, he went on and formulated the optimization problem:
$$\min_\beta \varepsilon'\varepsilon=\min_\beta(y-X\beta)'(y-X\beta)$$
When the guy solved the problem, he was amazed that the solution turned out to be a linear combination of $y$'s:
$$(X'X)^{-1}X'y$$
He wasn't looking for solutions that are BLUE or linear. He was just looking for a solution of least squares problem. Then his friends jumped on to study this solution from different angles and came up with Gauss-Markov theorem, BLUE etc.
After this was all done people today look at all kinds of formulations of "best" solution criteria, they're not simply sums of squared errors anymore. Some people want to also have "small" $\beta$, which leads to all kinds of shrinkage methods that are not BLUE or linear anymore, and so on.
I like your question a lot because it separates out the linear model specification $X\beta$ on independent variables and the fact that the solution is a linear combination of dependent variables $Cy$. In order to come from the latter to the former one needs special kind of goodness-of-fit criteria, such as minimum of sum of squares. Other goodness-of-fit criteria may lead to non-linear (on $y$) solutions. | Why don't we consider nonlinear estimators for the parameters of linear regression models? | In mathematics rarely things are developed in the way they're presented in textbooks. That's the real reason. Here's the explanation.
First, someone came up with a problem to fit $$y=X\beta+\varepsilo | Why don't we consider nonlinear estimators for the parameters of linear regression models?
In mathematics rarely things are developed in the way they're presented in textbooks. That's the real reason. Here's the explanation.
First, someone came up with a problem to fit $$y=X\beta+\varepsilon$$, i.e. find the "best" in some respect set of parameters $\beta$. Whoever did this didn't think that the solution would be a liner combination of $y$'s. He simply thought about what would be the criterion to pick the "best" solution, and came up with minimizing the sum of squared errors $\varepsilon'\varepsilon$. This is a very reasonable criterion for many people. So, he went on and formulated the optimization problem:
$$\min_\beta \varepsilon'\varepsilon=\min_\beta(y-X\beta)'(y-X\beta)$$
When the guy solved the problem, he was amazed that the solution turned out to be a linear combination of $y$'s:
$$(X'X)^{-1}X'y$$
He wasn't looking for solutions that are BLUE or linear. He was just looking for a solution of least squares problem. Then his friends jumped on to study this solution from different angles and came up with Gauss-Markov theorem, BLUE etc.
After this was all done people today look at all kinds of formulations of "best" solution criteria, they're not simply sums of squared errors anymore. Some people want to also have "small" $\beta$, which leads to all kinds of shrinkage methods that are not BLUE or linear anymore, and so on.
I like your question a lot because it separates out the linear model specification $X\beta$ on independent variables and the fact that the solution is a linear combination of dependent variables $Cy$. In order to come from the latter to the former one needs special kind of goodness-of-fit criteria, such as minimum of sum of squares. Other goodness-of-fit criteria may lead to non-linear (on $y$) solutions. | Why don't we consider nonlinear estimators for the parameters of linear regression models?
In mathematics rarely things are developed in the way they're presented in textbooks. That's the real reason. Here's the explanation.
First, someone came up with a problem to fit $$y=X\beta+\varepsilo |
36,569 | Why don't we consider nonlinear estimators for the parameters of linear regression models? | When the error term is not Gaussian, it will generally be the case that the best estimators (e.g. in terms of MSE) are not linear.
In some cases, all linear estimators may be arbitrarily bad. (It's not always so clear what all the fuss about being BLUE is, when even the best linear estimator may be terrible.)
So for example if the tails of the conditional distribution of the dependent variable are made heavier and heavier, you need give less and less weight to values further away, or the variance of the parameter estimates can be increased beyond any bound.
[Nonlinear estimators include more than just powers, though.] | Why don't we consider nonlinear estimators for the parameters of linear regression models? | When the error term is not Gaussian, it will generally be the case that the best estimators (e.g. in terms of MSE) are not linear.
In some cases, all linear estimators may be arbitrarily bad. (It's | Why don't we consider nonlinear estimators for the parameters of linear regression models?
When the error term is not Gaussian, it will generally be the case that the best estimators (e.g. in terms of MSE) are not linear.
In some cases, all linear estimators may be arbitrarily bad. (It's not always so clear what all the fuss about being BLUE is, when even the best linear estimator may be terrible.)
So for example if the tails of the conditional distribution of the dependent variable are made heavier and heavier, you need give less and less weight to values further away, or the variance of the parameter estimates can be increased beyond any bound.
[Nonlinear estimators include more than just powers, though.] | Why don't we consider nonlinear estimators for the parameters of linear regression models?
When the error term is not Gaussian, it will generally be the case that the best estimators (e.g. in terms of MSE) are not linear.
In some cases, all linear estimators may be arbitrarily bad. (It's |
36,570 | Why don't we consider nonlinear estimators for the parameters of linear regression models? | The question is how you find $\beta$? How do you actually derive OLS? You differentiate according to a certain parameter, and you get a set of equations, which you then solve. If $\beta$ is not linear in the model equation, the solution will not be a linear combination of $Y$. (It will probably not be a linear combination of a transformation of $Y$ either - which is what your $\widetilde{\beta}$ is) It might not have a close form, and can only be approximated numerically.
Next - how do you prove your estimator is the best (i.e. BLUE)? Linearity of Expectations, and linear operations on Variance - are usually needed to say anything about an estimator. You will usually need to use Linearity of Expectations to show that the estimator is unbiased, and you would need to use linear operations on Variance to show that it is minimal. This is what Gauss-Markov theorem does. But if your model is not linear in parameters, the estimator won't be linear in $Y$, so most likely you won't be able to use these.
So, it's not that you don't consider non-linear models - it's just that you need a way to a. find the estimator, b. show it's good. | Why don't we consider nonlinear estimators for the parameters of linear regression models? | The question is how you find $\beta$? How do you actually derive OLS? You differentiate according to a certain parameter, and you get a set of equations, which you then solve. If $\beta$ is not linear | Why don't we consider nonlinear estimators for the parameters of linear regression models?
The question is how you find $\beta$? How do you actually derive OLS? You differentiate according to a certain parameter, and you get a set of equations, which you then solve. If $\beta$ is not linear in the model equation, the solution will not be a linear combination of $Y$. (It will probably not be a linear combination of a transformation of $Y$ either - which is what your $\widetilde{\beta}$ is) It might not have a close form, and can only be approximated numerically.
Next - how do you prove your estimator is the best (i.e. BLUE)? Linearity of Expectations, and linear operations on Variance - are usually needed to say anything about an estimator. You will usually need to use Linearity of Expectations to show that the estimator is unbiased, and you would need to use linear operations on Variance to show that it is minimal. This is what Gauss-Markov theorem does. But if your model is not linear in parameters, the estimator won't be linear in $Y$, so most likely you won't be able to use these.
So, it's not that you don't consider non-linear models - it's just that you need a way to a. find the estimator, b. show it's good. | Why don't we consider nonlinear estimators for the parameters of linear regression models?
The question is how you find $\beta$? How do you actually derive OLS? You differentiate according to a certain parameter, and you get a set of equations, which you then solve. If $\beta$ is not linear |
36,571 | Why is ReLU setting negative values to zero particularly? | The weights learned in a neural network can be both positive and negative. So in effect, either form would work. Negating the input and output weights with the $\min$ form gives the same function as with the $\max$ form. The max form is used purely by convention. | Why is ReLU setting negative values to zero particularly? | The weights learned in a neural network can be both positive and negative. So in effect, either form would work. Negating the input and output weights with the $\min$ form gives the same function as w | Why is ReLU setting negative values to zero particularly?
The weights learned in a neural network can be both positive and negative. So in effect, either form would work. Negating the input and output weights with the $\min$ form gives the same function as with the $\max$ form. The max form is used purely by convention. | Why is ReLU setting negative values to zero particularly?
The weights learned in a neural network can be both positive and negative. So in effect, either form would work. Negating the input and output weights with the $\min$ form gives the same function as w |
36,572 | Extracting Maximum A Posteriori (MAP) estimates from MC samples | [The following is copied from earlier posts on my blog.]
I have never found MAP estimators very appealing for many reasons, one being indeed that the MAP estimator cannot correctly be expressed as the solution to a minimisation problem. I also find the point-wise nature of the estimator quite a drawback: the estimator is only associated with a local property of the posterior density, not with a global property of the posterior distribution. This is in particular striking when considering the MAP estimates for two different parametrisations. The estimates often are quite different, just due to the Jacobian in the change of parameterisation. For instance, the MAP of the usual normal mean $\mu$ under a flat prior is $x$, for instance x=2, but if one use a logit parameterisation instead
$$
\mu = \log \eta/(1-\eta)
$$
the MAP in $\eta$ can be quite distinct from $1/(1+\exp-x)$, for instance leading to $\mu=3$ when $x=2$… Another bad feature is the difference between the marginal MAP and the joint MAP estimates. This is not to state that the MAP cannot be optimal in any sense, as I suspect it could be admissible as a limit of Bayes estimates (under a sequence of loss functions).
Here are the details for the normal example. I am using a flat prior on $\mu$ when $x\sim\mathcal{N}(\mu,1)$. The MAP estimator of $\mu$ is then $\hat\mu=x$. If I consider the change of variable $\mu=\text{logit}(\eta)$, the posterior distribution on $\eta$ is
$$
\pi(\eta|x) = \exp[ -(\text{logit}(\eta)-x)^2/2 ] / \sqrt{2\pi} \eta (1-\eta)
$$
and the MAP in $\eta$ is then obtained numerically. For instance, the R code
f=function(x,mea) dnorm(log(x/(1-x)),mean=mea)/(x*(1-x))
g=function(x){ a=optimise(f,int=c(0,1),maximum=TRUE,mea=x)$max;log(a/(1-a))}
plot(seq(0,4,.01),apply(as.matrix(seq(0,4,.01)),1,g),type="l")
abline(a=0,b=1,col="tomato2",lwd=2)
shows the divergence between the MAP estimator \hat\mu and the reverse transform of the MAP estimator $\hat\eta$ of the transform… The second estimator is asymptotically (in $x$) equivalent to $x+1$.
An example I like very much in The Bayesian Choice is Example 4.1.2, when observing $x\sim\text{Cauchy}(\theta,1)$ with a double exponential prior on $\theta\sim\exp\{-|\theta|\}/2$. The MAP is then always $\hat\theta=0$!
The dependence of the MAP estimator on the dominating measure is also studied in a BA paper by Pierre Druihlet and Jean-Michel Marin, who propose a solution that relies on Jeffreys’ prior as the reference measure.
An interesting paper by Burger and Lucka compares MAP and posterior mean, even though I do not share their concern that we should pick between those two estimators (only or at all), since what matters is the posterior distribution and the use one makes of it. I thus disagree there is any kind of a "debate concerning the choice of point estimates”. If Bayesian inference reduces to producing a point estimate, this is a regularisation technique and the Bayesian interpretation is both incidental and superfluous.
Maybe the most interesting result in the paper is that the MAP is expressed as a proper Bayes estimator! I was under the opposite impression, mostly because the folklore (and even The Bayesian Core) have it that it corresponds to a 0-1 loss function does not hold for continuous parameter spaces and also because it seems to conflict with the results of Druihlet and Marin (BA, 2007), who point out that the MAP ultimately depends on the choice of the dominating measure. (Even though the Lebesgue measure is implicitly chosen as the default.) The authors of this arXived paper start with a distance based on the prior; called the Bregman distance. Which may be the quadratic or the entropy distance depending on the prior. Defining a loss function that is a mix of this Bregman distance and of the quadratic distance
$$
||K(\hat u-u)||^2+2D_\pi(\hat u,u)
$$
produces the MAP as the Bayes estimator. So where did the dominating measure go? In fact, nowhere: both the loss function and the resulting estimator are clearly dependent on the choice of the dominating measure… (The loss depends on the prior but this is not a drawback per se!) | Extracting Maximum A Posteriori (MAP) estimates from MC samples | [The following is copied from earlier posts on my blog.]
I have never found MAP estimators very appealing for many reasons, one being indeed that the MAP estimator cannot correctly be expressed as the | Extracting Maximum A Posteriori (MAP) estimates from MC samples
[The following is copied from earlier posts on my blog.]
I have never found MAP estimators very appealing for many reasons, one being indeed that the MAP estimator cannot correctly be expressed as the solution to a minimisation problem. I also find the point-wise nature of the estimator quite a drawback: the estimator is only associated with a local property of the posterior density, not with a global property of the posterior distribution. This is in particular striking when considering the MAP estimates for two different parametrisations. The estimates often are quite different, just due to the Jacobian in the change of parameterisation. For instance, the MAP of the usual normal mean $\mu$ under a flat prior is $x$, for instance x=2, but if one use a logit parameterisation instead
$$
\mu = \log \eta/(1-\eta)
$$
the MAP in $\eta$ can be quite distinct from $1/(1+\exp-x)$, for instance leading to $\mu=3$ when $x=2$… Another bad feature is the difference between the marginal MAP and the joint MAP estimates. This is not to state that the MAP cannot be optimal in any sense, as I suspect it could be admissible as a limit of Bayes estimates (under a sequence of loss functions).
Here are the details for the normal example. I am using a flat prior on $\mu$ when $x\sim\mathcal{N}(\mu,1)$. The MAP estimator of $\mu$ is then $\hat\mu=x$. If I consider the change of variable $\mu=\text{logit}(\eta)$, the posterior distribution on $\eta$ is
$$
\pi(\eta|x) = \exp[ -(\text{logit}(\eta)-x)^2/2 ] / \sqrt{2\pi} \eta (1-\eta)
$$
and the MAP in $\eta$ is then obtained numerically. For instance, the R code
f=function(x,mea) dnorm(log(x/(1-x)),mean=mea)/(x*(1-x))
g=function(x){ a=optimise(f,int=c(0,1),maximum=TRUE,mea=x)$max;log(a/(1-a))}
plot(seq(0,4,.01),apply(as.matrix(seq(0,4,.01)),1,g),type="l")
abline(a=0,b=1,col="tomato2",lwd=2)
shows the divergence between the MAP estimator \hat\mu and the reverse transform of the MAP estimator $\hat\eta$ of the transform… The second estimator is asymptotically (in $x$) equivalent to $x+1$.
An example I like very much in The Bayesian Choice is Example 4.1.2, when observing $x\sim\text{Cauchy}(\theta,1)$ with a double exponential prior on $\theta\sim\exp\{-|\theta|\}/2$. The MAP is then always $\hat\theta=0$!
The dependence of the MAP estimator on the dominating measure is also studied in a BA paper by Pierre Druihlet and Jean-Michel Marin, who propose a solution that relies on Jeffreys’ prior as the reference measure.
An interesting paper by Burger and Lucka compares MAP and posterior mean, even though I do not share their concern that we should pick between those two estimators (only or at all), since what matters is the posterior distribution and the use one makes of it. I thus disagree there is any kind of a "debate concerning the choice of point estimates”. If Bayesian inference reduces to producing a point estimate, this is a regularisation technique and the Bayesian interpretation is both incidental and superfluous.
Maybe the most interesting result in the paper is that the MAP is expressed as a proper Bayes estimator! I was under the opposite impression, mostly because the folklore (and even The Bayesian Core) have it that it corresponds to a 0-1 loss function does not hold for continuous parameter spaces and also because it seems to conflict with the results of Druihlet and Marin (BA, 2007), who point out that the MAP ultimately depends on the choice of the dominating measure. (Even though the Lebesgue measure is implicitly chosen as the default.) The authors of this arXived paper start with a distance based on the prior; called the Bregman distance. Which may be the quadratic or the entropy distance depending on the prior. Defining a loss function that is a mix of this Bregman distance and of the quadratic distance
$$
||K(\hat u-u)||^2+2D_\pi(\hat u,u)
$$
produces the MAP as the Bayes estimator. So where did the dominating measure go? In fact, nowhere: both the loss function and the resulting estimator are clearly dependent on the choice of the dominating measure… (The loss depends on the prior but this is not a drawback per se!) | Extracting Maximum A Posteriori (MAP) estimates from MC samples
[The following is copied from earlier posts on my blog.]
I have never found MAP estimators very appealing for many reasons, one being indeed that the MAP estimator cannot correctly be expressed as the |
36,573 | Is there any difference between estimating $\sigma^2$ and $\sigma$ in a simulation study? | I find this question of interest because it highlights the artificial nature of seeking unbiasedness above everything else. A few points:
the variance $\sigma^2$ allows for an unbiased estimator, while the square root of that estimator $\hat\sigma_n$ is biased [by Jensen's inequality];
there is no generic unbiased estimator of $\sigma$ [generic meaning across all distributions];
for a scale or location-scale family of distributions, since $\sigma$ is a scale, the expectation $\mathbb{E}^P[\hat\sigma_n]$ can be written as
$$\mathbb{E}^P[\hat\sigma]=c(P,n)\sigma$$
where $n$ is the sample size and $P$ is the family of distributions. Hence bias can be corrected family-wise | Is there any difference between estimating $\sigma^2$ and $\sigma$ in a simulation study? | I find this question of interest because it highlights the artificial nature of seeking unbiasedness above everything else. A few points:
the variance $\sigma^2$ allows for an unbiased estimator, whi | Is there any difference between estimating $\sigma^2$ and $\sigma$ in a simulation study?
I find this question of interest because it highlights the artificial nature of seeking unbiasedness above everything else. A few points:
the variance $\sigma^2$ allows for an unbiased estimator, while the square root of that estimator $\hat\sigma_n$ is biased [by Jensen's inequality];
there is no generic unbiased estimator of $\sigma$ [generic meaning across all distributions];
for a scale or location-scale family of distributions, since $\sigma$ is a scale, the expectation $\mathbb{E}^P[\hat\sigma_n]$ can be written as
$$\mathbb{E}^P[\hat\sigma]=c(P,n)\sigma$$
where $n$ is the sample size and $P$ is the family of distributions. Hence bias can be corrected family-wise | Is there any difference between estimating $\sigma^2$ and $\sigma$ in a simulation study?
I find this question of interest because it highlights the artificial nature of seeking unbiasedness above everything else. A few points:
the variance $\sigma^2$ allows for an unbiased estimator, whi |
36,574 | Accuracy vs Jaccard for multiclass problem | The issue has been reported on scikit-learn GitHub repository: multiclass jaccard_similarity_score should not be equal to accuracy_score #7332
scikit-learn's Jaccard score for the multiclass classification task is incorrect.
A neat overview of the most commonly used performance metrics from {1}:
The accuracy is $~\frac{\text{AA}+ \text{BB} +\text{CC} }{\text{AA}+ \text{AB} +\text{AC} + \text{BA} +\text{BB} + \text{BC} + \text{CA} +\text{CB}+\text{CC}}$.
The average Jaccard score a.k.a. average Jaccard coefficient is:
$~\frac{1}{3}\left(\frac{\text{AA}}{\text{AA}+ \text{AB} +\text{AC} + \text{BA} + \text{CA}} + \frac{\text{BB}}{\text{AB} +\text{BA} +\text{BB} + \text{BC} +\text{CB}} +
\frac{\text{CC}}{\text{AC} + \text{BC} + \text{CA} +\text{CB}+\text{CC}}\right)
$
For example, if the confusion matrix is:
Then:
the accuracy is $~\frac{1 + 0+ 0}{1 +0 +0 +1 +0 +0 +1 +0 +0 }=~\frac{1}{3}$
the average Jaccard score is $~\frac{1}{3}\left(\frac{1}{1 + 0+ 0+1 +1} + \frac{0}{0+1 +0 +0 +0} +
\frac{0}{0 +0 +1 +0 +0}\right) = \frac{1}{9}$
References:
{1} Li, Lin, Yue Wu, and Mao Ye. "Experimental comparisons of multi-class classifiers." Informatica 39, no. 1 (2015). https://scholar.google.com/scholar?cluster=13749694256988041292&hl=en&as_sdt=0,22 ; http://search.proquest.com/docview/1729233982 ; http://see-articles.ceon.rs/data/pdf/0350-5596/2015/0350-55961501071L.pdf | Accuracy vs Jaccard for multiclass problem | The issue has been reported on scikit-learn GitHub repository: multiclass jaccard_similarity_score should not be equal to accuracy_score #7332
scikit-learn's Jaccard score for the multiclass classific | Accuracy vs Jaccard for multiclass problem
The issue has been reported on scikit-learn GitHub repository: multiclass jaccard_similarity_score should not be equal to accuracy_score #7332
scikit-learn's Jaccard score for the multiclass classification task is incorrect.
A neat overview of the most commonly used performance metrics from {1}:
The accuracy is $~\frac{\text{AA}+ \text{BB} +\text{CC} }{\text{AA}+ \text{AB} +\text{AC} + \text{BA} +\text{BB} + \text{BC} + \text{CA} +\text{CB}+\text{CC}}$.
The average Jaccard score a.k.a. average Jaccard coefficient is:
$~\frac{1}{3}\left(\frac{\text{AA}}{\text{AA}+ \text{AB} +\text{AC} + \text{BA} + \text{CA}} + \frac{\text{BB}}{\text{AB} +\text{BA} +\text{BB} + \text{BC} +\text{CB}} +
\frac{\text{CC}}{\text{AC} + \text{BC} + \text{CA} +\text{CB}+\text{CC}}\right)
$
For example, if the confusion matrix is:
Then:
the accuracy is $~\frac{1 + 0+ 0}{1 +0 +0 +1 +0 +0 +1 +0 +0 }=~\frac{1}{3}$
the average Jaccard score is $~\frac{1}{3}\left(\frac{1}{1 + 0+ 0+1 +1} + \frac{0}{0+1 +0 +0 +0} +
\frac{0}{0 +0 +1 +0 +0}\right) = \frac{1}{9}$
References:
{1} Li, Lin, Yue Wu, and Mao Ye. "Experimental comparisons of multi-class classifiers." Informatica 39, no. 1 (2015). https://scholar.google.com/scholar?cluster=13749694256988041292&hl=en&as_sdt=0,22 ; http://search.proquest.com/docview/1729233982 ; http://see-articles.ceon.rs/data/pdf/0350-5596/2015/0350-55961501071L.pdf | Accuracy vs Jaccard for multiclass problem
The issue has been reported on scikit-learn GitHub repository: multiclass jaccard_similarity_score should not be equal to accuracy_score #7332
scikit-learn's Jaccard score for the multiclass classific |
36,575 | Accuracy vs Jaccard for multiclass problem | K-class multinomial classification results for n cases (tries) is a nominal variable. Therefore it can be represented as a set of k binary dummy variables.
Now, Jaccard similarity coefficient between two cases (row vectors) by a set of binary attributes is $\frac{a}{a+b+c}$; and accuracy score (I believe it is F1 score) is equal to Dice coefficient: $\frac{2a}{2a+b+c}$ (it will follow from the formula behind your link). The terms come from the table:
case Y
1 0
-------
1 | a | b |
case X -------
0 | c | d |
-------
a = number of variables on which both objects X and Y are 1
b = number of variables where object X is 1 and Y is 0
c = number of variables where object X is 0 and Y is 1
d = number of variables where both X and Y are 0
a+b+c+d = p, the number of variables.
OK. Consider the example given in the documentation you link to:
y_pred = [0, 2, 1, 3]
y_true = [0, 1, 2, 3]
where values are class labels; 4 classes in all
These can be seen as 8 cases (trials) paired as 4 experiments (X cases) and 4 corresponding true outputs (Y cases). Stack all in one column and convert to dummy variables. In dummy variables, there is single 1 in each row:
case data v_0 v_1 v_2 v_3
x1 0 1 0 0 0
x2 2 0 0 1 0
x3 1 0 1 0 0
x4 3 0 0 0 1
y1 0 1 0 0 0
y2 1 0 1 0 0
y3 2 0 0 1 0
y4 3 0 0 0 1
Compute the matrix of Jaccard coefficient between all 8 cases, pairwise, and likewise the matrix of Dice coefficient:
Because we are interested in comparisons only between X and Y cases, we'll pay attention only to the yellow-highlighted portion of the matrices. We are going to sum or average coefficients within yellow area. Moreover, since data were paired we'll probably consider only the diagonal red values and average them. Your document said that their "Jaccard score" is the average of individual Jaccard indices. So here we are.
You see that entries in two yellow squares are identical: Jaccard appears to be equal to Dice (for our situation with nominal data). And the average of the 4 diagonal values is (1+0+0+1) / 4 = 0.5, the result given in your documentation.
(As an example, showing computation of both coefficients of similarity between X1 and Y1 cases):
v_0 v_1 v_2 v_3
x1 1 0 0 0
y1 1 0 0 0
Y1
1 0
-------
1 | 1 | 0 |
X1 -------
0 | 0 | 3 |
-------
Jaccard: 1/(1+0+0)=1; Dice: 2*1/(2*1+0+0)=1
Note that with a single set of dummy variables both coefficients
can attain only values 0 or 1. | Accuracy vs Jaccard for multiclass problem | K-class multinomial classification results for n cases (tries) is a nominal variable. Therefore it can be represented as a set of k binary dummy variables.
Now, Jaccard similarity coefficient between | Accuracy vs Jaccard for multiclass problem
K-class multinomial classification results for n cases (tries) is a nominal variable. Therefore it can be represented as a set of k binary dummy variables.
Now, Jaccard similarity coefficient between two cases (row vectors) by a set of binary attributes is $\frac{a}{a+b+c}$; and accuracy score (I believe it is F1 score) is equal to Dice coefficient: $\frac{2a}{2a+b+c}$ (it will follow from the formula behind your link). The terms come from the table:
case Y
1 0
-------
1 | a | b |
case X -------
0 | c | d |
-------
a = number of variables on which both objects X and Y are 1
b = number of variables where object X is 1 and Y is 0
c = number of variables where object X is 0 and Y is 1
d = number of variables where both X and Y are 0
a+b+c+d = p, the number of variables.
OK. Consider the example given in the documentation you link to:
y_pred = [0, 2, 1, 3]
y_true = [0, 1, 2, 3]
where values are class labels; 4 classes in all
These can be seen as 8 cases (trials) paired as 4 experiments (X cases) and 4 corresponding true outputs (Y cases). Stack all in one column and convert to dummy variables. In dummy variables, there is single 1 in each row:
case data v_0 v_1 v_2 v_3
x1 0 1 0 0 0
x2 2 0 0 1 0
x3 1 0 1 0 0
x4 3 0 0 0 1
y1 0 1 0 0 0
y2 1 0 1 0 0
y3 2 0 0 1 0
y4 3 0 0 0 1
Compute the matrix of Jaccard coefficient between all 8 cases, pairwise, and likewise the matrix of Dice coefficient:
Because we are interested in comparisons only between X and Y cases, we'll pay attention only to the yellow-highlighted portion of the matrices. We are going to sum or average coefficients within yellow area. Moreover, since data were paired we'll probably consider only the diagonal red values and average them. Your document said that their "Jaccard score" is the average of individual Jaccard indices. So here we are.
You see that entries in two yellow squares are identical: Jaccard appears to be equal to Dice (for our situation with nominal data). And the average of the 4 diagonal values is (1+0+0+1) / 4 = 0.5, the result given in your documentation.
(As an example, showing computation of both coefficients of similarity between X1 and Y1 cases):
v_0 v_1 v_2 v_3
x1 1 0 0 0
y1 1 0 0 0
Y1
1 0
-------
1 | 1 | 0 |
X1 -------
0 | 0 | 3 |
-------
Jaccard: 1/(1+0+0)=1; Dice: 2*1/(2*1+0+0)=1
Note that with a single set of dummy variables both coefficients
can attain only values 0 or 1. | Accuracy vs Jaccard for multiclass problem
K-class multinomial classification results for n cases (tries) is a nominal variable. Therefore it can be represented as a set of k binary dummy variables.
Now, Jaccard similarity coefficient between |
36,576 | Is it better to compute a ROC curve using predicted probabilities or distances from the separating hyperplane? | I am answering this from a pragmatic perspective, simply by looking at code and deducing from examples. A more theoretic answer could be a great supplement.
Generally both can be used. The difference is well explained here.
Yet most relevant, not all algorithms offer both predict_proba and decision_function. To my knowledge, every classifiers allows predict_proba in sklearn. For some - specifically SVC (Support Vector Classification) - both give exactly the same result. To check, I used this example and change the code once using predict_proba and once decision_function.
Specifically I changed:
probas_ = classifier.fit(X[train], y[train]).predict_proba(X[test])
# Compute ROC curve and area the curve
fpr, tpr, thresholds = roc_curve(y[test], probas_[:, 1])
to:
probas_ = classifier.fit(X[train], y[train]).decision_function(X[test])
# Compute ROC curve and area the curve
fpr, tpr, thresholds = roc_curve(y[test], probas_)
And both yield the exact same result as you can see in the images:
Yet this only counts for SVC where the distance to the decision plane is used to compute the probability - therefore no difference in the ROC.
In another example a specific line of code is relevant for this question:
if hasattr(clf, "decision_function"):
Z = clf.decision_function(np.c_[xx.ravel(), yy.ravel()])
else:
Z = clf.predict_proba(np.c_[xx.ravel(), yy.ravel()])[:, 1]
Therefore, deducing from the sklearn example, I would recommend you use the decision_function wherever possible and if not, use the probability provided by predict_proba.
Examples for algorithms which do not provide a decision_function in sklearn:
KNeighborsClassifier()
RandomForestClassifier()
GaussianNB() | Is it better to compute a ROC curve using predicted probabilities or distances from the separating h | I am answering this from a pragmatic perspective, simply by looking at code and deducing from examples. A more theoretic answer could be a great supplement.
Generally both can be used. The difference | Is it better to compute a ROC curve using predicted probabilities or distances from the separating hyperplane?
I am answering this from a pragmatic perspective, simply by looking at code and deducing from examples. A more theoretic answer could be a great supplement.
Generally both can be used. The difference is well explained here.
Yet most relevant, not all algorithms offer both predict_proba and decision_function. To my knowledge, every classifiers allows predict_proba in sklearn. For some - specifically SVC (Support Vector Classification) - both give exactly the same result. To check, I used this example and change the code once using predict_proba and once decision_function.
Specifically I changed:
probas_ = classifier.fit(X[train], y[train]).predict_proba(X[test])
# Compute ROC curve and area the curve
fpr, tpr, thresholds = roc_curve(y[test], probas_[:, 1])
to:
probas_ = classifier.fit(X[train], y[train]).decision_function(X[test])
# Compute ROC curve and area the curve
fpr, tpr, thresholds = roc_curve(y[test], probas_)
And both yield the exact same result as you can see in the images:
Yet this only counts for SVC where the distance to the decision plane is used to compute the probability - therefore no difference in the ROC.
In another example a specific line of code is relevant for this question:
if hasattr(clf, "decision_function"):
Z = clf.decision_function(np.c_[xx.ravel(), yy.ravel()])
else:
Z = clf.predict_proba(np.c_[xx.ravel(), yy.ravel()])[:, 1]
Therefore, deducing from the sklearn example, I would recommend you use the decision_function wherever possible and if not, use the probability provided by predict_proba.
Examples for algorithms which do not provide a decision_function in sklearn:
KNeighborsClassifier()
RandomForestClassifier()
GaussianNB() | Is it better to compute a ROC curve using predicted probabilities or distances from the separating h
I am answering this from a pragmatic perspective, simply by looking at code and deducing from examples. A more theoretic answer could be a great supplement.
Generally both can be used. The difference |
36,577 | Variational Auto-encoders vs Restricted Boltzmann Machines | Theoretically RBMs are undirected models with no connections between any observed variables or any latent variables, VAEs are directed models with continuous latent variables.
The Deep Learning book (Chapter 20 Deep Generative Models) provides a very good summary of pros and cons of VAEs and all types of RBMs.
To quote some
The VAE framework is very straightforward to extend to a wide range of model architectures. This is a key advantage over Boltzmann machines, which require extremely careful model design to maintain tractability.
The variational autoencoderis defined for arbitrary computational graphs, which makes it applicable to a wider range of probabilistic model families because there is no need to restrict the choice of models to those with tractable mean field fixed point equations.
One very nice property of the variational autoencoder is that
simultaneously training a parametric encoder in combination with the
generator network forces the model to learn a predictable coordinate
system that the encoder can capture. This makes it an excellent
manifold learning algorithm. | Variational Auto-encoders vs Restricted Boltzmann Machines | Theoretically RBMs are undirected models with no connections between any observed variables or any latent variables, VAEs are directed models with continuous latent variables.
The Deep Learning book ( | Variational Auto-encoders vs Restricted Boltzmann Machines
Theoretically RBMs are undirected models with no connections between any observed variables or any latent variables, VAEs are directed models with continuous latent variables.
The Deep Learning book (Chapter 20 Deep Generative Models) provides a very good summary of pros and cons of VAEs and all types of RBMs.
To quote some
The VAE framework is very straightforward to extend to a wide range of model architectures. This is a key advantage over Boltzmann machines, which require extremely careful model design to maintain tractability.
The variational autoencoderis defined for arbitrary computational graphs, which makes it applicable to a wider range of probabilistic model families because there is no need to restrict the choice of models to those with tractable mean field fixed point equations.
One very nice property of the variational autoencoder is that
simultaneously training a parametric encoder in combination with the
generator network forces the model to learn a predictable coordinate
system that the encoder can capture. This makes it an excellent
manifold learning algorithm. | Variational Auto-encoders vs Restricted Boltzmann Machines
Theoretically RBMs are undirected models with no connections between any observed variables or any latent variables, VAEs are directed models with continuous latent variables.
The Deep Learning book ( |
36,578 | Quantile Regression vs OLS for homoscedasticity | Will the estimated slope coefficient $\beta_1$ always be the same for OLS and for QR for different quantiles?
No, of course not, because the empirical loss function being minimized differs in these different cases (OLS vs. QR for different quantiles).
I am well aware that in the presence of homoscedasticity all the slope parameters for different quantile regressions will be the same and that the QR models will differ only in the intercept.
No, not in finite samples. Here is an example taken from the help files of the quantreg package in R:
library(quantreg)
data(stackloss)
rq(stack.loss ~ stack.x,tau=0.50) #median (l1) regression fit
# for the stackloss data.
rq(stack.loss ~ stack.x,tau=0.25) #the 1st quartile
However, asymptotically they will all converge to the same true value.
But in the case of homoscedasticity, shouldn't outliers cancel each other out because positive errors are as likely as negative ones, rendering OLS and median QR slope coefficient equivalent?
No. First, perfect symmetry of errors is not guaranteed in any finite sample. Second, minimizing the sum of squares vs. absolute values will in general lead to different values even for symmetric errors. | Quantile Regression vs OLS for homoscedasticity | Will the estimated slope coefficient $\beta_1$ always be the same for OLS and for QR for different quantiles?
No, of course not, because the empirical loss function being minimized differs in these d | Quantile Regression vs OLS for homoscedasticity
Will the estimated slope coefficient $\beta_1$ always be the same for OLS and for QR for different quantiles?
No, of course not, because the empirical loss function being minimized differs in these different cases (OLS vs. QR for different quantiles).
I am well aware that in the presence of homoscedasticity all the slope parameters for different quantile regressions will be the same and that the QR models will differ only in the intercept.
No, not in finite samples. Here is an example taken from the help files of the quantreg package in R:
library(quantreg)
data(stackloss)
rq(stack.loss ~ stack.x,tau=0.50) #median (l1) regression fit
# for the stackloss data.
rq(stack.loss ~ stack.x,tau=0.25) #the 1st quartile
However, asymptotically they will all converge to the same true value.
But in the case of homoscedasticity, shouldn't outliers cancel each other out because positive errors are as likely as negative ones, rendering OLS and median QR slope coefficient equivalent?
No. First, perfect symmetry of errors is not guaranteed in any finite sample. Second, minimizing the sum of squares vs. absolute values will in general lead to different values even for symmetric errors. | Quantile Regression vs OLS for homoscedasticity
Will the estimated slope coefficient $\beta_1$ always be the same for OLS and for QR for different quantiles?
No, of course not, because the empirical loss function being minimized differs in these d |
36,579 | Quantile Regression vs OLS for homoscedasticity | Generally the answer is yes, at least for Theil's regression, which is a special case of QR. The slope estimator for Theil's regression is an unbiased estimator of the population slope. If all the requirements for OLS are met, then it has 85% relative efficiency. There are certain circumstances where it becomes more efficient than least squares on a relative basis.
In addition, if you are not sitting around with an infinite amount of data, but instead have a small sample, there are many places where it would be preferable. Skew and truncation by not permitting negative values can have a strong impact on OLS and little to none on Theil's method. | Quantile Regression vs OLS for homoscedasticity | Generally the answer is yes, at least for Theil's regression, which is a special case of QR. The slope estimator for Theil's regression is an unbiased estimator of the population slope. If all the r | Quantile Regression vs OLS for homoscedasticity
Generally the answer is yes, at least for Theil's regression, which is a special case of QR. The slope estimator for Theil's regression is an unbiased estimator of the population slope. If all the requirements for OLS are met, then it has 85% relative efficiency. There are certain circumstances where it becomes more efficient than least squares on a relative basis.
In addition, if you are not sitting around with an infinite amount of data, but instead have a small sample, there are many places where it would be preferable. Skew and truncation by not permitting negative values can have a strong impact on OLS and little to none on Theil's method. | Quantile Regression vs OLS for homoscedasticity
Generally the answer is yes, at least for Theil's regression, which is a special case of QR. The slope estimator for Theil's regression is an unbiased estimator of the population slope. If all the r |
36,580 | Using segmented linear regression as evidence for the limit of human lifespan | First of all, let's manually extract the values from their original Figure 2 and plot the data without any colors or regression lines biasing our first visual inspection of the raw data.
year <- c(1968, 1970, 1973, 1975, 1978, 1979, 1980, 1981, 1982,
1983, 1984, 1985, 1986, 1987, 1988, 1989, 1990, 1991,
1992, 1994, 1993, 1995, 1996, 1998, 1997, 1999, 2000,
2001, 2002, 2003, 2004, 2005, 2006)
age <- c(111, 111, 112, 111, 111, 110, 111, 113, 113, 113, 111,
114, 113, 114, 114, 112, 112, 112, 114, 115, 117, 112,
114, 115, 121, 119, 114, 115, 115, 114, 113, 114, 112)
plot(year,age,xlab="Year",
ylab="Yearly maximum reported age at death (years)",
pch=20,cex=2,ylim=c(108,124),xlim=c(1960,2010))
We obtain:
And, let's do the same for the data in Figure 6 (as presented in the question above):
age <- c(113, 109, 109, 110, 113, 109, 110, 111, 111, 111,
112, 112, 113, 111, 111, 113, 113, 113, 114, 115,
113, 114, 122, 119, 117, 114, 115, 115, 114, 114,
115, 116, 115, 115, 114, 114, 116, 116, 117)
year <- c(1954, 1957, 1958, 1958, 1963, 1964, 1965, 1967,
1968, 1970, 1975, 1972, 1976, 1976, 1977, 1980,
1981, 1982, 1984, 1985, 1986, 1987, 1997, 1998,
1998, 1999, 2001, 2001, 2002, 2003, 2006, 2006,
2008, 2007, 2010, 2011, 2011, 2012, 2015)
plot(year,age,xlab="Year",
ylab="MRAD from GRG",
pch=20,cex=2,ylim=c(108,124),xlim=c(1950,2020))
It seems that a simple linear regression model would be the natural candidate challenging the less parsimonious change-point model the authors proposed.
Indeed, Philipp Berens and Tom Wallis have done so and published their re-analysis on github: https://github.com/philippberens/lifespan | Using segmented linear regression as evidence for the limit of human lifespan | First of all, let's manually extract the values from their original Figure 2 and plot the data without any colors or regression lines biasing our first visual inspection of the raw data.
year <- c(19 | Using segmented linear regression as evidence for the limit of human lifespan
First of all, let's manually extract the values from their original Figure 2 and plot the data without any colors or regression lines biasing our first visual inspection of the raw data.
year <- c(1968, 1970, 1973, 1975, 1978, 1979, 1980, 1981, 1982,
1983, 1984, 1985, 1986, 1987, 1988, 1989, 1990, 1991,
1992, 1994, 1993, 1995, 1996, 1998, 1997, 1999, 2000,
2001, 2002, 2003, 2004, 2005, 2006)
age <- c(111, 111, 112, 111, 111, 110, 111, 113, 113, 113, 111,
114, 113, 114, 114, 112, 112, 112, 114, 115, 117, 112,
114, 115, 121, 119, 114, 115, 115, 114, 113, 114, 112)
plot(year,age,xlab="Year",
ylab="Yearly maximum reported age at death (years)",
pch=20,cex=2,ylim=c(108,124),xlim=c(1960,2010))
We obtain:
And, let's do the same for the data in Figure 6 (as presented in the question above):
age <- c(113, 109, 109, 110, 113, 109, 110, 111, 111, 111,
112, 112, 113, 111, 111, 113, 113, 113, 114, 115,
113, 114, 122, 119, 117, 114, 115, 115, 114, 114,
115, 116, 115, 115, 114, 114, 116, 116, 117)
year <- c(1954, 1957, 1958, 1958, 1963, 1964, 1965, 1967,
1968, 1970, 1975, 1972, 1976, 1976, 1977, 1980,
1981, 1982, 1984, 1985, 1986, 1987, 1997, 1998,
1998, 1999, 2001, 2001, 2002, 2003, 2006, 2006,
2008, 2007, 2010, 2011, 2011, 2012, 2015)
plot(year,age,xlab="Year",
ylab="MRAD from GRG",
pch=20,cex=2,ylim=c(108,124),xlim=c(1950,2020))
It seems that a simple linear regression model would be the natural candidate challenging the less parsimonious change-point model the authors proposed.
Indeed, Philipp Berens and Tom Wallis have done so and published their re-analysis on github: https://github.com/philippberens/lifespan | Using segmented linear regression as evidence for the limit of human lifespan
First of all, let's manually extract the values from their original Figure 2 and plot the data without any colors or regression lines biasing our first visual inspection of the raw data.
year <- c(19 |
36,581 | Using segmented linear regression as evidence for the limit of human lifespan | I think the nature of the conclusions are totally bunk. We see between 1950 and 2015 an increasing trend followed by a decreasing trend. It is a classic fallacy of applying data which are suggestive of a hypothesis different than the one tested and presenting them as such. With these data, a segmented regression can interpolate and predict that in 1995 a local maxima of lifespan was about 115 years $\pm$ whatever error they estimate from segmented regression. This does not preclude 2020 or 2030 trends superseding that value.
The concept of natural lifespan conflicts with the preponderance of research in aging, genetics, and telomeres.
An experimental design to address natural human lifespan is needed using "body on a chip" technology.
50 years is utterly trivial in the course of human history. There have been many points in the past where an upward trend in lifespan was followed by a downward one.
Data such as those presented could have been simulated from a non-linear model having discontinuities and/or asymptotes which are unmeasurable.
Since the model's goal is prediction, distributional assumptions, and mean-model correctness are needed, and neither (it seems) were these checked nor are they met. | Using segmented linear regression as evidence for the limit of human lifespan | I think the nature of the conclusions are totally bunk. We see between 1950 and 2015 an increasing trend followed by a decreasing trend. It is a classic fallacy of applying data which are suggestive o | Using segmented linear regression as evidence for the limit of human lifespan
I think the nature of the conclusions are totally bunk. We see between 1950 and 2015 an increasing trend followed by a decreasing trend. It is a classic fallacy of applying data which are suggestive of a hypothesis different than the one tested and presenting them as such. With these data, a segmented regression can interpolate and predict that in 1995 a local maxima of lifespan was about 115 years $\pm$ whatever error they estimate from segmented regression. This does not preclude 2020 or 2030 trends superseding that value.
The concept of natural lifespan conflicts with the preponderance of research in aging, genetics, and telomeres.
An experimental design to address natural human lifespan is needed using "body on a chip" technology.
50 years is utterly trivial in the course of human history. There have been many points in the past where an upward trend in lifespan was followed by a downward one.
Data such as those presented could have been simulated from a non-linear model having discontinuities and/or asymptotes which are unmeasurable.
Since the model's goal is prediction, distributional assumptions, and mean-model correctness are needed, and neither (it seems) were these checked nor are they met. | Using segmented linear regression as evidence for the limit of human lifespan
I think the nature of the conclusions are totally bunk. We see between 1950 and 2015 an increasing trend followed by a decreasing trend. It is a classic fallacy of applying data which are suggestive o |
36,582 | Why is $B^TB+\lambda\Omega$ positive definite? | Showing that $B^TB+\lambda\Omega$ is PD amounts to showing that $\Omega$ is PD. (Thanks to Matthew Gunn for pointing that out in the comments.)
This is because $B^TB$ is, in the case that $p>n$, rank deficient and therefore PSD. This is because the quadratic form $a^TB^TBa\ge0\forall a\in\{\mathbb{R}^n\setminus0\}$ because we can rewrite it as $||Ba||_2^2\ge0$ because the square of any real number is nonnegative. So we have $a^T(B^TB+\Omega)a=a^TB^TBa+a^T\Omega a >0$ because if $\Omega$ is PD, then $a^T\Omega a>0$, the quantity $a^TB^TBa+a^T\Omega a$ is the sum of a nonnegative and a positive number, which must be positive. Therefore $B^TB+\Omega$ is PD as long as $\Omega$ is PD.
So we need to reason about $\Omega$. It fits the definition of a Gram matrix because it is given by the standard inner product on functions (that's stipulated in the question). The basis functions are linearly independent (because they form a basis), therefore $\Omega$ is PD.
$\Omega$ is PD iff its columns are independent. We can write $\Omega=A^TA.$ If the vectors of $A$ are linearly dependent, then we have $\Omega a=A^TAa=A^T0=0$ for some $a\neq 0$ because $Aa=0$ by definition of linear dependence, and $|\Omega|=|A^TA|=|A|^2=0$ by the properties of the determinant.
It's easy to show that this is true for any $\lambda>0$; all the same arguments apply because positive numbers are closed under multiplication. | Why is $B^TB+\lambda\Omega$ positive definite? | Showing that $B^TB+\lambda\Omega$ is PD amounts to showing that $\Omega$ is PD. (Thanks to Matthew Gunn for pointing that out in the comments.)
This is because $B^TB$ is, in the case that $p>n$, rank | Why is $B^TB+\lambda\Omega$ positive definite?
Showing that $B^TB+\lambda\Omega$ is PD amounts to showing that $\Omega$ is PD. (Thanks to Matthew Gunn for pointing that out in the comments.)
This is because $B^TB$ is, in the case that $p>n$, rank deficient and therefore PSD. This is because the quadratic form $a^TB^TBa\ge0\forall a\in\{\mathbb{R}^n\setminus0\}$ because we can rewrite it as $||Ba||_2^2\ge0$ because the square of any real number is nonnegative. So we have $a^T(B^TB+\Omega)a=a^TB^TBa+a^T\Omega a >0$ because if $\Omega$ is PD, then $a^T\Omega a>0$, the quantity $a^TB^TBa+a^T\Omega a$ is the sum of a nonnegative and a positive number, which must be positive. Therefore $B^TB+\Omega$ is PD as long as $\Omega$ is PD.
So we need to reason about $\Omega$. It fits the definition of a Gram matrix because it is given by the standard inner product on functions (that's stipulated in the question). The basis functions are linearly independent (because they form a basis), therefore $\Omega$ is PD.
$\Omega$ is PD iff its columns are independent. We can write $\Omega=A^TA.$ If the vectors of $A$ are linearly dependent, then we have $\Omega a=A^TAa=A^T0=0$ for some $a\neq 0$ because $Aa=0$ by definition of linear dependence, and $|\Omega|=|A^TA|=|A|^2=0$ by the properties of the determinant.
It's easy to show that this is true for any $\lambda>0$; all the same arguments apply because positive numbers are closed under multiplication. | Why is $B^TB+\lambda\Omega$ positive definite?
Showing that $B^TB+\lambda\Omega$ is PD amounts to showing that $\Omega$ is PD. (Thanks to Matthew Gunn for pointing that out in the comments.)
This is because $B^TB$ is, in the case that $p>n$, rank |
36,583 | Is PCA invariant to orthogonal transformations? | The covariance matrix of $B$ is decomposed as:
$$ \frac{1}{n-1} B^T B = V_B L_B V^T_B $$
If we rewrite the covariance matrix of $B$ in terms of $A$ and $Q$ we have:
$$ \frac{1}{n-1} B^T B = \frac{1}{n-1} (AQ)^T AQ = \frac{1}{n-1} Q^T A^T A Q = Q^T (\frac{1}{n-1} A^T A) Q = Q^T V_A L_A V^T_A Q $$
We observe that the covariance matrices of $A$ and $B$ are generally different:
$$ V_A L_A V^T_A \neq Q^T V_A L_A V^T_A Q $$
We identify (wasn't sure about this step at first):
$$ V_B = Q^T V_A $$
$$ L_B = L_A $$
$$ V^T_B = (Q^T V_A)^T = V^T_A Q $$
And now we have:
$$ B V_B = A Q Q^T V_A = A V_A $$
Which means that the datasets are identical upon "transforming" them with PCA.
Many thanks to @amoeba and @Alex R. | Is PCA invariant to orthogonal transformations? | The covariance matrix of $B$ is decomposed as:
$$ \frac{1}{n-1} B^T B = V_B L_B V^T_B $$
If we rewrite the covariance matrix of $B$ in terms of $A$ and $Q$ we have:
$$ \frac{1}{n-1} B^T B = \frac{1}{n | Is PCA invariant to orthogonal transformations?
The covariance matrix of $B$ is decomposed as:
$$ \frac{1}{n-1} B^T B = V_B L_B V^T_B $$
If we rewrite the covariance matrix of $B$ in terms of $A$ and $Q$ we have:
$$ \frac{1}{n-1} B^T B = \frac{1}{n-1} (AQ)^T AQ = \frac{1}{n-1} Q^T A^T A Q = Q^T (\frac{1}{n-1} A^T A) Q = Q^T V_A L_A V^T_A Q $$
We observe that the covariance matrices of $A$ and $B$ are generally different:
$$ V_A L_A V^T_A \neq Q^T V_A L_A V^T_A Q $$
We identify (wasn't sure about this step at first):
$$ V_B = Q^T V_A $$
$$ L_B = L_A $$
$$ V^T_B = (Q^T V_A)^T = V^T_A Q $$
And now we have:
$$ B V_B = A Q Q^T V_A = A V_A $$
Which means that the datasets are identical upon "transforming" them with PCA.
Many thanks to @amoeba and @Alex R. | Is PCA invariant to orthogonal transformations?
The covariance matrix of $B$ is decomposed as:
$$ \frac{1}{n-1} B^T B = V_B L_B V^T_B $$
If we rewrite the covariance matrix of $B$ in terms of $A$ and $Q$ we have:
$$ \frac{1}{n-1} B^T B = \frac{1}{n |
36,584 | Is PCA invariant to orthogonal transformations? | Let $R$ be a rotation (i.e. an orthogonal matrix: $R^T=R^{-1}$). $A=U\Sigma V^*$ by SVD, and correspondingly $A^TA=V\Sigma^2 V^*$.
On the other hand if $B:=RA$, then:
$$B^TB=A^TR^TRA=A^TA=V\Sigma^2V^*.$$
So PCA is "invariant" under rotations applied to $A$ from the left. Specifically, this means that the covariance matrix is invariant. However the actual projections will differ. Specifically, $A=U\Sigma V^*$, whereas $B=RA=RU\Sigma V^*$, giving $B=W\Sigma V^*$, where $W:=R^*U$. | Is PCA invariant to orthogonal transformations? | Let $R$ be a rotation (i.e. an orthogonal matrix: $R^T=R^{-1}$). $A=U\Sigma V^*$ by SVD, and correspondingly $A^TA=V\Sigma^2 V^*$.
On the other hand if $B:=RA$, then:
$$B^TB=A^TR^TRA=A^TA=V\Sigma^2V^* | Is PCA invariant to orthogonal transformations?
Let $R$ be a rotation (i.e. an orthogonal matrix: $R^T=R^{-1}$). $A=U\Sigma V^*$ by SVD, and correspondingly $A^TA=V\Sigma^2 V^*$.
On the other hand if $B:=RA$, then:
$$B^TB=A^TR^TRA=A^TA=V\Sigma^2V^*.$$
So PCA is "invariant" under rotations applied to $A$ from the left. Specifically, this means that the covariance matrix is invariant. However the actual projections will differ. Specifically, $A=U\Sigma V^*$, whereas $B=RA=RU\Sigma V^*$, giving $B=W\Sigma V^*$, where $W:=R^*U$. | Is PCA invariant to orthogonal transformations?
Let $R$ be a rotation (i.e. an orthogonal matrix: $R^T=R^{-1}$). $A=U\Sigma V^*$ by SVD, and correspondingly $A^TA=V\Sigma^2 V^*$.
On the other hand if $B:=RA$, then:
$$B^TB=A^TR^TRA=A^TA=V\Sigma^2V^* |
36,585 | What is Significant about the Bayesian Approach in Machine Learning? | In any case then, do Bayesian Models offer some sort of inherent advantages or disadvantages over non-Bayesian models?
Simple answer: no. It's just a different type of thinking. Bayesian modeling just gives you a posterior density for the parameters your estimating. Usually, frequentist models like generalized linear models are simpler to compute but do not provide a posterior distribution because frequentists do not believe the parameters are random, but rather fixed things you have to estimate. Generally, if the sample size is large enough (about 300+ rows of data from my experience), both Bayesian models and frequentist models come out with the same parameter estimates.
In simple terms, a frequentist views the data as the random variable, where as the Bayesian views the parameters you're estimating as the random variable.
You should review some fundamental ideas about Bayesian statistical analyses before trying to apply them. A good reference that I recommend is Bayesian Ideas and Data Analysis: An Introduction for Scientists and Statisticians. It's a fairly easy read, with math at the Master's graduate level. | What is Significant about the Bayesian Approach in Machine Learning? | In any case then, do Bayesian Models offer some sort of inherent advantages or disadvantages over non-Bayesian models?
Simple answer: no. It's just a different type of thinking. Bayesian modeling jus | What is Significant about the Bayesian Approach in Machine Learning?
In any case then, do Bayesian Models offer some sort of inherent advantages or disadvantages over non-Bayesian models?
Simple answer: no. It's just a different type of thinking. Bayesian modeling just gives you a posterior density for the parameters your estimating. Usually, frequentist models like generalized linear models are simpler to compute but do not provide a posterior distribution because frequentists do not believe the parameters are random, but rather fixed things you have to estimate. Generally, if the sample size is large enough (about 300+ rows of data from my experience), both Bayesian models and frequentist models come out with the same parameter estimates.
In simple terms, a frequentist views the data as the random variable, where as the Bayesian views the parameters you're estimating as the random variable.
You should review some fundamental ideas about Bayesian statistical analyses before trying to apply them. A good reference that I recommend is Bayesian Ideas and Data Analysis: An Introduction for Scientists and Statisticians. It's a fairly easy read, with math at the Master's graduate level. | What is Significant about the Bayesian Approach in Machine Learning?
In any case then, do Bayesian Models offer some sort of inherent advantages or disadvantages over non-Bayesian models?
Simple answer: no. It's just a different type of thinking. Bayesian modeling jus |
36,586 | What is Significant about the Bayesian Approach in Machine Learning? | Agree with the previous answer. In fact, the idea behind almost any Bayesian model is having random variable, which can be distributed according to prior and posterior distributions. It doesn't imply that Bayesian approach works better or worse than non-Bayesian one, but usually it requires more data (for prior distribution of parameters) and in many cases (not all of them) it needs the variables we're working with to be independent.
Moreover, Bayesian approaches can be implemented only for parametric models; they're easier to interpret than other types of ML techniques, but the choice of probability distributions and their parameters is crucial here. My opinion is subjective one, but in practice non-Bayesian approaches are used more frequently in real-life applications, where we have no idea about the source of data coming from and have a really bad understanding of probability distributions suitable for the data we have.
Overall, for almost any of the Bayesian techniques there's an alternative one. It is more a matter of choice and situation, than a matter of a result, as my experience tells me. | What is Significant about the Bayesian Approach in Machine Learning? | Agree with the previous answer. In fact, the idea behind almost any Bayesian model is having random variable, which can be distributed according to prior and posterior distributions. It doesn't imply | What is Significant about the Bayesian Approach in Machine Learning?
Agree with the previous answer. In fact, the idea behind almost any Bayesian model is having random variable, which can be distributed according to prior and posterior distributions. It doesn't imply that Bayesian approach works better or worse than non-Bayesian one, but usually it requires more data (for prior distribution of parameters) and in many cases (not all of them) it needs the variables we're working with to be independent.
Moreover, Bayesian approaches can be implemented only for parametric models; they're easier to interpret than other types of ML techniques, but the choice of probability distributions and their parameters is crucial here. My opinion is subjective one, but in practice non-Bayesian approaches are used more frequently in real-life applications, where we have no idea about the source of data coming from and have a really bad understanding of probability distributions suitable for the data we have.
Overall, for almost any of the Bayesian techniques there's an alternative one. It is more a matter of choice and situation, than a matter of a result, as my experience tells me. | What is Significant about the Bayesian Approach in Machine Learning?
Agree with the previous answer. In fact, the idea behind almost any Bayesian model is having random variable, which can be distributed according to prior and posterior distributions. It doesn't imply |
36,587 | What exactly does scipy.stats.ttest_ind test? | The quoted sentence:
This is a two-sided test for the null hypothesis that 2 independent samples have identical average (expected) values.
is a reference to the population means not the sample means; it is otherwise misleading and should certainly be clearer but they do t least say "(expected) values", which can only be a reference to population means from which the samples were drawn.
However, you were understandably misled by it and if a student wrote that I would certainly mark it wrong (since it does seem to suggest that it is the sample means being tested for equality, just as it did to you).
Therefore I'm thinking what they really mean is that the Null Hypothesis is that both samples come from the same distribution. Is that correct?
Usually the hypothesis that people wish to test with this hypothesis test is $H_0: \mu_X=\mu_Y$, but when accompanied by the assumptions of the usual equal variance two sample t-test, that's the same as saying they come from the same distribution. The assumption of equal variances is the default for the scipy implementation of this test, but set otherwise it doesn't assume equal variances and then the null doesn't imply that distributions are the same.
That's true of many of the commonly used hypothesis tests -- that the null (when combined with the assumptions) amounts to assuming equal distributions. | What exactly does scipy.stats.ttest_ind test? | The quoted sentence:
This is a two-sided test for the null hypothesis that 2 independent samples have identical average (expected) values.
is a reference to the population means not the sample means | What exactly does scipy.stats.ttest_ind test?
The quoted sentence:
This is a two-sided test for the null hypothesis that 2 independent samples have identical average (expected) values.
is a reference to the population means not the sample means; it is otherwise misleading and should certainly be clearer but they do t least say "(expected) values", which can only be a reference to population means from which the samples were drawn.
However, you were understandably misled by it and if a student wrote that I would certainly mark it wrong (since it does seem to suggest that it is the sample means being tested for equality, just as it did to you).
Therefore I'm thinking what they really mean is that the Null Hypothesis is that both samples come from the same distribution. Is that correct?
Usually the hypothesis that people wish to test with this hypothesis test is $H_0: \mu_X=\mu_Y$, but when accompanied by the assumptions of the usual equal variance two sample t-test, that's the same as saying they come from the same distribution. The assumption of equal variances is the default for the scipy implementation of this test, but set otherwise it doesn't assume equal variances and then the null doesn't imply that distributions are the same.
That's true of many of the commonly used hypothesis tests -- that the null (when combined with the assumptions) amounts to assuming equal distributions. | What exactly does scipy.stats.ttest_ind test?
The quoted sentence:
This is a two-sided test for the null hypothesis that 2 independent samples have identical average (expected) values.
is a reference to the population means not the sample means |
36,588 | What exactly does scipy.stats.ttest_ind test? | A bit more exact, see the docs you quoted
equal_var : bool, optional
If True (default), perform a standard independent 2 sample test that
assumes equal population variances [R263]. If False, perform Welch’s
t-test, which does not assume equal population variance [R264].
So it either performs student's or Welch's t-test for independent samples. BTW, Welch's test is recommended as of When conducting a t-test why would one prefer to assume (or test for) equal variances rather than always use a Welch approximation of the df?. | What exactly does scipy.stats.ttest_ind test? | A bit more exact, see the docs you quoted
equal_var : bool, optional
If True (default), perform a standard independent 2 sample test that
assumes equal population variances [R263]. If False, perform | What exactly does scipy.stats.ttest_ind test?
A bit more exact, see the docs you quoted
equal_var : bool, optional
If True (default), perform a standard independent 2 sample test that
assumes equal population variances [R263]. If False, perform Welch’s
t-test, which does not assume equal population variance [R264].
So it either performs student's or Welch's t-test for independent samples. BTW, Welch's test is recommended as of When conducting a t-test why would one prefer to assume (or test for) equal variances rather than always use a Welch approximation of the df?. | What exactly does scipy.stats.ttest_ind test?
A bit more exact, see the docs you quoted
equal_var : bool, optional
If True (default), perform a standard independent 2 sample test that
assumes equal population variances [R263]. If False, perform |
36,589 | Variance of weighted mean greater than unweighted mean | Your linked question is addressing using weights as a shortcut for dealing with equally weighted per data point variance in which some data points occur more than once.
@whuber has addressed in a comment the situation in which the variances of all data points are equal. So I will address the situation in which they are not equal. It is in this situation that the optimal weighted mean produces a lower variance than the unweighted, i.e., equally weighted, mean.
The weighted mean, using weights $w_i$, equals $\Sigma_{i=1}^n{w_i x_i}$, and has variance = $\Sigma_{i=1}^n{w_i^2 Var(x_i)}$. So we wish to minimize $\Sigma_{i=1}^n{w_i^2 Var(x_i)}$, subject to $\Sigma_{i=1}^n{w_i} = 1$ and $w_i \ge 0$ for all i.
The Karush-Kuhn-Tucker conditions, which are necessary and sufficient for a global minimum for this problem, given that it is a convex Quadratic Programming problem, result in a closed form solution, namely:
The optimal $w_i = [1/Var(x_i)]/\Sigma_{j=1}^n{[1/Var(x_j)]}$ for 1 = 1 .. n.
The variance of the corresponding optimal weighted mean = $1/\Sigma_{i=1}^n{[1/Var(x_i)]}$.
By contrast, equal weighting means $w_i = \frac{1}{n}$ for all i, where n is the number of data points. As pointed out by whuber, equal weights are optimal if all data point variances are equal, which can be seen from the above formula for optimal $w_i$. However, as evident by that formula, equal weights are not optimal if the data point variances are not all equal, and indeed result in larger variance (of the weighted mean) than the optimal weights. The variance of the equally weighted mean, i.e., the variance of the weighted mean using equal weights = $\frac{1}{n^2}\Sigma_{i=1}^n{Var(x_i)}$.
Here are some example numerical results:
There are two data points, having variances respectively of 1 and 4. The unweighted mean has variance = 1.25. The weighted mean using the optimal weights of 0.8 and 0.2 respectively, has variance = 0.8, which of course is less than 1.25.
There are three data points, having variances respectively of 1, 4,
and 9. The unweighted mean has variance = 1.5556. The weighted mean
using the optimal weights of 0.7347, 0.1837, 0.0816 respectively, has
variance = 0.7347, which of course is less than 1.5556.
Of course, it is possible for the weighted mean to have a greater variance than the unweighted mean, if the weights are chosen in a poor manner. By choosing weight of 1 on the data point with largest variance, and 0 for all other data points, the weighted mean would have variance = the largest variance of any data point. This extreme example would be the result of maximizing rather than minimizing in the optimization problem I laid out. | Variance of weighted mean greater than unweighted mean | Your linked question is addressing using weights as a shortcut for dealing with equally weighted per data point variance in which some data points occur more than once.
@whuber has addressed in a comm | Variance of weighted mean greater than unweighted mean
Your linked question is addressing using weights as a shortcut for dealing with equally weighted per data point variance in which some data points occur more than once.
@whuber has addressed in a comment the situation in which the variances of all data points are equal. So I will address the situation in which they are not equal. It is in this situation that the optimal weighted mean produces a lower variance than the unweighted, i.e., equally weighted, mean.
The weighted mean, using weights $w_i$, equals $\Sigma_{i=1}^n{w_i x_i}$, and has variance = $\Sigma_{i=1}^n{w_i^2 Var(x_i)}$. So we wish to minimize $\Sigma_{i=1}^n{w_i^2 Var(x_i)}$, subject to $\Sigma_{i=1}^n{w_i} = 1$ and $w_i \ge 0$ for all i.
The Karush-Kuhn-Tucker conditions, which are necessary and sufficient for a global minimum for this problem, given that it is a convex Quadratic Programming problem, result in a closed form solution, namely:
The optimal $w_i = [1/Var(x_i)]/\Sigma_{j=1}^n{[1/Var(x_j)]}$ for 1 = 1 .. n.
The variance of the corresponding optimal weighted mean = $1/\Sigma_{i=1}^n{[1/Var(x_i)]}$.
By contrast, equal weighting means $w_i = \frac{1}{n}$ for all i, where n is the number of data points. As pointed out by whuber, equal weights are optimal if all data point variances are equal, which can be seen from the above formula for optimal $w_i$. However, as evident by that formula, equal weights are not optimal if the data point variances are not all equal, and indeed result in larger variance (of the weighted mean) than the optimal weights. The variance of the equally weighted mean, i.e., the variance of the weighted mean using equal weights = $\frac{1}{n^2}\Sigma_{i=1}^n{Var(x_i)}$.
Here are some example numerical results:
There are two data points, having variances respectively of 1 and 4. The unweighted mean has variance = 1.25. The weighted mean using the optimal weights of 0.8 and 0.2 respectively, has variance = 0.8, which of course is less than 1.25.
There are three data points, having variances respectively of 1, 4,
and 9. The unweighted mean has variance = 1.5556. The weighted mean
using the optimal weights of 0.7347, 0.1837, 0.0816 respectively, has
variance = 0.7347, which of course is less than 1.5556.
Of course, it is possible for the weighted mean to have a greater variance than the unweighted mean, if the weights are chosen in a poor manner. By choosing weight of 1 on the data point with largest variance, and 0 for all other data points, the weighted mean would have variance = the largest variance of any data point. This extreme example would be the result of maximizing rather than minimizing in the optimization problem I laid out. | Variance of weighted mean greater than unweighted mean
Your linked question is addressing using weights as a shortcut for dealing with equally weighted per data point variance in which some data points occur more than once.
@whuber has addressed in a comm |
36,590 | Variance of weighted mean greater than unweighted mean | Here is a simple example using the $\frac1n\sum_i\left(x_i-\frac1n\sum_j x_j\right)^2$ and $\frac1{\sum_k w_k}\sum_i w_i\left(x_i-\frac1{\sum_k w_k}\sum_j w_j x_j\right)^2$ forms of the variance:
Suppose your population has measurements $20,30,40,50$.
Unweighted the mean is $35$ and variance is $125$
With respective weights $1000,4000,3000,2000$ the weighted mean is $36$ and the weighted variance is $84$
With respective weights $3000,2000,1000,4000$ the weighted mean is $36$ and the weighted variance is $164$
This example is consistent with my comment that the your statistician's quote is likely to be true for a population with a unimodal distribution, though it need not be true in general.
I suppose the point is that if you are quoting the weighted mean, you should probably be associating it with the weighted variance. If in fact your mean is the result of the sample, the standard error of the weighted sample mean is a more complicated calculation. | Variance of weighted mean greater than unweighted mean | Here is a simple example using the $\frac1n\sum_i\left(x_i-\frac1n\sum_j x_j\right)^2$ and $\frac1{\sum_k w_k}\sum_i w_i\left(x_i-\frac1{\sum_k w_k}\sum_j w_j x_j\right)^2$ forms of the variance:
Sup | Variance of weighted mean greater than unweighted mean
Here is a simple example using the $\frac1n\sum_i\left(x_i-\frac1n\sum_j x_j\right)^2$ and $\frac1{\sum_k w_k}\sum_i w_i\left(x_i-\frac1{\sum_k w_k}\sum_j w_j x_j\right)^2$ forms of the variance:
Suppose your population has measurements $20,30,40,50$.
Unweighted the mean is $35$ and variance is $125$
With respective weights $1000,4000,3000,2000$ the weighted mean is $36$ and the weighted variance is $84$
With respective weights $3000,2000,1000,4000$ the weighted mean is $36$ and the weighted variance is $164$
This example is consistent with my comment that the your statistician's quote is likely to be true for a population with a unimodal distribution, though it need not be true in general.
I suppose the point is that if you are quoting the weighted mean, you should probably be associating it with the weighted variance. If in fact your mean is the result of the sample, the standard error of the weighted sample mean is a more complicated calculation. | Variance of weighted mean greater than unweighted mean
Here is a simple example using the $\frac1n\sum_i\left(x_i-\frac1n\sum_j x_j\right)^2$ and $\frac1{\sum_k w_k}\sum_i w_i\left(x_i-\frac1{\sum_k w_k}\sum_j w_j x_j\right)^2$ forms of the variance:
Sup |
36,591 | Variance of weighted mean greater than unweighted mean | Searching for how to compute variance of a weighted sum I came across this question, and I don't see a satisfactory answer that applies to the situation state by @user08041991, namely "Let's say we have collected a series of heart rate measurements from a sample of people in a hospital. A weighting factor can then applied to each individual to scale the measurements to be reflective of national estimates."
In abstract terms, let $\{x_1,\dots,x_L\}$ be an i.i.d. sample drawn from a random variable $X$ with distribution $dP$ (in the example, these are the observed values of heart rate of people in a hospital). We want to estimate the expected value of $X$ not under $dP$, but under another probability distribution, $\omega\ dP$, where $\omega > 0$ a.s. [$dP$] is a known "weight" function, and the values ${\omega_1,\dots,\omega_L}$ at the randomly sampled observations are known. The setting bares resemblance to setting of importance sampling, where the weight is sought.
We can use the observations of $X$ and $\omega$ to define an estimator of the expected value of $X$ with respect to $\omega\ dP$, namely, the weighted average:
$$
\bar{x} = \frac{\sum_{j=1}^L x_j\omega_j}{ \sum_{j=1}^L \omega_j}
$$
The exact mean and variance of $\bar{x}$ cannot be given in closed form in general. However, one can compute the asymptotic distribution of $\bar{x}$ as $L \rightarrow \infty$. Towards that goal, consider the random vector
$$
V_L = \left(\begin{matrix} \frac{1}{L} \sum_j x_j \omega_j \\ \frac{1}{L} \sum_j \omega_j \end{matrix} \right)
$$
which, under suitable assumptions. converges a.e.[$dP$] to
$$
\left(\begin{matrix} \int{X \omega\ dP} \\ 1 \end{matrix} \right) ;
$$
moreover, under suitable assumptions,
$$
\sqrt{L} \left( V_L - \left(\begin{matrix} \int{X \omega\ dP} \\ 1 \end{matrix} \right) \right) \overset{P}{\rightsquigarrow} Z
$$
where $Z = \left(\begin{matrix} z_1 \\ z_2 \end{matrix} \right)$ is a normal vector with mean 0 and covariance
$$
\Sigma = \left[\begin{matrix} Var_P(X \omega) & Cov_P(X \omega, \omega) \\ Cov_P(X \omega, \omega) & Var_P(\omega) \end{matrix} \right]
$$
(here $Var_P$ is the variance under probability $dP$, etc.)
Therefore,
$$
\bar{x} = \frac{
\frac{1}{L} \sum_j x_j \omega_j }
{\frac{1}{L} \sum_j \omega_j} =
\frac{ \int{X \omega\ dP} + \frac{1}{ \sqrt{L}} z_1}{ 1 + \frac{1}{\sqrt{L}} z_2} \\
\approx
\int{X \omega\ dP} + \frac{1}{ \sqrt{L}} (z_1 -z_2) \\
= \int{X \omega\ dP} + \frac{1}{ \sqrt{L}} (1, -1)Z
$$
Now $(1, -1)Z$ is normal, with mean $0$ and variance
$$
E( (1,-1)Z Z^* (\begin{matrix} 1 \\-1 \end{matrix} )) = (1,-1) \Sigma (\begin{matrix} 1 \\-1 \end{matrix} ) \\
= Var_P(X \omega) - 2 Cov_P(X \omega, \omega) + Var_P(\omega) \\
= Var_P( X \omega - \omega) = Var_P( (X-1)\omega)
$$
Thus, we get:
$$
\sqrt{L} \Big( \bar{x} - \int{X \omega\ dP} \Big) ~ \overset{dP}{\rightsquigarrow } ~ u
$$
where $u$ is normally distributed, with mean $0$ and variance $Var_P\left( (X-1)\omega \right) $. The variance of $u$ can be estimated with the sample variance of $(X-1)\omega$.
A couple of notes on the original question:
the unweighted mean would not be an estimator of $\int{X \omega\ dP}$ in general, so if the objective is to estimate a quantity in a general population by means of observations in a different population, the consideration of simple mean is irrelevant ( $\omega$ is the likelihood ratio of the general population likelihood, and the observed population likelihood)
If one smooths $X$ by averaging over some other variable $A$ (e.g.: averaging over age group) to get $E(X|A)$, then the variance of the result is reduced: $Var( E(X|A) ) \le Var(X)$, what might have been what the statistician you consulted had in mind. The case of your question is different. In general, for a given $X$, $Var( (X-1)\omega)$ can be larger or smaller than $Var( (X-1) ) $, depending on $\omega$ (example follows).
** Example **
Here is an example to show that when the weights are case specific, the (asymptotic) standard deviation of the weighted mean is not comparable to the sd. of the unweighted mean. We work on the real line. Let $\varphi(x) = \frac{1}{2}$ if $|x| < 1$, $0$ otherwise and let
$$
dP = \frac{1}{2} \left[ \frac{1}{\epsilon} \varphi(\frac{x}{\epsilon} ) + \varphi(x-4) \right] dx ;
$$
$dP$ is a probability measure on the real line. We will take $\epsilon > 0$ and small.
Let $ \omega(x) = A$ if $-1 < x < 1$, $B$ if $1 \le x < 5$, where $A,B > 0$. Then $\omega(x) > 0$ a.e. $[dP]$. Moreover, $\int \omega dP = \frac{A+B}{2} = 1$ if we take $A,B$ so that $A+B=2$. The choice $A=B=1$ gives $\omega(x) = 1$, and using these values corresponds to using unweighted means.
When $A=1 - \delta$, $B=1+\delta$, a staightfoward computation shows that $Var( (X-1)\omega )$ is a quadratic function of $\delta$ of the form:
$$
Var( (X-1)\omega ) = Var(X) +
2\left[ \frac{7-\epsilon^2}{3} \right]\ \delta + O(\delta^2)
$$
so for small $\delta$, $Var( (X-1)\omega) > Var(X)$ if $\delta > 0$ and $Var( (X-1)\omega) < Var(X)$ if $\delta < 0$. | Variance of weighted mean greater than unweighted mean | Searching for how to compute variance of a weighted sum I came across this question, and I don't see a satisfactory answer that applies to the situation state by @user08041991, namely "Let's say we ha | Variance of weighted mean greater than unweighted mean
Searching for how to compute variance of a weighted sum I came across this question, and I don't see a satisfactory answer that applies to the situation state by @user08041991, namely "Let's say we have collected a series of heart rate measurements from a sample of people in a hospital. A weighting factor can then applied to each individual to scale the measurements to be reflective of national estimates."
In abstract terms, let $\{x_1,\dots,x_L\}$ be an i.i.d. sample drawn from a random variable $X$ with distribution $dP$ (in the example, these are the observed values of heart rate of people in a hospital). We want to estimate the expected value of $X$ not under $dP$, but under another probability distribution, $\omega\ dP$, where $\omega > 0$ a.s. [$dP$] is a known "weight" function, and the values ${\omega_1,\dots,\omega_L}$ at the randomly sampled observations are known. The setting bares resemblance to setting of importance sampling, where the weight is sought.
We can use the observations of $X$ and $\omega$ to define an estimator of the expected value of $X$ with respect to $\omega\ dP$, namely, the weighted average:
$$
\bar{x} = \frac{\sum_{j=1}^L x_j\omega_j}{ \sum_{j=1}^L \omega_j}
$$
The exact mean and variance of $\bar{x}$ cannot be given in closed form in general. However, one can compute the asymptotic distribution of $\bar{x}$ as $L \rightarrow \infty$. Towards that goal, consider the random vector
$$
V_L = \left(\begin{matrix} \frac{1}{L} \sum_j x_j \omega_j \\ \frac{1}{L} \sum_j \omega_j \end{matrix} \right)
$$
which, under suitable assumptions. converges a.e.[$dP$] to
$$
\left(\begin{matrix} \int{X \omega\ dP} \\ 1 \end{matrix} \right) ;
$$
moreover, under suitable assumptions,
$$
\sqrt{L} \left( V_L - \left(\begin{matrix} \int{X \omega\ dP} \\ 1 \end{matrix} \right) \right) \overset{P}{\rightsquigarrow} Z
$$
where $Z = \left(\begin{matrix} z_1 \\ z_2 \end{matrix} \right)$ is a normal vector with mean 0 and covariance
$$
\Sigma = \left[\begin{matrix} Var_P(X \omega) & Cov_P(X \omega, \omega) \\ Cov_P(X \omega, \omega) & Var_P(\omega) \end{matrix} \right]
$$
(here $Var_P$ is the variance under probability $dP$, etc.)
Therefore,
$$
\bar{x} = \frac{
\frac{1}{L} \sum_j x_j \omega_j }
{\frac{1}{L} \sum_j \omega_j} =
\frac{ \int{X \omega\ dP} + \frac{1}{ \sqrt{L}} z_1}{ 1 + \frac{1}{\sqrt{L}} z_2} \\
\approx
\int{X \omega\ dP} + \frac{1}{ \sqrt{L}} (z_1 -z_2) \\
= \int{X \omega\ dP} + \frac{1}{ \sqrt{L}} (1, -1)Z
$$
Now $(1, -1)Z$ is normal, with mean $0$ and variance
$$
E( (1,-1)Z Z^* (\begin{matrix} 1 \\-1 \end{matrix} )) = (1,-1) \Sigma (\begin{matrix} 1 \\-1 \end{matrix} ) \\
= Var_P(X \omega) - 2 Cov_P(X \omega, \omega) + Var_P(\omega) \\
= Var_P( X \omega - \omega) = Var_P( (X-1)\omega)
$$
Thus, we get:
$$
\sqrt{L} \Big( \bar{x} - \int{X \omega\ dP} \Big) ~ \overset{dP}{\rightsquigarrow } ~ u
$$
where $u$ is normally distributed, with mean $0$ and variance $Var_P\left( (X-1)\omega \right) $. The variance of $u$ can be estimated with the sample variance of $(X-1)\omega$.
A couple of notes on the original question:
the unweighted mean would not be an estimator of $\int{X \omega\ dP}$ in general, so if the objective is to estimate a quantity in a general population by means of observations in a different population, the consideration of simple mean is irrelevant ( $\omega$ is the likelihood ratio of the general population likelihood, and the observed population likelihood)
If one smooths $X$ by averaging over some other variable $A$ (e.g.: averaging over age group) to get $E(X|A)$, then the variance of the result is reduced: $Var( E(X|A) ) \le Var(X)$, what might have been what the statistician you consulted had in mind. The case of your question is different. In general, for a given $X$, $Var( (X-1)\omega)$ can be larger or smaller than $Var( (X-1) ) $, depending on $\omega$ (example follows).
** Example **
Here is an example to show that when the weights are case specific, the (asymptotic) standard deviation of the weighted mean is not comparable to the sd. of the unweighted mean. We work on the real line. Let $\varphi(x) = \frac{1}{2}$ if $|x| < 1$, $0$ otherwise and let
$$
dP = \frac{1}{2} \left[ \frac{1}{\epsilon} \varphi(\frac{x}{\epsilon} ) + \varphi(x-4) \right] dx ;
$$
$dP$ is a probability measure on the real line. We will take $\epsilon > 0$ and small.
Let $ \omega(x) = A$ if $-1 < x < 1$, $B$ if $1 \le x < 5$, where $A,B > 0$. Then $\omega(x) > 0$ a.e. $[dP]$. Moreover, $\int \omega dP = \frac{A+B}{2} = 1$ if we take $A,B$ so that $A+B=2$. The choice $A=B=1$ gives $\omega(x) = 1$, and using these values corresponds to using unweighted means.
When $A=1 - \delta$, $B=1+\delta$, a staightfoward computation shows that $Var( (X-1)\omega )$ is a quadratic function of $\delta$ of the form:
$$
Var( (X-1)\omega ) = Var(X) +
2\left[ \frac{7-\epsilon^2}{3} \right]\ \delta + O(\delta^2)
$$
so for small $\delta$, $Var( (X-1)\omega) > Var(X)$ if $\delta > 0$ and $Var( (X-1)\omega) < Var(X)$ if $\delta < 0$. | Variance of weighted mean greater than unweighted mean
Searching for how to compute variance of a weighted sum I came across this question, and I don't see a satisfactory answer that applies to the situation state by @user08041991, namely "Let's say we ha |
36,592 | k-means++ algorithm and outliers | In K-Means++ method, the first centroid (let's call C1) can be among any of the points. In other words, all points have an equal chance of getting selected as first centroid in the initialization stage. Now, once the first centroid is selected, the second centroid is selected in such as manner that, a probability of any point in the dataset (barring C1 of course) to get selected as second centroid is proportional to its squared-distance from the first centroid. Likewise, this logic extends for selecting the rest of the centroids among the data points in the initialization stage. In general, the probability that a point gets selected as centroid is proportional to its distance from the nearest centroid. In this way, the probabilistic approach in K-means++ as opposed to the random selection in K-Means ensures that the centroids selected in the initialization stage are as far as possible.
Now coming to your question, K-means++ is still sensitive to the outliers. One workaround could be removing outliers using techniques like LOF, RANSAC, simple univariate box-plots, etc. before clustering. The other I think could be reinitialize the Centroids in case you are getting sub-optimal performance in the first attempt. | k-means++ algorithm and outliers | In K-Means++ method, the first centroid (let's call C1) can be among any of the points. In other words, all points have an equal chance of getting selected as first centroid in the initialization stag | k-means++ algorithm and outliers
In K-Means++ method, the first centroid (let's call C1) can be among any of the points. In other words, all points have an equal chance of getting selected as first centroid in the initialization stage. Now, once the first centroid is selected, the second centroid is selected in such as manner that, a probability of any point in the dataset (barring C1 of course) to get selected as second centroid is proportional to its squared-distance from the first centroid. Likewise, this logic extends for selecting the rest of the centroids among the data points in the initialization stage. In general, the probability that a point gets selected as centroid is proportional to its distance from the nearest centroid. In this way, the probabilistic approach in K-means++ as opposed to the random selection in K-Means ensures that the centroids selected in the initialization stage are as far as possible.
Now coming to your question, K-means++ is still sensitive to the outliers. One workaround could be removing outliers using techniques like LOF, RANSAC, simple univariate box-plots, etc. before clustering. The other I think could be reinitialize the Centroids in case you are getting sub-optimal performance in the first attempt. | k-means++ algorithm and outliers
In K-Means++ method, the first centroid (let's call C1) can be among any of the points. In other words, all points have an equal chance of getting selected as first centroid in the initialization stag |
36,593 | k-means++ algorithm and outliers | Yes, the outlier os more likely to be picked. But there are also many more inliers, the chance of choosing one of them is also substantial. Say you have one outlier that is 10x farther, then it is 100x more likely to be picket than one inlier. If you have 100 inliers, the chances are about 50%, and if you have 1000 inliers, the chance of picking the outlier is about 10%.
But all in all I'd say k-means++ is probably more likely to pick outliers as initial centers (in above example, random would pick it at 1% resp. 0.1%), and thus probably more sensitive to outliers (and in fact, many people report little improvement with k-means++). Yet it does not make much of a difference: any k-means method is affected, because they all optimize the same objective. And sum-of-squares is an objective sensitive to outliers, independently of how you optimize.
Because of the problem being in the objective, picking the outlier as center may yield a "better" result. The global optimum may look like this! | k-means++ algorithm and outliers | Yes, the outlier os more likely to be picked. But there are also many more inliers, the chance of choosing one of them is also substantial. Say you have one outlier that is 10x farther, then it is 100 | k-means++ algorithm and outliers
Yes, the outlier os more likely to be picked. But there are also many more inliers, the chance of choosing one of them is also substantial. Say you have one outlier that is 10x farther, then it is 100x more likely to be picket than one inlier. If you have 100 inliers, the chances are about 50%, and if you have 1000 inliers, the chance of picking the outlier is about 10%.
But all in all I'd say k-means++ is probably more likely to pick outliers as initial centers (in above example, random would pick it at 1% resp. 0.1%), and thus probably more sensitive to outliers (and in fact, many people report little improvement with k-means++). Yet it does not make much of a difference: any k-means method is affected, because they all optimize the same objective. And sum-of-squares is an objective sensitive to outliers, independently of how you optimize.
Because of the problem being in the objective, picking the outlier as center may yield a "better" result. The global optimum may look like this! | k-means++ algorithm and outliers
Yes, the outlier os more likely to be picked. But there are also many more inliers, the chance of choosing one of them is also substantial. Say you have one outlier that is 10x farther, then it is 100 |
36,594 | k-means++ algorithm and outliers | This seems to be explained on slide 27.
They propose choosing the first cluster centroid randomly, as per classic k-means. But the second is chosen differently. We look at each point x and assign it a weight equal to the distance between x and the first chosen centroid, raised to a power alpha. Alpha can take several interesting values.
If alpha is 0, we have the classic k-means algorithm, because all points have weight 1, so they're all equally likely to be chosen.
If alpha is infinity (or, in practice, a very large number) we have the Furthest point method, where the furthest point has a very large weight, that makes it very likely to be picked. As seen on slides 24-26, this makes it sensitive to outliers.
They propose setting alpha to 2. This gives a nice probability of picking points farther away from the first picked centroid, but not automatically picking the furthest. This gives their method, k-means++, the nice property of being less sensitive to outliers. | k-means++ algorithm and outliers | This seems to be explained on slide 27.
They propose choosing the first cluster centroid randomly, as per classic k-means. But the second is chosen differently. We look at each point x and assign it a | k-means++ algorithm and outliers
This seems to be explained on slide 27.
They propose choosing the first cluster centroid randomly, as per classic k-means. But the second is chosen differently. We look at each point x and assign it a weight equal to the distance between x and the first chosen centroid, raised to a power alpha. Alpha can take several interesting values.
If alpha is 0, we have the classic k-means algorithm, because all points have weight 1, so they're all equally likely to be chosen.
If alpha is infinity (or, in practice, a very large number) we have the Furthest point method, where the furthest point has a very large weight, that makes it very likely to be picked. As seen on slides 24-26, this makes it sensitive to outliers.
They propose setting alpha to 2. This gives a nice probability of picking points farther away from the first picked centroid, but not automatically picking the furthest. This gives their method, k-means++, the nice property of being less sensitive to outliers. | k-means++ algorithm and outliers
This seems to be explained on slide 27.
They propose choosing the first cluster centroid randomly, as per classic k-means. But the second is chosen differently. We look at each point x and assign it a |
36,595 | Convergence of L-BFGS in non-convex settings | Yes, it is true that the L-BFGS-B algorithm will not converge in the true global minimum even if the learning rate is very small.
Using a Quasi-Newton method means you try to find the optimal $\theta$ using an iterative scheme similar to: $\theta_{k+1} = \theta_{k} - \alpha S_k g_k$ where $\theta$ are the parameters you optimise for, $k$ indices the iteration you are in, $\alpha$ is your learning rate, $S$ is the "Hessian-like" matrix associated with the system $A$ you try to solve and $g$ is the gradient, usually $S_{k=0} = I$. (Notice that if $S = A^{-1}$ you get back the simple Newton's method and if $S = I$ you get back the standard steepest descent algorithms.)
Now as you see the learning rate $\alpha$ only enters this scheme in the way that the algorithm updates its current solution. Having a very small $\alpha$ will only make sure that you use the local gradient information more prominently to the expense of the Hessian information. To draw a parallel with the paper you cite, this is the reason that L-BFGS-B occasionally diverges in the optimization of the $L_2$ regularised regression conducted while the gradient descent always converges. A very low $\alpha$ guarantees you will eventually converge to a local minimum but at the expense of a low learning rate.
Having said all that, non-convexity implies (but does not equates to) the presence of multiple local minima. The scheme above guarantees that you will find one of them for every given $\theta_0$. Converging to a particular minimum though does not guarantee that you will converge to the global minimum, just that in the presence of many local ones you choose the one that is closer to your $\theta_0$. Notice that L-BFGS-B works best when used on an at least locally differentiable convex objective/loss function. This is why in the case of robust regression they fail (rather miserably); the Hessian information gets muddled up completely and the algorithms gets stuck. This is further emphasised in the authors nice plot $2(c)$ where you see that the gradient descent just bounces around like crazy after a while because even the first order gradient information is not very informative. As pointed out in the comments there are other update schemes alternative to BFGS (eg. SR-1) that can handle non-convexity in case that standard BFGS updates fail. | Convergence of L-BFGS in non-convex settings | Yes, it is true that the L-BFGS-B algorithm will not converge in the true global minimum even if the learning rate is very small.
Using a Quasi-Newton method means you try to find the optimal $\theta$ | Convergence of L-BFGS in non-convex settings
Yes, it is true that the L-BFGS-B algorithm will not converge in the true global minimum even if the learning rate is very small.
Using a Quasi-Newton method means you try to find the optimal $\theta$ using an iterative scheme similar to: $\theta_{k+1} = \theta_{k} - \alpha S_k g_k$ where $\theta$ are the parameters you optimise for, $k$ indices the iteration you are in, $\alpha$ is your learning rate, $S$ is the "Hessian-like" matrix associated with the system $A$ you try to solve and $g$ is the gradient, usually $S_{k=0} = I$. (Notice that if $S = A^{-1}$ you get back the simple Newton's method and if $S = I$ you get back the standard steepest descent algorithms.)
Now as you see the learning rate $\alpha$ only enters this scheme in the way that the algorithm updates its current solution. Having a very small $\alpha$ will only make sure that you use the local gradient information more prominently to the expense of the Hessian information. To draw a parallel with the paper you cite, this is the reason that L-BFGS-B occasionally diverges in the optimization of the $L_2$ regularised regression conducted while the gradient descent always converges. A very low $\alpha$ guarantees you will eventually converge to a local minimum but at the expense of a low learning rate.
Having said all that, non-convexity implies (but does not equates to) the presence of multiple local minima. The scheme above guarantees that you will find one of them for every given $\theta_0$. Converging to a particular minimum though does not guarantee that you will converge to the global minimum, just that in the presence of many local ones you choose the one that is closer to your $\theta_0$. Notice that L-BFGS-B works best when used on an at least locally differentiable convex objective/loss function. This is why in the case of robust regression they fail (rather miserably); the Hessian information gets muddled up completely and the algorithms gets stuck. This is further emphasised in the authors nice plot $2(c)$ where you see that the gradient descent just bounces around like crazy after a while because even the first order gradient information is not very informative. As pointed out in the comments there are other update schemes alternative to BFGS (eg. SR-1) that can handle non-convexity in case that standard BFGS updates fail. | Convergence of L-BFGS in non-convex settings
Yes, it is true that the L-BFGS-B algorithm will not converge in the true global minimum even if the learning rate is very small.
Using a Quasi-Newton method means you try to find the optimal $\theta$ |
36,596 | Should data be normalized before or after imputation of missing data? | In my opinion, since you are using kNN imputation, and kNN is based on distances you should normalize your data prior to imputation kNN. The problem is, the normalization will be affected by NA values which should be ignored.
For instance, take the e.coli, in which variables magnitude is quite homogeneous. Creating NA's artificially for percentages from .05 to .20 by 0.1 will produce mean square error (MSE) between original and imputed dataset as follow:
0.08380378;
0.08594711;
0.09165323;
0.1005489;
0.09978495;
0.1120758;
0.1046071;
0.1048477;
0.1087384;
0.1283818;
0.1201014;
0.1264724;
0.1337024;
0.1457246;
0.1365055;
0.154879;
Otherwise, if you take Breast Tissue dataset, which have a heterogeneous magnitude through data you will have,
889.4696;
927.6151;
773.7256;
1229.74;
3356.833;
645.8142;
755.98;
2110.523;
987.5008;
1796.339;
1603.461;
1476.863;
2887.509;
2001.222;
905.6305;
2334.935;
This is, with normalization you can keep a reasonable track of MSE. | Should data be normalized before or after imputation of missing data? | In my opinion, since you are using kNN imputation, and kNN is based on distances you should normalize your data prior to imputation kNN. The problem is, the normalization will be affected by NA values | Should data be normalized before or after imputation of missing data?
In my opinion, since you are using kNN imputation, and kNN is based on distances you should normalize your data prior to imputation kNN. The problem is, the normalization will be affected by NA values which should be ignored.
For instance, take the e.coli, in which variables magnitude is quite homogeneous. Creating NA's artificially for percentages from .05 to .20 by 0.1 will produce mean square error (MSE) between original and imputed dataset as follow:
0.08380378;
0.08594711;
0.09165323;
0.1005489;
0.09978495;
0.1120758;
0.1046071;
0.1048477;
0.1087384;
0.1283818;
0.1201014;
0.1264724;
0.1337024;
0.1457246;
0.1365055;
0.154879;
Otherwise, if you take Breast Tissue dataset, which have a heterogeneous magnitude through data you will have,
889.4696;
927.6151;
773.7256;
1229.74;
3356.833;
645.8142;
755.98;
2110.523;
987.5008;
1796.339;
1603.461;
1476.863;
2887.509;
2001.222;
905.6305;
2334.935;
This is, with normalization you can keep a reasonable track of MSE. | Should data be normalized before or after imputation of missing data?
In my opinion, since you are using kNN imputation, and kNN is based on distances you should normalize your data prior to imputation kNN. The problem is, the normalization will be affected by NA values |
36,597 | Should data be normalized before or after imputation of missing data? | this paper suggests that normalization should be done before imputation
We suggest that normalization be done first followed by missing value imputations.
https://www.ncbi.nlm.nih.gov/pmc/articles/PMC3489534/#:~:text=We%20suggest%20that%20normalization%20be,imputation%2C%20significance%20analysis%20and%20visualization. | Should data be normalized before or after imputation of missing data? | this paper suggests that normalization should be done before imputation
We suggest that normalization be done first followed by missing value imputations.
https://www.ncbi.nlm.nih.gov/pmc/articles/P | Should data be normalized before or after imputation of missing data?
this paper suggests that normalization should be done before imputation
We suggest that normalization be done first followed by missing value imputations.
https://www.ncbi.nlm.nih.gov/pmc/articles/PMC3489534/#:~:text=We%20suggest%20that%20normalization%20be,imputation%2C%20significance%20analysis%20and%20visualization. | Should data be normalized before or after imputation of missing data?
this paper suggests that normalization should be done before imputation
We suggest that normalization be done first followed by missing value imputations.
https://www.ncbi.nlm.nih.gov/pmc/articles/P |
36,598 | Are parametric tests on rank transformed data equivalent to non-parametric test on raw data? | I think it's important to clearly distinguish between
a. using a parametric statistic on the ranks as the basis for a nonparametric test
b. using a parametric test as is, on the ranks
(we might also consider a third option -- like "b." but in some way scaling or adjusting the statistic to get a better approximation to the "true" p-value from ordinary tables. I'll ignore this possibility for now, but it may be a fruitful endeavour.)
In the first case, we would compute the statistic as usual, but when finding the p-value we'd look at the distribution of that test statistic under the null. In particular, the non-parametric rank-based tests are permutation tests (which - because the set of ranks is fixed for each sample size, for continuous distributions - don't depend on the specific observed values). So we would compute the permutation distribution of the parametric test applied to the ranks.
When we do that we do indeed sometimes get a test that's equivalent to a well-known non-parametric test (equivalent in this case means that it "orders" the set of possible samples in the same way, so it will always give the same p-values)
In the second case, we simply ignore that we have ranks and treat the ranks as if they were independent samples from whatever the assumed distribution was. That won't give the same p-values as the nonparametric test. Indeed, in small samples the distribution can't be right. However, for some tests, at larger sample sizes it can become fairly close, and then the tests will have about the right significance levels. When that happens, p-values may be quite similar to what they were in the first case.
We can see this with the ordinary equal variance two-sample t-test vs the Wilcoxon test:
The first plot shows us that indeed in this example the p-values for each of the samples are in the same order (the monotonicity indicates that the "equivalent tests" under part a was holding up -- as is already known for this pair of tests). It is also encouraging because it looks like the p-vaue pairs are quite close to the $y=x$ line. The second plot shows the difference in p-values. Now we can see that the t-test applied directly to ranks as if they were i.i.d normal data gives p-values that are nearly always lower than the Wilcoxon-Mann-Whitney (and indeed, typically too low).
[Other sample sizes show similar patterns - at equal sample sizes the broad shape of the pattern of differences remains, but the scale on the y-axis of the second plot gets smaller as sample size goes up; at unequal sample sizes the shape of the second plot changes but the lower p-values for the t remains.]
So if we use the test as in "b.", we reject too often at any significance level.
However, since that difference grows smaller as sample size increases, if both samples are large, this may not bother us much.
(Note that this discussion hasn't investigated power yet, nor any other tests than this simple comparison, but many of the points I made will carry over to other tests.)
Oh, I guess people will want code. I did that in R:
n1=40;n=n1+n1
res=replicate(1000,{v=sample(n);
c(t.test(v[1:n1],v[(n1+1):n],var.equal=TRUE)$p.value,
wilcox.test(v[1:n1],v[(n1+1):n])$p.value)
})
note that v contains the current random permutation of ranks under the null
Takes about a second on my laptop. Note that the t-test p-values are in the first row of res and the WMW p-values are in the second row. | Are parametric tests on rank transformed data equivalent to non-parametric test on raw data? | I think it's important to clearly distinguish between
a. using a parametric statistic on the ranks as the basis for a nonparametric test
b. using a parametric test as is, on the ranks
(we might also c | Are parametric tests on rank transformed data equivalent to non-parametric test on raw data?
I think it's important to clearly distinguish between
a. using a parametric statistic on the ranks as the basis for a nonparametric test
b. using a parametric test as is, on the ranks
(we might also consider a third option -- like "b." but in some way scaling or adjusting the statistic to get a better approximation to the "true" p-value from ordinary tables. I'll ignore this possibility for now, but it may be a fruitful endeavour.)
In the first case, we would compute the statistic as usual, but when finding the p-value we'd look at the distribution of that test statistic under the null. In particular, the non-parametric rank-based tests are permutation tests (which - because the set of ranks is fixed for each sample size, for continuous distributions - don't depend on the specific observed values). So we would compute the permutation distribution of the parametric test applied to the ranks.
When we do that we do indeed sometimes get a test that's equivalent to a well-known non-parametric test (equivalent in this case means that it "orders" the set of possible samples in the same way, so it will always give the same p-values)
In the second case, we simply ignore that we have ranks and treat the ranks as if they were independent samples from whatever the assumed distribution was. That won't give the same p-values as the nonparametric test. Indeed, in small samples the distribution can't be right. However, for some tests, at larger sample sizes it can become fairly close, and then the tests will have about the right significance levels. When that happens, p-values may be quite similar to what they were in the first case.
We can see this with the ordinary equal variance two-sample t-test vs the Wilcoxon test:
The first plot shows us that indeed in this example the p-values for each of the samples are in the same order (the monotonicity indicates that the "equivalent tests" under part a was holding up -- as is already known for this pair of tests). It is also encouraging because it looks like the p-vaue pairs are quite close to the $y=x$ line. The second plot shows the difference in p-values. Now we can see that the t-test applied directly to ranks as if they were i.i.d normal data gives p-values that are nearly always lower than the Wilcoxon-Mann-Whitney (and indeed, typically too low).
[Other sample sizes show similar patterns - at equal sample sizes the broad shape of the pattern of differences remains, but the scale on the y-axis of the second plot gets smaller as sample size goes up; at unequal sample sizes the shape of the second plot changes but the lower p-values for the t remains.]
So if we use the test as in "b.", we reject too often at any significance level.
However, since that difference grows smaller as sample size increases, if both samples are large, this may not bother us much.
(Note that this discussion hasn't investigated power yet, nor any other tests than this simple comparison, but many of the points I made will carry over to other tests.)
Oh, I guess people will want code. I did that in R:
n1=40;n=n1+n1
res=replicate(1000,{v=sample(n);
c(t.test(v[1:n1],v[(n1+1):n],var.equal=TRUE)$p.value,
wilcox.test(v[1:n1],v[(n1+1):n])$p.value)
})
note that v contains the current random permutation of ranks under the null
Takes about a second on my laptop. Note that the t-test p-values are in the first row of res and the WMW p-values are in the second row. | Are parametric tests on rank transformed data equivalent to non-parametric test on raw data?
I think it's important to clearly distinguish between
a. using a parametric statistic on the ranks as the basis for a nonparametric test
b. using a parametric test as is, on the ranks
(we might also c |
36,599 | How to measure probabilistic forecast accuracy? | Your comment sounds as if you are really looking for a density forecast rather than a point forecast, i.e., you want to forecast the full probability distribution of the future outcome(s). This is a very good idea. Density forecasting is common in financial or econometric forecasting, but unfortunately it is rarely treated in other forecasting textbooks and courses. Tay & Wallis (2000, Journal of Forecasting) give a useful early survey.
The most common way of evaluating density forecasts uses the Probability Integral Transform (PIT). The canonical reference is Diebold, Gunther & Tay (1998, International Economic Review). Berkowitz (2001, Journal of Business & Economic Statistics) and Bao, Lee & Saltoglu (2007, Journal of Forecasting) give alternatives.
Recently, interest has risen in (proper) scoring rules, like the Brier score you mention. Literature includes Mitchell & Wallis (2011, Journal of Applied Econometrics) and Gneiting, Balabdaoui & Raftery (2007, JRSS-B).
Finally, Gneiting & Katzfuss (2014, Annual Review of Statistics and its Application) gives a more recent overview of density (or probabilistic) forecasting, focusing again on scoring rules. | How to measure probabilistic forecast accuracy? | Your comment sounds as if you are really looking for a density forecast rather than a point forecast, i.e., you want to forecast the full probability distribution of the future outcome(s). This is a v | How to measure probabilistic forecast accuracy?
Your comment sounds as if you are really looking for a density forecast rather than a point forecast, i.e., you want to forecast the full probability distribution of the future outcome(s). This is a very good idea. Density forecasting is common in financial or econometric forecasting, but unfortunately it is rarely treated in other forecasting textbooks and courses. Tay & Wallis (2000, Journal of Forecasting) give a useful early survey.
The most common way of evaluating density forecasts uses the Probability Integral Transform (PIT). The canonical reference is Diebold, Gunther & Tay (1998, International Economic Review). Berkowitz (2001, Journal of Business & Economic Statistics) and Bao, Lee & Saltoglu (2007, Journal of Forecasting) give alternatives.
Recently, interest has risen in (proper) scoring rules, like the Brier score you mention. Literature includes Mitchell & Wallis (2011, Journal of Applied Econometrics) and Gneiting, Balabdaoui & Raftery (2007, JRSS-B).
Finally, Gneiting & Katzfuss (2014, Annual Review of Statistics and its Application) gives a more recent overview of density (or probabilistic) forecasting, focusing again on scoring rules. | How to measure probabilistic forecast accuracy?
Your comment sounds as if you are really looking for a density forecast rather than a point forecast, i.e., you want to forecast the full probability distribution of the future outcome(s). This is a v |
36,600 | What's the relationship between covariance, shared variance, and common variance? | Because the 1st link in your question sets against my comments in that other thread I'm just repeating here what some of the comments there said. I think that your question is chiefly about terminology, which might be used differently by different people.
I believe that "shared variance" between two variables could be identified as their covariance. Texts/books often define correlation coefficient to be "shared variance divided by combined [or hybrid] variance". But "common variance" is a well established term coming from factor analysis. It is that collinearity variance due to common factor(s) which make the variables correlate and thus funds the covariance.
Note that covariance is the inside affair between the variables, but common variance is the variance of (and given by) the third party, a factor (another, latent variable).
Covariance is depicted just below. Two correlated variables $X_1$ and $X_2$ are vectors displayed in the reduced subject space, and because we assume the variables were centered their vectors length squared are their variances, while the cosine of the angle between them is their correlation: $\sigma_1^2=|X_1|^2$, $\sigma_2^2=|X_2|^2$, $r_{12}=\cos \phi$.
Orthogonal projection of $X_2$ on $X_1$, labeled here as $X_2'$, is the linear prediction of $X_2$ by $X_1$ (simple linear regression) and its variance $\sigma_2'^2=|X_2'|^2$. Symmetrically the prediction of $X_1$ by $X_2$ is $X_1'$, with variance $\sigma_1'^2=|X_1'|^2$. Then the covariance or "shared variance" is
$\sigma_{12}^2= \sigma_1\sigma_2 r_{12}= \sigma_1\sigma_2' = \sigma_1'\sigma_2$.
Covariance is the predicted variability amplified (multiplied) by the variability of the predictor.
Common variance is portrayed on the following picture; it is brought from here where it was explained in detail.
Instead of just 2 variables $X_1$, $X_2$, we have also latent common factor $F$. This factor partly is the generator of both $X_1$ and $X_2$ and thus is the cause of their correlatedness. The remaining, not generated by $F$ portions of the variables are their latent unique factors $U_1$ and $U_2$. Unique factors are independent of each other and of the common factor and they are what attenuate the absolute collinear correlation (covariation) to its observed magnitude.
The $F$'s variance or common variance is (Pythagorean):
$\sigma_F^2= a_1^2+a_2^2 = (\sigma_1^2-u_1^2) + (\sigma_2^2-u_2^2) = (\sigma_1^2+\sigma_2^2)-(u_1^2+u_2^2)$,
where $a$s are the factor loadings, the covariances between the factor and the variables. And, according to factor theorem,
$\sigma_{12}^2=a_1a_2$,
so you can see the difference between "shared" $\sigma_{12}^2$ and "common" $\sigma_F^2$ variances.
By "common variance" we sometimes may mean not the common factor variance as before but the portion of it, that can be linearly explained, predicted by the variables $X_1$ and $X_2$. I'm speaking now of the factor scores variance. Factor scores are the approximately estimated values of a factor (true factor's values aren't available). That prediction vector (and its variance is its length squared) lies in "plane X", the space of the variables - see pic at the end of this answer. | What's the relationship between covariance, shared variance, and common variance? | Because the 1st link in your question sets against my comments in that other thread I'm just repeating here what some of the comments there said. I think that your question is chiefly about terminolog | What's the relationship between covariance, shared variance, and common variance?
Because the 1st link in your question sets against my comments in that other thread I'm just repeating here what some of the comments there said. I think that your question is chiefly about terminology, which might be used differently by different people.
I believe that "shared variance" between two variables could be identified as their covariance. Texts/books often define correlation coefficient to be "shared variance divided by combined [or hybrid] variance". But "common variance" is a well established term coming from factor analysis. It is that collinearity variance due to common factor(s) which make the variables correlate and thus funds the covariance.
Note that covariance is the inside affair between the variables, but common variance is the variance of (and given by) the third party, a factor (another, latent variable).
Covariance is depicted just below. Two correlated variables $X_1$ and $X_2$ are vectors displayed in the reduced subject space, and because we assume the variables were centered their vectors length squared are their variances, while the cosine of the angle between them is their correlation: $\sigma_1^2=|X_1|^2$, $\sigma_2^2=|X_2|^2$, $r_{12}=\cos \phi$.
Orthogonal projection of $X_2$ on $X_1$, labeled here as $X_2'$, is the linear prediction of $X_2$ by $X_1$ (simple linear regression) and its variance $\sigma_2'^2=|X_2'|^2$. Symmetrically the prediction of $X_1$ by $X_2$ is $X_1'$, with variance $\sigma_1'^2=|X_1'|^2$. Then the covariance or "shared variance" is
$\sigma_{12}^2= \sigma_1\sigma_2 r_{12}= \sigma_1\sigma_2' = \sigma_1'\sigma_2$.
Covariance is the predicted variability amplified (multiplied) by the variability of the predictor.
Common variance is portrayed on the following picture; it is brought from here where it was explained in detail.
Instead of just 2 variables $X_1$, $X_2$, we have also latent common factor $F$. This factor partly is the generator of both $X_1$ and $X_2$ and thus is the cause of their correlatedness. The remaining, not generated by $F$ portions of the variables are their latent unique factors $U_1$ and $U_2$. Unique factors are independent of each other and of the common factor and they are what attenuate the absolute collinear correlation (covariation) to its observed magnitude.
The $F$'s variance or common variance is (Pythagorean):
$\sigma_F^2= a_1^2+a_2^2 = (\sigma_1^2-u_1^2) + (\sigma_2^2-u_2^2) = (\sigma_1^2+\sigma_2^2)-(u_1^2+u_2^2)$,
where $a$s are the factor loadings, the covariances between the factor and the variables. And, according to factor theorem,
$\sigma_{12}^2=a_1a_2$,
so you can see the difference between "shared" $\sigma_{12}^2$ and "common" $\sigma_F^2$ variances.
By "common variance" we sometimes may mean not the common factor variance as before but the portion of it, that can be linearly explained, predicted by the variables $X_1$ and $X_2$. I'm speaking now of the factor scores variance. Factor scores are the approximately estimated values of a factor (true factor's values aren't available). That prediction vector (and its variance is its length squared) lies in "plane X", the space of the variables - see pic at the end of this answer. | What's the relationship between covariance, shared variance, and common variance?
Because the 1st link in your question sets against my comments in that other thread I'm just repeating here what some of the comments there said. I think that your question is chiefly about terminolog |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.