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
|
|---|---|---|---|---|---|---|
45,201
|
Math behind applying elastic net penalties to logistic regression
|
Yes, the penalties are simply added to the cost function (and negative/positive depending on whether you minimize or maximize the function).
You can view penalty terms in a cost function (e.g. costfunction like the likelihood) as being equivalent to the Lagrange multiplier equivalent of a problem like
$${\text{maximize} f(\beta) \text{ subject to $g(\beta) \leq t$ and $h(\beta) \leq t_2$}}$$
$$\begin{align}
f(\beta) &= \mathcal{L}(\beta \vert x) \\
g(\beta) &= \vert\vert \beta \vert\vert_1\\
h(\beta) &= \vert\vert \beta \vert\vert^2
\end{align}$$
In simple words. You maximize the log likelihood function with restrictions on the size of the quadratic norm of the coefficients $\vert\vert \beta \vert\vert^2$ (equivalent to ridge regression) and the size of the $l_1$ norm of the coefficients $\vert\vert \beta \vert\vert_1$ (equivalent to lasso).
See also Equivalence between Elastic Net formulations
|
Math behind applying elastic net penalties to logistic regression
|
Yes, the penalties are simply added to the cost function (and negative/positive depending on whether you minimize or maximize the function).
You can view penalty terms in a cost function (e.g. costfun
|
Math behind applying elastic net penalties to logistic regression
Yes, the penalties are simply added to the cost function (and negative/positive depending on whether you minimize or maximize the function).
You can view penalty terms in a cost function (e.g. costfunction like the likelihood) as being equivalent to the Lagrange multiplier equivalent of a problem like
$${\text{maximize} f(\beta) \text{ subject to $g(\beta) \leq t$ and $h(\beta) \leq t_2$}}$$
$$\begin{align}
f(\beta) &= \mathcal{L}(\beta \vert x) \\
g(\beta) &= \vert\vert \beta \vert\vert_1\\
h(\beta) &= \vert\vert \beta \vert\vert^2
\end{align}$$
In simple words. You maximize the log likelihood function with restrictions on the size of the quadratic norm of the coefficients $\vert\vert \beta \vert\vert^2$ (equivalent to ridge regression) and the size of the $l_1$ norm of the coefficients $\vert\vert \beta \vert\vert_1$ (equivalent to lasso).
See also Equivalence between Elastic Net formulations
|
Math behind applying elastic net penalties to logistic regression
Yes, the penalties are simply added to the cost function (and negative/positive depending on whether you minimize or maximize the function).
You can view penalty terms in a cost function (e.g. costfun
|
45,202
|
How to reconcile these two versions of a "linear model"?
|
You have it exactly right.
For instance, you might have two predictors $X_1$ and $X_2$. In your model, you decide to use $X_1$ untransformed, "as-is": $h_1(X_1)=X_1$. For your second predictor, you decide to use $X_2$ both untransformed, $h_1(X_2)=X_2$ and squared, $h_2(X_2)=X_2^2$. Your model contains three predictors $X_1, X_2, X_2^2$, so your parameter vector is also of length three.
Unless you also add an intercept, that is. Which in this framework you could consider yet another function, namely the one that sends everything to $1$: $h_0(X)=1$.
|
How to reconcile these two versions of a "linear model"?
|
You have it exactly right.
For instance, you might have two predictors $X_1$ and $X_2$. In your model, you decide to use $X_1$ untransformed, "as-is": $h_1(X_1)=X_1$. For your second predictor, you de
|
How to reconcile these two versions of a "linear model"?
You have it exactly right.
For instance, you might have two predictors $X_1$ and $X_2$. In your model, you decide to use $X_1$ untransformed, "as-is": $h_1(X_1)=X_1$. For your second predictor, you decide to use $X_2$ both untransformed, $h_1(X_2)=X_2$ and squared, $h_2(X_2)=X_2^2$. Your model contains three predictors $X_1, X_2, X_2^2$, so your parameter vector is also of length three.
Unless you also add an intercept, that is. Which in this framework you could consider yet another function, namely the one that sends everything to $1$: $h_0(X)=1$.
|
How to reconcile these two versions of a "linear model"?
You have it exactly right.
For instance, you might have two predictors $X_1$ and $X_2$. In your model, you decide to use $X_1$ untransformed, "as-is": $h_1(X_1)=X_1$. For your second predictor, you de
|
45,203
|
How to reconcile these two versions of a "linear model"?
|
Consider what happens if every $h_j$ is the identity function.
Spoiler alert: It's exactly the same as the other model.
What your professor is showing you is the idea of nonlinear basis functions that allow you to introduce curvature, not just lines and planes. The gist is that, once you do the transformation, you have some other features and then fit the linear regression to those new features. Let's go through an example.
EXAMPLE
We start out with a variable $y$ that we want to predict, given two features $x_1$ and $x_2$. The basic linear regression would be $y = \beta_0 + \beta_1x_1 +\beta_2x_2 +\epsilon$. However, you know from your domain knowledge (your understanding of the physics, biology, economics, etc) that $y$ should depend on $x_1^2$, not $x_1$. Enter the $h$ function $h(x_1) = x_1^2$. Now write your new linear regression equation, $y = \beta_0 + \beta_1h(x_1) +\beta_2x_2 +\epsilon$. You can think of this as $h(x_1) = x_3$. Then you wind up with a linear regression $y = \beta_0 + \beta_1x_3 +\beta_2x_2 +\epsilon$, which is the usual format.
The idea is that the matrix multipliction does not know or care how you got your $x_3$, only that you got it.
(In fact, your professor has not made this complicated enough. It is routine to use interaction terms, such as $y = \beta_0 + \beta_1x_1 +\beta_2x_2 \beta_3 x_1x_2 +\epsilon$. This involves some function $h(x_1, x_2) = x_1x_2$, yet your definition does not allow for that. Really, each of your $h$ functions should be functions of all of the features.)
MathematicalMonk (Jeffrey Miller) has a great video about this on YouTube.
|
How to reconcile these two versions of a "linear model"?
|
Consider what happens if every $h_j$ is the identity function.
Spoiler alert: It's exactly the same as the other model.
What your professor is showing you is the idea of nonlinear basis functions that
|
How to reconcile these two versions of a "linear model"?
Consider what happens if every $h_j$ is the identity function.
Spoiler alert: It's exactly the same as the other model.
What your professor is showing you is the idea of nonlinear basis functions that allow you to introduce curvature, not just lines and planes. The gist is that, once you do the transformation, you have some other features and then fit the linear regression to those new features. Let's go through an example.
EXAMPLE
We start out with a variable $y$ that we want to predict, given two features $x_1$ and $x_2$. The basic linear regression would be $y = \beta_0 + \beta_1x_1 +\beta_2x_2 +\epsilon$. However, you know from your domain knowledge (your understanding of the physics, biology, economics, etc) that $y$ should depend on $x_1^2$, not $x_1$. Enter the $h$ function $h(x_1) = x_1^2$. Now write your new linear regression equation, $y = \beta_0 + \beta_1h(x_1) +\beta_2x_2 +\epsilon$. You can think of this as $h(x_1) = x_3$. Then you wind up with a linear regression $y = \beta_0 + \beta_1x_3 +\beta_2x_2 +\epsilon$, which is the usual format.
The idea is that the matrix multipliction does not know or care how you got your $x_3$, only that you got it.
(In fact, your professor has not made this complicated enough. It is routine to use interaction terms, such as $y = \beta_0 + \beta_1x_1 +\beta_2x_2 \beta_3 x_1x_2 +\epsilon$. This involves some function $h(x_1, x_2) = x_1x_2$, yet your definition does not allow for that. Really, each of your $h$ functions should be functions of all of the features.)
MathematicalMonk (Jeffrey Miller) has a great video about this on YouTube.
|
How to reconcile these two versions of a "linear model"?
Consider what happens if every $h_j$ is the identity function.
Spoiler alert: It's exactly the same as the other model.
What your professor is showing you is the idea of nonlinear basis functions that
|
45,204
|
Do I lose a degree of freedom if there is a restriction on the explanatory variables?
|
By introducing a constraint, you would normally gain a degree of freedom, since there are fewer free parameters to be estimated. In your case, you would have to omit one of the variables (e.g. $x_3$) from the model to prevent perfect multicollinearity, and you would no longer have to estimate $\beta_3$ and $\beta_6$. So you would actually gain two degrees of freedom.
|
Do I lose a degree of freedom if there is a restriction on the explanatory variables?
|
By introducing a constraint, you would normally gain a degree of freedom, since there are fewer free parameters to be estimated. In your case, you would have to omit one of the variables (e.g. $x_3$)
|
Do I lose a degree of freedom if there is a restriction on the explanatory variables?
By introducing a constraint, you would normally gain a degree of freedom, since there are fewer free parameters to be estimated. In your case, you would have to omit one of the variables (e.g. $x_3$) from the model to prevent perfect multicollinearity, and you would no longer have to estimate $\beta_3$ and $\beta_6$. So you would actually gain two degrees of freedom.
|
Do I lose a degree of freedom if there is a restriction on the explanatory variables?
By introducing a constraint, you would normally gain a degree of freedom, since there are fewer free parameters to be estimated. In your case, you would have to omit one of the variables (e.g. $x_3$)
|
45,205
|
What is the score function of two parameters?
|
The score for a multiple parameter problem (a vector parameter) is itself a vector. We need to take partial derivatives of the log likelihood with respect to each model parameter.
Let's consider an example. Find the score vector for $X_1, X_2, \ldots, X_n \sim N(\mu, \sigma^2)$ where the $X_i$ are iid $N(\mu, \sigma^2)$ samples. Let $\mathbf{x} = (x_1, x_2, \ldots, x_n)$ be a random sample of $(X_1, X_2, \ldots, X_n)$.
In this case, it can be shown that the log likelihood is
$$\ell(\mu, \sigma | \mathbf{x}) = -\frac{n}{2}\log (2 \pi) - n\log\sigma - \frac{1}{2\sigma^2} \sum_{i=1}^n (x_i - \mu)^2$$
So differentiation w.r.t. $\mu$ gives
$$ \frac{\partial \ell}{\partial \mu} = \frac{1}{\sigma^2} \sum_{i=1}^n (x_i - \mu)$$
differentiation w.r.t. $\sigma$ gives
$$ \frac{\partial \ell}{\partial \sigma} = -\frac{n}{\sigma} + \frac{1}{\sigma^3}\sum_{i=1}^n (x_i - \mu)^2.$$
The score is then the vector $S(\mu, \sigma) = \left( \frac{\partial \ell}{\partial \mu}, \frac{\partial \ell}{\partial \sigma} \right)^T$.
Concisely, we can write $S(\mathbf{\theta}) = \nabla_{\mathbf{\theta}} \ell(\mathbf{\theta}|\mathbf{x})$ for any vector parameter $\mathbf{\theta}$ where $\ell(\theta |\mathbf{x})$ is the log likelihood function.
|
What is the score function of two parameters?
|
The score for a multiple parameter problem (a vector parameter) is itself a vector. We need to take partial derivatives of the log likelihood with respect to each model parameter.
Let's consider an ex
|
What is the score function of two parameters?
The score for a multiple parameter problem (a vector parameter) is itself a vector. We need to take partial derivatives of the log likelihood with respect to each model parameter.
Let's consider an example. Find the score vector for $X_1, X_2, \ldots, X_n \sim N(\mu, \sigma^2)$ where the $X_i$ are iid $N(\mu, \sigma^2)$ samples. Let $\mathbf{x} = (x_1, x_2, \ldots, x_n)$ be a random sample of $(X_1, X_2, \ldots, X_n)$.
In this case, it can be shown that the log likelihood is
$$\ell(\mu, \sigma | \mathbf{x}) = -\frac{n}{2}\log (2 \pi) - n\log\sigma - \frac{1}{2\sigma^2} \sum_{i=1}^n (x_i - \mu)^2$$
So differentiation w.r.t. $\mu$ gives
$$ \frac{\partial \ell}{\partial \mu} = \frac{1}{\sigma^2} \sum_{i=1}^n (x_i - \mu)$$
differentiation w.r.t. $\sigma$ gives
$$ \frac{\partial \ell}{\partial \sigma} = -\frac{n}{\sigma} + \frac{1}{\sigma^3}\sum_{i=1}^n (x_i - \mu)^2.$$
The score is then the vector $S(\mu, \sigma) = \left( \frac{\partial \ell}{\partial \mu}, \frac{\partial \ell}{\partial \sigma} \right)^T$.
Concisely, we can write $S(\mathbf{\theta}) = \nabla_{\mathbf{\theta}} \ell(\mathbf{\theta}|\mathbf{x})$ for any vector parameter $\mathbf{\theta}$ where $\ell(\theta |\mathbf{x})$ is the log likelihood function.
|
What is the score function of two parameters?
The score for a multiple parameter problem (a vector parameter) is itself a vector. We need to take partial derivatives of the log likelihood with respect to each model parameter.
Let's consider an ex
|
45,206
|
Confusion in classification and regression task exception
|
To start from the end:
should I just stop reading random articles?
Maybe you should first take a course on statistics, data science, or machine learning, before you return to reading 'random articles'. There are many gems on the internet, but even more garbage, and without a solid foundation it may be hard to distinguish between them.
Classification with probabilities output seems odd
This is subjective. Maybe probabilities aren't always the best criterion for classification, but sometimes they are, and even more often, another continuous value (perhaps expected gain/loss, which is, in part, derived from the probability) is. As an (artificial) example:
Say, you are an umbrella shop owner and the weather forecast says that there is a 70% chance of raining today. Do you open your shop, or do you give your employees a day off? If you open your shop, but it doesn't rain, you have effectively lost money. If you don't open the shop, but it rains, you have forgone profit. Depending on the cost of keeping the shop open and the profit you make on a rainy day and on the probability of raining you can make the optimal decision.
IMHO many models can be reformed for either
For example: Generalised linear models. Depending on the 'link function' they can be used for linear regression, Poisson regression, logistic regression (which would give you probabilities and allow for classification), and many more.
The choice of the model depends (or should depend) on the assumed process that generates the data. In statistics, people usually assume a law that relates the input and the output variables and superimpose a random noise ('error') over it. Depending on the form (probability distribution) of the noise you get different models.
For example, if you assume that the noise is additive and Gaussian, this leads to ordinary linear regression. On the other hand, if you assume that the 'noise' is something like a coin flip (a 'Bernoulli process'), you get logistic regression.
Hope that helps.
|
Confusion in classification and regression task exception
|
To start from the end:
should I just stop reading random articles?
Maybe you should first take a course on statistics, data science, or machine learning, before you return to reading 'random article
|
Confusion in classification and regression task exception
To start from the end:
should I just stop reading random articles?
Maybe you should first take a course on statistics, data science, or machine learning, before you return to reading 'random articles'. There are many gems on the internet, but even more garbage, and without a solid foundation it may be hard to distinguish between them.
Classification with probabilities output seems odd
This is subjective. Maybe probabilities aren't always the best criterion for classification, but sometimes they are, and even more often, another continuous value (perhaps expected gain/loss, which is, in part, derived from the probability) is. As an (artificial) example:
Say, you are an umbrella shop owner and the weather forecast says that there is a 70% chance of raining today. Do you open your shop, or do you give your employees a day off? If you open your shop, but it doesn't rain, you have effectively lost money. If you don't open the shop, but it rains, you have forgone profit. Depending on the cost of keeping the shop open and the profit you make on a rainy day and on the probability of raining you can make the optimal decision.
IMHO many models can be reformed for either
For example: Generalised linear models. Depending on the 'link function' they can be used for linear regression, Poisson regression, logistic regression (which would give you probabilities and allow for classification), and many more.
The choice of the model depends (or should depend) on the assumed process that generates the data. In statistics, people usually assume a law that relates the input and the output variables and superimpose a random noise ('error') over it. Depending on the form (probability distribution) of the noise you get different models.
For example, if you assume that the noise is additive and Gaussian, this leads to ordinary linear regression. On the other hand, if you assume that the 'noise' is something like a coin flip (a 'Bernoulli process'), you get logistic regression.
Hope that helps.
|
Confusion in classification and regression task exception
To start from the end:
should I just stop reading random articles?
Maybe you should first take a course on statistics, data science, or machine learning, before you return to reading 'random article
|
45,207
|
Confusion in classification and regression task exception
|
Any neural network trained on a crossentropy loss function performs categorical prediction, but the raw (trained) model output is a probability distribution (after normalization, possibly softmax).
Outputting a distribution is a hallmark of probabilistic methods. The model doesn't make a prediction, per se, but you can think of the model return as prediction distribution. This is the theoretical basis for using crossentropy functions for training models. The prediction comes from taking the choice that maximizes the probability of being correct according to the distribution. To obtain a single prediction from the model for use in an application, we guess the most-likely prediction according to the distribution we got from the neural network model.
Any distinction is a result of the method used to define the model and the mathematical optimization method used to solve it.
|
Confusion in classification and regression task exception
|
Any neural network trained on a crossentropy loss function performs categorical prediction, but the raw (trained) model output is a probability distribution (after normalization, possibly softmax).
Ou
|
Confusion in classification and regression task exception
Any neural network trained on a crossentropy loss function performs categorical prediction, but the raw (trained) model output is a probability distribution (after normalization, possibly softmax).
Outputting a distribution is a hallmark of probabilistic methods. The model doesn't make a prediction, per se, but you can think of the model return as prediction distribution. This is the theoretical basis for using crossentropy functions for training models. The prediction comes from taking the choice that maximizes the probability of being correct according to the distribution. To obtain a single prediction from the model for use in an application, we guess the most-likely prediction according to the distribution we got from the neural network model.
Any distinction is a result of the method used to define the model and the mathematical optimization method used to solve it.
|
Confusion in classification and regression task exception
Any neural network trained on a crossentropy loss function performs categorical prediction, but the raw (trained) model output is a probability distribution (after normalization, possibly softmax).
Ou
|
45,208
|
"Information" Correlation
|
Taking a different angle from the information coefficient of correlation, I'll give background on the formula you gave.
It's called the normalized mutual information.
Unfortunately, lots of things are called the normalized mutual information. What you've shown uses the geometric mean of $H(X)$ and $H(Y)$ as the denominator. Other common choices are the arithmetic mean, the min, and the max. Any generalized mean will do. Another choice of denominator is the joint entropy $H(X, Y)$.
Because of this, it's important to give the formula you use for normalized mutual information.
That being said, there are big problems with the normalized mutual information. It suffers from what's called the finite size effect; the baseline keeps steadily rising, and you can get a high NMI in cases when one of the variables conveys nothing. It's better to use an adjusted-for-chance variant ("adjusted mutual information") whose expectation (rather than its minimum) is 0.
|
"Information" Correlation
|
Taking a different angle from the information coefficient of correlation, I'll give background on the formula you gave.
It's called the normalized mutual information.
Unfortunately, lots of things are
|
"Information" Correlation
Taking a different angle from the information coefficient of correlation, I'll give background on the formula you gave.
It's called the normalized mutual information.
Unfortunately, lots of things are called the normalized mutual information. What you've shown uses the geometric mean of $H(X)$ and $H(Y)$ as the denominator. Other common choices are the arithmetic mean, the min, and the max. Any generalized mean will do. Another choice of denominator is the joint entropy $H(X, Y)$.
Because of this, it's important to give the formula you use for normalized mutual information.
That being said, there are big problems with the normalized mutual information. It suffers from what's called the finite size effect; the baseline keeps steadily rising, and you can get a high NMI in cases when one of the variables conveys nothing. It's better to use an adjusted-for-chance variant ("adjusted mutual information") whose expectation (rather than its minimum) is 0.
|
"Information" Correlation
Taking a different angle from the information coefficient of correlation, I'll give background on the formula you gave.
It's called the normalized mutual information.
Unfortunately, lots of things are
|
45,209
|
"Information" Correlation
|
To answer your question "Has any literature explored this idea?". Linfoot (1957) introduced the informational coefficient of correlation, $\mathit{(IC)}$:
$$IC=\sqrt{1-e^{-2\cdot{I(X;Y)}}}$$
where $\mathit{I(X;Y)}$ is the mutual information.
While it does not seem to be a commonly used statistic in literature, in may satisfy your requirements. (Note: $\mathit{IC}$ is a measure of ${r}$, not ${r^2}$).
Reference: Linfoot, E.H. (1957). An informational measure of correlation. Information and Control, 1, 85-89.
|
"Information" Correlation
|
To answer your question "Has any literature explored this idea?". Linfoot (1957) introduced the informational coefficient of correlation, $\mathit{(IC)}$:
$$IC=\sqrt{1-e^{-2\cdot{I(X;Y)}}}$$
where $\m
|
"Information" Correlation
To answer your question "Has any literature explored this idea?". Linfoot (1957) introduced the informational coefficient of correlation, $\mathit{(IC)}$:
$$IC=\sqrt{1-e^{-2\cdot{I(X;Y)}}}$$
where $\mathit{I(X;Y)}$ is the mutual information.
While it does not seem to be a commonly used statistic in literature, in may satisfy your requirements. (Note: $\mathit{IC}$ is a measure of ${r}$, not ${r^2}$).
Reference: Linfoot, E.H. (1957). An informational measure of correlation. Information and Control, 1, 85-89.
|
"Information" Correlation
To answer your question "Has any literature explored this idea?". Linfoot (1957) introduced the informational coefficient of correlation, $\mathit{(IC)}$:
$$IC=\sqrt{1-e^{-2\cdot{I(X;Y)}}}$$
where $\m
|
45,210
|
What is the median of Bernoulli distribution?
|
Let $X \sim \mathsf{Bern}(p=.2)\equiv\mathsf{Binom}(n=1, p=.2).$ In R, where qbinom is the inverse CDF (quantile function) of a binomial distribution a median $\eta = 0.$
qbinom(.5, 1, .2)
[1] 0
$P(X \le 0) = P(X = 0) = 0.8 \ge 1/2.$
dbinom(0, 1, .2)
[1] 0.8
And obviously, $P(X \ge 0) = 1 \ge 1/2.$
The CDF of $X$ is plotted below. The median of $X$ is taken to be the value
at which the CDF 'curve' is (or 'crosses') $1/2.$
curve(pbinom(x, 1, .2), -.5, 1.5, n=10001, xaxs="i", ylab="CDF")
k = 0:1; cdf = pbinom(k, 1, .2)
points(k,cdf,pch=19)
abline(h = .5, col="blue", lwd=2, lty="dotted")
Also, for context, if we simulate $1000$ observations from this distribution, we get $805$ Failures (0) and $195$ Successes. According to R, the sample median is also $0.$
set.seed(2020)
x = rbinom(1000, 1, .2)
table(x)
x
0 1
805 195
summary(x)
Min. 1st Qu. Median Mean 3rd Qu. Max.
0.000 0.000 0.000 0.195 0.000 1.000
|
What is the median of Bernoulli distribution?
|
Let $X \sim \mathsf{Bern}(p=.2)\equiv\mathsf{Binom}(n=1, p=.2).$ In R, where qbinom is the inverse CDF (quantile function) of a binomial distribution a median $\eta = 0.$
qbinom(.5, 1, .2)
[1] 0
$P(X
|
What is the median of Bernoulli distribution?
Let $X \sim \mathsf{Bern}(p=.2)\equiv\mathsf{Binom}(n=1, p=.2).$ In R, where qbinom is the inverse CDF (quantile function) of a binomial distribution a median $\eta = 0.$
qbinom(.5, 1, .2)
[1] 0
$P(X \le 0) = P(X = 0) = 0.8 \ge 1/2.$
dbinom(0, 1, .2)
[1] 0.8
And obviously, $P(X \ge 0) = 1 \ge 1/2.$
The CDF of $X$ is plotted below. The median of $X$ is taken to be the value
at which the CDF 'curve' is (or 'crosses') $1/2.$
curve(pbinom(x, 1, .2), -.5, 1.5, n=10001, xaxs="i", ylab="CDF")
k = 0:1; cdf = pbinom(k, 1, .2)
points(k,cdf,pch=19)
abline(h = .5, col="blue", lwd=2, lty="dotted")
Also, for context, if we simulate $1000$ observations from this distribution, we get $805$ Failures (0) and $195$ Successes. According to R, the sample median is also $0.$
set.seed(2020)
x = rbinom(1000, 1, .2)
table(x)
x
0 1
805 195
summary(x)
Min. 1st Qu. Median Mean 3rd Qu. Max.
0.000 0.000 0.000 0.195 0.000 1.000
|
What is the median of Bernoulli distribution?
Let $X \sim \mathsf{Bern}(p=.2)\equiv\mathsf{Binom}(n=1, p=.2).$ In R, where qbinom is the inverse CDF (quantile function) of a binomial distribution a median $\eta = 0.$
qbinom(.5, 1, .2)
[1] 0
$P(X
|
45,211
|
What is the median of Bernoulli distribution?
|
$X \sim Bern(0.2)$
By the definition of median
$P(X \leq m) \geq 1/2$ and $P(X \geq m) \geq 1/2$
It has
$m = \begin{cases}
0, \quad p < 1/2\\
[0,1], \quad p = 1/2\\
1, \quad p > 1/2
\end{cases}$
It then follows that $m = 0$.
|
What is the median of Bernoulli distribution?
|
$X \sim Bern(0.2)$
By the definition of median
$P(X \leq m) \geq 1/2$ and $P(X \geq m) \geq 1/2$
It has
$m = \begin{cases}
0, \quad p < 1/2\\
[0,1], \quad p = 1/2\\
1, \quad p > 1/2
\end{cases}$
It t
|
What is the median of Bernoulli distribution?
$X \sim Bern(0.2)$
By the definition of median
$P(X \leq m) \geq 1/2$ and $P(X \geq m) \geq 1/2$
It has
$m = \begin{cases}
0, \quad p < 1/2\\
[0,1], \quad p = 1/2\\
1, \quad p > 1/2
\end{cases}$
It then follows that $m = 0$.
|
What is the median of Bernoulli distribution?
$X \sim Bern(0.2)$
By the definition of median
$P(X \leq m) \geq 1/2$ and $P(X \geq m) \geq 1/2$
It has
$m = \begin{cases}
0, \quad p < 1/2\\
[0,1], \quad p = 1/2\\
1, \quad p > 1/2
\end{cases}$
It t
|
45,212
|
Multinomial glmm with glmmADMB in R
|
Anna, because you used family = "binomial" and link = "logit" as options in your model, R assumes that you are trying to model a binary response variable which takes the values 0 ("failure") or 1 ("success"). This assumption is also based on the fact that you didn't use cbind() on the left hand side of your model formula - otherwise, your response variable would have been treated as a binomial count (i.e., number of successes k out of n independent trials).
Under this assumption, what R is fitting is a mixed effects binary logistic regression model. This type of model looks at how the log odds of "success" are influenced by call and duration for a "typical" dyad and how the other dyads differ from the "typical" dyad with respect to the log odds of success corresponding to call1 = 0 and duration = 0.
On your left hand side of the model, you indicated through your response variable naming that your response is multinomial, which would mean that your response is NOT binary since it takes more than 2 values (i.e., at least 3). These values would be "categories" - for instance "failure", "success", "undetermined". To fit a mixed effects multinomial logistic regression model, you would need to change your family from "binomial" to whatever the R package you are using suggests you should be using in a multinomial context. I am not familiar with this package, so others here may be able to give you hints on what the appropriate family to use would be. It could be "multinomial" but you would have to check the package documentation to verify that.
Addendum
One possibility for fitting a mixed effects multinomial logistic regression model in a frequentist setting would be to use the function npmlt from the mixcat package of R. Something like this:
install.packages("mixcat")
library(mixcat)
attach(dur)
model.po <- npmlt(formula = EEC_multinomial ~ call + duration,
formula.npo = ~ 1,
random = ~ 1|dyad,
k = 2)
model.npo <- npmlt(formula = EEC_multinomial ~ call + duration,
formula.npo = ~ 1 + call + duration,
random = ~ 1|dyad,
k = 2)
summary(model.po)
summary(model.npo)
detach(dur)
Note that you need to make sure your outcome variable, EEC_multinomial, is treated as a factor by R. Also, you need to attach your dataset prior to fitting your model(s) and then detach it after fitting your model(s).
If EEC_multinomial has 3 categories, say, R will set one category aside and treat it as the baseline (or reference) category. If the 3 categories are A, B and C and A is the reference category, the npmlt function will model two sets of log odds:
Log odds of response variable falling in category B rather than A as a function of (i) your predictor variables and (ii) a random intercept for Subject;
Log odds of response variable falling in category C rather than A as a function of (i) your predictor variables and (ii) a random intercept for Subject;
How npmlt will model these log odds will depend on your specification of the model:
For model.po, npmlt will assume that the effect of the predictor variable call is same for both sets of log odds, conditional on the random intercept effect AND that the effect of the predictor variable duration is the same for both sets of log odds. [This is called the proportional odds assumption or po in short.]
For model.npo, npmlt will assume that the effect of each of the predictor variables call and duration is different across the two sets of log odds, conditional on the random intercept effect. [This is called the "nonproportional odds assumption" or npo in short.]
Of course, you could also formulate models where one of the predictors satisfies the po assumption and the other does not and viceversa:
model.npo.1 <- npmlt(formula = EEC_multinomial ~ call + duration,
formula.npo = ~ 1 + call,
random = ~ 1|dyad,
k = 2)
model.npo.2 <- npmlt(formula = EEC_multinomial ~ call + duration,
formula.npo = ~ 1 + duration,
random = ~ 1|dyad,
k = 2)
The predictor variables listed in both formula and formula.npo do NOT satisfy the proportional odds assumption. The predictor variables listed only in formula DO satisfy the proportional odds assumption.
I have not used this function much so please check out how you can best set the value of k in your model (e.g., contact the package author for guidance on choice of k or try out different k > 1 values to make sure your end results and conclusions are not sensitive to the choice of k).
There are other R packages for fitting this type of models, some of which will take you to a Bayesian (e.g., brms) rather than frequentist framework.
|
Multinomial glmm with glmmADMB in R
|
Anna, because you used family = "binomial" and link = "logit" as options in your model, R assumes that you are trying to model a binary response variable which takes the values 0 ("failure") or 1 ("su
|
Multinomial glmm with glmmADMB in R
Anna, because you used family = "binomial" and link = "logit" as options in your model, R assumes that you are trying to model a binary response variable which takes the values 0 ("failure") or 1 ("success"). This assumption is also based on the fact that you didn't use cbind() on the left hand side of your model formula - otherwise, your response variable would have been treated as a binomial count (i.e., number of successes k out of n independent trials).
Under this assumption, what R is fitting is a mixed effects binary logistic regression model. This type of model looks at how the log odds of "success" are influenced by call and duration for a "typical" dyad and how the other dyads differ from the "typical" dyad with respect to the log odds of success corresponding to call1 = 0 and duration = 0.
On your left hand side of the model, you indicated through your response variable naming that your response is multinomial, which would mean that your response is NOT binary since it takes more than 2 values (i.e., at least 3). These values would be "categories" - for instance "failure", "success", "undetermined". To fit a mixed effects multinomial logistic regression model, you would need to change your family from "binomial" to whatever the R package you are using suggests you should be using in a multinomial context. I am not familiar with this package, so others here may be able to give you hints on what the appropriate family to use would be. It could be "multinomial" but you would have to check the package documentation to verify that.
Addendum
One possibility for fitting a mixed effects multinomial logistic regression model in a frequentist setting would be to use the function npmlt from the mixcat package of R. Something like this:
install.packages("mixcat")
library(mixcat)
attach(dur)
model.po <- npmlt(formula = EEC_multinomial ~ call + duration,
formula.npo = ~ 1,
random = ~ 1|dyad,
k = 2)
model.npo <- npmlt(formula = EEC_multinomial ~ call + duration,
formula.npo = ~ 1 + call + duration,
random = ~ 1|dyad,
k = 2)
summary(model.po)
summary(model.npo)
detach(dur)
Note that you need to make sure your outcome variable, EEC_multinomial, is treated as a factor by R. Also, you need to attach your dataset prior to fitting your model(s) and then detach it after fitting your model(s).
If EEC_multinomial has 3 categories, say, R will set one category aside and treat it as the baseline (or reference) category. If the 3 categories are A, B and C and A is the reference category, the npmlt function will model two sets of log odds:
Log odds of response variable falling in category B rather than A as a function of (i) your predictor variables and (ii) a random intercept for Subject;
Log odds of response variable falling in category C rather than A as a function of (i) your predictor variables and (ii) a random intercept for Subject;
How npmlt will model these log odds will depend on your specification of the model:
For model.po, npmlt will assume that the effect of the predictor variable call is same for both sets of log odds, conditional on the random intercept effect AND that the effect of the predictor variable duration is the same for both sets of log odds. [This is called the proportional odds assumption or po in short.]
For model.npo, npmlt will assume that the effect of each of the predictor variables call and duration is different across the two sets of log odds, conditional on the random intercept effect. [This is called the "nonproportional odds assumption" or npo in short.]
Of course, you could also formulate models where one of the predictors satisfies the po assumption and the other does not and viceversa:
model.npo.1 <- npmlt(formula = EEC_multinomial ~ call + duration,
formula.npo = ~ 1 + call,
random = ~ 1|dyad,
k = 2)
model.npo.2 <- npmlt(formula = EEC_multinomial ~ call + duration,
formula.npo = ~ 1 + duration,
random = ~ 1|dyad,
k = 2)
The predictor variables listed in both formula and formula.npo do NOT satisfy the proportional odds assumption. The predictor variables listed only in formula DO satisfy the proportional odds assumption.
I have not used this function much so please check out how you can best set the value of k in your model (e.g., contact the package author for guidance on choice of k or try out different k > 1 values to make sure your end results and conclusions are not sensitive to the choice of k).
There are other R packages for fitting this type of models, some of which will take you to a Bayesian (e.g., brms) rather than frequentist framework.
|
Multinomial glmm with glmmADMB in R
Anna, because you used family = "binomial" and link = "logit" as options in your model, R assumes that you are trying to model a binary response variable which takes the values 0 ("failure") or 1 ("su
|
45,213
|
Multinomial glmm with glmmADMB in R
|
I'm late to the party here but I really struggled to find a good way to do a mixed multinomial regression and didn't have success with the mixcat package, mostly due to the near complete lack of support/documentation. Just thought I'd add a different solution for anyone else struggling with this - you can use the gam() function of the mgcv package, and set family=multinom(). This package has much better support and flexibility than the other alternatives that I've found.
So to run the model in the example, you would use
mgcv::gam(list(EEC_multinomial ~ call + duration + s(dyad, bs="re"),
~ call + duration + s(dyad, bs="re"),
~ call + duration + s(dyad, bs="re")),
data = dur, family = multinom(K=3))
where EEC_multinomial is an integer with the reference level equal to 0 and the categorical variables are factors.
The s(dyad, bs="re") is the random effect term for dyad, and the K value specified in multinom is the number of levels of the categorical response minus 1. Because there are four levels to this response, K=3 and we must repeat the formula three times, within a list. The summary() output of the model will show three sections - the summary for each level of the response compared to the reference level. This also allows the flexibility to include different predictors for different levels of the response.
|
Multinomial glmm with glmmADMB in R
|
I'm late to the party here but I really struggled to find a good way to do a mixed multinomial regression and didn't have success with the mixcat package, mostly due to the near complete lack of suppo
|
Multinomial glmm with glmmADMB in R
I'm late to the party here but I really struggled to find a good way to do a mixed multinomial regression and didn't have success with the mixcat package, mostly due to the near complete lack of support/documentation. Just thought I'd add a different solution for anyone else struggling with this - you can use the gam() function of the mgcv package, and set family=multinom(). This package has much better support and flexibility than the other alternatives that I've found.
So to run the model in the example, you would use
mgcv::gam(list(EEC_multinomial ~ call + duration + s(dyad, bs="re"),
~ call + duration + s(dyad, bs="re"),
~ call + duration + s(dyad, bs="re")),
data = dur, family = multinom(K=3))
where EEC_multinomial is an integer with the reference level equal to 0 and the categorical variables are factors.
The s(dyad, bs="re") is the random effect term for dyad, and the K value specified in multinom is the number of levels of the categorical response minus 1. Because there are four levels to this response, K=3 and we must repeat the formula three times, within a list. The summary() output of the model will show three sections - the summary for each level of the response compared to the reference level. This also allows the flexibility to include different predictors for different levels of the response.
|
Multinomial glmm with glmmADMB in R
I'm late to the party here but I really struggled to find a good way to do a mixed multinomial regression and didn't have success with the mixcat package, mostly due to the near complete lack of suppo
|
45,214
|
Multinomial glmm with glmmADMB in R
|
mgcv package seems very slow and space inefficient. I was only able to estimate the binary model. The multinomial model could not complete the estimation.
|
Multinomial glmm with glmmADMB in R
|
mgcv package seems very slow and space inefficient. I was only able to estimate the binary model. The multinomial model could not complete the estimation.
|
Multinomial glmm with glmmADMB in R
mgcv package seems very slow and space inefficient. I was only able to estimate the binary model. The multinomial model could not complete the estimation.
|
Multinomial glmm with glmmADMB in R
mgcv package seems very slow and space inefficient. I was only able to estimate the binary model. The multinomial model could not complete the estimation.
|
45,215
|
Conditional probability greater than 1?
|
It's because of your independence assumption, which is not true based on the data. For example,
$$P(\text{Outlook=Sunny, Temp=High}|\text{Beach})=1/2$$
because there are 4 situations where you go to Beach and in only two of them the Outlook is Sunny and Temp is High. It's the same situation for the denominator.
|
Conditional probability greater than 1?
|
It's because of your independence assumption, which is not true based on the data. For example,
$$P(\text{Outlook=Sunny, Temp=High}|\text{Beach})=1/2$$
because there are 4 situations where you go to B
|
Conditional probability greater than 1?
It's because of your independence assumption, which is not true based on the data. For example,
$$P(\text{Outlook=Sunny, Temp=High}|\text{Beach})=1/2$$
because there are 4 situations where you go to Beach and in only two of them the Outlook is Sunny and Temp is High. It's the same situation for the denominator.
|
Conditional probability greater than 1?
It's because of your independence assumption, which is not true based on the data. For example,
$$P(\text{Outlook=Sunny, Temp=High}|\text{Beach})=1/2$$
because there are 4 situations where you go to B
|
45,216
|
Why is it bad if the estimates vary greatly depending on whether we divide by N or (N - 1) in multivariate analysis?
|
The comment seems to be a way of saying that we like large sample sizes in machine learning.
The numerator is the numerator, whether you divide by $N$ or $N-1$, so all that matters to our discussion is the denominator.
The only way for the two fractions to differ immensely is if $N$ and $N-1$ are very different, say if $\frac{N}{N-1}$ is much greater than $1$ (whatever "much greater" means to us).
That only happens when $N$ is small. If we have $N=1000000$, $\frac{N}{N-1}$ is about 1.
$$\underset{N\rightarrow \infty}{\text{lim}} \dfrac{N}{N-1} = 1$$
So the comment seems to be a way of saying that we like large sample sizes in machine learning.
|
Why is it bad if the estimates vary greatly depending on whether we divide by N or (N - 1) in multiv
|
The comment seems to be a way of saying that we like large sample sizes in machine learning.
The numerator is the numerator, whether you divide by $N$ or $N-1$, so all that matters to our discussion i
|
Why is it bad if the estimates vary greatly depending on whether we divide by N or (N - 1) in multivariate analysis?
The comment seems to be a way of saying that we like large sample sizes in machine learning.
The numerator is the numerator, whether you divide by $N$ or $N-1$, so all that matters to our discussion is the denominator.
The only way for the two fractions to differ immensely is if $N$ and $N-1$ are very different, say if $\frac{N}{N-1}$ is much greater than $1$ (whatever "much greater" means to us).
That only happens when $N$ is small. If we have $N=1000000$, $\frac{N}{N-1}$ is about 1.
$$\underset{N\rightarrow \infty}{\text{lim}} \dfrac{N}{N-1} = 1$$
So the comment seems to be a way of saying that we like large sample sizes in machine learning.
|
Why is it bad if the estimates vary greatly depending on whether we divide by N or (N - 1) in multiv
The comment seems to be a way of saying that we like large sample sizes in machine learning.
The numerator is the numerator, whether you divide by $N$ or $N-1$, so all that matters to our discussion i
|
45,217
|
Can this distribution be sampled from efficiently? $f(x) \propto x^{\alpha-1}e^{-\beta x - \gamma/x}$
|
After quite a bit of searching - this is the density of a Generalized Inverse Gaussian random variable. There are a number of algorithms for sampling from this distribution.
R packages include GIGrvg, ghyp and Runuran. More details can be found in the following papers.
Wolfgang Hörmann and Josef Leydold (2013). Generating generalized inverse Gaussian random variates, Statistics and Computing, DOI: 10.1007/s11222-013-9387-3
J. S. Dagpunar (1989). An easily implemented generalised inverse Gaussian generator, Comm. Statist. B – Simulation Comput. 18, 703–710.
Devroye, Luc. "Random variate generation for the generalized inverse Gaussian distribution." Statistics and Computing 24.2 (2014): 239-246.
|
Can this distribution be sampled from efficiently? $f(x) \propto x^{\alpha-1}e^{-\beta x - \gamma/x}
|
After quite a bit of searching - this is the density of a Generalized Inverse Gaussian random variable. There are a number of algorithms for sampling from this distribution.
R packages include GIGrvg,
|
Can this distribution be sampled from efficiently? $f(x) \propto x^{\alpha-1}e^{-\beta x - \gamma/x}$
After quite a bit of searching - this is the density of a Generalized Inverse Gaussian random variable. There are a number of algorithms for sampling from this distribution.
R packages include GIGrvg, ghyp and Runuran. More details can be found in the following papers.
Wolfgang Hörmann and Josef Leydold (2013). Generating generalized inverse Gaussian random variates, Statistics and Computing, DOI: 10.1007/s11222-013-9387-3
J. S. Dagpunar (1989). An easily implemented generalised inverse Gaussian generator, Comm. Statist. B – Simulation Comput. 18, 703–710.
Devroye, Luc. "Random variate generation for the generalized inverse Gaussian distribution." Statistics and Computing 24.2 (2014): 239-246.
|
Can this distribution be sampled from efficiently? $f(x) \propto x^{\alpha-1}e^{-\beta x - \gamma/x}
After quite a bit of searching - this is the density of a Generalized Inverse Gaussian random variable. There are a number of algorithms for sampling from this distribution.
R packages include GIGrvg,
|
45,218
|
Can this distribution be sampled from efficiently? $f(x) \propto x^{\alpha-1}e^{-\beta x - \gamma/x}$
|
scipy package in python can do it (https://docs.scipy.org/doc/scipy/reference/generated/scipy.stats.geninvgauss.html#scipy.stats.geninvgauss), but its expression are slightly different from above. so I wonder how to convert their parameters
|
Can this distribution be sampled from efficiently? $f(x) \propto x^{\alpha-1}e^{-\beta x - \gamma/x}
|
scipy package in python can do it (https://docs.scipy.org/doc/scipy/reference/generated/scipy.stats.geninvgauss.html#scipy.stats.geninvgauss), but its expression are slightly different from above. so
|
Can this distribution be sampled from efficiently? $f(x) \propto x^{\alpha-1}e^{-\beta x - \gamma/x}$
scipy package in python can do it (https://docs.scipy.org/doc/scipy/reference/generated/scipy.stats.geninvgauss.html#scipy.stats.geninvgauss), but its expression are slightly different from above. so I wonder how to convert their parameters
|
Can this distribution be sampled from efficiently? $f(x) \propto x^{\alpha-1}e^{-\beta x - \gamma/x}
scipy package in python can do it (https://docs.scipy.org/doc/scipy/reference/generated/scipy.stats.geninvgauss.html#scipy.stats.geninvgauss), but its expression are slightly different from above. so
|
45,219
|
interpretation of model coefficient in logistic regression
|
In logistic regression we have that:
$$
\ln\left({\frac{p}{1-p}}\right) = \mathbf{Xb}
$$
where $\mathbf{Xb}$ is the linear predictor, $\mathbf{X}$ being the model matrix of explanatory variables and $\mathbf{b}$ the vector of coefficients. $\ln\left({\frac{p}{1-p}}\right)$ is the logit function (log of the odds).
Therefore every component of $\mathbf{X}$ (eg, an individual explanatory variable) is proportional to the log odds and so any change in one of them has a linear effect on it.
|
interpretation of model coefficient in logistic regression
|
In logistic regression we have that:
$$
\ln\left({\frac{p}{1-p}}\right) = \mathbf{Xb}
$$
where $\mathbf{Xb}$ is the linear predictor, $\mathbf{X}$ being the model matrix of explanatory variables and $
|
interpretation of model coefficient in logistic regression
In logistic regression we have that:
$$
\ln\left({\frac{p}{1-p}}\right) = \mathbf{Xb}
$$
where $\mathbf{Xb}$ is the linear predictor, $\mathbf{X}$ being the model matrix of explanatory variables and $\mathbf{b}$ the vector of coefficients. $\ln\left({\frac{p}{1-p}}\right)$ is the logit function (log of the odds).
Therefore every component of $\mathbf{X}$ (eg, an individual explanatory variable) is proportional to the log odds and so any change in one of them has a linear effect on it.
|
interpretation of model coefficient in logistic regression
In logistic regression we have that:
$$
\ln\left({\frac{p}{1-p}}\right) = \mathbf{Xb}
$$
where $\mathbf{Xb}$ is the linear predictor, $\mathbf{X}$ being the model matrix of explanatory variables and $
|
45,220
|
Bayesian interpretation of logistic ridge regression
|
As a preliminary note, I see that your equations seem to be dealing with the case where we only have a single explanatory variable and a single data point (and no intercept term). I will generalise this to look at the general case where you observe $n$ data points, so that the log-likelihood function is a sum over these $n$ observations. (I will use only one explanatory variable, as in your question.) For a logistic regression of this kind you have the observable values $Y_i|\mathbf{x}_i \sim \text{Bern}(\mu_i)$ with true mean values:
$$\mu_i \equiv \mathbb{E}(Y_i|\mathbf{x}_i) = \text{logistic}(\boldsymbol{\beta}^\text{T} \mathbf{x}) = \frac{e^{\boldsymbol{\beta}^\text{T} \mathbf{x}}}{1+e^{\boldsymbol{\beta}^\text{T} \mathbf{x}}}.$$
The log-likelihood function is given by:
$$\begin{align}
\ell(\mathbf{y}|\mathbf{x},\boldsymbol{\beta})
&= \sum_{i=1}^n \log \text{Bern}(y_i|\mu_i) \\[6pt]
&= \sum_{i=1}^n y_i \log (\mu_i) + \sum_{i=1}^n (1-y_i) \log (1-\mu_i) \\[6pt]
&= \sum_{i=1}^n y_i \log (\mu_i) + \sum_{i=1}^n (1-y_i) \log (1-\mu_i) \\[6pt]
&= \sum_{i=1}^n y_i \log(\boldsymbol{\beta}^\text{T} \mathbf{x}) - \sum_{i=1}^n y_i \log(1+e^{\boldsymbol{\beta}^\text{T} \mathbf{x}}) - (1-y_i) \log(1+e^{\boldsymbol{\beta}^\text{T} \mathbf{x}}) \\[6pt]
&= \sum_{i=1}^n y_i \log(\boldsymbol{\beta}^\text{T} \mathbf{x}) - \sum_{i=1}^n \log(1+e^{\boldsymbol{\beta}^\text{T} \mathbf{x}}). \\[6pt]
\end{align}$$
Logistic ridge regression operates by using an estimation method that imposes a penalty on the parameter $\boldsymbol{\beta}$ that is proportionate to its squared norm. (Note that you have stated this slightly incorrectly in your question.) It estimates the parameter $\boldsymbol{\beta} = (\beta_1,...,\beta_K)$ via the optimisation problem:
$$\begin{align}
\hat{\boldsymbol{\beta}}_\text{Ridge}
&= \underset{\boldsymbol{\beta} \in \mathbb{R}^K}{\text{argmax}} \ \ \ \ \ell(\mathbf{y}|\mathbf{x},\boldsymbol{\beta}) - \lambda ||\boldsymbol{\beta}||^2. \\[6pt]
\end{align}$$
Since the log-posterior is the sum of the log-likelihood and log-prior, the MAP estimator is:
$$\begin{align}
\hat{\boldsymbol{\beta}}_\text{MAP}
&= \underset{\boldsymbol{\beta} \in \mathbb{R}^K}{\text{argmax}} \ \ \ \ \ell(\mathbf{y}|\mathbf{x},\boldsymbol{\beta}) + \log \pi(\boldsymbol{\beta}). \\[6pt]
\end{align}$$
We obtain the result $\hat{\boldsymbol{\beta}}_\text{Ridge} = \hat{\boldsymbol{\beta}}_\text{MAP}$ by using the prior kernel $\pi(\boldsymbol{\beta}) \propto \exp(- \lambda ||\boldsymbol{\beta}||^2)$ so that $\log \pi (\boldsymbol{\beta}) = - \lambda ||\boldsymbol{\beta}||^2 + \text{const}$ in the above equation. Integrating to find the constant of integration gives the prior distribution:
$$\pi(\boldsymbol{\beta}) = \prod_k \mathcal{N} \bigg( \beta_k \bigg| 0, \frac{1}{2\lambda} \bigg).$$
Thus, we see that ridge logistic regression is equivalent to MAP estimation if a priori the individual $\beta_k$ parameters are IID normal random variables with zero mean. The variance parameter for this normal distribution is a one-to-one mapping of the "penalty" hyperparameter in the ridge logistic regression --- a larger penalty in the ridge regression corresponds to a smaller variance for the prior.
(Note: For a related question showing LASSO and ridge regression framed in Bayesian terms see here.)
|
Bayesian interpretation of logistic ridge regression
|
As a preliminary note, I see that your equations seem to be dealing with the case where we only have a single explanatory variable and a single data point (and no intercept term). I will generalise t
|
Bayesian interpretation of logistic ridge regression
As a preliminary note, I see that your equations seem to be dealing with the case where we only have a single explanatory variable and a single data point (and no intercept term). I will generalise this to look at the general case where you observe $n$ data points, so that the log-likelihood function is a sum over these $n$ observations. (I will use only one explanatory variable, as in your question.) For a logistic regression of this kind you have the observable values $Y_i|\mathbf{x}_i \sim \text{Bern}(\mu_i)$ with true mean values:
$$\mu_i \equiv \mathbb{E}(Y_i|\mathbf{x}_i) = \text{logistic}(\boldsymbol{\beta}^\text{T} \mathbf{x}) = \frac{e^{\boldsymbol{\beta}^\text{T} \mathbf{x}}}{1+e^{\boldsymbol{\beta}^\text{T} \mathbf{x}}}.$$
The log-likelihood function is given by:
$$\begin{align}
\ell(\mathbf{y}|\mathbf{x},\boldsymbol{\beta})
&= \sum_{i=1}^n \log \text{Bern}(y_i|\mu_i) \\[6pt]
&= \sum_{i=1}^n y_i \log (\mu_i) + \sum_{i=1}^n (1-y_i) \log (1-\mu_i) \\[6pt]
&= \sum_{i=1}^n y_i \log (\mu_i) + \sum_{i=1}^n (1-y_i) \log (1-\mu_i) \\[6pt]
&= \sum_{i=1}^n y_i \log(\boldsymbol{\beta}^\text{T} \mathbf{x}) - \sum_{i=1}^n y_i \log(1+e^{\boldsymbol{\beta}^\text{T} \mathbf{x}}) - (1-y_i) \log(1+e^{\boldsymbol{\beta}^\text{T} \mathbf{x}}) \\[6pt]
&= \sum_{i=1}^n y_i \log(\boldsymbol{\beta}^\text{T} \mathbf{x}) - \sum_{i=1}^n \log(1+e^{\boldsymbol{\beta}^\text{T} \mathbf{x}}). \\[6pt]
\end{align}$$
Logistic ridge regression operates by using an estimation method that imposes a penalty on the parameter $\boldsymbol{\beta}$ that is proportionate to its squared norm. (Note that you have stated this slightly incorrectly in your question.) It estimates the parameter $\boldsymbol{\beta} = (\beta_1,...,\beta_K)$ via the optimisation problem:
$$\begin{align}
\hat{\boldsymbol{\beta}}_\text{Ridge}
&= \underset{\boldsymbol{\beta} \in \mathbb{R}^K}{\text{argmax}} \ \ \ \ \ell(\mathbf{y}|\mathbf{x},\boldsymbol{\beta}) - \lambda ||\boldsymbol{\beta}||^2. \\[6pt]
\end{align}$$
Since the log-posterior is the sum of the log-likelihood and log-prior, the MAP estimator is:
$$\begin{align}
\hat{\boldsymbol{\beta}}_\text{MAP}
&= \underset{\boldsymbol{\beta} \in \mathbb{R}^K}{\text{argmax}} \ \ \ \ \ell(\mathbf{y}|\mathbf{x},\boldsymbol{\beta}) + \log \pi(\boldsymbol{\beta}). \\[6pt]
\end{align}$$
We obtain the result $\hat{\boldsymbol{\beta}}_\text{Ridge} = \hat{\boldsymbol{\beta}}_\text{MAP}$ by using the prior kernel $\pi(\boldsymbol{\beta}) \propto \exp(- \lambda ||\boldsymbol{\beta}||^2)$ so that $\log \pi (\boldsymbol{\beta}) = - \lambda ||\boldsymbol{\beta}||^2 + \text{const}$ in the above equation. Integrating to find the constant of integration gives the prior distribution:
$$\pi(\boldsymbol{\beta}) = \prod_k \mathcal{N} \bigg( \beta_k \bigg| 0, \frac{1}{2\lambda} \bigg).$$
Thus, we see that ridge logistic regression is equivalent to MAP estimation if a priori the individual $\beta_k$ parameters are IID normal random variables with zero mean. The variance parameter for this normal distribution is a one-to-one mapping of the "penalty" hyperparameter in the ridge logistic regression --- a larger penalty in the ridge regression corresponds to a smaller variance for the prior.
(Note: For a related question showing LASSO and ridge regression framed in Bayesian terms see here.)
|
Bayesian interpretation of logistic ridge regression
As a preliminary note, I see that your equations seem to be dealing with the case where we only have a single explanatory variable and a single data point (and no intercept term). I will generalise t
|
45,221
|
Bayesian interpretation of logistic ridge regression
|
To look for equivalence one should compare the form of,
$$\hat{\beta} = \underset{\beta}{\text{argmin}} -y\log(\hat{y}) - (1-y)\log(1-\hat{y}) + \lambda||\beta||_2^2,$$
with the posterior distribution whilst keeping a general expression for the prior.
The posterior distribution has form,
$$\pi(\beta|x) \propto \pi(\beta)L(\beta;x).$$
Where $\pi(\beta)$ is the prior and $L(\beta;x)$ is the likelihood. Noting that $\beta$ is $p\times1$ and that $x$ represents the data where $x_i$ is one observation and would be $p\times1$. In logistic regression the model for the data is Bernoulli (more generally Binomial). So,
$$y_i|\beta,x_i \sim Bernoulli(p_i)$$
where $p_i = \frac{\exp\{\beta^Tx_i\}}{1 + \exp\{\beta^Tx_i\}}.$ Let $f(\cdot)$ be the density function, then the posterior for $\beta$ becomes
\begin{align*}
\pi(\beta|x)&\propto\pi(\beta)\prod_{i=1}^{n}f(x_i|\beta) \\
&= \pi(\beta)\prod_{i=1}^{n}p_i^{y_i}(1-p_i)^{1-y_i}.
\end{align*}
The maximum-a-posterior (MAP) of $\beta$ is the mode of its posterior distribution and since $\log$ is monotone,
$$\hat{\beta}_{MAP} = \underset{\beta}{\text{argmax}}\pi(\beta|x) = \underset{\beta}{\text{argmax}}\log\pi(\beta|x).$$
So taking,
$$\log\pi(\beta|x) \propto \log\pi(\beta) + \sum_{i=1}^n\big\{y_i\log p_i + (1-y_i)\log(1-p_i)\big\}$$
and noting that $\hat{\beta}_{MAP} = \underset{\beta}{\text{argmax}}\log\pi(\beta|x) = \underset{\beta}{\text{argmin}}\big\{-\log\pi(\beta|x)\big\}$ we can see that,
\begin{align*}
\log\pi(\beta) &\propto - \lambda||\beta||_2^2 \\
\Rightarrow \pi(\beta) &\propto \exp\{-\lambda||\beta||_2^2\}.
\end{align*}
This can be seen as taking independent normal priors with mean zero and variance $\frac{1}{2\lambda}$,
$$\beta_j \sim N\left(0,\frac{1}{2\lambda}\right) \ \ j=1,\dots,p.$$
|
Bayesian interpretation of logistic ridge regression
|
To look for equivalence one should compare the form of,
$$\hat{\beta} = \underset{\beta}{\text{argmin}} -y\log(\hat{y}) - (1-y)\log(1-\hat{y}) + \lambda||\beta||_2^2,$$
with the posterior distributi
|
Bayesian interpretation of logistic ridge regression
To look for equivalence one should compare the form of,
$$\hat{\beta} = \underset{\beta}{\text{argmin}} -y\log(\hat{y}) - (1-y)\log(1-\hat{y}) + \lambda||\beta||_2^2,$$
with the posterior distribution whilst keeping a general expression for the prior.
The posterior distribution has form,
$$\pi(\beta|x) \propto \pi(\beta)L(\beta;x).$$
Where $\pi(\beta)$ is the prior and $L(\beta;x)$ is the likelihood. Noting that $\beta$ is $p\times1$ and that $x$ represents the data where $x_i$ is one observation and would be $p\times1$. In logistic regression the model for the data is Bernoulli (more generally Binomial). So,
$$y_i|\beta,x_i \sim Bernoulli(p_i)$$
where $p_i = \frac{\exp\{\beta^Tx_i\}}{1 + \exp\{\beta^Tx_i\}}.$ Let $f(\cdot)$ be the density function, then the posterior for $\beta$ becomes
\begin{align*}
\pi(\beta|x)&\propto\pi(\beta)\prod_{i=1}^{n}f(x_i|\beta) \\
&= \pi(\beta)\prod_{i=1}^{n}p_i^{y_i}(1-p_i)^{1-y_i}.
\end{align*}
The maximum-a-posterior (MAP) of $\beta$ is the mode of its posterior distribution and since $\log$ is monotone,
$$\hat{\beta}_{MAP} = \underset{\beta}{\text{argmax}}\pi(\beta|x) = \underset{\beta}{\text{argmax}}\log\pi(\beta|x).$$
So taking,
$$\log\pi(\beta|x) \propto \log\pi(\beta) + \sum_{i=1}^n\big\{y_i\log p_i + (1-y_i)\log(1-p_i)\big\}$$
and noting that $\hat{\beta}_{MAP} = \underset{\beta}{\text{argmax}}\log\pi(\beta|x) = \underset{\beta}{\text{argmin}}\big\{-\log\pi(\beta|x)\big\}$ we can see that,
\begin{align*}
\log\pi(\beta) &\propto - \lambda||\beta||_2^2 \\
\Rightarrow \pi(\beta) &\propto \exp\{-\lambda||\beta||_2^2\}.
\end{align*}
This can be seen as taking independent normal priors with mean zero and variance $\frac{1}{2\lambda}$,
$$\beta_j \sim N\left(0,\frac{1}{2\lambda}\right) \ \ j=1,\dots,p.$$
|
Bayesian interpretation of logistic ridge regression
To look for equivalence one should compare the form of,
$$\hat{\beta} = \underset{\beta}{\text{argmin}} -y\log(\hat{y}) - (1-y)\log(1-\hat{y}) + \lambda||\beta||_2^2,$$
with the posterior distributi
|
45,222
|
Multilevel regression model for nested data using "multilevel" and "lme4" R packages?
|
From what I can see of your data and the descriptions, you do not have multiple measures within ID. You have measured several variables, D_d, RI, RV, and MRP once for each ID.
Thus ID seems is the unit of measurements (that is, it unique to each row in your data).
However you do seem to have multiple measures within Group, and therefore a model with random intercepts for Group would seem to be appropriate. I would therefore suggest the following model as a starting point:
lmer(TI ~ D_d + RI + RV + MRP + (1 | Group), data = ... )
This will estimate fixed effects for D_d, RI, RV, and MRP, along with a variance for the random Group variable, which will account for the non-independence of measurements within each group.
|
Multilevel regression model for nested data using "multilevel" and "lme4" R packages?
|
From what I can see of your data and the descriptions, you do not have multiple measures within ID. You have measured several variables, D_d, RI, RV, and MRP once for each ID.
Thus ID seems is the uni
|
Multilevel regression model for nested data using "multilevel" and "lme4" R packages?
From what I can see of your data and the descriptions, you do not have multiple measures within ID. You have measured several variables, D_d, RI, RV, and MRP once for each ID.
Thus ID seems is the unit of measurements (that is, it unique to each row in your data).
However you do seem to have multiple measures within Group, and therefore a model with random intercepts for Group would seem to be appropriate. I would therefore suggest the following model as a starting point:
lmer(TI ~ D_d + RI + RV + MRP + (1 | Group), data = ... )
This will estimate fixed effects for D_d, RI, RV, and MRP, along with a variance for the random Group variable, which will account for the non-independence of measurements within each group.
|
Multilevel regression model for nested data using "multilevel" and "lme4" R packages?
From what I can see of your data and the descriptions, you do not have multiple measures within ID. You have measured several variables, D_d, RI, RV, and MRP once for each ID.
Thus ID seems is the uni
|
45,223
|
Multilevel regression model for nested data using "multilevel" and "lme4" R packages?
|
A couple of points:
Mixed models are indeed used to account for correlations in your outcome variable, I guess TI within the levels of grouping/cluster variables, i.e., ID and Group in your case. Assuming that normal error terms would be adequate for TI, you could use a linear mixed model. For example, using function lmer() from package lme4, e.g.,
fm1 <- lmer(TI ~ RI + (1 | Group / ID), data = tisia)
If you are going also to load the lmerTest package, you will obtain a p-value for the association between TI and RI.
Model fm1 above postulates that the correlation between any pair of measurements of TI within the same combination of levels of ID and Group is the same. If instead, you want to assume that the correlations within the same combination of ID and Group decay as the difference in RI values increases, then you could include the random slope for RI, i.e.,
fm2 <- lmer(TI ~ RI + (RI | Group / ID), data = tisia)
You could compare the two models to see if this improves the fit using a likelihood ratio test implemented by the anova() function, i.e.,
anova(fm1, fm2)
|
Multilevel regression model for nested data using "multilevel" and "lme4" R packages?
|
A couple of points:
Mixed models are indeed used to account for correlations in your outcome variable, I guess TI within the levels of grouping/cluster variables, i.e., ID and Group in your case. Ass
|
Multilevel regression model for nested data using "multilevel" and "lme4" R packages?
A couple of points:
Mixed models are indeed used to account for correlations in your outcome variable, I guess TI within the levels of grouping/cluster variables, i.e., ID and Group in your case. Assuming that normal error terms would be adequate for TI, you could use a linear mixed model. For example, using function lmer() from package lme4, e.g.,
fm1 <- lmer(TI ~ RI + (1 | Group / ID), data = tisia)
If you are going also to load the lmerTest package, you will obtain a p-value for the association between TI and RI.
Model fm1 above postulates that the correlation between any pair of measurements of TI within the same combination of levels of ID and Group is the same. If instead, you want to assume that the correlations within the same combination of ID and Group decay as the difference in RI values increases, then you could include the random slope for RI, i.e.,
fm2 <- lmer(TI ~ RI + (RI | Group / ID), data = tisia)
You could compare the two models to see if this improves the fit using a likelihood ratio test implemented by the anova() function, i.e.,
anova(fm1, fm2)
|
Multilevel regression model for nested data using "multilevel" and "lme4" R packages?
A couple of points:
Mixed models are indeed used to account for correlations in your outcome variable, I guess TI within the levels of grouping/cluster variables, i.e., ID and Group in your case. Ass
|
45,224
|
The odds ratio calculated in my regression model seems to be too high
|
Is it okay that the direction of the fixed effects is opposite to the intercept in my model?
Yes. The interpretation of the intercept is that it is the log-odds of the event (DV = 1) for the those in the none group (so, being negative, it is a protective effect), while the estimates for the other 2 groups are the log-odds of the event in each of those groups compared to the none group (so being positive, they are risk factors). So the log-odds for the event for those in the weak group are 4.2876 higher than in the none group, and the log-odds for the the event for those in the strong group are 6.1598 higher than for those in the none group.
Most importantly, is the odds ratio I've calculated usable? i.e. can my IV function as a proper predictor?
Yes, but note that the fixed effects are conditional on the random effects. This means in your case, the log odds - or odds ratios if you exponentiate them - are for the same subject and the same item, rather than being averaged across all subjects and items. If you want the averaged estimates then you could get those using the GLMMAdaptive package
Or have I missed or done something wrong?
Without more information about your study design it is difficult to say, but if you are worried about the results note that by default, glmer uses the Laplace approximation which means only 1 point per axis for evaluating the adaptive Gauss-Hermite approximation to the log-likelihood, and this can produce biased results with a binary outcome. Try setting nAGQ = 2 or higher. You could also try using the mixed_model function in the GLMMAdaptive package which is specifically written for adaptive quadrature in generalized linear mixed models.
|
The odds ratio calculated in my regression model seems to be too high
|
Is it okay that the direction of the fixed effects is opposite to the intercept in my model?
Yes. The interpretation of the intercept is that it is the log-odds of the event (DV = 1) for the those in
|
The odds ratio calculated in my regression model seems to be too high
Is it okay that the direction of the fixed effects is opposite to the intercept in my model?
Yes. The interpretation of the intercept is that it is the log-odds of the event (DV = 1) for the those in the none group (so, being negative, it is a protective effect), while the estimates for the other 2 groups are the log-odds of the event in each of those groups compared to the none group (so being positive, they are risk factors). So the log-odds for the event for those in the weak group are 4.2876 higher than in the none group, and the log-odds for the the event for those in the strong group are 6.1598 higher than for those in the none group.
Most importantly, is the odds ratio I've calculated usable? i.e. can my IV function as a proper predictor?
Yes, but note that the fixed effects are conditional on the random effects. This means in your case, the log odds - or odds ratios if you exponentiate them - are for the same subject and the same item, rather than being averaged across all subjects and items. If you want the averaged estimates then you could get those using the GLMMAdaptive package
Or have I missed or done something wrong?
Without more information about your study design it is difficult to say, but if you are worried about the results note that by default, glmer uses the Laplace approximation which means only 1 point per axis for evaluating the adaptive Gauss-Hermite approximation to the log-likelihood, and this can produce biased results with a binary outcome. Try setting nAGQ = 2 or higher. You could also try using the mixed_model function in the GLMMAdaptive package which is specifically written for adaptive quadrature in generalized linear mixed models.
|
The odds ratio calculated in my regression model seems to be too high
Is it okay that the direction of the fixed effects is opposite to the intercept in my model?
Yes. The interpretation of the intercept is that it is the log-odds of the event (DV = 1) for the those in
|
45,225
|
Prove that a simple random walk is a martingale
|
\begin{align}
E[X_{t+1} \mid X_1, \ldots, X_t]
&= E[X_t + a_{t+1} \mid X_1, \ldots, X_t]
\\
&= X_t + E[a_{t+1} \mid X_1, \ldots, X_t]
\\
&= X_t
\end{align}
|
Prove that a simple random walk is a martingale
|
\begin{align}
E[X_{t+1} \mid X_1, \ldots, X_t]
&= E[X_t + a_{t+1} \mid X_1, \ldots, X_t]
\\
&= X_t + E[a_{t+1} \mid X_1, \ldots, X_t]
\\
&= X_t
\end{align}
|
Prove that a simple random walk is a martingale
\begin{align}
E[X_{t+1} \mid X_1, \ldots, X_t]
&= E[X_t + a_{t+1} \mid X_1, \ldots, X_t]
\\
&= X_t + E[a_{t+1} \mid X_1, \ldots, X_t]
\\
&= X_t
\end{align}
|
Prove that a simple random walk is a martingale
\begin{align}
E[X_{t+1} \mid X_1, \ldots, X_t]
&= E[X_t + a_{t+1} \mid X_1, \ldots, X_t]
\\
&= X_t + E[a_{t+1} \mid X_1, \ldots, X_t]
\\
&= X_t
\end{align}
|
45,226
|
Prove that a simple random walk is a martingale
|
Let $\{X_t\}_{t\geq 1}$ be a sequence of independent random variables such that $\Pr\{X_t=1\}=\Pr\{X_t=-1\}=1/2$. Define $\mathscr{F_t}=\sigma(X_1,\dots,X_t)$ and $M_t=X_1+\dots+X_t$. We have (equalities between conditional expectations holding almost surely)
$$
\mathbb{E}[M_{t+1}\mid\mathscr{F_t}] = \mathbb{E}[X_{t+1}+M_t\mid\mathscr{F_t}] = \mathbb{E}[X_{t+1}\mid\mathscr{F_t}] + \mathbb{E}[M_t\mid\mathscr{F_t}].
$$
But $X_{t+1}$ is independent of $\mathscr{F_t}$, therefore, $\mathbb{E}[X_{t+1}\mid\mathscr{F_t}]=\mathbb{E}[X_{t+1}]=0$. Also, $M_t$ is $\mathscr{F}_t$-measurable, hence, $\mathbb{E}[M_t\mid\mathscr{F_t}]=M_t$. It follows that $\mathbb{E}[M_{t+1}\mid\mathscr{F_t}]=M_t$ and $\{(M_t,\mathscr{F}_t)\}_{t\geq 1}$ is a martingale.
|
Prove that a simple random walk is a martingale
|
Let $\{X_t\}_{t\geq 1}$ be a sequence of independent random variables such that $\Pr\{X_t=1\}=\Pr\{X_t=-1\}=1/2$. Define $\mathscr{F_t}=\sigma(X_1,\dots,X_t)$ and $M_t=X_1+\dots+X_t$. We have (equalit
|
Prove that a simple random walk is a martingale
Let $\{X_t\}_{t\geq 1}$ be a sequence of independent random variables such that $\Pr\{X_t=1\}=\Pr\{X_t=-1\}=1/2$. Define $\mathscr{F_t}=\sigma(X_1,\dots,X_t)$ and $M_t=X_1+\dots+X_t$. We have (equalities between conditional expectations holding almost surely)
$$
\mathbb{E}[M_{t+1}\mid\mathscr{F_t}] = \mathbb{E}[X_{t+1}+M_t\mid\mathscr{F_t}] = \mathbb{E}[X_{t+1}\mid\mathscr{F_t}] + \mathbb{E}[M_t\mid\mathscr{F_t}].
$$
But $X_{t+1}$ is independent of $\mathscr{F_t}$, therefore, $\mathbb{E}[X_{t+1}\mid\mathscr{F_t}]=\mathbb{E}[X_{t+1}]=0$. Also, $M_t$ is $\mathscr{F}_t$-measurable, hence, $\mathbb{E}[M_t\mid\mathscr{F_t}]=M_t$. It follows that $\mathbb{E}[M_{t+1}\mid\mathscr{F_t}]=M_t$ and $\{(M_t,\mathscr{F}_t)\}_{t\geq 1}$ is a martingale.
|
Prove that a simple random walk is a martingale
Let $\{X_t\}_{t\geq 1}$ be a sequence of independent random variables such that $\Pr\{X_t=1\}=\Pr\{X_t=-1\}=1/2$. Define $\mathscr{F_t}=\sigma(X_1,\dots,X_t)$ and $M_t=X_1+\dots+X_t$. We have (equalit
|
45,227
|
Forcing smoothness of regression coefficients
|
If you want something simple, I would look at (weighted) fused LASSO or similarly ridge-style regression. Suppose you have
$$ y \in \mathbf{R}^{T\times 1} \text{ response} \qquad X_{k} \in \mathbf{R}^{T\times 1} \text{ where } k\in\{1, \dots, K\} \text{ $k$th covariate }$$
You want some smoothness of coefficients that should be close, ie if $k$th and $j$th covariates should have coefficients that are close in some norm. For simplicity, assume chain-type structure, ie $1$st covariate is related to $2$nd, $2$nd to $3$rd ect. The estimators you may want to look at are
$$ \hat\beta \in \underset{\beta\in \mathbf{R}^{K}}{ \text{arg min}}\|y-X\beta\|^2_T + 2\lambda_1 \|\beta\|_1 + 2\lambda_2 \|D \beta\|_1 \quad \text{fused LASSO}$$
or
$$ \hat\beta \in \underset{\beta\in \mathbf{R}^{K}}{ \text{arg min}}\|y-X\beta\|^2_T + 2\lambda \|D \beta\|^2_2 \quad \text{Ridge-type}$$
where
$$
D = \begin{pmatrix}
0 & 0 & 0 & \dots & 0 & 0 \\
1 & -1 & 0 & \dots & 0 & 0 \\
0 & 1 & -1 & \dots & 0 & 0 \\
\vdots & \vdots & \vdots & \ddots & \vdots & \vdots \\
0 & 0 & 0 & \dots & 1 & -1 \\
\end{pmatrix}.
$$
and $\|u\|^2_T = \langle u,u \rangle/T$. You may also add LASSO-type constraint to the second estimator to impose sparsity on top of $\ell_2$ constraint (you will get something like the elastic net). As usual, Ridge (without additional LASSO constraint) has closed form (provided that $D$ satisfies some simple conditions).
The first reference for the fused LASSO I would look at is: https://web.stanford.edu/group/SOL/papers/fused-lasso-JRSSB.pdf. There are many efficient solvers in many software packages for such type of problems.
Lastly, you may use correlation as weights for $k$ and $j$ pair of covariates and adjust the penalty term accordingly. Define $\rho_{k,j}$ as a simple correlation between two covariates. You probably want to have a correlation between two consecutive covariates, i.e. $\rho_{k,k+1}$, $k \in \{1,\dots, K-1\}$, and you want to take the absolute value of correlations. Then, redefine the $D$ matrix as
$$
D = \begin{pmatrix}
0 & 0 & 0 & \dots & 0 & 0 \\
|\rho_{1,2}| & -|\rho_{2,1}| & 0 & \dots & 0 & 0 & 0 \\
0 & |\rho_{2,3}| & -|\rho_{3,2}| & \dots & 0 & 0 & 0 \\
\vdots & \vdots & \vdots & \ddots & \vdots & \vdots & \vdots \\
0 & 0 & 0 & \dots & 0 & |\rho_{K-1,K}| & -|\rho_{K,K-1}| \\
\end{pmatrix}.
$$
where $\rho_{k,k-1} = \rho_{k-1,k}$, of course. Then you take into account the relative strength between each pair of covariates, which can help.
You have to try several estimators and see what works best for your dataset.
For your second question, maybe you can use the dictionary of functions, say $W$, to approximate the weight function of different frequencies you have in your dataset. So, if your predictors are $Z_{j,k}$, for $j\in \{1,\dots,J\}$, define $X_{k}=(Z_{1,k},\dots,Z_{J,k})W$, and run the usual regression of $y$ on $X$. $W$ can be splines for example. I'm not sure if it makes sense to smooth coefficients in this case.
Hope this helps.
|
Forcing smoothness of regression coefficients
|
If you want something simple, I would look at (weighted) fused LASSO or similarly ridge-style regression. Suppose you have
$$ y \in \mathbf{R}^{T\times 1} \text{ response} \qquad X_{k} \in \mathbf{R}^
|
Forcing smoothness of regression coefficients
If you want something simple, I would look at (weighted) fused LASSO or similarly ridge-style regression. Suppose you have
$$ y \in \mathbf{R}^{T\times 1} \text{ response} \qquad X_{k} \in \mathbf{R}^{T\times 1} \text{ where } k\in\{1, \dots, K\} \text{ $k$th covariate }$$
You want some smoothness of coefficients that should be close, ie if $k$th and $j$th covariates should have coefficients that are close in some norm. For simplicity, assume chain-type structure, ie $1$st covariate is related to $2$nd, $2$nd to $3$rd ect. The estimators you may want to look at are
$$ \hat\beta \in \underset{\beta\in \mathbf{R}^{K}}{ \text{arg min}}\|y-X\beta\|^2_T + 2\lambda_1 \|\beta\|_1 + 2\lambda_2 \|D \beta\|_1 \quad \text{fused LASSO}$$
or
$$ \hat\beta \in \underset{\beta\in \mathbf{R}^{K}}{ \text{arg min}}\|y-X\beta\|^2_T + 2\lambda \|D \beta\|^2_2 \quad \text{Ridge-type}$$
where
$$
D = \begin{pmatrix}
0 & 0 & 0 & \dots & 0 & 0 \\
1 & -1 & 0 & \dots & 0 & 0 \\
0 & 1 & -1 & \dots & 0 & 0 \\
\vdots & \vdots & \vdots & \ddots & \vdots & \vdots \\
0 & 0 & 0 & \dots & 1 & -1 \\
\end{pmatrix}.
$$
and $\|u\|^2_T = \langle u,u \rangle/T$. You may also add LASSO-type constraint to the second estimator to impose sparsity on top of $\ell_2$ constraint (you will get something like the elastic net). As usual, Ridge (without additional LASSO constraint) has closed form (provided that $D$ satisfies some simple conditions).
The first reference for the fused LASSO I would look at is: https://web.stanford.edu/group/SOL/papers/fused-lasso-JRSSB.pdf. There are many efficient solvers in many software packages for such type of problems.
Lastly, you may use correlation as weights for $k$ and $j$ pair of covariates and adjust the penalty term accordingly. Define $\rho_{k,j}$ as a simple correlation between two covariates. You probably want to have a correlation between two consecutive covariates, i.e. $\rho_{k,k+1}$, $k \in \{1,\dots, K-1\}$, and you want to take the absolute value of correlations. Then, redefine the $D$ matrix as
$$
D = \begin{pmatrix}
0 & 0 & 0 & \dots & 0 & 0 \\
|\rho_{1,2}| & -|\rho_{2,1}| & 0 & \dots & 0 & 0 & 0 \\
0 & |\rho_{2,3}| & -|\rho_{3,2}| & \dots & 0 & 0 & 0 \\
\vdots & \vdots & \vdots & \ddots & \vdots & \vdots & \vdots \\
0 & 0 & 0 & \dots & 0 & |\rho_{K-1,K}| & -|\rho_{K,K-1}| \\
\end{pmatrix}.
$$
where $\rho_{k,k-1} = \rho_{k-1,k}$, of course. Then you take into account the relative strength between each pair of covariates, which can help.
You have to try several estimators and see what works best for your dataset.
For your second question, maybe you can use the dictionary of functions, say $W$, to approximate the weight function of different frequencies you have in your dataset. So, if your predictors are $Z_{j,k}$, for $j\in \{1,\dots,J\}$, define $X_{k}=(Z_{1,k},\dots,Z_{J,k})W$, and run the usual regression of $y$ on $X$. $W$ can be splines for example. I'm not sure if it makes sense to smooth coefficients in this case.
Hope this helps.
|
Forcing smoothness of regression coefficients
If you want something simple, I would look at (weighted) fused LASSO or similarly ridge-style regression. Suppose you have
$$ y \in \mathbf{R}^{T\times 1} \text{ response} \qquad X_{k} \in \mathbf{R}^
|
45,228
|
Forcing smoothness of regression coefficients
|
This is the motivation for Functional Data Analysis.
I will describe the functional covariate and scalar response linear model which is just one of many many possible models.
Asumes pairs $(x, y)$ where $$ y = \int_{a}^{b} \beta(t)x(t) \, dt + \varepsilon$$
Here $x$ is a random curve, y a scalar response and $\beta$ an unknown function that links both variables.
There are many approachs to estimate $\beta$ but one that is a direct solution to your problem is finding $\alpha$ in a suitable finite dimentional space such that minimices
$$ \sum_{i=1}^n \left(y_i - \int_a^b \alpha(t) x_i(t) \,dt\right)^2 + \lambda \| \alpha^{(m)} \|^2 $$
Usually $m=2$ so you penalize roughness of your function. Higher values of $\lambda$ will give smoother estimations.
Usually one does not observe curves but a discretized version of them. If $(t_k, x_i (t_k))$ are your values for frecuency an intensity $1\leq k\leq p$ and $1 \leq i \leq n$ then you may estimates your curves with splines or any other method of your choice. A great plus of this method is that you do not need to have all your observations in the same grid. You can actually have different $p_i$. An other important aspect to consider is that these method ares specially designed to bypass the high correlation between the $x_i(t_k)$ $x_i(t_{k+s})$. Also using a suitable finite dimentional space make optimization tasks simple.
A great book for studing this models is Functional Data Analysis by Ramsay And Silverman..
There are also R packages such as fda and fda.usc.
|
Forcing smoothness of regression coefficients
|
This is the motivation for Functional Data Analysis.
I will describe the functional covariate and scalar response linear model which is just one of many many possible models.
Asumes pairs $(x, y)$ wh
|
Forcing smoothness of regression coefficients
This is the motivation for Functional Data Analysis.
I will describe the functional covariate and scalar response linear model which is just one of many many possible models.
Asumes pairs $(x, y)$ where $$ y = \int_{a}^{b} \beta(t)x(t) \, dt + \varepsilon$$
Here $x$ is a random curve, y a scalar response and $\beta$ an unknown function that links both variables.
There are many approachs to estimate $\beta$ but one that is a direct solution to your problem is finding $\alpha$ in a suitable finite dimentional space such that minimices
$$ \sum_{i=1}^n \left(y_i - \int_a^b \alpha(t) x_i(t) \,dt\right)^2 + \lambda \| \alpha^{(m)} \|^2 $$
Usually $m=2$ so you penalize roughness of your function. Higher values of $\lambda$ will give smoother estimations.
Usually one does not observe curves but a discretized version of them. If $(t_k, x_i (t_k))$ are your values for frecuency an intensity $1\leq k\leq p$ and $1 \leq i \leq n$ then you may estimates your curves with splines or any other method of your choice. A great plus of this method is that you do not need to have all your observations in the same grid. You can actually have different $p_i$. An other important aspect to consider is that these method ares specially designed to bypass the high correlation between the $x_i(t_k)$ $x_i(t_{k+s})$. Also using a suitable finite dimentional space make optimization tasks simple.
A great book for studing this models is Functional Data Analysis by Ramsay And Silverman..
There are also R packages such as fda and fda.usc.
|
Forcing smoothness of regression coefficients
This is the motivation for Functional Data Analysis.
I will describe the functional covariate and scalar response linear model which is just one of many many possible models.
Asumes pairs $(x, y)$ wh
|
45,229
|
Is the value of probability invariant of function of a random variable
|
Let $X_1, X_2$ be two independent random variables each with pmf
$$ P_{X}(x)=
\begin{cases}
\frac{1}{2} & x =1 \\
\frac{1}{2} & x =-1 \\
\end{cases} $$
Then $\mathsf P(X_1>X_2)=0.25$ but $\mathsf P\big(X_1^2>X_2^2\big)=0$
|
Is the value of probability invariant of function of a random variable
|
Let $X_1, X_2$ be two independent random variables each with pmf
$$ P_{X}(x)=
\begin{cases}
\frac{1}{2} & x =1 \\
\frac{1}{2} & x =-1 \\
\end{cases} $$
Then $\mathsf P(X_1>X_2)=0.25$ but $\mathsf
|
Is the value of probability invariant of function of a random variable
Let $X_1, X_2$ be two independent random variables each with pmf
$$ P_{X}(x)=
\begin{cases}
\frac{1}{2} & x =1 \\
\frac{1}{2} & x =-1 \\
\end{cases} $$
Then $\mathsf P(X_1>X_2)=0.25$ but $\mathsf P\big(X_1^2>X_2^2\big)=0$
|
Is the value of probability invariant of function of a random variable
Let $X_1, X_2$ be two independent random variables each with pmf
$$ P_{X}(x)=
\begin{cases}
\frac{1}{2} & x =1 \\
\frac{1}{2} & x =-1 \\
\end{cases} $$
Then $\mathsf P(X_1>X_2)=0.25$ but $\mathsf
|
45,230
|
Is the value of probability invariant of function of a random variable
|
No. That equation does not hold in general. Although that equation does not hold in general, it does hold for monotonically increasing functions. If $f$ is monotone increasing (e.g., exponential or logarithmic functions) then you have the event equivalence:
$$\{ X > Y \} \quad \quad \iff \quad \quad \{ f(X) > f(Y) \}.$$
In this case the underlying events are equivalent and so the probability equation you give holds regardless of the distribution of $X_1$ and $X_2$. Note also that there are some special combinations of a distribution $F$ and a function $f$ for which your probability equation holds, but it will not hold as a general property unless $f$ is a monotonically increasing function.
|
Is the value of probability invariant of function of a random variable
|
No. That equation does not hold in general. Although that equation does not hold in general, it does hold for monotonically increasing functions. If $f$ is monotone increasing (e.g., exponential or
|
Is the value of probability invariant of function of a random variable
No. That equation does not hold in general. Although that equation does not hold in general, it does hold for monotonically increasing functions. If $f$ is monotone increasing (e.g., exponential or logarithmic functions) then you have the event equivalence:
$$\{ X > Y \} \quad \quad \iff \quad \quad \{ f(X) > f(Y) \}.$$
In this case the underlying events are equivalent and so the probability equation you give holds regardless of the distribution of $X_1$ and $X_2$. Note also that there are some special combinations of a distribution $F$ and a function $f$ for which your probability equation holds, but it will not hold as a general property unless $f$ is a monotonically increasing function.
|
Is the value of probability invariant of function of a random variable
No. That equation does not hold in general. Although that equation does not hold in general, it does hold for monotonically increasing functions. If $f$ is monotone increasing (e.g., exponential or
|
45,231
|
Is the value of probability invariant of function of a random variable
|
A simple counterexample for any $X_i$ with $P(X_i > 0) = 1$ is the function $f(x) = x^{-1}$. It reverses inequalities, hence $P(f(X_1) > f(X_2)) = P(X_1 < X_2)$, which is in general different from $P(X_1 > X_2)$.
|
Is the value of probability invariant of function of a random variable
|
A simple counterexample for any $X_i$ with $P(X_i > 0) = 1$ is the function $f(x) = x^{-1}$. It reverses inequalities, hence $P(f(X_1) > f(X_2)) = P(X_1 < X_2)$, which is in general different from $P(
|
Is the value of probability invariant of function of a random variable
A simple counterexample for any $X_i$ with $P(X_i > 0) = 1$ is the function $f(x) = x^{-1}$. It reverses inequalities, hence $P(f(X_1) > f(X_2)) = P(X_1 < X_2)$, which is in general different from $P(X_1 > X_2)$.
|
Is the value of probability invariant of function of a random variable
A simple counterexample for any $X_i$ with $P(X_i > 0) = 1$ is the function $f(x) = x^{-1}$. It reverses inequalities, hence $P(f(X_1) > f(X_2)) = P(X_1 < X_2)$, which is in general different from $P(
|
45,232
|
Should I do a regression analysis even if the variables do not seem to be associated at all?
|
A couple of thoughts:
It is usual to put the dependent (or outcome) variable on the vertical axis and the independent (or predictor) variable on the horizontal axis
If you do two separate simple linear regressions, you are, essentially, fitting a line to the plots you have posted. I agree that it doesn't look like there is much there. If you do a single multiple linear regression, then you are looking at the relationship between A and C, controlling for B and between B and C, controlling for A. That may show something that you didn't find here.
Something is wrong with your plots, as C has very different values in the two plots 0 in the one on the left, it ranges from 0 to 15, in the one on the right, it ranges from 200 to 320.
|
Should I do a regression analysis even if the variables do not seem to be associated at all?
|
A couple of thoughts:
It is usual to put the dependent (or outcome) variable on the vertical axis and the independent (or predictor) variable on the horizontal axis
If you do two separate simple line
|
Should I do a regression analysis even if the variables do not seem to be associated at all?
A couple of thoughts:
It is usual to put the dependent (or outcome) variable on the vertical axis and the independent (or predictor) variable on the horizontal axis
If you do two separate simple linear regressions, you are, essentially, fitting a line to the plots you have posted. I agree that it doesn't look like there is much there. If you do a single multiple linear regression, then you are looking at the relationship between A and C, controlling for B and between B and C, controlling for A. That may show something that you didn't find here.
Something is wrong with your plots, as C has very different values in the two plots 0 in the one on the left, it ranges from 0 to 15, in the one on the right, it ranges from 200 to 320.
|
Should I do a regression analysis even if the variables do not seem to be associated at all?
A couple of thoughts:
It is usual to put the dependent (or outcome) variable on the vertical axis and the independent (or predictor) variable on the horizontal axis
If you do two separate simple line
|
45,233
|
What is the benefit of latent variables?
|
There are some elements to answer your question in Section 16.5 of the Deep Learning book by Ian Goodfellow and al.:
A good generative model needs to accurately capture the distribution over the
observed or “visible” variables $v$ . Often the different elements of $v$ are highly
dependent on each other. In the context of deep learning, the approach most
commonly used to model these dependencies is to introduce several latent or
“hidden” variables, $h$. The model can then capture dependencies between any pair
of variables $v_i$ and $v_j$ indirectly, via direct dependencies between $v_i$ and $h$, and direct dependencies between $h$ and $v_j$.
The section also opposes the approach of adding latent variable to that of trying to model $p(v)$ without any latent variable:
A good model of v which did not contain any latent variables would need to have very large numbers of parents per node in a Bayesian network or very large
cliques in a Markov network. Just representing these higher order interactions is
costly. [...]
As an approach to discover such relevant (and computationaly tractable) interactions between the visible variables, the concept of structure learning is introduced. In general, modeling a fixed structure with latent variables avoids the need of structure learning between the visible variables. The book seems to imply that the former is easier than the latter. Indeed, we find later on this sentence:
Using simple parameter
learning techniques we can learn a model with a fixed structure that imputes the
right structure on the marginal $p( v )$.
Edit (thanks to carlo's comment): Going further in the analysis of structures with latent variables, we come accross the notion of interpretability. Jumping to Section 16.7, we can read:
When latent variables are used in the context of traditional graphical models, they are often designed with some specific semantics in mind—the topic of a document, the intelligence of a student, the disease causing a patient’s symptoms, etc. These models are often much more interpretable by human practitioners and often have more theoretical guarantees [...]
|
What is the benefit of latent variables?
|
There are some elements to answer your question in Section 16.5 of the Deep Learning book by Ian Goodfellow and al.:
A good generative model needs to accurately capture the distribution over the
ob
|
What is the benefit of latent variables?
There are some elements to answer your question in Section 16.5 of the Deep Learning book by Ian Goodfellow and al.:
A good generative model needs to accurately capture the distribution over the
observed or “visible” variables $v$ . Often the different elements of $v$ are highly
dependent on each other. In the context of deep learning, the approach most
commonly used to model these dependencies is to introduce several latent or
“hidden” variables, $h$. The model can then capture dependencies between any pair
of variables $v_i$ and $v_j$ indirectly, via direct dependencies between $v_i$ and $h$, and direct dependencies between $h$ and $v_j$.
The section also opposes the approach of adding latent variable to that of trying to model $p(v)$ without any latent variable:
A good model of v which did not contain any latent variables would need to have very large numbers of parents per node in a Bayesian network or very large
cliques in a Markov network. Just representing these higher order interactions is
costly. [...]
As an approach to discover such relevant (and computationaly tractable) interactions between the visible variables, the concept of structure learning is introduced. In general, modeling a fixed structure with latent variables avoids the need of structure learning between the visible variables. The book seems to imply that the former is easier than the latter. Indeed, we find later on this sentence:
Using simple parameter
learning techniques we can learn a model with a fixed structure that imputes the
right structure on the marginal $p( v )$.
Edit (thanks to carlo's comment): Going further in the analysis of structures with latent variables, we come accross the notion of interpretability. Jumping to Section 16.7, we can read:
When latent variables are used in the context of traditional graphical models, they are often designed with some specific semantics in mind—the topic of a document, the intelligence of a student, the disease causing a patient’s symptoms, etc. These models are often much more interpretable by human practitioners and often have more theoretical guarantees [...]
|
What is the benefit of latent variables?
There are some elements to answer your question in Section 16.5 of the Deep Learning book by Ian Goodfellow and al.:
A good generative model needs to accurately capture the distribution over the
ob
|
45,234
|
What is the benefit of latent variables?
|
In many cases the data we observe depends on some hidden variables, that were not observed, or could not be observed. Knowing those variables would simplify our model, and in many cases we can get away from not knowing their values by assuming a latent variable model, that can "recover" the unobserved variables from the data.
Among popular examples of such models are finite mixture models, which assume that the data is clustered, while the cluster assignment is unknown and to be learned from the data. Those models can be used to learning distribution of the data, or more complicate cases like regression. In each case, the model learns to distinguish among several groups in the data, that share common characteristics, and fits the sub-models per each group, no matter that the group assignment was not known a priori. In plain English, instead of needing to build a complicated one-size-fitts-all model, you are building a model that consists of several, problem-specific, simpler models.
Another popular example is principle components analysis (see e.g. chapter 12 from Pattern Recognition and Machine Learning book by Bishop, 2006), or basically any other dimensionality reduction model, that are used to "compress" the observed data to smaller number of dimensions without much loss of information. Here the latent variables are the unobserved "features" of the data, that almost fully explain it. We are aiming at finding those features.
You can find very different example in my recent question, where we observed an aggregated data, while wanting to learn about the individual-level variability. As pointed in the answer, this can be thought as latent variable model, where we treat the predictions for the individuals as latent variables, that get aggregated, so that we can predict the aggregated responses to train the model. So contrary to previous examples where we used latent variables to find some higher-level features, here we use them to make lower-level, de-aggregated predictions. Again, here the individual-level values were not observed, so we replaced them with latent variables placeholders and made the model to predict them from the data.
Those are just few examples that illustrate latent variable models. You can find some more in the books by Bishop (2006), or Machine Learning: A Probabilistic Perspective by Kevin P. Murphy, who give many more examples and detailed explanations.
As a sidenote, it is worth mentioning, that those models can be in many cases hard to identify and often need some problem-specific computational tweaks and algorithms, so "guessing" the data that was not observed comes at some cost.
|
What is the benefit of latent variables?
|
In many cases the data we observe depends on some hidden variables, that were not observed, or could not be observed. Knowing those variables would simplify our model, and in many cases we can get awa
|
What is the benefit of latent variables?
In many cases the data we observe depends on some hidden variables, that were not observed, or could not be observed. Knowing those variables would simplify our model, and in many cases we can get away from not knowing their values by assuming a latent variable model, that can "recover" the unobserved variables from the data.
Among popular examples of such models are finite mixture models, which assume that the data is clustered, while the cluster assignment is unknown and to be learned from the data. Those models can be used to learning distribution of the data, or more complicate cases like regression. In each case, the model learns to distinguish among several groups in the data, that share common characteristics, and fits the sub-models per each group, no matter that the group assignment was not known a priori. In plain English, instead of needing to build a complicated one-size-fitts-all model, you are building a model that consists of several, problem-specific, simpler models.
Another popular example is principle components analysis (see e.g. chapter 12 from Pattern Recognition and Machine Learning book by Bishop, 2006), or basically any other dimensionality reduction model, that are used to "compress" the observed data to smaller number of dimensions without much loss of information. Here the latent variables are the unobserved "features" of the data, that almost fully explain it. We are aiming at finding those features.
You can find very different example in my recent question, where we observed an aggregated data, while wanting to learn about the individual-level variability. As pointed in the answer, this can be thought as latent variable model, where we treat the predictions for the individuals as latent variables, that get aggregated, so that we can predict the aggregated responses to train the model. So contrary to previous examples where we used latent variables to find some higher-level features, here we use them to make lower-level, de-aggregated predictions. Again, here the individual-level values were not observed, so we replaced them with latent variables placeholders and made the model to predict them from the data.
Those are just few examples that illustrate latent variable models. You can find some more in the books by Bishop (2006), or Machine Learning: A Probabilistic Perspective by Kevin P. Murphy, who give many more examples and detailed explanations.
As a sidenote, it is worth mentioning, that those models can be in many cases hard to identify and often need some problem-specific computational tweaks and algorithms, so "guessing" the data that was not observed comes at some cost.
|
What is the benefit of latent variables?
In many cases the data we observe depends on some hidden variables, that were not observed, or could not be observed. Knowing those variables would simplify our model, and in many cases we can get awa
|
45,235
|
What is the benefit of latent variables?
|
Take a simple case: the data $x$ is a mixture of Gaussians generated by picking a cluster index $z$ (from a categoric distribution $p(z)$) and then sampling from the Gaussian of that cluster $p(x|z)$. So $x$ is defined by nature as $p(x)=\sum_zp(x|z)p(z)$.
If you observe samples from $p(x)$ and want to model the distribution, the most accurate model will be one that reflects the true generative process (which may not be unique), i.e. that models the unobserved $z$ as a latent variable.
You could fit another model: like one big Gaussian, which would be a terrible fit; or a very flexible autoregressive model (e.g. a normalising flow [1]); but they are approximations and will not do better than fitting a latent variable model that reflects/respects the generative process. Also they do not reveal the "natural structure" of the data (see next point).
The latent variables may be of interest in themselves. For example, in the mixture of Gaussians case, inferring $z$ identifies the cluster of each data point, which may be semantically meaningful. This would be true for a more complex mixture distribution and may identify images of the same object, or words of the same sentiment. In physics, a latent variable might represent a certain property to be estimated.
[1] A Family of Nonparametric Density Estimation Algorithms; Tabak & Turner
|
What is the benefit of latent variables?
|
Take a simple case: the data $x$ is a mixture of Gaussians generated by picking a cluster index $z$ (from a categoric distribution $p(z)$) and then sampling from the Gaussian of that cluster $p(x|z)$.
|
What is the benefit of latent variables?
Take a simple case: the data $x$ is a mixture of Gaussians generated by picking a cluster index $z$ (from a categoric distribution $p(z)$) and then sampling from the Gaussian of that cluster $p(x|z)$. So $x$ is defined by nature as $p(x)=\sum_zp(x|z)p(z)$.
If you observe samples from $p(x)$ and want to model the distribution, the most accurate model will be one that reflects the true generative process (which may not be unique), i.e. that models the unobserved $z$ as a latent variable.
You could fit another model: like one big Gaussian, which would be a terrible fit; or a very flexible autoregressive model (e.g. a normalising flow [1]); but they are approximations and will not do better than fitting a latent variable model that reflects/respects the generative process. Also they do not reveal the "natural structure" of the data (see next point).
The latent variables may be of interest in themselves. For example, in the mixture of Gaussians case, inferring $z$ identifies the cluster of each data point, which may be semantically meaningful. This would be true for a more complex mixture distribution and may identify images of the same object, or words of the same sentiment. In physics, a latent variable might represent a certain property to be estimated.
[1] A Family of Nonparametric Density Estimation Algorithms; Tabak & Turner
|
What is the benefit of latent variables?
Take a simple case: the data $x$ is a mixture of Gaussians generated by picking a cluster index $z$ (from a categoric distribution $p(z)$) and then sampling from the Gaussian of that cluster $p(x|z)$.
|
45,236
|
Generate synthetic data given AUC
|
There are multiple ways to do it. One is to assume to transform AUC to cohen's D and then just sample data from 2 standard normal distributions D standard deviations apart.
We can transform AUC to D according to a formula from SALGADO, Jesús F.. Transforming the Area under the Normal Curve (AUC) into Cohen’s d, Pearson’s r pb , Odds-Ratio, and Natural Log Odds-Ratio: Two Conversion Tables. The European Journal of Psychology Applied to Legal Context [online]. 2018, vol.10, n.1, pp.35-47. ISSN 1989-4007. http://dx.doi.org/10.5093/ejpalc2018a5
Which in R code will work like this
auc <- 0.95
t <- sqrt(log(1/(1-auc)**2))
z <- t-((2.515517 + 0.802853*t + 0.0103328*t**2) /
(1 + 1.432788*t + 0.189269*t**2 + 0.001308*t**3))
d <- z*sqrt(2)
n <- 10000
x <- c(rnorm(n/2, mean = 0), rnorm(n/2, mean = d))
y <- c(rep(0, n/2), rep(1, n/2))
library(AUC)
auc(roc(x, as.factor(y)))
# out
# [1] 0.9486257
Of course, since we are sampling, this will produce the correct AUC on average, but the specific sample will not be exactly the required AUC.
|
Generate synthetic data given AUC
|
There are multiple ways to do it. One is to assume to transform AUC to cohen's D and then just sample data from 2 standard normal distributions D standard deviations apart.
We can transform AUC to D
|
Generate synthetic data given AUC
There are multiple ways to do it. One is to assume to transform AUC to cohen's D and then just sample data from 2 standard normal distributions D standard deviations apart.
We can transform AUC to D according to a formula from SALGADO, Jesús F.. Transforming the Area under the Normal Curve (AUC) into Cohen’s d, Pearson’s r pb , Odds-Ratio, and Natural Log Odds-Ratio: Two Conversion Tables. The European Journal of Psychology Applied to Legal Context [online]. 2018, vol.10, n.1, pp.35-47. ISSN 1989-4007. http://dx.doi.org/10.5093/ejpalc2018a5
Which in R code will work like this
auc <- 0.95
t <- sqrt(log(1/(1-auc)**2))
z <- t-((2.515517 + 0.802853*t + 0.0103328*t**2) /
(1 + 1.432788*t + 0.189269*t**2 + 0.001308*t**3))
d <- z*sqrt(2)
n <- 10000
x <- c(rnorm(n/2, mean = 0), rnorm(n/2, mean = d))
y <- c(rep(0, n/2), rep(1, n/2))
library(AUC)
auc(roc(x, as.factor(y)))
# out
# [1] 0.9486257
Of course, since we are sampling, this will produce the correct AUC on average, but the specific sample will not be exactly the required AUC.
|
Generate synthetic data given AUC
There are multiple ways to do it. One is to assume to transform AUC to cohen's D and then just sample data from 2 standard normal distributions D standard deviations apart.
We can transform AUC to D
|
45,237
|
Regression when x and y each have uncertainties
|
In both cases you want to use Deming regression. Case 1 is a special case of Deming regression called orthogonal regression, which minimizes the sum of squared perpendicular distances from the data points to the regression line. For case 2, the general case, you will need an estimate of the ratio $\delta = \sigma^2_y / \sigma^2_x$ for the problem to be solvable.
|
Regression when x and y each have uncertainties
|
In both cases you want to use Deming regression. Case 1 is a special case of Deming regression called orthogonal regression, which minimizes the sum of squared perpendicular distances from the data po
|
Regression when x and y each have uncertainties
In both cases you want to use Deming regression. Case 1 is a special case of Deming regression called orthogonal regression, which minimizes the sum of squared perpendicular distances from the data points to the regression line. For case 2, the general case, you will need an estimate of the ratio $\delta = \sigma^2_y / \sigma^2_x$ for the problem to be solvable.
|
Regression when x and y each have uncertainties
In both cases you want to use Deming regression. Case 1 is a special case of Deming regression called orthogonal regression, which minimizes the sum of squared perpendicular distances from the data po
|
45,238
|
Regression when x and y each have uncertainties
|
As a general concept the problem of error in X is called measurement error.
In linear regression analysis it causes attenuation bias, which is considered as one of the sources of engogeneity. Measuremet error shrinks coefficient of the right-hand-side variable measured with an error towards zero. It causes not uncertainty of an estimator, but its inconsistency instead.
While mentioned in other answer deming regression is two-variable concept, the multivariate solutions include instrumental variable method as preferred option.
Formulas for attenuation bias in case of linear regression are precisely derived, for example in here. This means if you have a clue of the variation of the error, you might estimate severity of the problem and possibly correct for it.
Measurement in Y, in case of linear regression is less of the problem, as linear regression assumes random error in the dependent variable. It causes worse prediction and higher residual variance, but do not bias coefficients in any way.
EDIT: This problem is directly described in Hausman (2001).
Hausman, Jerry. "Mismeasured variables in econometric analysis: problems from the right and problems from the left." Journal of Economic perspectives 15, no. 4 (2001): 57-67.
|
Regression when x and y each have uncertainties
|
As a general concept the problem of error in X is called measurement error.
In linear regression analysis it causes attenuation bias, which is considered as one of the sources of engogeneity. Measurem
|
Regression when x and y each have uncertainties
As a general concept the problem of error in X is called measurement error.
In linear regression analysis it causes attenuation bias, which is considered as one of the sources of engogeneity. Measuremet error shrinks coefficient of the right-hand-side variable measured with an error towards zero. It causes not uncertainty of an estimator, but its inconsistency instead.
While mentioned in other answer deming regression is two-variable concept, the multivariate solutions include instrumental variable method as preferred option.
Formulas for attenuation bias in case of linear regression are precisely derived, for example in here. This means if you have a clue of the variation of the error, you might estimate severity of the problem and possibly correct for it.
Measurement in Y, in case of linear regression is less of the problem, as linear regression assumes random error in the dependent variable. It causes worse prediction and higher residual variance, but do not bias coefficients in any way.
EDIT: This problem is directly described in Hausman (2001).
Hausman, Jerry. "Mismeasured variables in econometric analysis: problems from the right and problems from the left." Journal of Economic perspectives 15, no. 4 (2001): 57-67.
|
Regression when x and y each have uncertainties
As a general concept the problem of error in X is called measurement error.
In linear regression analysis it causes attenuation bias, which is considered as one of the sources of engogeneity. Measurem
|
45,239
|
Wilcoxon signed rank test – critical value for n>50
|
The Wilcoxon signed rank test has a null distribution that rapidly approaches a normal distribution.
The tables tend to stop by n=50 because the normal approximation is excellent well before that point. Indeed, there's probably little point tabulating much beyond n=20. The normal approximation is given at the Wikipedia page for the test -- but you need to make sure you're using the same version of the statistic (there's more than one definition going around; they should all give the same p-values though). Wikipedia's version uses the sum of all the signed ranks.
If you use R (or a number of other statistical packages), they'll happily give critical values for one and two tailed tests. Again, you have to make sure you're using the same definition of the statistic as they do (R uses "the sum of the positive ranks" as the statistic).
Using R's definition of the statistic, at n=63, the 5% two tailed critical value is 1294; the 5% (upper) one tailed critical value is 1248.
Using the corresponding normal approximation (with or without continuity correction) gives the same values.
To get a p-value using a normal approximation you need:
the mean and standard deviation of the particular statistic you're using, when $H_0$ is true. You can (for example) then compute a standardized version of the test statistic (which is approximately normally distributed) if you wish - though with computer packages you can avoid the need to standardize.
You can then use normal tables or computer functions for the normal distribution to obtain a p-value, or you can simply compare your statistic with critical values for your significance level.
|
Wilcoxon signed rank test – critical value for n>50
|
The Wilcoxon signed rank test has a null distribution that rapidly approaches a normal distribution.
The tables tend to stop by n=50 because the normal approximation is excellent well before that poin
|
Wilcoxon signed rank test – critical value for n>50
The Wilcoxon signed rank test has a null distribution that rapidly approaches a normal distribution.
The tables tend to stop by n=50 because the normal approximation is excellent well before that point. Indeed, there's probably little point tabulating much beyond n=20. The normal approximation is given at the Wikipedia page for the test -- but you need to make sure you're using the same version of the statistic (there's more than one definition going around; they should all give the same p-values though). Wikipedia's version uses the sum of all the signed ranks.
If you use R (or a number of other statistical packages), they'll happily give critical values for one and two tailed tests. Again, you have to make sure you're using the same definition of the statistic as they do (R uses "the sum of the positive ranks" as the statistic).
Using R's definition of the statistic, at n=63, the 5% two tailed critical value is 1294; the 5% (upper) one tailed critical value is 1248.
Using the corresponding normal approximation (with or without continuity correction) gives the same values.
To get a p-value using a normal approximation you need:
the mean and standard deviation of the particular statistic you're using, when $H_0$ is true. You can (for example) then compute a standardized version of the test statistic (which is approximately normally distributed) if you wish - though with computer packages you can avoid the need to standardize.
You can then use normal tables or computer functions for the normal distribution to obtain a p-value, or you can simply compare your statistic with critical values for your significance level.
|
Wilcoxon signed rank test – critical value for n>50
The Wilcoxon signed rank test has a null distribution that rapidly approaches a normal distribution.
The tables tend to stop by n=50 because the normal approximation is excellent well before that poin
|
45,240
|
Why is the bayesian information criterion called that way?
|
BIC, sometimes called the Schwarz information criterion (SIC) was introduced by Gideon Schwartz in 1975. Here is that paper. It's not very long.
Both AIC and BIC address the model evaluation problem where more parameters lead to increased likelihood. To resolve this they penalize additional parameters. Schwartz gave a bayesian argument. His central thesis was, "In a model of given dimension, maximum likelihood estimators can be obtained as large-sample limits of the Bayes estimators for arbitrary nowhere vanishing a priori distributions."
So even though the formula for BIC has nothing Bayesian about it, the original paper is chock full of Bayesian explanations for the procedure since it was derived from a special "large-sample" case of Bayes Theorem.
|
Why is the bayesian information criterion called that way?
|
BIC, sometimes called the Schwarz information criterion (SIC) was introduced by Gideon Schwartz in 1975. Here is that paper. It's not very long.
Both AIC and BIC address the model evaluation problem w
|
Why is the bayesian information criterion called that way?
BIC, sometimes called the Schwarz information criterion (SIC) was introduced by Gideon Schwartz in 1975. Here is that paper. It's not very long.
Both AIC and BIC address the model evaluation problem where more parameters lead to increased likelihood. To resolve this they penalize additional parameters. Schwartz gave a bayesian argument. His central thesis was, "In a model of given dimension, maximum likelihood estimators can be obtained as large-sample limits of the Bayes estimators for arbitrary nowhere vanishing a priori distributions."
So even though the formula for BIC has nothing Bayesian about it, the original paper is chock full of Bayesian explanations for the procedure since it was derived from a special "large-sample" case of Bayes Theorem.
|
Why is the bayesian information criterion called that way?
BIC, sometimes called the Schwarz information criterion (SIC) was introduced by Gideon Schwartz in 1975. Here is that paper. It's not very long.
Both AIC and BIC address the model evaluation problem w
|
45,241
|
Why is the bayesian information criterion called that way?
|
One of my favourite simple interpretations and derivation of the BIC is in a lecture by Prof. Michael Jordan. This connects the Laplace approximation of the marginal likelihood (normalising constant in the Bayes Theorem, which is used for model comparison) with the BIC.
https://people.eecs.berkeley.edu/~jordan/courses/260-spring10/lectures/lecture16.pdf
Here, he derives the BIC using a Laplace approximation and some intuitive asymptotic arguments.
Laplace approximation:
Then,
Finally,
|
Why is the bayesian information criterion called that way?
|
One of my favourite simple interpretations and derivation of the BIC is in a lecture by Prof. Michael Jordan. This connects the Laplace approximation of the marginal likelihood (normalising constant i
|
Why is the bayesian information criterion called that way?
One of my favourite simple interpretations and derivation of the BIC is in a lecture by Prof. Michael Jordan. This connects the Laplace approximation of the marginal likelihood (normalising constant in the Bayes Theorem, which is used for model comparison) with the BIC.
https://people.eecs.berkeley.edu/~jordan/courses/260-spring10/lectures/lecture16.pdf
Here, he derives the BIC using a Laplace approximation and some intuitive asymptotic arguments.
Laplace approximation:
Then,
Finally,
|
Why is the bayesian information criterion called that way?
One of my favourite simple interpretations and derivation of the BIC is in a lecture by Prof. Michael Jordan. This connects the Laplace approximation of the marginal likelihood (normalising constant i
|
45,242
|
Mean and variance of $\tan(\mathcal{N}(\mu,\,\sigma^{2}))$
|
The mean is not defined and the variance is infinite.
To see why this is, we have to analyze the integrals a little indirectly, because there are no formulas available. We will thereby obtain a more general result: namely,
When $X$ is a random variable whose distribution has a density $f$ that is positive and continuous in a neighborhood of any one of the numbers $(k+1/2)\pi$ (where $k$ is any integer), then $E[\tan(X)]$ is undefined and $E[\tan(x)^2]$ is infinite.
The very form of this statement exposes the essential idea: the tangent function grows so large so quickly near its poles at the values $(k+1/2)\pi$ that $\tan(X)$ cannot have an expectation unless $X$ has vanishingly small probability of being near any of those poles.
When $X$ has a distribution with density $f,$ the expectation of $\tan(X)^j$ (for any power $j=0, 1, 2, \ldots$) is
$$E[\tan(X)] = \int_\mathbb{R} \tan(x)^j f(x) \mathrm{d}x\tag{*}$$
Let's begin with the fact that $\tan$ has poles at the values $\pi/2 + k\pi$ for all integers $k.$ Thus, if this expectation $(*)$ exists, it can be broken into integrals of width $\pi$ spanning each successive pairs of poles. Between one pole and the other the tangent function rises from $-\infty$ to $\infty,$ crossing zero halfway through. Let's therefore further break such integrals into a left and right half. The rseulting integrals are of the form
$$I_{-}(f,j,k) = \int_{(k-1/2)\pi}^{k\pi} \tan(x)^j f(x) \mathrm{d}x$$
at the left, where $\tan(x)\le 0,$ and
$$I_{+}(f,j,k) = \int_{k\pi}^{(k+1/2)\pi} \tan(x)^j f(x) \mathrm{d}x$$
at the right, where $\tan(x)\ge 0.$
Assuming $f$ is continuous--which it is for all Normal distributions--we may interpret these as Riemann integrals. By definition, when the integrand might grow infinite at the endpoints, the Riemann integral is obtained by taking limits. For instance, the right integral is defined as
$$I_{+}(f,j,k) = \lim_{\epsilon\to 0^{+}} \int_{k\pi}^{(k+1/2)\pi-\epsilon} \tan(x)^j f(x) \mathrm{d}x.$$
Let's consider the case $j=1.$ Fix $k$ and note (just to make the analysis a little simpler looking) that
$$\int_{k\pi}^{(k+1/2)\pi-\epsilon} \tan(x) f(x) \mathrm{d}x = \int_{0}^{\pi/2-\epsilon} \tan(x) f(x-k\pi) \mathrm{d}x = \int_{0}^{\pi/2-\epsilon} \tan(x) g_k(x) \mathrm{d}x$$
where $g_k(x)=f(x-k\pi)$ is still a continuous function.
This figure depicts the setup: the graph of $\tan$ in blue, the density function $g$ filled in red, and their product--the thing we are integrating to find part of the expectation--filled in gold near the pole at $\pi/2.$ The analysis will underestimate both the upper gold area (the $I_{+}$ part) and lower gold area (the $I_{-}$ part) by showing the size of each exceeds some small multiple of the area bounded by the blue curve.
Indeed, $g$ is strictly positive (because the Normal density $f$ is never zero). Thus, for any given $\epsilon \gt 0,$ $g_k$ attains a positive minimum value $g_{k,0}$ on the interval $[0, \pi/2].$ Consequently
$$I_{+}(f,1,k) \ge g_{k,0}\int_{0}^{\pi/2-\epsilon} \tan(x) \mathrm{d}x \gt 0.\tag{**}$$
That got rid of the complicated factor $g(x),$ leaving an easy analysis,
$$\int_{0}^{\pi/2-\epsilon} \tan(x) \mathrm{d}x= -\log \cos(x)\vert_0^{\pi/2-\epsilon} = -\log\sin(\epsilon).$$
This diverges as $\epsilon \to 0^{+}.$ By virtue of the inequality $(**),$ $I_{+}(f,1,k)$ diverges for all $k.$
The same analysis applies to $I_{-}(f,1,k),$ which diverges (to $-\infty$). Consequently, $E[\tan(X)]$ is undefined because it's effectively an infinite sum of terms alternately diverging to $\infty$ and $-\infty.$
The power-mean inequality (or, if you like, a comparable analysis for the case $j=2$) shows that all the integrals summing to $E[\tan(X)^2]$ diverge to $+\infty,$ which means $E[\tan(X)^2]$ diverges to $+\infty:$ it is infinite. This implies the variance is infinite.
|
Mean and variance of $\tan(\mathcal{N}(\mu,\,\sigma^{2}))$
|
The mean is not defined and the variance is infinite.
To see why this is, we have to analyze the integrals a little indirectly, because there are no formulas available. We will thereby obtain a more
|
Mean and variance of $\tan(\mathcal{N}(\mu,\,\sigma^{2}))$
The mean is not defined and the variance is infinite.
To see why this is, we have to analyze the integrals a little indirectly, because there are no formulas available. We will thereby obtain a more general result: namely,
When $X$ is a random variable whose distribution has a density $f$ that is positive and continuous in a neighborhood of any one of the numbers $(k+1/2)\pi$ (where $k$ is any integer), then $E[\tan(X)]$ is undefined and $E[\tan(x)^2]$ is infinite.
The very form of this statement exposes the essential idea: the tangent function grows so large so quickly near its poles at the values $(k+1/2)\pi$ that $\tan(X)$ cannot have an expectation unless $X$ has vanishingly small probability of being near any of those poles.
When $X$ has a distribution with density $f,$ the expectation of $\tan(X)^j$ (for any power $j=0, 1, 2, \ldots$) is
$$E[\tan(X)] = \int_\mathbb{R} \tan(x)^j f(x) \mathrm{d}x\tag{*}$$
Let's begin with the fact that $\tan$ has poles at the values $\pi/2 + k\pi$ for all integers $k.$ Thus, if this expectation $(*)$ exists, it can be broken into integrals of width $\pi$ spanning each successive pairs of poles. Between one pole and the other the tangent function rises from $-\infty$ to $\infty,$ crossing zero halfway through. Let's therefore further break such integrals into a left and right half. The rseulting integrals are of the form
$$I_{-}(f,j,k) = \int_{(k-1/2)\pi}^{k\pi} \tan(x)^j f(x) \mathrm{d}x$$
at the left, where $\tan(x)\le 0,$ and
$$I_{+}(f,j,k) = \int_{k\pi}^{(k+1/2)\pi} \tan(x)^j f(x) \mathrm{d}x$$
at the right, where $\tan(x)\ge 0.$
Assuming $f$ is continuous--which it is for all Normal distributions--we may interpret these as Riemann integrals. By definition, when the integrand might grow infinite at the endpoints, the Riemann integral is obtained by taking limits. For instance, the right integral is defined as
$$I_{+}(f,j,k) = \lim_{\epsilon\to 0^{+}} \int_{k\pi}^{(k+1/2)\pi-\epsilon} \tan(x)^j f(x) \mathrm{d}x.$$
Let's consider the case $j=1.$ Fix $k$ and note (just to make the analysis a little simpler looking) that
$$\int_{k\pi}^{(k+1/2)\pi-\epsilon} \tan(x) f(x) \mathrm{d}x = \int_{0}^{\pi/2-\epsilon} \tan(x) f(x-k\pi) \mathrm{d}x = \int_{0}^{\pi/2-\epsilon} \tan(x) g_k(x) \mathrm{d}x$$
where $g_k(x)=f(x-k\pi)$ is still a continuous function.
This figure depicts the setup: the graph of $\tan$ in blue, the density function $g$ filled in red, and their product--the thing we are integrating to find part of the expectation--filled in gold near the pole at $\pi/2.$ The analysis will underestimate both the upper gold area (the $I_{+}$ part) and lower gold area (the $I_{-}$ part) by showing the size of each exceeds some small multiple of the area bounded by the blue curve.
Indeed, $g$ is strictly positive (because the Normal density $f$ is never zero). Thus, for any given $\epsilon \gt 0,$ $g_k$ attains a positive minimum value $g_{k,0}$ on the interval $[0, \pi/2].$ Consequently
$$I_{+}(f,1,k) \ge g_{k,0}\int_{0}^{\pi/2-\epsilon} \tan(x) \mathrm{d}x \gt 0.\tag{**}$$
That got rid of the complicated factor $g(x),$ leaving an easy analysis,
$$\int_{0}^{\pi/2-\epsilon} \tan(x) \mathrm{d}x= -\log \cos(x)\vert_0^{\pi/2-\epsilon} = -\log\sin(\epsilon).$$
This diverges as $\epsilon \to 0^{+}.$ By virtue of the inequality $(**),$ $I_{+}(f,1,k)$ diverges for all $k.$
The same analysis applies to $I_{-}(f,1,k),$ which diverges (to $-\infty$). Consequently, $E[\tan(X)]$ is undefined because it's effectively an infinite sum of terms alternately diverging to $\infty$ and $-\infty.$
The power-mean inequality (or, if you like, a comparable analysis for the case $j=2$) shows that all the integrals summing to $E[\tan(X)^2]$ diverge to $+\infty,$ which means $E[\tan(X)^2]$ diverges to $+\infty:$ it is infinite. This implies the variance is infinite.
|
Mean and variance of $\tan(\mathcal{N}(\mu,\,\sigma^{2}))$
The mean is not defined and the variance is infinite.
To see why this is, we have to analyze the integrals a little indirectly, because there are no formulas available. We will thereby obtain a more
|
45,243
|
How exactly to evaluate Treatment effect after Matching?
|
The documentation for Matching is sadly fairly incomplete, leaving what it does quite mysterious. What is clear is that it takes a different approach from Stuart (2010) (and the Ho, Imai, King, and Stuart camp) in estimating treatment effects and their standard errors. Rather, it takes heavy inspiration from Abadie & Imbens (2006, 2011), who describe variance estimators and bias-correction for matching estimators. While Stuart and colleagues consider matching a nonparametric pre-processing method that doesn't change the variance of the effect estimates, Abadie, Imbens, and Sekhon are careful to consider the variability in the effect estimate induced by the matching. Thus, the analysis that Matching performs is not described in Stuart (2010).
The philosophy of matching described by Ho, Imai, King, & Stuart (2007) (the authors of the MatchIt package) is that the analysis that would have been performed without matching should be that performed after matching, and the benefit of matching is robustness to misspecification of the functional form of the model used. The most basic model is none at all, i.e., the difference in treatment group means, but regression models on the treatment and covariates work too. This group argues that no adjustment to the standard error is required, so the standard error you get from the standard analysis on the matched sample is sufficient. This is why you can simply export the matched sample from the output of MatchIt and run a regression on it, forgetting that the matched sample came from a matching procedure. Austin has additionally argued that standard errors should account for the paired nature of the data, though the MatchIt camp argue that matching doesn't imply pairing and an unpaired standard error is sufficient. Using cluster-robust standard errors with pair membership as the cluster should accomplish this. This can be done using the sandwich package after estimating the effect using glm() or by using the jtools package.
The philosophy of matching used by Matching considers the act of matching to be part of the analysis, and the variability it induces in the effect estimate must be taken account of. Much of the theory used in Matching comes from a series of papers written by Abadie and Imbens, who discuss the bias and variance of matching estimators. Although the documentation for Matching is not very descriptive, the Stata function teffects nnmatch is almost identical and uses all the same theory, and its documentation is very descriptive. The effect estimator is that described by Abadie & Imbens (2006); it's not a simple difference in means estimator because of the possibility of ties, k:1 matching, and matching with replacement. Its standard error is described in the paper. There is an option to perform bias correction, which uses a technique described by Abadie & Imbens (2011). This is not the same as performing regression on the matched set. Rather than using matching to provide robustness to a regression estimator, the bias-corrected matching estimator provides robustness to a matching estimator by using parametric bias-correction using the covariates.
The only difference between genetic matching and standard "nearest neighbor" matching is the distance metric used to decide whether two units are near to each other. In teffects nnmatch in Stata and Match() in Matching, the default is the Mahalanobis distance. The innovation of genetic matching is that the distance matrix is continuously reweighted until good balance is found instead of just using the default distance matrix, so the theory for the matching estimators still applies.
I think a clear way to write your methods section might be something like
Matching was performed using a genetic matching algorithm (Diamond &
Sekhon, 2013) as implemented in the Matching package (Sekhon, 2011).
Treatment effects were estimated using the Match function in
Matching, which implements the matching estimators and standard error estimators described by Abadie and Imbens (2006). To improve
robustness, we performed bias correction on all continuous covariates
as described by Abadie and Imbens (2011) and implemented using the
BiasAdjust option in the Match function.
This makes your analysis reproducible and curious readers can investigate the literature for themselves (although Matching is almost an industry standard and already well trusted).
Abadie, A., & Imbens, G. W. (2006). Large Sample Properties of Matching Estimators for Average Treatment Effects. Econometrica, 74(1), 235–267. https://doi.org/10.1111/j.1468-0262.2006.00655.x
Abadie, A., & Imbens, G. W. (2011). Bias-Corrected Matching Estimators for Average Treatment Effects. Journal of Business & Economic Statistics, 29(1), 1–11. https://doi.org/10.1198/jbes.2009.07333
Diamond, A., & Sekhon, J. S. (2013). Genetic matching for estimating causal effects: A general multivariate matching method for achieving balance in observational studies. Review of Economics and Statistics, 95(3), 932–945.
Ho, D. E., Imai, K., King, G., & Stuart, E. A. (2007). Matching as Nonparametric Preprocessing for Reducing Model Dependence in Parametric Causal Inference. Political Analysis, 15(3), 199–236. https://doi.org/10.1093/pan/mpl013
Stuart, E. A. (2010). Matching Methods for Causal Inference: A Review and a Look Forward. Statistical Science, 25(1), 1–21. https://doi.org/10.1214/09-STS313
|
How exactly to evaluate Treatment effect after Matching?
|
The documentation for Matching is sadly fairly incomplete, leaving what it does quite mysterious. What is clear is that it takes a different approach from Stuart (2010) (and the Ho, Imai, King, and St
|
How exactly to evaluate Treatment effect after Matching?
The documentation for Matching is sadly fairly incomplete, leaving what it does quite mysterious. What is clear is that it takes a different approach from Stuart (2010) (and the Ho, Imai, King, and Stuart camp) in estimating treatment effects and their standard errors. Rather, it takes heavy inspiration from Abadie & Imbens (2006, 2011), who describe variance estimators and bias-correction for matching estimators. While Stuart and colleagues consider matching a nonparametric pre-processing method that doesn't change the variance of the effect estimates, Abadie, Imbens, and Sekhon are careful to consider the variability in the effect estimate induced by the matching. Thus, the analysis that Matching performs is not described in Stuart (2010).
The philosophy of matching described by Ho, Imai, King, & Stuart (2007) (the authors of the MatchIt package) is that the analysis that would have been performed without matching should be that performed after matching, and the benefit of matching is robustness to misspecification of the functional form of the model used. The most basic model is none at all, i.e., the difference in treatment group means, but regression models on the treatment and covariates work too. This group argues that no adjustment to the standard error is required, so the standard error you get from the standard analysis on the matched sample is sufficient. This is why you can simply export the matched sample from the output of MatchIt and run a regression on it, forgetting that the matched sample came from a matching procedure. Austin has additionally argued that standard errors should account for the paired nature of the data, though the MatchIt camp argue that matching doesn't imply pairing and an unpaired standard error is sufficient. Using cluster-robust standard errors with pair membership as the cluster should accomplish this. This can be done using the sandwich package after estimating the effect using glm() or by using the jtools package.
The philosophy of matching used by Matching considers the act of matching to be part of the analysis, and the variability it induces in the effect estimate must be taken account of. Much of the theory used in Matching comes from a series of papers written by Abadie and Imbens, who discuss the bias and variance of matching estimators. Although the documentation for Matching is not very descriptive, the Stata function teffects nnmatch is almost identical and uses all the same theory, and its documentation is very descriptive. The effect estimator is that described by Abadie & Imbens (2006); it's not a simple difference in means estimator because of the possibility of ties, k:1 matching, and matching with replacement. Its standard error is described in the paper. There is an option to perform bias correction, which uses a technique described by Abadie & Imbens (2011). This is not the same as performing regression on the matched set. Rather than using matching to provide robustness to a regression estimator, the bias-corrected matching estimator provides robustness to a matching estimator by using parametric bias-correction using the covariates.
The only difference between genetic matching and standard "nearest neighbor" matching is the distance metric used to decide whether two units are near to each other. In teffects nnmatch in Stata and Match() in Matching, the default is the Mahalanobis distance. The innovation of genetic matching is that the distance matrix is continuously reweighted until good balance is found instead of just using the default distance matrix, so the theory for the matching estimators still applies.
I think a clear way to write your methods section might be something like
Matching was performed using a genetic matching algorithm (Diamond &
Sekhon, 2013) as implemented in the Matching package (Sekhon, 2011).
Treatment effects were estimated using the Match function in
Matching, which implements the matching estimators and standard error estimators described by Abadie and Imbens (2006). To improve
robustness, we performed bias correction on all continuous covariates
as described by Abadie and Imbens (2011) and implemented using the
BiasAdjust option in the Match function.
This makes your analysis reproducible and curious readers can investigate the literature for themselves (although Matching is almost an industry standard and already well trusted).
Abadie, A., & Imbens, G. W. (2006). Large Sample Properties of Matching Estimators for Average Treatment Effects. Econometrica, 74(1), 235–267. https://doi.org/10.1111/j.1468-0262.2006.00655.x
Abadie, A., & Imbens, G. W. (2011). Bias-Corrected Matching Estimators for Average Treatment Effects. Journal of Business & Economic Statistics, 29(1), 1–11. https://doi.org/10.1198/jbes.2009.07333
Diamond, A., & Sekhon, J. S. (2013). Genetic matching for estimating causal effects: A general multivariate matching method for achieving balance in observational studies. Review of Economics and Statistics, 95(3), 932–945.
Ho, D. E., Imai, K., King, G., & Stuart, E. A. (2007). Matching as Nonparametric Preprocessing for Reducing Model Dependence in Parametric Causal Inference. Political Analysis, 15(3), 199–236. https://doi.org/10.1093/pan/mpl013
Stuart, E. A. (2010). Matching Methods for Causal Inference: A Review and a Look Forward. Statistical Science, 25(1), 1–21. https://doi.org/10.1214/09-STS313
|
How exactly to evaluate Treatment effect after Matching?
The documentation for Matching is sadly fairly incomplete, leaving what it does quite mysterious. What is clear is that it takes a different approach from Stuart (2010) (and the Ho, Imai, King, and St
|
45,244
|
R: How to fit a GLMM in nlme
|
I was looking for a way to do what you're trying to accomplish and came across a couple of things. First was this question that was asked elsewhere on the website with this answer. The second was this paper, which did exactly what you were asking about. What they did was perform a logit transformation on the response variable, which could then be fitted into the lme function.
Full disclosure:
1. According to the answer I linked above, the method I'm about to share is apparently not recommended (though the comment by Aaron on the answer indicates that this is a very common way of doing it?)
2. There are very different results with the outputs I'm about to provide
Okay, onwards and outwards...
1. Create some simulated data
RNGkind('Mersenne-Twister')
set.seed(42)
x1 <- rnorm(1000)
x2 <- rnorm(1000)
x3 <- factor(rep(c('a', 'b', 'c'), length.out = 1000))
#x3 won't cause a lot of random noise, it's just for illustrative purposes.
beta0 <- 0.6
beta1 <- 0.9
beta2 <- 0.7
z <- beta0 + beta1*x1 + beta2*x2
pr <- 1/(1+exp(-z))
y <- rbinom(1000, 1, pr)
table(y) #Just check since I'm kiasu
2. Logit-transform the response variable and prepare our data frame
#####This is the part that isn't recommended#####
library(car)
logit.y <- logit(y)
df <- data.frame(y, logit.y, x1, x2, x3)
3. Run some models
library(nlme)
library(lme4)
library(glmmTMB)
test.lme <- lme(logit.y ~ x1 + x2, random = ~1|x3, data = df, method = 'ML') #We set this to maximum-likelihood as the default is REML (restricted maximum likelihood)
test.glmer <- glmer(y ~ x1 + x2 + (1|x3), data = df, family = binomial)
test.glmmTMB <- glmmTMB(y ~ x1 + x2 + (1|x3), data = df, family = binomial)
4. Look at the summaries
summary(test.lme)$tTable
Value Std.Error DF t-value p-value
(Intercept) 0.8431364 0.1020533 995 8.261726 4.546389e-16
x1 1.2517987 0.1018175 995 12.294535 1.920042e-32
x2 0.9074567 0.1035171 995 8.766248 7.863229e-18
summary(test.glmer)$coefficients
Estimate Std. Error z value Pr(>|z|)
(Intercept) 0.5834385 0.07423036 7.859836 3.846378e-15
x1 0.9044080 0.08409916 10.754067 5.670490e-27
x2 0.6545513 0.07965376 8.217456 2.078662e-16
summary(test.glmmTMB)$coefficients$cond
Estimate Std. Error z value Pr(>|z|)
(Intercept) 0.5834385 0.07423036 7.859836 3.846380e-15
x1 0.9044079 0.08409911 10.754072 5.670193e-27
x2 0.6545512 0.07965371 8.217460 2.078583e-16
The results from test.glmer and test.glmmTMB are quite similar, but the test.lme results (i.e. the one where we logit-transformed the response variable) is just a little bit different.
Also note that the nlme output uses a t-test, while glmer and glmmTMB use a z-test. More on the z-test used to test individual parameters can be found here.
5. Compare back-transformed estimates
logit.lme <- summary(test.lme)$tTable[,1]
logit.glmer <- summary(test.glmer)$coefficients[,1]
logit.glmmTMB <- summary(test.glmmTMB)$coefficients$cond[,1]
prob.lme <- exp(logit.lme)/(1+exp(logit.lme))
prob.glmer <- exp(logit.glmer)/(1+exp(logit.glmer))
prob.glmmTMB <- exp(logit.glmmTMB)/(1+exp(logit.glmmTMB))
prob.brms <- apply(as.data.frame(test.brms$fit), 2, mean)[1:3] #Example model not provided
names(prob.brms) <- names(prob.glmmTMB)
round(t(cbind(original = c('(Intercept)' = beta0, x1 = beta1, x2 = beta2),
lme = prob.lme, glmer = prob.glmer, glmmTMB = prob.glmmTMB, brms = prob.brms)), 2)
(Intercept) x1 x2
original 0.60 0.90 0.70
lme 0.70 0.78 0.71
glmer 0.64 0.71 0.66
glmmTMB 0.64 0.71 0.66
brms 0.60 0.91 0.66
#Not incredible all round except for the brms method (which uses
#Bayesian anyway!), but nearly there. The point is that the results
#from the glmer, glmmTMB, and brms methods are more similiar to each
#other than the result from the lme method.
6. Let's look at some visualizations.
#Make some predicted data
#x1 axis
predicted.df.x1 <- data.frame(x1 = seq(min(df$x1), max(df$x1), length.out = 1000),
x2 = mean(df$x2))
predicted.df.x1 <- as.data.frame(do.call(rbind, replicate(3, predicted.df.x1, simplify = F)))
predicted.df.x1$x3 <- rep(c('a', 'b', 'c'), each = 1000)
predict.lme.x1 <- logit.lme[1] + predicted.df.x1$x1*logit.lme[2] + predicted.df.x1$x2*logit.lme[3]
#Recall that we logit transformed our data, so we need to 'manually' get our predicted variables
predict.lme.x1 <- exp(predict.lme.x1)/(1+exp(predict.lme.x1))
predict.glmer.x1 <- predict(test.glmer, predicted.df.x1, type = 'response')
predict.glmmTMB.x1 <- predict(test.glmmTMB, predicted.df.x1, type = 'response')
#x2 axis
predicted.df.x2 <- data.frame(x2 = seq(min(df$x2), max(df$x2), length.out = 1000),
x1 = mean(df$x1))
predicted.df.x2 <- as.data.frame(do.call(rbind, replicate(3, predicted.df.x2, simplify = F)))
predicted.df.x2$x3 <- rep(c('a', 'b', 'c'), each = 1000)
predict.lme.x2 <- logit.lme[1] + predicted.df.x2$x1*logit.lme[2] + predicted.df.x2$x2*logit.lme[3]
predict.lme.x2 <- exp(predict.lme.x2)/(1+exp(predict.lme.x2))
predict.glmer.x2 <- predict(test.glmer, predicted.df.x2, type = 'response')
predict.glmmTMB.x2 <- predict(test.glmmTMB, predicted.df.x2, type = 'response')
#Plot it
par(mfrow = c(2,3))
plot(df$x1, (exp(predict(test.lme))/(1+exp(predict(test.lme)))), pch = 16, cex = 0.4, col = 'red', xlab = 'x1', ylab = 'Predicted Prob.', main = 'Logit-transormed')
lines(predicted.df.x1$x1[1:1000], predict.lme.x1[1:1000], col = 'black', lwd = 2)
plot(df$x1, predict(test.glmer, type = 'response'), pch = 16, cex = 0.4, col = 'blue', xlab = 'x1', ylab = 'Predicted Prob.', main = 'glmer Function')
lines(predicted.df.x1$x1[1:1000], predict.glmer.x1[1:1000], col = 'black', lwd = 2)
plot(df$x1, predict(test.glmmTMB, type = 'response'), pch = 16, cex = 0.4, col = 'darkgreen', xlab = 'x1', ylab = 'Predicted Prob.', main = 'glmerTMB function')
lines(predicted.df.x1$x1[1:1000], predict.glmmTMB.x1[1:1000], col = 'black', lwd = 2)
plot(df$x2, (exp(predict(test.lme))/(1+exp(predict(test.lme)))), pch = 16, cex = 0.4, col = 'red', xlab = 'x2', ylab = 'Predicted Prob.', main = 'Logit-transormed')
lines(predicted.df.x2$x2[1:1000], predict.lme.x2[1:1000], col = 'black', lwd = 2)
plot(df$x2, predict(test.glmer, type = 'response'), pch = 16, cex = 0.4, col = 'blue', xlab = 'x2', ylab = 'Predicted Prob.', main = 'glmer Function')
lines(predicted.df.x2$x2[1:1000], predict.glmer.x2[1:1000], col = 'black', lwd = 2)
plot(df$x2, predict(test.glmmTMB, type = 'response'), pch = 16, cex = 0.4, col = 'darkgreen', xlab = 'x2', ylab = 'Predicted Prob.', main = 'glmerTMB function')
lines(predicted.df.x2$x2[1:1000], predict.glmmTMB.x2[1:1000], col = 'black', lwd = 2)
So the result we get from the logit-transformed response variable with the linear nlme is slightly different from outputs provided using the glmer and glmmTMB when specifying the binomial family. It also doesn't take too much to see that there is a difference between the methods when looking at the visuals.
Now the question is why is it different. I'm sure there is an answer, I just don't know what it is.
Some other things:
I'm not entirely sure if my syntax/calculations are correct in getting the logit-transformed response variable, so if someone is able to check and verify if I did it correctly, then maybe we'd be getting warmer.
I'm not going to profess to being an expert, I just happened to (vaguely) know how to code it, albeit with the help of the answer I highlighted earlier in this post. Would someone be able to shed some light on the differences?
The only reason I'd imagine anyone would want to use the lme method is to fit an autoregressive correlation structure of some kind to account for temporal/spatial autocorrelation, much like was done in the paper I mentioned earlier. Ben Bolker does provide a succinct brain dump (unlike this answer) on which packages can be used for fitting mixed models with temporally autocorrelative data, though I haven't tried any of them myself (I'm afraid I'm too intimidated to even try, lets I break R again).
|
R: How to fit a GLMM in nlme
|
I was looking for a way to do what you're trying to accomplish and came across a couple of things. First was this question that was asked elsewhere on the website with this answer. The second was this
|
R: How to fit a GLMM in nlme
I was looking for a way to do what you're trying to accomplish and came across a couple of things. First was this question that was asked elsewhere on the website with this answer. The second was this paper, which did exactly what you were asking about. What they did was perform a logit transformation on the response variable, which could then be fitted into the lme function.
Full disclosure:
1. According to the answer I linked above, the method I'm about to share is apparently not recommended (though the comment by Aaron on the answer indicates that this is a very common way of doing it?)
2. There are very different results with the outputs I'm about to provide
Okay, onwards and outwards...
1. Create some simulated data
RNGkind('Mersenne-Twister')
set.seed(42)
x1 <- rnorm(1000)
x2 <- rnorm(1000)
x3 <- factor(rep(c('a', 'b', 'c'), length.out = 1000))
#x3 won't cause a lot of random noise, it's just for illustrative purposes.
beta0 <- 0.6
beta1 <- 0.9
beta2 <- 0.7
z <- beta0 + beta1*x1 + beta2*x2
pr <- 1/(1+exp(-z))
y <- rbinom(1000, 1, pr)
table(y) #Just check since I'm kiasu
2. Logit-transform the response variable and prepare our data frame
#####This is the part that isn't recommended#####
library(car)
logit.y <- logit(y)
df <- data.frame(y, logit.y, x1, x2, x3)
3. Run some models
library(nlme)
library(lme4)
library(glmmTMB)
test.lme <- lme(logit.y ~ x1 + x2, random = ~1|x3, data = df, method = 'ML') #We set this to maximum-likelihood as the default is REML (restricted maximum likelihood)
test.glmer <- glmer(y ~ x1 + x2 + (1|x3), data = df, family = binomial)
test.glmmTMB <- glmmTMB(y ~ x1 + x2 + (1|x3), data = df, family = binomial)
4. Look at the summaries
summary(test.lme)$tTable
Value Std.Error DF t-value p-value
(Intercept) 0.8431364 0.1020533 995 8.261726 4.546389e-16
x1 1.2517987 0.1018175 995 12.294535 1.920042e-32
x2 0.9074567 0.1035171 995 8.766248 7.863229e-18
summary(test.glmer)$coefficients
Estimate Std. Error z value Pr(>|z|)
(Intercept) 0.5834385 0.07423036 7.859836 3.846378e-15
x1 0.9044080 0.08409916 10.754067 5.670490e-27
x2 0.6545513 0.07965376 8.217456 2.078662e-16
summary(test.glmmTMB)$coefficients$cond
Estimate Std. Error z value Pr(>|z|)
(Intercept) 0.5834385 0.07423036 7.859836 3.846380e-15
x1 0.9044079 0.08409911 10.754072 5.670193e-27
x2 0.6545512 0.07965371 8.217460 2.078583e-16
The results from test.glmer and test.glmmTMB are quite similar, but the test.lme results (i.e. the one where we logit-transformed the response variable) is just a little bit different.
Also note that the nlme output uses a t-test, while glmer and glmmTMB use a z-test. More on the z-test used to test individual parameters can be found here.
5. Compare back-transformed estimates
logit.lme <- summary(test.lme)$tTable[,1]
logit.glmer <- summary(test.glmer)$coefficients[,1]
logit.glmmTMB <- summary(test.glmmTMB)$coefficients$cond[,1]
prob.lme <- exp(logit.lme)/(1+exp(logit.lme))
prob.glmer <- exp(logit.glmer)/(1+exp(logit.glmer))
prob.glmmTMB <- exp(logit.glmmTMB)/(1+exp(logit.glmmTMB))
prob.brms <- apply(as.data.frame(test.brms$fit), 2, mean)[1:3] #Example model not provided
names(prob.brms) <- names(prob.glmmTMB)
round(t(cbind(original = c('(Intercept)' = beta0, x1 = beta1, x2 = beta2),
lme = prob.lme, glmer = prob.glmer, glmmTMB = prob.glmmTMB, brms = prob.brms)), 2)
(Intercept) x1 x2
original 0.60 0.90 0.70
lme 0.70 0.78 0.71
glmer 0.64 0.71 0.66
glmmTMB 0.64 0.71 0.66
brms 0.60 0.91 0.66
#Not incredible all round except for the brms method (which uses
#Bayesian anyway!), but nearly there. The point is that the results
#from the glmer, glmmTMB, and brms methods are more similiar to each
#other than the result from the lme method.
6. Let's look at some visualizations.
#Make some predicted data
#x1 axis
predicted.df.x1 <- data.frame(x1 = seq(min(df$x1), max(df$x1), length.out = 1000),
x2 = mean(df$x2))
predicted.df.x1 <- as.data.frame(do.call(rbind, replicate(3, predicted.df.x1, simplify = F)))
predicted.df.x1$x3 <- rep(c('a', 'b', 'c'), each = 1000)
predict.lme.x1 <- logit.lme[1] + predicted.df.x1$x1*logit.lme[2] + predicted.df.x1$x2*logit.lme[3]
#Recall that we logit transformed our data, so we need to 'manually' get our predicted variables
predict.lme.x1 <- exp(predict.lme.x1)/(1+exp(predict.lme.x1))
predict.glmer.x1 <- predict(test.glmer, predicted.df.x1, type = 'response')
predict.glmmTMB.x1 <- predict(test.glmmTMB, predicted.df.x1, type = 'response')
#x2 axis
predicted.df.x2 <- data.frame(x2 = seq(min(df$x2), max(df$x2), length.out = 1000),
x1 = mean(df$x1))
predicted.df.x2 <- as.data.frame(do.call(rbind, replicate(3, predicted.df.x2, simplify = F)))
predicted.df.x2$x3 <- rep(c('a', 'b', 'c'), each = 1000)
predict.lme.x2 <- logit.lme[1] + predicted.df.x2$x1*logit.lme[2] + predicted.df.x2$x2*logit.lme[3]
predict.lme.x2 <- exp(predict.lme.x2)/(1+exp(predict.lme.x2))
predict.glmer.x2 <- predict(test.glmer, predicted.df.x2, type = 'response')
predict.glmmTMB.x2 <- predict(test.glmmTMB, predicted.df.x2, type = 'response')
#Plot it
par(mfrow = c(2,3))
plot(df$x1, (exp(predict(test.lme))/(1+exp(predict(test.lme)))), pch = 16, cex = 0.4, col = 'red', xlab = 'x1', ylab = 'Predicted Prob.', main = 'Logit-transormed')
lines(predicted.df.x1$x1[1:1000], predict.lme.x1[1:1000], col = 'black', lwd = 2)
plot(df$x1, predict(test.glmer, type = 'response'), pch = 16, cex = 0.4, col = 'blue', xlab = 'x1', ylab = 'Predicted Prob.', main = 'glmer Function')
lines(predicted.df.x1$x1[1:1000], predict.glmer.x1[1:1000], col = 'black', lwd = 2)
plot(df$x1, predict(test.glmmTMB, type = 'response'), pch = 16, cex = 0.4, col = 'darkgreen', xlab = 'x1', ylab = 'Predicted Prob.', main = 'glmerTMB function')
lines(predicted.df.x1$x1[1:1000], predict.glmmTMB.x1[1:1000], col = 'black', lwd = 2)
plot(df$x2, (exp(predict(test.lme))/(1+exp(predict(test.lme)))), pch = 16, cex = 0.4, col = 'red', xlab = 'x2', ylab = 'Predicted Prob.', main = 'Logit-transormed')
lines(predicted.df.x2$x2[1:1000], predict.lme.x2[1:1000], col = 'black', lwd = 2)
plot(df$x2, predict(test.glmer, type = 'response'), pch = 16, cex = 0.4, col = 'blue', xlab = 'x2', ylab = 'Predicted Prob.', main = 'glmer Function')
lines(predicted.df.x2$x2[1:1000], predict.glmer.x2[1:1000], col = 'black', lwd = 2)
plot(df$x2, predict(test.glmmTMB, type = 'response'), pch = 16, cex = 0.4, col = 'darkgreen', xlab = 'x2', ylab = 'Predicted Prob.', main = 'glmerTMB function')
lines(predicted.df.x2$x2[1:1000], predict.glmmTMB.x2[1:1000], col = 'black', lwd = 2)
So the result we get from the logit-transformed response variable with the linear nlme is slightly different from outputs provided using the glmer and glmmTMB when specifying the binomial family. It also doesn't take too much to see that there is a difference between the methods when looking at the visuals.
Now the question is why is it different. I'm sure there is an answer, I just don't know what it is.
Some other things:
I'm not entirely sure if my syntax/calculations are correct in getting the logit-transformed response variable, so if someone is able to check and verify if I did it correctly, then maybe we'd be getting warmer.
I'm not going to profess to being an expert, I just happened to (vaguely) know how to code it, albeit with the help of the answer I highlighted earlier in this post. Would someone be able to shed some light on the differences?
The only reason I'd imagine anyone would want to use the lme method is to fit an autoregressive correlation structure of some kind to account for temporal/spatial autocorrelation, much like was done in the paper I mentioned earlier. Ben Bolker does provide a succinct brain dump (unlike this answer) on which packages can be used for fitting mixed models with temporally autocorrelative data, though I haven't tried any of them myself (I'm afraid I'm too intimidated to even try, lets I break R again).
|
R: How to fit a GLMM in nlme
I was looking for a way to do what you're trying to accomplish and came across a couple of things. First was this question that was asked elsewhere on the website with this answer. The second was this
|
45,245
|
R: How to fit a GLMM in nlme
|
I don't think nlme can be used to fit a mixed effects logistic regression model. However, you have plenty of other options available for this task via packages such as the ones listed below, whose use is illustrated for your model 4.
GLMMadaptive
install.packages("GLMMadaptive")
library(GLMMadaptive)
model4 <- mixed_model(fixed = y ~ x, random = ~ 1 | group,
data = data,
family = binomial(link="logit"))
See https://cran.r-project.org/web/packages/GLMMadaptive/vignettes/GLMMadaptive_basics.html.
glmmTMB
install.packages("glmmTMB")
library(glmmTMB)
model4 <- glmmTMB(y ~ x + (1 | group),
data = data,
family = binomial(link = "logit"))
See https://cran.r-project.org/web/packages/sjPlot/vignettes/tab_mixed.html.
MASS
install.packages("MASS")
library(MASS)
model4 <- glmmPQL(fixed = y ~ x,
random = ~ 1 | group,
data = data,
family = binomial(link="logit"))
See https://quantdev.ssri.psu.edu/sites/qdev/files/ILD_Ch04_2017_GeneralizedMLM.html.
brms
install.packages("brms")
library(brms)
model4 <- brm(y ~ x + (1|group),
data = data,
family=binomial(link="logit"))
See https://bayesat.github.io/lund2018/slides/andrey_anikin_slides.pdf and What would be a Bayesian equivalent of this mixed-effects logistic regression model, for example.
The brms package fits mixed effects models using a Bayesian framework; the other packages suggested here fit mixed effects models using a frequentist framework.
|
R: How to fit a GLMM in nlme
|
I don't think nlme can be used to fit a mixed effects logistic regression model. However, you have plenty of other options available for this task via packages such as the ones listed below, whose use
|
R: How to fit a GLMM in nlme
I don't think nlme can be used to fit a mixed effects logistic regression model. However, you have plenty of other options available for this task via packages such as the ones listed below, whose use is illustrated for your model 4.
GLMMadaptive
install.packages("GLMMadaptive")
library(GLMMadaptive)
model4 <- mixed_model(fixed = y ~ x, random = ~ 1 | group,
data = data,
family = binomial(link="logit"))
See https://cran.r-project.org/web/packages/GLMMadaptive/vignettes/GLMMadaptive_basics.html.
glmmTMB
install.packages("glmmTMB")
library(glmmTMB)
model4 <- glmmTMB(y ~ x + (1 | group),
data = data,
family = binomial(link = "logit"))
See https://cran.r-project.org/web/packages/sjPlot/vignettes/tab_mixed.html.
MASS
install.packages("MASS")
library(MASS)
model4 <- glmmPQL(fixed = y ~ x,
random = ~ 1 | group,
data = data,
family = binomial(link="logit"))
See https://quantdev.ssri.psu.edu/sites/qdev/files/ILD_Ch04_2017_GeneralizedMLM.html.
brms
install.packages("brms")
library(brms)
model4 <- brm(y ~ x + (1|group),
data = data,
family=binomial(link="logit"))
See https://bayesat.github.io/lund2018/slides/andrey_anikin_slides.pdf and What would be a Bayesian equivalent of this mixed-effects logistic regression model, for example.
The brms package fits mixed effects models using a Bayesian framework; the other packages suggested here fit mixed effects models using a frequentist framework.
|
R: How to fit a GLMM in nlme
I don't think nlme can be used to fit a mixed effects logistic regression model. However, you have plenty of other options available for this task via packages such as the ones listed below, whose use
|
45,246
|
DAGs and all models are wrong motto, what's the implication?
|
I believe the language you are looking for is sensitivity analysis. Sensitivity analysis is the examination of the causal assumptions you made to identify your effect. Sensitivity analysis has been explored quite a bit over many years in the literature, going back quite a ways1. To answer your question, however, yes, you can put bounds on the causal effect, but the usefulness of those bounds may be very limited.
To provide an example I just want to reframe your question regarding the existence of multiple DAGs. Instead, I would look at it as a problem that some unobserved variable could exist that would break the backdoor path criterion in the DAG you have developed.
A simple example is that you have a direct path from treatment to outcome, $X \rightarrow Y$, and a confounder that affects both, $Z$. The concern would be that another, unobserved confounder, $W$, exists that would bias your results.
We know that for the confounder to bias our estimate it consists of two things: the imbalance between treated and control and the magnitude of the confounding relationship. Therefore, if we assume some level of imbalance and use prior knowledge to estimate bounds on the magnitude and it's the direction, we could estimate the bias induced by an unobserved confounder.
The first article I cite below is used as an example of sensitivity analysis. If you want to get into this more check out the second citation. In the introduction the cite several prior articles. Also, the methodology is really interesting.
Cornfield, J., Haenszel, W., Hammond, E. C., Lilienfeld, A. M., Shimkin, M. B., & Wynder, E. L. (1959). Smoking and lung cancer: recent evidence and a discussion of some questions. Journal of the National Cancer Institute, 22(1), 173-203.
Cinelli, C., & Hazlett, C. (2020). Making Sense of Sensitivity: Extending Omitted Variable Bias. Journal of the Royal Statistical Society, Series B (Statistical Methodology).
|
DAGs and all models are wrong motto, what's the implication?
|
I believe the language you are looking for is sensitivity analysis. Sensitivity analysis is the examination of the causal assumptions you made to identify your effect. Sensitivity analysis has been ex
|
DAGs and all models are wrong motto, what's the implication?
I believe the language you are looking for is sensitivity analysis. Sensitivity analysis is the examination of the causal assumptions you made to identify your effect. Sensitivity analysis has been explored quite a bit over many years in the literature, going back quite a ways1. To answer your question, however, yes, you can put bounds on the causal effect, but the usefulness of those bounds may be very limited.
To provide an example I just want to reframe your question regarding the existence of multiple DAGs. Instead, I would look at it as a problem that some unobserved variable could exist that would break the backdoor path criterion in the DAG you have developed.
A simple example is that you have a direct path from treatment to outcome, $X \rightarrow Y$, and a confounder that affects both, $Z$. The concern would be that another, unobserved confounder, $W$, exists that would bias your results.
We know that for the confounder to bias our estimate it consists of two things: the imbalance between treated and control and the magnitude of the confounding relationship. Therefore, if we assume some level of imbalance and use prior knowledge to estimate bounds on the magnitude and it's the direction, we could estimate the bias induced by an unobserved confounder.
The first article I cite below is used as an example of sensitivity analysis. If you want to get into this more check out the second citation. In the introduction the cite several prior articles. Also, the methodology is really interesting.
Cornfield, J., Haenszel, W., Hammond, E. C., Lilienfeld, A. M., Shimkin, M. B., & Wynder, E. L. (1959). Smoking and lung cancer: recent evidence and a discussion of some questions. Journal of the National Cancer Institute, 22(1), 173-203.
Cinelli, C., & Hazlett, C. (2020). Making Sense of Sensitivity: Extending Omitted Variable Bias. Journal of the Royal Statistical Society, Series B (Statistical Methodology).
|
DAGs and all models are wrong motto, what's the implication?
I believe the language you are looking for is sensitivity analysis. Sensitivity analysis is the examination of the causal assumptions you made to identify your effect. Sensitivity analysis has been ex
|
45,247
|
DAGs and all models are wrong motto, what's the implication?
|
To complement Landon's answer, let me elaborate a bit further.
Causal inference always requires untestable assumptions, the usual ones are absence of direct effects among variables (exclusion restrictions) or absence of unobserved common causes among variables (independence restrictions). For now, let us focus on the violation of these two, but, of course, there are other built-in assumptions as well, such as no selection bias, correctly measured variables, no interference between units and so on.
So the first thing I would point out is that DAGs, as models, have no special status under the "all models are wrong" motto---if you don't write down the implied DAG of your model, your model will still be "wrong" (or, better, "not useful"). Wherr DAGs can really help is to make it easier for you (and your peers) to see where your model could be wrong, and to better pin down where the sources of disagreements are. Then you can assess whether your conclusions are sensitive to that disagreement.
To perform this task, we need tools to derive sensitivity curves of the target quantity of interest in our causal models. Regarding linear structural models, we have just started developing algorithms for making this type of sensitivity analysis automatic and systematic. For instance, take the following example:
Suppose you posit model $G_O$ and obtain that the causal effect of $X$ on $Y$ is identified (and given by the regression coefficient adjusting for $Z$). Now someone challenges you and say that your assumption of no unobserved confounders between $Z$ and $X$ is unreasonable, which leads to the alternative model model $G_A$. In $G_A$, however, the causal effect is not identifiable anymore. So what can you do? Here is where sensitivity analysis comes in.
Instead of point identifying the causal effect, you are going to express the causal effect as a function of other unidentifiable parameters of the model---such as the strength of the unobserved confounders. Then you can see how sensitive your conclusions are to different strengths of that parameter, and resort to outside knowledge and scientific plausibility judgments on those parameters to bound the causal effect of interest.
So the first task we need to solve is to decide whether information on some parameters, say, the strength of confounding between $X$ and $Z$, is sufficient for the identification of the quantity of interest and to find the correct estimand. Once you do that, you can use it to see how sensitivity your estimate is to violations of the zero confounding assumption.
So, back to the example, in $G_A$, can you use that information to bound the causal effect of $X$ on $Y$? The answer here is yes, and we can algorithmically derive the sensitivity curve (if the model were $G_B$, the answer would be no). But suppose you don't have direct external information about the confounders themselves, but you do have some prior studies that give plausible bounds on the causal effect of $Z$ on $X$. Can we use that information for the sensitivity analysis of $X$ and $Y$ instead? Here the answer is also yes. In this way we are building tools to have a disciplined discussion about violations of assumptions on arbitrary causal models (as represented by DAGs).
|
DAGs and all models are wrong motto, what's the implication?
|
To complement Landon's answer, let me elaborate a bit further.
Causal inference always requires untestable assumptions, the usual ones are absence of direct effects among variables (exclusion restrict
|
DAGs and all models are wrong motto, what's the implication?
To complement Landon's answer, let me elaborate a bit further.
Causal inference always requires untestable assumptions, the usual ones are absence of direct effects among variables (exclusion restrictions) or absence of unobserved common causes among variables (independence restrictions). For now, let us focus on the violation of these two, but, of course, there are other built-in assumptions as well, such as no selection bias, correctly measured variables, no interference between units and so on.
So the first thing I would point out is that DAGs, as models, have no special status under the "all models are wrong" motto---if you don't write down the implied DAG of your model, your model will still be "wrong" (or, better, "not useful"). Wherr DAGs can really help is to make it easier for you (and your peers) to see where your model could be wrong, and to better pin down where the sources of disagreements are. Then you can assess whether your conclusions are sensitive to that disagreement.
To perform this task, we need tools to derive sensitivity curves of the target quantity of interest in our causal models. Regarding linear structural models, we have just started developing algorithms for making this type of sensitivity analysis automatic and systematic. For instance, take the following example:
Suppose you posit model $G_O$ and obtain that the causal effect of $X$ on $Y$ is identified (and given by the regression coefficient adjusting for $Z$). Now someone challenges you and say that your assumption of no unobserved confounders between $Z$ and $X$ is unreasonable, which leads to the alternative model model $G_A$. In $G_A$, however, the causal effect is not identifiable anymore. So what can you do? Here is where sensitivity analysis comes in.
Instead of point identifying the causal effect, you are going to express the causal effect as a function of other unidentifiable parameters of the model---such as the strength of the unobserved confounders. Then you can see how sensitive your conclusions are to different strengths of that parameter, and resort to outside knowledge and scientific plausibility judgments on those parameters to bound the causal effect of interest.
So the first task we need to solve is to decide whether information on some parameters, say, the strength of confounding between $X$ and $Z$, is sufficient for the identification of the quantity of interest and to find the correct estimand. Once you do that, you can use it to see how sensitivity your estimate is to violations of the zero confounding assumption.
So, back to the example, in $G_A$, can you use that information to bound the causal effect of $X$ on $Y$? The answer here is yes, and we can algorithmically derive the sensitivity curve (if the model were $G_B$, the answer would be no). But suppose you don't have direct external information about the confounders themselves, but you do have some prior studies that give plausible bounds on the causal effect of $Z$ on $X$. Can we use that information for the sensitivity analysis of $X$ and $Y$ instead? Here the answer is also yes. In this way we are building tools to have a disciplined discussion about violations of assumptions on arbitrary causal models (as represented by DAGs).
|
DAGs and all models are wrong motto, what's the implication?
To complement Landon's answer, let me elaborate a bit further.
Causal inference always requires untestable assumptions, the usual ones are absence of direct effects among variables (exclusion restrict
|
45,248
|
Am I allowed to average the list of precision and recall after k-fold cross validation?
|
First of all, when you do 5-fold cross validation, you don't have one model, you have five. So it's not really correct to talk about the precision/recall of the "whole model" since there isn't just one. Rather, you're getting an estimate of the precision/recall from your model-building process.
That said, each fold is a model with its own precision and recall, and you can average them to get a mean performance metric over all your folds. One thing to note, though, that since recall is the proportion of true positives out of all positives, you'll have to weight each fold by the number of positives.
Imagine a case where you have 4 folds that each have only one positive, which is correctly identified, giving you 100% recall on those folds. The fifth fold has 96 positives, 46 of which are correctly identified, for 48% recall . A straight mean would give you a recall of 90%, but if you account for the greater number of positives in the fifth fold, your overall recall rate is only 50% (50 of 100 positives identified). If your folds are well-stratified, this problem would fix itself for recall, but for precision, which depends on the number of predicted positives in each fold, I don't see any way to stratify before doing prediction (you'd have to know the prediction output before defining the folds and training the model). I would implement the weighted average method, as it will work for any metric you choose to compute, and will work in cases where perfectly equal stratification isn't possible (when N isn't evenly divisble by K).
Another approach suggested in the comments, which would be equivalent to weighted averages of summary metrics, is to sum the prediction confusion matrices from each fold and compute summary statistics from the combined matrix. By summing the TP, TN, FP, and FN from all folds and then computing precision/recall, you are implicitly accounting for any differences in prevalence of positive cases or positive predictions across folds.
|
Am I allowed to average the list of precision and recall after k-fold cross validation?
|
First of all, when you do 5-fold cross validation, you don't have one model, you have five. So it's not really correct to talk about the precision/recall of the "whole model" since there isn't just on
|
Am I allowed to average the list of precision and recall after k-fold cross validation?
First of all, when you do 5-fold cross validation, you don't have one model, you have five. So it's not really correct to talk about the precision/recall of the "whole model" since there isn't just one. Rather, you're getting an estimate of the precision/recall from your model-building process.
That said, each fold is a model with its own precision and recall, and you can average them to get a mean performance metric over all your folds. One thing to note, though, that since recall is the proportion of true positives out of all positives, you'll have to weight each fold by the number of positives.
Imagine a case where you have 4 folds that each have only one positive, which is correctly identified, giving you 100% recall on those folds. The fifth fold has 96 positives, 46 of which are correctly identified, for 48% recall . A straight mean would give you a recall of 90%, but if you account for the greater number of positives in the fifth fold, your overall recall rate is only 50% (50 of 100 positives identified). If your folds are well-stratified, this problem would fix itself for recall, but for precision, which depends on the number of predicted positives in each fold, I don't see any way to stratify before doing prediction (you'd have to know the prediction output before defining the folds and training the model). I would implement the weighted average method, as it will work for any metric you choose to compute, and will work in cases where perfectly equal stratification isn't possible (when N isn't evenly divisble by K).
Another approach suggested in the comments, which would be equivalent to weighted averages of summary metrics, is to sum the prediction confusion matrices from each fold and compute summary statistics from the combined matrix. By summing the TP, TN, FP, and FN from all folds and then computing precision/recall, you are implicitly accounting for any differences in prevalence of positive cases or positive predictions across folds.
|
Am I allowed to average the list of precision and recall after k-fold cross validation?
First of all, when you do 5-fold cross validation, you don't have one model, you have five. So it's not really correct to talk about the precision/recall of the "whole model" since there isn't just on
|
45,249
|
Unbiased Estimator for $\log\left[\int p(x\mid z)p(z) \, dz\right]$
|
It can be shown that by using sufficiently large sample sizes for the MC approximation, a lower bound to the marginal log-likelihood is tightened. While this estimator is hence biased, in can serve the same practical purposes. It was shown in [1] that
$$
\log p(x) \ge \mathcal{L}_{K+1} \ge \mathcal{L}_{K}
$$
for $\mathcal{L}_K = \mathbb E_{z_1, \ldots, z_K \sim q^K} \left[\log \frac{1}{K} \sum_{k=1}^K \frac{p(x, z_k)}{q(z_k)}\right]$, where $q^K \equiv \underbrace{q \otimes q \otimes \cdots \otimes q}_{K times}$.
This also holds for $q(z) = p(z)$.
[1] Burda, Yuri, Roger Grosse, and Ruslan Salakhutdinov. "Importance weighted autoencoders." arXiv preprint arXiv:1509.00519 (2015).
|
Unbiased Estimator for $\log\left[\int p(x\mid z)p(z) \, dz\right]$
|
It can be shown that by using sufficiently large sample sizes for the MC approximation, a lower bound to the marginal log-likelihood is tightened. While this estimator is hence biased, in can serve th
|
Unbiased Estimator for $\log\left[\int p(x\mid z)p(z) \, dz\right]$
It can be shown that by using sufficiently large sample sizes for the MC approximation, a lower bound to the marginal log-likelihood is tightened. While this estimator is hence biased, in can serve the same practical purposes. It was shown in [1] that
$$
\log p(x) \ge \mathcal{L}_{K+1} \ge \mathcal{L}_{K}
$$
for $\mathcal{L}_K = \mathbb E_{z_1, \ldots, z_K \sim q^K} \left[\log \frac{1}{K} \sum_{k=1}^K \frac{p(x, z_k)}{q(z_k)}\right]$, where $q^K \equiv \underbrace{q \otimes q \otimes \cdots \otimes q}_{K times}$.
This also holds for $q(z) = p(z)$.
[1] Burda, Yuri, Roger Grosse, and Ruslan Salakhutdinov. "Importance weighted autoencoders." arXiv preprint arXiv:1509.00519 (2015).
|
Unbiased Estimator for $\log\left[\int p(x\mid z)p(z) \, dz\right]$
It can be shown that by using sufficiently large sample sizes for the MC approximation, a lower bound to the marginal log-likelihood is tightened. While this estimator is hence biased, in can serve th
|
45,250
|
Unbiased Estimator for $\log\left[\int p(x\mid z)p(z) \, dz\right]$
|
Path sampling is a way to evaluate the log integral by an unbiased estimator. Let us introduce a temperature index $0\le t\le 1$ and a sequence of conditional functions $p_t(x|z)$ such that
$$p_0(x|z)=1\qquad\qquad\text{and}\qquad\qquad p_1(x|z)=p(x|z)$$
Then, if $$\mathfrak{Z}_t(x)=\int p_t(x|z)\,q(z)\text{d}z$$
\begin{align*}\frac{\text{d}}{\text{d}t} \log(\mathfrak{Z}_t(x))
&= \frac{1}{\mathfrak{Z}_t(x)}\frac{\text{d}}{\text{d}t}\mathfrak{Z}_t(x)\\
&=\frac{1}{\mathfrak{Z}_t(x)}\int\frac{\text{d}}{\text{d}t}p_t(x|z)\,q(z)\text{d}z\\
&=\frac{1}{\mathfrak{Z}_t(x)}\int\frac{\text{d}}{\text{d}t}p_t(x|z)\,q(z)\text{d}z\\
&=\frac{1}{\mathfrak{Z}_t(x)}\int\frac{\text{d}}{\text{d}t}\log(p_t(x|z))\,p_t(x|z)q(z)\text{d}z\\
&=\mathbb{E}\left[\left.\frac{\text{d}}{\text{d}t}\log(p_t(x|Z))\right| X=x\right]\end{align*}
Therefore, since
$$\log(\mathfrak{Z}_1(x)/\mathfrak{Z}_0(x)) = \int_0^1 \frac{\text{d}}{\text{d}t} \log(\mathfrak{Z}_t(x))\,\text{d}t$$
and $\mathfrak{Z}_0(x)=1$, a remarkable identity is that
$$\log(\mathfrak{Z}_1(x))=\log\left\{\int p(x|z) q(z)\text{d}z\right\}=\int_0^1 \mathbb{E}\left[\left.\frac{\text{d}}{\text{d}t}\log(p_t(x|Z))\right| X=x\right]\,\text{d}t$$
Hence, assuming simulations $z_i=\zeta(x,t,\epsilon_i)$ ($i=1,\ldots,I$) from $$q(z|x)=\frac{q(z) p(x|z)}{\mathfrak{Z}_1(x))}$$ are available (e.g. by MCMC), an unbiased estimator of $\log(\mathfrak{Z}_1(x))$ is
$$\int_0^1 \frac{1}{I}\sum_{i=1}^I\frac{\text{d}}{\text{d}t}\log(p_t(x|\zeta(x,t,\epsilon_i)))\,\text{d}t$$
|
Unbiased Estimator for $\log\left[\int p(x\mid z)p(z) \, dz\right]$
|
Path sampling is a way to evaluate the log integral by an unbiased estimator. Let us introduce a temperature index $0\le t\le 1$ and a sequence of conditional functions $p_t(x|z)$ such that
$$p_0(x|z)
|
Unbiased Estimator for $\log\left[\int p(x\mid z)p(z) \, dz\right]$
Path sampling is a way to evaluate the log integral by an unbiased estimator. Let us introduce a temperature index $0\le t\le 1$ and a sequence of conditional functions $p_t(x|z)$ such that
$$p_0(x|z)=1\qquad\qquad\text{and}\qquad\qquad p_1(x|z)=p(x|z)$$
Then, if $$\mathfrak{Z}_t(x)=\int p_t(x|z)\,q(z)\text{d}z$$
\begin{align*}\frac{\text{d}}{\text{d}t} \log(\mathfrak{Z}_t(x))
&= \frac{1}{\mathfrak{Z}_t(x)}\frac{\text{d}}{\text{d}t}\mathfrak{Z}_t(x)\\
&=\frac{1}{\mathfrak{Z}_t(x)}\int\frac{\text{d}}{\text{d}t}p_t(x|z)\,q(z)\text{d}z\\
&=\frac{1}{\mathfrak{Z}_t(x)}\int\frac{\text{d}}{\text{d}t}p_t(x|z)\,q(z)\text{d}z\\
&=\frac{1}{\mathfrak{Z}_t(x)}\int\frac{\text{d}}{\text{d}t}\log(p_t(x|z))\,p_t(x|z)q(z)\text{d}z\\
&=\mathbb{E}\left[\left.\frac{\text{d}}{\text{d}t}\log(p_t(x|Z))\right| X=x\right]\end{align*}
Therefore, since
$$\log(\mathfrak{Z}_1(x)/\mathfrak{Z}_0(x)) = \int_0^1 \frac{\text{d}}{\text{d}t} \log(\mathfrak{Z}_t(x))\,\text{d}t$$
and $\mathfrak{Z}_0(x)=1$, a remarkable identity is that
$$\log(\mathfrak{Z}_1(x))=\log\left\{\int p(x|z) q(z)\text{d}z\right\}=\int_0^1 \mathbb{E}\left[\left.\frac{\text{d}}{\text{d}t}\log(p_t(x|Z))\right| X=x\right]\,\text{d}t$$
Hence, assuming simulations $z_i=\zeta(x,t,\epsilon_i)$ ($i=1,\ldots,I$) from $$q(z|x)=\frac{q(z) p(x|z)}{\mathfrak{Z}_1(x))}$$ are available (e.g. by MCMC), an unbiased estimator of $\log(\mathfrak{Z}_1(x))$ is
$$\int_0^1 \frac{1}{I}\sum_{i=1}^I\frac{\text{d}}{\text{d}t}\log(p_t(x|\zeta(x,t,\epsilon_i)))\,\text{d}t$$
|
Unbiased Estimator for $\log\left[\int p(x\mid z)p(z) \, dz\right]$
Path sampling is a way to evaluate the log integral by an unbiased estimator. Let us introduce a temperature index $0\le t\le 1$ and a sequence of conditional functions $p_t(x|z)$ such that
$$p_0(x|z)
|
45,251
|
Unbiased Estimator for $\log\left[\int p(x\mid z)p(z) \, dz\right]$
|
The Monte Carlo estimator using $n$ samples of
$$l = \int p(x \mid z) g(z) dz = E(p(x \mid Z))$$
with $Z\sim g$ is
$$\hat l_n = \frac 1n \sum_{i = 1}p(x\mid Z_i) \qquad Z_i\sim g$$
Following Durbin and Koopman
(1997), the error of the log
marginal likelihood is given by
$$\begin{align*}
\log\hat l_n - \log l
&= \log\left(1 + \frac{\hat l_n - l}{l}\right) \\
&= \frac{\hat l_n - l}{l}
- \frac 12\left(\frac{\hat l_n - l}{l}\right)^2 +
O\left(\left(\frac{\hat l_n - l}{l}\right)^3\right)
\end{align*}$$
implying that the bias is
$$
E(\log\hat l_n) = \log l
- \frac 12\frac{E\left((\hat l_n - l)^2\right)}{l^2} +
O\left(\frac{E\left((\hat l_n - l)^3\right)}{l^3}\right)
$$
Thus, the bias is approximately proportional to the variance
of the estimated log-likelihood using the delta method and
that $E(\hat l_n) =l$.
The bias corrected version from Durbin and Koopman (1997) is
therefor
$$
\log\hat l_n + \frac 12 \frac{\widehat{\text{Var}}(\hat l_n)}{\hat l_n^2}
$$
where $\widehat{\text{Var}}$ is the estimated variance. That is,
$$\widehat{\text{Var}}(\hat l_n) = \frac 1{n(n -1)} \sum_{i = 1}^n\left(p(x\mid Z_i) - \hat l_n\right)^2.$$
The adjusted estimator is convenient as we already have all the quantities we need from the standard Monte Carlo estimator.
The above can also be
extended to importance sampling. Pick an importance distribution with density $h$ with the same support as $g$. Then replace $p(x\mid Z_i)$ in $\hat l_n$ (and the variance estimate) with
$$
\frac{p(x\mid Z_i)g(Z_i)}{h(Z_i)}
$$
and sample $Z_i\sim h$.
Example
Take $g(z) = \phi(z)$ where $\phi$ is the standard normal
distribution's density function and
$$
p(x\mid z) = \Phi(0.5 + z)\Phi(-0.25 - z)
$$
where $\Phi$ is the standard normal distribution's cumulative density function. In this case $l$ is the bivariate normal CDF integrated up to 0.5 and -0.25 with covariance matrix
$$\begin{pmatrix} 2 & -1 \\ -1 & 2 \end{pmatrix}$$
which can be computed to floating point precision which makes this example nice.
A small simulation study investigating the bias of the adjusted and unadjusted Monte Carlo estimator as a function of the sample size is run below.
# the true value of l
truth <- mvtnorm::pmvnorm(
upper = c(.5, -.25), sigma = matrix(c(2, -1, -1, 2), 2))
n_reps <- 100000L # the number of replications
# the sample sizes
n_samples <- seq(log(10), log(1000), length.out = 40) |> exp() |> floor()
# compute the estimates
set.seed(1)
ests <- sapply(n_samples, \(n_samp){
smps <- matrix(rnorm(n_samp * n_reps), n_samp)
weight <- pnorm(.5 + smps) * pnorm(-0.25 - smps)
rbind(Estimate = colMeans(weight), Var = apply(weight, 2L, var) / n_samp)
}, simplify = "array")
# compute the bias estimates
err_unadjusted <- log(ests["Estimate", , ]) - log(truth)
bias_ests_unadjusted <- colMeans(err_unadjusted)
err_adjusted <-
log(ests["Estimate", , ]) + ests["Var", , ] / (2 * ests["Estimate", , ]^2) -
log(truth)
bias_ests_adjusted <- colMeans(err_adjusted)
# plot the bias estimates versus the sample size
ylim <- range(bias_ests_unadjusted, bias_ests_adjusted)
par(mar = c(5, 5, 1, 1))
plot(n_samples, bias_ests_unadjusted, pch = 16, bty = "l", ylim = ylim,
ylab = "Bias estimate (unadjusted)", xlab = "Sample size", log = "x")
abline(h = 0, lty = 2)
plot(n_samples, bias_ests_adjusted, pch = 16, bty = "l", ylim = ylim,
ylab = "Bias estimate (adjusted)", xlab = "Sample size", log = "x")
abline(h = 0, lty = 2)
The plots show that the adjusted estimator seems to be unbiased but the standard Monte Carlo estimator is downward biased consistent with the answer by bayerj. However, the bias of the latter gets smaller as the number of samples is increased also consistent with the answer by bayerj.
A side note, the plot above shows that the variance of the log-likelihood estimator is about $2 \cdot 0.012$ in the worst case when we use $n = 10$ samples. Thus,
the standard error of the estimator is $\sqrt{2 \cdot 0.012} = 0.125$. Hence, a bias of $0.012$ may not be the main concern.
|
Unbiased Estimator for $\log\left[\int p(x\mid z)p(z) \, dz\right]$
|
The Monte Carlo estimator using $n$ samples of
$$l = \int p(x \mid z) g(z) dz = E(p(x \mid Z))$$
with $Z\sim g$ is
$$\hat l_n = \frac 1n \sum_{i = 1}p(x\mid Z_i) \qquad Z_i\sim g$$
Following Durbin an
|
Unbiased Estimator for $\log\left[\int p(x\mid z)p(z) \, dz\right]$
The Monte Carlo estimator using $n$ samples of
$$l = \int p(x \mid z) g(z) dz = E(p(x \mid Z))$$
with $Z\sim g$ is
$$\hat l_n = \frac 1n \sum_{i = 1}p(x\mid Z_i) \qquad Z_i\sim g$$
Following Durbin and Koopman
(1997), the error of the log
marginal likelihood is given by
$$\begin{align*}
\log\hat l_n - \log l
&= \log\left(1 + \frac{\hat l_n - l}{l}\right) \\
&= \frac{\hat l_n - l}{l}
- \frac 12\left(\frac{\hat l_n - l}{l}\right)^2 +
O\left(\left(\frac{\hat l_n - l}{l}\right)^3\right)
\end{align*}$$
implying that the bias is
$$
E(\log\hat l_n) = \log l
- \frac 12\frac{E\left((\hat l_n - l)^2\right)}{l^2} +
O\left(\frac{E\left((\hat l_n - l)^3\right)}{l^3}\right)
$$
Thus, the bias is approximately proportional to the variance
of the estimated log-likelihood using the delta method and
that $E(\hat l_n) =l$.
The bias corrected version from Durbin and Koopman (1997) is
therefor
$$
\log\hat l_n + \frac 12 \frac{\widehat{\text{Var}}(\hat l_n)}{\hat l_n^2}
$$
where $\widehat{\text{Var}}$ is the estimated variance. That is,
$$\widehat{\text{Var}}(\hat l_n) = \frac 1{n(n -1)} \sum_{i = 1}^n\left(p(x\mid Z_i) - \hat l_n\right)^2.$$
The adjusted estimator is convenient as we already have all the quantities we need from the standard Monte Carlo estimator.
The above can also be
extended to importance sampling. Pick an importance distribution with density $h$ with the same support as $g$. Then replace $p(x\mid Z_i)$ in $\hat l_n$ (and the variance estimate) with
$$
\frac{p(x\mid Z_i)g(Z_i)}{h(Z_i)}
$$
and sample $Z_i\sim h$.
Example
Take $g(z) = \phi(z)$ where $\phi$ is the standard normal
distribution's density function and
$$
p(x\mid z) = \Phi(0.5 + z)\Phi(-0.25 - z)
$$
where $\Phi$ is the standard normal distribution's cumulative density function. In this case $l$ is the bivariate normal CDF integrated up to 0.5 and -0.25 with covariance matrix
$$\begin{pmatrix} 2 & -1 \\ -1 & 2 \end{pmatrix}$$
which can be computed to floating point precision which makes this example nice.
A small simulation study investigating the bias of the adjusted and unadjusted Monte Carlo estimator as a function of the sample size is run below.
# the true value of l
truth <- mvtnorm::pmvnorm(
upper = c(.5, -.25), sigma = matrix(c(2, -1, -1, 2), 2))
n_reps <- 100000L # the number of replications
# the sample sizes
n_samples <- seq(log(10), log(1000), length.out = 40) |> exp() |> floor()
# compute the estimates
set.seed(1)
ests <- sapply(n_samples, \(n_samp){
smps <- matrix(rnorm(n_samp * n_reps), n_samp)
weight <- pnorm(.5 + smps) * pnorm(-0.25 - smps)
rbind(Estimate = colMeans(weight), Var = apply(weight, 2L, var) / n_samp)
}, simplify = "array")
# compute the bias estimates
err_unadjusted <- log(ests["Estimate", , ]) - log(truth)
bias_ests_unadjusted <- colMeans(err_unadjusted)
err_adjusted <-
log(ests["Estimate", , ]) + ests["Var", , ] / (2 * ests["Estimate", , ]^2) -
log(truth)
bias_ests_adjusted <- colMeans(err_adjusted)
# plot the bias estimates versus the sample size
ylim <- range(bias_ests_unadjusted, bias_ests_adjusted)
par(mar = c(5, 5, 1, 1))
plot(n_samples, bias_ests_unadjusted, pch = 16, bty = "l", ylim = ylim,
ylab = "Bias estimate (unadjusted)", xlab = "Sample size", log = "x")
abline(h = 0, lty = 2)
plot(n_samples, bias_ests_adjusted, pch = 16, bty = "l", ylim = ylim,
ylab = "Bias estimate (adjusted)", xlab = "Sample size", log = "x")
abline(h = 0, lty = 2)
The plots show that the adjusted estimator seems to be unbiased but the standard Monte Carlo estimator is downward biased consistent with the answer by bayerj. However, the bias of the latter gets smaller as the number of samples is increased also consistent with the answer by bayerj.
A side note, the plot above shows that the variance of the log-likelihood estimator is about $2 \cdot 0.012$ in the worst case when we use $n = 10$ samples. Thus,
the standard error of the estimator is $\sqrt{2 \cdot 0.012} = 0.125$. Hence, a bias of $0.012$ may not be the main concern.
|
Unbiased Estimator for $\log\left[\int p(x\mid z)p(z) \, dz\right]$
The Monte Carlo estimator using $n$ samples of
$$l = \int p(x \mid z) g(z) dz = E(p(x \mid Z))$$
with $Z\sim g$ is
$$\hat l_n = \frac 1n \sum_{i = 1}p(x\mid Z_i) \qquad Z_i\sim g$$
Following Durbin an
|
45,252
|
Regression when both the predictor and outcome variables are proportions
|
A glm with a binomial distribution and a logit link should work fine. If there are no probabilities of $0$ or $1$, beta regression is another possibility. In this case, they yield almost indistinguishable results (not shown).
The relationship between the logit of the actual and the logit of the estimated probabilities looks quite linear (see picture below), which would lead me to use the logit of the estimated probabilities as predictor. The R code using to generate the plots is at the bottom of this answer.
Let's visualize the model on the original scale (the points are partial residuals):
Possible extensions include:
Using robust standard errors (see R code below). Stata's fracreg command uses them by default.
Using a quasi-likelihood (by using quasibinomial as family in glm)
R code:
library(betareg)
library(visreg)
library(lmtest)
library(sandwich)
# Convert probabilities to log-odds
est_p_logit <- log(est_prob/(1 - est_prob))
act_p_logit <- log(act_prob/(1 - act_prob))
# Check linearity
scatter.smooth(act_p_logit~est_p_logit, las = 1)
# GLM with binomial distribution and logit-link
mod <- glm(act_prob~est_p_logit, family = binomial)
summary(mod)
# Robust standard errors
coeftest(mod, vcov = vcovHC, type = "HC3")
# Visualize GLM model
res_glm <- visreg(mod, scale = "response", ylim = c(0, 1), partial = TRUE, rug = 2)
# Beta regression
mod_beta <- betareg(act_prob~est_p_logit)
# Compare GLM results with beta regression
res_beta <- visreg(mod_beta, scale = "response", ylim = c(0, 1))
lines(res_beta$fit$visregFit~res_beta$fit$est_p_logit, type = "l", col = "red")
|
Regression when both the predictor and outcome variables are proportions
|
A glm with a binomial distribution and a logit link should work fine. If there are no probabilities of $0$ or $1$, beta regression is another possibility. In this case, they yield almost indistinguish
|
Regression when both the predictor and outcome variables are proportions
A glm with a binomial distribution and a logit link should work fine. If there are no probabilities of $0$ or $1$, beta regression is another possibility. In this case, they yield almost indistinguishable results (not shown).
The relationship between the logit of the actual and the logit of the estimated probabilities looks quite linear (see picture below), which would lead me to use the logit of the estimated probabilities as predictor. The R code using to generate the plots is at the bottom of this answer.
Let's visualize the model on the original scale (the points are partial residuals):
Possible extensions include:
Using robust standard errors (see R code below). Stata's fracreg command uses them by default.
Using a quasi-likelihood (by using quasibinomial as family in glm)
R code:
library(betareg)
library(visreg)
library(lmtest)
library(sandwich)
# Convert probabilities to log-odds
est_p_logit <- log(est_prob/(1 - est_prob))
act_p_logit <- log(act_prob/(1 - act_prob))
# Check linearity
scatter.smooth(act_p_logit~est_p_logit, las = 1)
# GLM with binomial distribution and logit-link
mod <- glm(act_prob~est_p_logit, family = binomial)
summary(mod)
# Robust standard errors
coeftest(mod, vcov = vcovHC, type = "HC3")
# Visualize GLM model
res_glm <- visreg(mod, scale = "response", ylim = c(0, 1), partial = TRUE, rug = 2)
# Beta regression
mod_beta <- betareg(act_prob~est_p_logit)
# Compare GLM results with beta regression
res_beta <- visreg(mod_beta, scale = "response", ylim = c(0, 1))
lines(res_beta$fit$visregFit~res_beta$fit$est_p_logit, type = "l", col = "red")
|
Regression when both the predictor and outcome variables are proportions
A glm with a binomial distribution and a logit link should work fine. If there are no probabilities of $0$ or $1$, beta regression is another possibility. In this case, they yield almost indistinguish
|
45,253
|
Regression when both the predictor and outcome variables are proportions
|
Differently from the other answer here which I think is a good answer, I think a linear regression suffices in your exact situation. As a matter of principle, it might be wrong because of the hard bounds on the outcome but a plot of your data suggests why it is a good enough approximation. At both extremes, the mean of your data is far enough from the extremes of the outcome, hence, there is no bending or curving of the relationship to respect the bounds on the original outcome. In short, your predictions appear to be linearly related to the outcome, the major requirement for linear regression.
If the above is true, the advantages of the linear model are then:
ease of interpretation, the coefficients you posted make sense on arrival
one can obtain a relatively simple measure of variability around the fitted line from the regression standard deviation if one cares.
I began by exploring the data:
dat <- read.csv("Estimated probability of winning vs Actual proportion of score - Sheet1.csv")
names(dat) <- c("x", "y")
ggplot(dat, aes(x, y)) + geom_point(shape = 1) + theme_bw() +
geom_smooth() + geom_smooth(method = "lm", se = FALSE, col = "red")
The blue line is a generalized additive model smoother. The red line is the linear fit. One can observe some curvature at the ends but outwards, not inwards. So your predictions are not exactly linearly related to the outcome. Since you have enough data points, this is probably not arbitrary.
A logit transformation of $y$ is unlikely to help here, rather, a logit transformation of $x$ since it bends outwards. We can shrink the middle $x$ values somewhat and expand the larger $x$ values:
ggplot(dat, aes(log(x / (1 - x)), y)) + geom_point(shape = 1) + theme_bw() +
geom_smooth() + geom_smooth(method = "lm", se = FALSE, col = "red")
And this time, the linear fit approximates the smoothed fit quite well, not so well at the tails, but good enough for most applications. And homoskedasticity is a plausible assumption.
So the regression model of choice is then:
coef(summary(fit.lm <- lm(y ~ log(x / (1 - x)), dat)))
Estimate Std. Error t value Pr(>|t|)
(Intercept) 0.50116288 0.002897402 172.96973 0.000000e+00
log(x/(1 - x)) 0.05446613 0.002045560 26.62652 6.846189e-124
When the predicted log-odds are zero, we expect the win probability to be about 50%. A log-odd higher, and expectation is 5% higher. As seen in the second plot above, the log-odds don't go any further than 5 in either direction. So all the predicted values of $y$ are bound between about 25% and 75%. The regression effect is clear enough and at a large enough sample size that I trust that the inference is not misleading overall. There are always alternatives for better precision.
We can also get a sense of the error about the fitted line.
sigma(fit.lm)
[1] 0.09958555
Given a prediction, about 95% of values should be within about $\pm20\%$. The interval when added to the minimum and maximum predicted $y$ also lies within bounds.
The justification for the linear approach is its simplicity and its adequacy in this particular application.
|
Regression when both the predictor and outcome variables are proportions
|
Differently from the other answer here which I think is a good answer, I think a linear regression suffices in your exact situation. As a matter of principle, it might be wrong because of the hard bou
|
Regression when both the predictor and outcome variables are proportions
Differently from the other answer here which I think is a good answer, I think a linear regression suffices in your exact situation. As a matter of principle, it might be wrong because of the hard bounds on the outcome but a plot of your data suggests why it is a good enough approximation. At both extremes, the mean of your data is far enough from the extremes of the outcome, hence, there is no bending or curving of the relationship to respect the bounds on the original outcome. In short, your predictions appear to be linearly related to the outcome, the major requirement for linear regression.
If the above is true, the advantages of the linear model are then:
ease of interpretation, the coefficients you posted make sense on arrival
one can obtain a relatively simple measure of variability around the fitted line from the regression standard deviation if one cares.
I began by exploring the data:
dat <- read.csv("Estimated probability of winning vs Actual proportion of score - Sheet1.csv")
names(dat) <- c("x", "y")
ggplot(dat, aes(x, y)) + geom_point(shape = 1) + theme_bw() +
geom_smooth() + geom_smooth(method = "lm", se = FALSE, col = "red")
The blue line is a generalized additive model smoother. The red line is the linear fit. One can observe some curvature at the ends but outwards, not inwards. So your predictions are not exactly linearly related to the outcome. Since you have enough data points, this is probably not arbitrary.
A logit transformation of $y$ is unlikely to help here, rather, a logit transformation of $x$ since it bends outwards. We can shrink the middle $x$ values somewhat and expand the larger $x$ values:
ggplot(dat, aes(log(x / (1 - x)), y)) + geom_point(shape = 1) + theme_bw() +
geom_smooth() + geom_smooth(method = "lm", se = FALSE, col = "red")
And this time, the linear fit approximates the smoothed fit quite well, not so well at the tails, but good enough for most applications. And homoskedasticity is a plausible assumption.
So the regression model of choice is then:
coef(summary(fit.lm <- lm(y ~ log(x / (1 - x)), dat)))
Estimate Std. Error t value Pr(>|t|)
(Intercept) 0.50116288 0.002897402 172.96973 0.000000e+00
log(x/(1 - x)) 0.05446613 0.002045560 26.62652 6.846189e-124
When the predicted log-odds are zero, we expect the win probability to be about 50%. A log-odd higher, and expectation is 5% higher. As seen in the second plot above, the log-odds don't go any further than 5 in either direction. So all the predicted values of $y$ are bound between about 25% and 75%. The regression effect is clear enough and at a large enough sample size that I trust that the inference is not misleading overall. There are always alternatives for better precision.
We can also get a sense of the error about the fitted line.
sigma(fit.lm)
[1] 0.09958555
Given a prediction, about 95% of values should be within about $\pm20\%$. The interval when added to the minimum and maximum predicted $y$ also lies within bounds.
The justification for the linear approach is its simplicity and its adequacy in this particular application.
|
Regression when both the predictor and outcome variables are proportions
Differently from the other answer here which I think is a good answer, I think a linear regression suffices in your exact situation. As a matter of principle, it might be wrong because of the hard bou
|
45,254
|
What's the intuition for a Beta Distribution with alpha and / or beta less than 1?
|
Here is a frivolous example that may have some intuitive value.
In US Major League Baseball each team plays 162 games per season.
Suppose a team is equally likely to win or lose each of its games. What
proportion of the time will such a team have more wins than losses?
(In order to have symmetry, if a team's wins and losses are tied
at any point, we say it is ahead if it was ahead just before the tie occurred, otherwise behind.)
Suppose we look at a team's win-loss record as the season progresses. For our team with wins and losses are as if determined by tosses of a fair coin, you might think a team would most likely be ahead about half the time throughout a season. Actually, half the time is the least likely proportion of time for being ahead.
The "bathtub shaped" histogram below shows the approximate distribution of the proportion of time during a season that such a team is ahead.
The curve is the PDF of $\mathsf{Beta}(.5,.5).$ The histogram is based on 20,000 simulated 162-game seasons for a team where wins and losses are like independent tosses of a fair coin, simulated in R as follows:
set.seed(1212); m = 20000; n = 162; prop.ahead = numeric(m)
for (i in 1:m)
{
x = sample(c(-1,1), n, repl=T); cum = cumsum(x)
ahead = (c(0, cum) + c(cum,0))[1:n] # Adjustment for ties
prop.ahead[i] = mean(ahead >= 0)
}
cut=seq(0, 1, by=.1); hdr="Proportion of 162-Game Season when Team Leads"
hist(prop.ahead, breaks=cut, prob=T, col="skyblue2", xlab="Proportion", main=hdr)
curve(dbeta(x, .5, .5), add=T, col="blue", lwd=2)
Note: Feller (Vol. 1) discusses such a process. The CDF of $\mathsf{Beta}(.5,.5)$ is a constant multiple of an arcsine function, so Feller calls it
an 'Arcsine Law'.
|
What's the intuition for a Beta Distribution with alpha and / or beta less than 1?
|
Here is a frivolous example that may have some intuitive value.
In US Major League Baseball each team plays 162 games per season.
Suppose a team is equally likely to win or lose each of its games. Wha
|
What's the intuition for a Beta Distribution with alpha and / or beta less than 1?
Here is a frivolous example that may have some intuitive value.
In US Major League Baseball each team plays 162 games per season.
Suppose a team is equally likely to win or lose each of its games. What
proportion of the time will such a team have more wins than losses?
(In order to have symmetry, if a team's wins and losses are tied
at any point, we say it is ahead if it was ahead just before the tie occurred, otherwise behind.)
Suppose we look at a team's win-loss record as the season progresses. For our team with wins and losses are as if determined by tosses of a fair coin, you might think a team would most likely be ahead about half the time throughout a season. Actually, half the time is the least likely proportion of time for being ahead.
The "bathtub shaped" histogram below shows the approximate distribution of the proportion of time during a season that such a team is ahead.
The curve is the PDF of $\mathsf{Beta}(.5,.5).$ The histogram is based on 20,000 simulated 162-game seasons for a team where wins and losses are like independent tosses of a fair coin, simulated in R as follows:
set.seed(1212); m = 20000; n = 162; prop.ahead = numeric(m)
for (i in 1:m)
{
x = sample(c(-1,1), n, repl=T); cum = cumsum(x)
ahead = (c(0, cum) + c(cum,0))[1:n] # Adjustment for ties
prop.ahead[i] = mean(ahead >= 0)
}
cut=seq(0, 1, by=.1); hdr="Proportion of 162-Game Season when Team Leads"
hist(prop.ahead, breaks=cut, prob=T, col="skyblue2", xlab="Proportion", main=hdr)
curve(dbeta(x, .5, .5), add=T, col="blue", lwd=2)
Note: Feller (Vol. 1) discusses such a process. The CDF of $\mathsf{Beta}(.5,.5)$ is a constant multiple of an arcsine function, so Feller calls it
an 'Arcsine Law'.
|
What's the intuition for a Beta Distribution with alpha and / or beta less than 1?
Here is a frivolous example that may have some intuitive value.
In US Major League Baseball each team plays 162 games per season.
Suppose a team is equally likely to win or lose each of its games. Wha
|
45,255
|
What's the intuition for a Beta Distribution with alpha and / or beta less than 1?
|
BruceET's answer really helped me understand this better.
It occurred to me that this "bathtub-shape" is due to any random process with saved state.
So I wanted to write a quick answer that might help others like me, who understand the math and are not novices, but who like to find cases which demonstrate the natural phenomenon.
The $\alpha = 0.5$, $\beta = 0.5$ case represents a random coin flip with saved state. Some examples:
Total winnings or losses when betting (assuming 50%/50% odds and constant bet size)
Sports team records like Bruce's example
Likelihood that there will be more total rain this year than last year (this isn't quite 50%/50% and has many externalities, but it does capture the "running total" which is critical to get the "horseshoe shape" that Jeffrey's Prior generates.
Many thanks, Bruce!
|
What's the intuition for a Beta Distribution with alpha and / or beta less than 1?
|
BruceET's answer really helped me understand this better.
It occurred to me that this "bathtub-shape" is due to any random process with saved state.
So I wanted to write a quick answer that might help
|
What's the intuition for a Beta Distribution with alpha and / or beta less than 1?
BruceET's answer really helped me understand this better.
It occurred to me that this "bathtub-shape" is due to any random process with saved state.
So I wanted to write a quick answer that might help others like me, who understand the math and are not novices, but who like to find cases which demonstrate the natural phenomenon.
The $\alpha = 0.5$, $\beta = 0.5$ case represents a random coin flip with saved state. Some examples:
Total winnings or losses when betting (assuming 50%/50% odds and constant bet size)
Sports team records like Bruce's example
Likelihood that there will be more total rain this year than last year (this isn't quite 50%/50% and has many externalities, but it does capture the "running total" which is critical to get the "horseshoe shape" that Jeffrey's Prior generates.
Many thanks, Bruce!
|
What's the intuition for a Beta Distribution with alpha and / or beta less than 1?
BruceET's answer really helped me understand this better.
It occurred to me that this "bathtub-shape" is due to any random process with saved state.
So I wanted to write a quick answer that might help
|
45,256
|
What's the intuition for a Beta Distribution with alpha and / or beta less than 1?
|
If you take for example $\alpha=\beta=0.5$, then the pdf looks like a horse-shoe, with high density near ends of the interval $(0,1)$ and low density near $0.5$. So as a prior, it puts a lot of density on the extremes, and that helps the posterior have a similar shape.
I understand it as a device to help the posterior move away from $50\%$ and towards $0$ or $1$, which can be helpful if you are trying to make a binary decision.
|
What's the intuition for a Beta Distribution with alpha and / or beta less than 1?
|
If you take for example $\alpha=\beta=0.5$, then the pdf looks like a horse-shoe, with high density near ends of the interval $(0,1)$ and low density near $0.5$. So as a prior, it puts a lot of densit
|
What's the intuition for a Beta Distribution with alpha and / or beta less than 1?
If you take for example $\alpha=\beta=0.5$, then the pdf looks like a horse-shoe, with high density near ends of the interval $(0,1)$ and low density near $0.5$. So as a prior, it puts a lot of density on the extremes, and that helps the posterior have a similar shape.
I understand it as a device to help the posterior move away from $50\%$ and towards $0$ or $1$, which can be helpful if you are trying to make a binary decision.
|
What's the intuition for a Beta Distribution with alpha and / or beta less than 1?
If you take for example $\alpha=\beta=0.5$, then the pdf looks like a horse-shoe, with high density near ends of the interval $(0,1)$ and low density near $0.5$. So as a prior, it puts a lot of densit
|
45,257
|
Notation in statistics (parameter/estimator/estimate)
|
There is no single answer to this question because different authors may use different notation. For me, the most handy notation is the one used, for example, by Larry Wasserman in All of Statistics:
By convention, we denote a point estimate of $\theta$ by $\hat\theta$
or $\widehat\theta_n$. Remember that $\theta$ is a fixed, unknown
quantity. The estimate $\hat\theta$ depends on the data so
$\hat\theta$ is a random variable.
More formally, let $X_1,\dots,X_n$ be $n$ iid data points from some
distribution $F$. A point estimator $\widehat\theta_n$ of a parameter
$\theta$ is some function of $X_1,\dots,X_n$:
$$ \widehat\theta_n = g(X_1,\dots,X_n). $$
So $\theta$ is the unknown parameter, $\hat\theta$ is the estimate, and a function $g$ of the sample is the estimator. Such notation makes it also clear that $g$ is a function.
|
Notation in statistics (parameter/estimator/estimate)
|
There is no single answer to this question because different authors may use different notation. For me, the most handy notation is the one used, for example, by Larry Wasserman in All of Statistics:
|
Notation in statistics (parameter/estimator/estimate)
There is no single answer to this question because different authors may use different notation. For me, the most handy notation is the one used, for example, by Larry Wasserman in All of Statistics:
By convention, we denote a point estimate of $\theta$ by $\hat\theta$
or $\widehat\theta_n$. Remember that $\theta$ is a fixed, unknown
quantity. The estimate $\hat\theta$ depends on the data so
$\hat\theta$ is a random variable.
More formally, let $X_1,\dots,X_n$ be $n$ iid data points from some
distribution $F$. A point estimator $\widehat\theta_n$ of a parameter
$\theta$ is some function of $X_1,\dots,X_n$:
$$ \widehat\theta_n = g(X_1,\dots,X_n). $$
So $\theta$ is the unknown parameter, $\hat\theta$ is the estimate, and a function $g$ of the sample is the estimator. Such notation makes it also clear that $g$ is a function.
|
Notation in statistics (parameter/estimator/estimate)
There is no single answer to this question because different authors may use different notation. For me, the most handy notation is the one used, for example, by Larry Wasserman in All of Statistics:
|
45,258
|
Notation in statistics (parameter/estimator/estimate)
|
You are right that the use of lower-case Greek letters creates a potential ambiguity here; this is a common issue in teaching estimation theory to students. To differentiate between an estimator and the corresponding estimate I find it helpful to use notation that includes the data as an argument value, and thereby stresses that we have a function of the data:
$$\begin{matrix}
\text{Estimator} & & & \hat{\theta}(\boldsymbol{X}), \\[6pt]
\text{Estimate } \text{ } & & & \hat{\theta}(\boldsymbol{x}). \\[6pt]
\end{matrix}$$
With this notation you substitute the upper case $\boldsymbol{X}$ to denote the random variable (estimator) and the lower-case $\boldsymbol{x}$ to denote a fixed observed value (estimate). It also has the advantage of being more technically sound, since for a fixed $n$ the estimator is a function $\hat{\theta}: \mathscr{X}^n \rightarrow \Theta$. So when I am writing with this notation I usually say things like this:
For large $n$ we can rely on the central limit theorem to write the distribution of the estimator as $\hat{\theta}(\boldsymbol{X}) \sim \text{N}(\theta, \sigma_{se}^2)$. In our previous simulation example we simulated values from a distribution with true mean $\theta = 3$, yielding data $\boldsymbol{x} = (3.1, 5.2, 1.6)$, giving us the estimate $\hat{\theta}(\boldsymbol{x}) = 3.3$.
Once the students understand the difference between the random estimator and the fixed estimate, and if the meaning is obvious from context, you can then drop the argument later.
|
Notation in statistics (parameter/estimator/estimate)
|
You are right that the use of lower-case Greek letters creates a potential ambiguity here; this is a common issue in teaching estimation theory to students. To differentiate between an estimator and
|
Notation in statistics (parameter/estimator/estimate)
You are right that the use of lower-case Greek letters creates a potential ambiguity here; this is a common issue in teaching estimation theory to students. To differentiate between an estimator and the corresponding estimate I find it helpful to use notation that includes the data as an argument value, and thereby stresses that we have a function of the data:
$$\begin{matrix}
\text{Estimator} & & & \hat{\theta}(\boldsymbol{X}), \\[6pt]
\text{Estimate } \text{ } & & & \hat{\theta}(\boldsymbol{x}). \\[6pt]
\end{matrix}$$
With this notation you substitute the upper case $\boldsymbol{X}$ to denote the random variable (estimator) and the lower-case $\boldsymbol{x}$ to denote a fixed observed value (estimate). It also has the advantage of being more technically sound, since for a fixed $n$ the estimator is a function $\hat{\theta}: \mathscr{X}^n \rightarrow \Theta$. So when I am writing with this notation I usually say things like this:
For large $n$ we can rely on the central limit theorem to write the distribution of the estimator as $\hat{\theta}(\boldsymbol{X}) \sim \text{N}(\theta, \sigma_{se}^2)$. In our previous simulation example we simulated values from a distribution with true mean $\theta = 3$, yielding data $\boldsymbol{x} = (3.1, 5.2, 1.6)$, giving us the estimate $\hat{\theta}(\boldsymbol{x}) = 3.3$.
Once the students understand the difference between the random estimator and the fixed estimate, and if the meaning is obvious from context, you can then drop the argument later.
|
Notation in statistics (parameter/estimator/estimate)
You are right that the use of lower-case Greek letters creates a potential ambiguity here; this is a common issue in teaching estimation theory to students. To differentiate between an estimator and
|
45,259
|
Understanding a Coursera exam question on significance testing
|
The correct response is that only II is true:
I. If you conduct a significance test you assume that the alternative hypothesis
is true unless the data provide strong evidence against it.
False - in any significance test, you must assume that the null hypothesis is true. After all, when we test for significance, we are concerned with some $\alpha$ value that represents the probability of a Type I error (i.e. rejecting a null hypothesis assuming that it is true). In calculating this probability, we can contextualize the likelihood of our observed data being meaningfully different (as opposed to being a result of chance).
Example - Suppose we are testing the likelihood of our coin being unfair and that we decide to flip it several times and track the proportion of times it lands on heads and the proportion of times it lands on tails.
The null hypothesis may be that the proportion of heads and tails are equal (.5 each).
The alternative hypothesis may be that they are unequal.
Significance testing can allow us to understand the probability that we make the wrong conclusion of the coin being unfair (e.g. because .58 of the outcomes were heads and .42 were tails) given that it's actually a fair coin.
II. The null hypothesis and the alternative hypothesis are always mutually
exclusive.
True - The null hypothesis and alternative hypotheses must be mutually exclusive (i.e. only one of the two can be true) and exhaustive (i.e. collectively represent all possible outcomes).
|
Understanding a Coursera exam question on significance testing
|
The correct response is that only II is true:
I. If you conduct a significance test you assume that the alternative hypothesis
is true unless the data provide strong evidence against it.
False
|
Understanding a Coursera exam question on significance testing
The correct response is that only II is true:
I. If you conduct a significance test you assume that the alternative hypothesis
is true unless the data provide strong evidence against it.
False - in any significance test, you must assume that the null hypothesis is true. After all, when we test for significance, we are concerned with some $\alpha$ value that represents the probability of a Type I error (i.e. rejecting a null hypothesis assuming that it is true). In calculating this probability, we can contextualize the likelihood of our observed data being meaningfully different (as opposed to being a result of chance).
Example - Suppose we are testing the likelihood of our coin being unfair and that we decide to flip it several times and track the proportion of times it lands on heads and the proportion of times it lands on tails.
The null hypothesis may be that the proportion of heads and tails are equal (.5 each).
The alternative hypothesis may be that they are unequal.
Significance testing can allow us to understand the probability that we make the wrong conclusion of the coin being unfair (e.g. because .58 of the outcomes were heads and .42 were tails) given that it's actually a fair coin.
II. The null hypothesis and the alternative hypothesis are always mutually
exclusive.
True - The null hypothesis and alternative hypotheses must be mutually exclusive (i.e. only one of the two can be true) and exhaustive (i.e. collectively represent all possible outcomes).
|
Understanding a Coursera exam question on significance testing
The correct response is that only II is true:
I. If you conduct a significance test you assume that the alternative hypothesis
is true unless the data provide strong evidence against it.
False
|
45,260
|
Sufficient statistics for Uniform $(-\theta,\theta)$
|
Suppose we have a random sample $(X_1,X_2,\cdots,X_n)$ drawn from $\mathcal U(-\theta,\theta)$ distribution.
PDF of $X\sim\mathcal U(-\theta,\theta)$ is
$$f(x;\theta)=\frac{1}{2\theta}\mathbf1_{-\theta<x<\theta},\quad\theta>0$$
Joint density of $(X_1,X_2,\cdots,X_n)$ is
\begin{align}f_{\theta}(x_1,x_2,\cdots,x_n)&=\prod_{i=1}^nf(x_i;\theta)
\\&=\frac{1}{(2\theta)^n}\mathbf1_{-\theta<x_1,\cdots,x_n<\theta}
\\&=\frac{1}{(2\theta)^n}\mathbf1_{0<|x_1|,\cdots,|x_n|<\theta}
\\&=\frac{1}{(2\theta)^n}\mathbf1_{\max_{1\le i\le n}|x_i|<\theta}
\end{align}
To clearly use the factorisation theorem, let us define $\mathbb I(x)=\begin{cases}1&,\text{ if }x>0\\0&,\text{ otherwise }\end{cases}$
Then we have
\begin{align}
f_{\theta}(x_1,x_2,\cdots,x_n)&=\frac{1}{(2\theta)^n}\mathbb I\left(\theta-\max_{1\le i\le n}|x_i|\right)
\\&=g\left(\theta,\max_{1\le i\le n}|x_i|\right)h(x_1,x_2,\cdots,x_n)
\end{align}
where $g\left(\theta,\max_{1\le i\le n}|x_i|\right)=\frac{1}{(2\theta)^n}\mathbb I\left(\theta-\max_{1\le i\le n}|x_i|\right)$ depends on $\theta$ and on $x_1,x_2,\cdots,x_n$ through $\max_{1\le i\le n}|x_i|$, and $h(x_1,x_2,\cdots,x_n)=1$ is independent of $\theta$.
So by factorisation theorem, $\max_{1\le i\le n}|X_i|$ is a sufficient statistic for $\theta$.
In fact, it can be shown to be minimal sufficient for $\theta$.
Since $-\theta<x_i<\theta\implies \theta>\max(-x_{(1)},x_{(n)})$, you are correct that $\max(-X_{(1)},X_{(n)})$ is a sufficient statistic for $\theta$ by a similar logic. In fact, if I am not wrong, it can be shown that $$\max(-X_{(1)},X_{(n)})=\max_{1\le i\le n}|X_i|$$
It is perfectly valid for a single unknown parameter to have jointly sufficient statistics since the definition of sufficiency tells us that a set of statistics $T_1(X_1,\cdots,X_n),\cdots,T_k(X_1,\cdots,X_n)$ is jointly sufficient for $\theta$ (which may be a vector) if and only if the conditional distribution of $X_1,\cdots,X_n$ given $T_1,\cdots,T_k$ does not depend on $\theta$.
As for example, we always have two trivial choices of jointly sufficient statistics. One is the sample $(X_1,X_2,\cdots,X_n)$ itself and the other is the set of order statistics $(X_{(1)},X_{(2)},\cdots,X_{(n)})$ as mentioned by knrumsey in the comments.
Again, $(X_{(1)},X_{(n)})$ is also sufficient for $\theta$ as it has the two components $X_{(1)}$ and $X_{(n)}$ of the minimal sufficient statistic, but it is not itself minimal sufficient as mentioned in the comments.
To clarify further queries of OP in the comments:
If a statistic $T$ is sufficient for a one-dimensional parameter $\theta$, then $\mathbf T=(T,T_0)$ will also be a sufficient statistic for $\theta$ for any other statistic $T_0$. This is because $\mathbf T$ can be looked as a one-to-one function of $T$. In particular, if $T$ is minimal sufficient, then $\mathbf T$ will be sufficient in a sense that the second component $T_0$ in $\mathbf T$ will be of no use in further data condensation and data reduction without loosing any information about $\theta$. So $T$ will be preferred to $(T,T_0)$ as a sufficient statistic.
For example, consider the $\mathcal N(\theta,1)$ population. Here the sample mean $\bar X$ is minimal sufficient for $\theta$. Now if we take $\mathbf T=(\bar X,S^2)$ where $S^2$ is the sample variance, then $\mathbf T$ will remain sufficient but no longer minimal sufficient.
Thanks to @knrumsey for pointing out my error.
|
Sufficient statistics for Uniform $(-\theta,\theta)$
|
Suppose we have a random sample $(X_1,X_2,\cdots,X_n)$ drawn from $\mathcal U(-\theta,\theta)$ distribution.
PDF of $X\sim\mathcal U(-\theta,\theta)$ is
$$f(x;\theta)=\frac{1}{2\theta}\mathbf1_{-\the
|
Sufficient statistics for Uniform $(-\theta,\theta)$
Suppose we have a random sample $(X_1,X_2,\cdots,X_n)$ drawn from $\mathcal U(-\theta,\theta)$ distribution.
PDF of $X\sim\mathcal U(-\theta,\theta)$ is
$$f(x;\theta)=\frac{1}{2\theta}\mathbf1_{-\theta<x<\theta},\quad\theta>0$$
Joint density of $(X_1,X_2,\cdots,X_n)$ is
\begin{align}f_{\theta}(x_1,x_2,\cdots,x_n)&=\prod_{i=1}^nf(x_i;\theta)
\\&=\frac{1}{(2\theta)^n}\mathbf1_{-\theta<x_1,\cdots,x_n<\theta}
\\&=\frac{1}{(2\theta)^n}\mathbf1_{0<|x_1|,\cdots,|x_n|<\theta}
\\&=\frac{1}{(2\theta)^n}\mathbf1_{\max_{1\le i\le n}|x_i|<\theta}
\end{align}
To clearly use the factorisation theorem, let us define $\mathbb I(x)=\begin{cases}1&,\text{ if }x>0\\0&,\text{ otherwise }\end{cases}$
Then we have
\begin{align}
f_{\theta}(x_1,x_2,\cdots,x_n)&=\frac{1}{(2\theta)^n}\mathbb I\left(\theta-\max_{1\le i\le n}|x_i|\right)
\\&=g\left(\theta,\max_{1\le i\le n}|x_i|\right)h(x_1,x_2,\cdots,x_n)
\end{align}
where $g\left(\theta,\max_{1\le i\le n}|x_i|\right)=\frac{1}{(2\theta)^n}\mathbb I\left(\theta-\max_{1\le i\le n}|x_i|\right)$ depends on $\theta$ and on $x_1,x_2,\cdots,x_n$ through $\max_{1\le i\le n}|x_i|$, and $h(x_1,x_2,\cdots,x_n)=1$ is independent of $\theta$.
So by factorisation theorem, $\max_{1\le i\le n}|X_i|$ is a sufficient statistic for $\theta$.
In fact, it can be shown to be minimal sufficient for $\theta$.
Since $-\theta<x_i<\theta\implies \theta>\max(-x_{(1)},x_{(n)})$, you are correct that $\max(-X_{(1)},X_{(n)})$ is a sufficient statistic for $\theta$ by a similar logic. In fact, if I am not wrong, it can be shown that $$\max(-X_{(1)},X_{(n)})=\max_{1\le i\le n}|X_i|$$
It is perfectly valid for a single unknown parameter to have jointly sufficient statistics since the definition of sufficiency tells us that a set of statistics $T_1(X_1,\cdots,X_n),\cdots,T_k(X_1,\cdots,X_n)$ is jointly sufficient for $\theta$ (which may be a vector) if and only if the conditional distribution of $X_1,\cdots,X_n$ given $T_1,\cdots,T_k$ does not depend on $\theta$.
As for example, we always have two trivial choices of jointly sufficient statistics. One is the sample $(X_1,X_2,\cdots,X_n)$ itself and the other is the set of order statistics $(X_{(1)},X_{(2)},\cdots,X_{(n)})$ as mentioned by knrumsey in the comments.
Again, $(X_{(1)},X_{(n)})$ is also sufficient for $\theta$ as it has the two components $X_{(1)}$ and $X_{(n)}$ of the minimal sufficient statistic, but it is not itself minimal sufficient as mentioned in the comments.
To clarify further queries of OP in the comments:
If a statistic $T$ is sufficient for a one-dimensional parameter $\theta$, then $\mathbf T=(T,T_0)$ will also be a sufficient statistic for $\theta$ for any other statistic $T_0$. This is because $\mathbf T$ can be looked as a one-to-one function of $T$. In particular, if $T$ is minimal sufficient, then $\mathbf T$ will be sufficient in a sense that the second component $T_0$ in $\mathbf T$ will be of no use in further data condensation and data reduction without loosing any information about $\theta$. So $T$ will be preferred to $(T,T_0)$ as a sufficient statistic.
For example, consider the $\mathcal N(\theta,1)$ population. Here the sample mean $\bar X$ is minimal sufficient for $\theta$. Now if we take $\mathbf T=(\bar X,S^2)$ where $S^2$ is the sample variance, then $\mathbf T$ will remain sufficient but no longer minimal sufficient.
Thanks to @knrumsey for pointing out my error.
|
Sufficient statistics for Uniform $(-\theta,\theta)$
Suppose we have a random sample $(X_1,X_2,\cdots,X_n)$ drawn from $\mathcal U(-\theta,\theta)$ distribution.
PDF of $X\sim\mathcal U(-\theta,\theta)$ is
$$f(x;\theta)=\frac{1}{2\theta}\mathbf1_{-\the
|
45,261
|
Consistency of lasso
|
You'll be disappointed to find that the consistency that matters the most with lasso is the consistency about which predictors are chosen. If you simulate two moderately large datasets and perform lasso independently and compare the results, the low degree of overlap will reveal the difficulty of the task in selecting features. This is even more true when co-linearities are present. lasso spends too much of its energy on feature selection intead of estimation, and the L1 norm results in too much shrinkage of truly important predictors (hence the popularity of the horseshoe prior in Bayesian high-dimensional modeling). I wouldn't be too interested in the type of consistency you described above until these more fundamental issues are addressed. I discuss these issues in general, and show how the bootstrap can help uncover them, here in the chapter on challenges of high-dimensional data analysis.
|
Consistency of lasso
|
You'll be disappointed to find that the consistency that matters the most with lasso is the consistency about which predictors are chosen. If you simulate two moderately large datasets and perform la
|
Consistency of lasso
You'll be disappointed to find that the consistency that matters the most with lasso is the consistency about which predictors are chosen. If you simulate two moderately large datasets and perform lasso independently and compare the results, the low degree of overlap will reveal the difficulty of the task in selecting features. This is even more true when co-linearities are present. lasso spends too much of its energy on feature selection intead of estimation, and the L1 norm results in too much shrinkage of truly important predictors (hence the popularity of the horseshoe prior in Bayesian high-dimensional modeling). I wouldn't be too interested in the type of consistency you described above until these more fundamental issues are addressed. I discuss these issues in general, and show how the bootstrap can help uncover them, here in the chapter on challenges of high-dimensional data analysis.
|
Consistency of lasso
You'll be disappointed to find that the consistency that matters the most with lasso is the consistency about which predictors are chosen. If you simulate two moderately large datasets and perform la
|
45,262
|
Why is the $x$ axis for a histogram labeled "bin"?
|
When wanting to create a histogram of a continuous variable, you first need to split those into bins (sometimes referred to as buckets). Subsequently, this procedure is called binning or bucketing.
So the x-axis of a histogram represents the bins of the continuous variable.
|
Why is the $x$ axis for a histogram labeled "bin"?
|
When wanting to create a histogram of a continuous variable, you first need to split those into bins (sometimes referred to as buckets). Subsequently, this procedure is called binning or bucketing.
So
|
Why is the $x$ axis for a histogram labeled "bin"?
When wanting to create a histogram of a continuous variable, you first need to split those into bins (sometimes referred to as buckets). Subsequently, this procedure is called binning or bucketing.
So the x-axis of a histogram represents the bins of the continuous variable.
|
Why is the $x$ axis for a histogram labeled "bin"?
When wanting to create a histogram of a continuous variable, you first need to split those into bins (sometimes referred to as buckets). Subsequently, this procedure is called binning or bucketing.
So
|
45,263
|
What is the Difference between Inductive Reasoning and Statistical Inference?
|
Definitions:
Lots of definitions abound, here is two I found that basically speak for the others I read
‘Inductive reasoning is the opposite of deductive reasoning. Inductive reasoning makes broad generalizations from specific observations.’ (https://www.livescience.com/21569-deduction-vs-induction.html)
‘Statistical inference means drawing conclusions based on data’ (http://www2.stat.duke.edu/~fab2/inference_talk.pdf)
The way I understand it is that Statistical Inference is a specialised type of Inductive Reasoning that specifically uses statistical tools to support and guide the reasoning/inference in a rigorous way.
It is the difference between looking at the data for two samples and saying,
‘A is greater than B’
‘A is greater than B with a probability of <5% that this magnitude of difference could arise by random chance’
Comments on Overfitting
You particularly reference overfitting which I see as one of the biggest challenges for machine learning. However, as you indicate by your statement it is not exclusive to machine learning by any stretch, and is a fundamental problem across science and is the very heart of the dangers of statistical inference. Statistical inference is by definition taking the results of applying some sort of construct or model to your specific data and then speculating that it would continue to apply in comparable or even reasoning how it may perform in expanded (extrapolation) situations.
Machine Learning example
So in machine learning the inductive reasoning could be simple as:
‘Model A showed good performance when we calibrated it and maintained strong performance in the validation set. We therefore expect that when we deploy the model in the final use case it will continue to provide similar levels of performance. This is based on the assumption that the subjects in the final use case fit a similar profile to those in the validation set. Specific exclusions are A, B C and D.'
A reasonably thorough statistical inference would be:
‘Model A worked with X (X$_1$-X$_2$) % accuracy in the calibration and Y (Y$_1$-Y$_2$)% in the validation set, therefore we expect to achieve an accuracy of Z (Z$_1$-Z$_2$) % when the model is deployed to its final use case’. This is based on the assumption that the subjects in the final use case fit a similar profile to those in the validation set, which a set of characteristics M(M$_1$-M$_2$), N(N$_1$-N$_2$), O(O$_1$-O$_2$). Specific exclusions are A, B C and D. If the final use case exposes the model to subjects with M$<$M$_1$ then the accuracy will likely be affected by V% (etc.)’
|
What is the Difference between Inductive Reasoning and Statistical Inference?
|
Definitions:
Lots of definitions abound, here is two I found that basically speak for the others I read
‘Inductive reasoning is the opposite of deductive reasoning. Inductive reasoning makes broad gen
|
What is the Difference between Inductive Reasoning and Statistical Inference?
Definitions:
Lots of definitions abound, here is two I found that basically speak for the others I read
‘Inductive reasoning is the opposite of deductive reasoning. Inductive reasoning makes broad generalizations from specific observations.’ (https://www.livescience.com/21569-deduction-vs-induction.html)
‘Statistical inference means drawing conclusions based on data’ (http://www2.stat.duke.edu/~fab2/inference_talk.pdf)
The way I understand it is that Statistical Inference is a specialised type of Inductive Reasoning that specifically uses statistical tools to support and guide the reasoning/inference in a rigorous way.
It is the difference between looking at the data for two samples and saying,
‘A is greater than B’
‘A is greater than B with a probability of <5% that this magnitude of difference could arise by random chance’
Comments on Overfitting
You particularly reference overfitting which I see as one of the biggest challenges for machine learning. However, as you indicate by your statement it is not exclusive to machine learning by any stretch, and is a fundamental problem across science and is the very heart of the dangers of statistical inference. Statistical inference is by definition taking the results of applying some sort of construct or model to your specific data and then speculating that it would continue to apply in comparable or even reasoning how it may perform in expanded (extrapolation) situations.
Machine Learning example
So in machine learning the inductive reasoning could be simple as:
‘Model A showed good performance when we calibrated it and maintained strong performance in the validation set. We therefore expect that when we deploy the model in the final use case it will continue to provide similar levels of performance. This is based on the assumption that the subjects in the final use case fit a similar profile to those in the validation set. Specific exclusions are A, B C and D.'
A reasonably thorough statistical inference would be:
‘Model A worked with X (X$_1$-X$_2$) % accuracy in the calibration and Y (Y$_1$-Y$_2$)% in the validation set, therefore we expect to achieve an accuracy of Z (Z$_1$-Z$_2$) % when the model is deployed to its final use case’. This is based on the assumption that the subjects in the final use case fit a similar profile to those in the validation set, which a set of characteristics M(M$_1$-M$_2$), N(N$_1$-N$_2$), O(O$_1$-O$_2$). Specific exclusions are A, B C and D. If the final use case exposes the model to subjects with M$<$M$_1$ then the accuracy will likely be affected by V% (etc.)’
|
What is the Difference between Inductive Reasoning and Statistical Inference?
Definitions:
Lots of definitions abound, here is two I found that basically speak for the others I read
‘Inductive reasoning is the opposite of deductive reasoning. Inductive reasoning makes broad gen
|
45,264
|
What is the Difference between Inductive Reasoning and Statistical Inference?
|
Inductive reasoning refers broadly to the general process of making inferences about unknowns from knowns, and usually involves some attempt to measure the evidential support for an uncertain proposition, based on what is known. It is distinguished from deductive reasoning insofar as the truth or falsity of the uncertain proposition is not logically determined by what is known. Statistical inference is a formalised form of inductive reasoning where observations are quantified as data and the rules of probability and statistical theory are applied to this data to make inferences.
Statistical theory is (in part) a normative theory telling you how you should undertake inductive reasoning. Formal application of this theory requires quantification of data and some technical knowledge, but the theory also gives you broad principles that can be applied in a qualitative way to less formalised contexts. In practice, inductive reasoning is ubiquitous, and statistical theory is time-consuming and hard, so human beings (even expert statisticians) apply the formal apparatus of statistical theory in only a tiny fraction of induction problems they encounter.
Since you are engaging in a talk within the context of formal statistical theory, it probably makes more sense to refer to overfitting within this context (i.e., say “statistical inference” rather than “inductive reasoning”). Overfitting refers to the use of analysis that fails to adequately allow for randomness, and therefore fits the data too closely. If you were to refer to overfitting in the context of statistical inference, you might want to describe this in terms that put it in context of that theory, with an appropriate level of formality (e.g., describing overfitting that occurs with an excessive number of parameters in a model, failure to use a train-test split, etc.).
It is also possible to talk about overfitting within the broader context of inductive reasoning, outside of formal statistical inference. In this broader context, overfitting similarly refers to an overactive pattern-recognition that fails to adequately allow for randomness, and therefore reasons too closely to observation. This general cognitive tendency has been referred to as apophenia and has been studied extensively. There are a number of studies in psychology that test the ability of humans to recognise sequences of random numbers. These show that human beings tend to have an overactive sense of pattern-finding, and tend to perceive patterns even in complete randomness (e.g., they tend to underestimate the likely number of runs, sample correlations, etc., in randomly generated data). This discussion is outside the scope of formal discussion of machine learning, but it is an interesting little tid-bit of information that relates to overfitting in that context.
So, as to what words you should use, I think that depends on the level of generality at which you want to discuss this phenomenon.
(Side note: I agree with the comment by Jacom Socolar that “overfitting” is not the most important aspect of machine learning and statistics. It is very important, but I would say that being able to fit a model in the first place is far more important.)
|
What is the Difference between Inductive Reasoning and Statistical Inference?
|
Inductive reasoning refers broadly to the general process of making inferences about unknowns from knowns, and usually involves some attempt to measure the evidential support for an uncertain proposit
|
What is the Difference between Inductive Reasoning and Statistical Inference?
Inductive reasoning refers broadly to the general process of making inferences about unknowns from knowns, and usually involves some attempt to measure the evidential support for an uncertain proposition, based on what is known. It is distinguished from deductive reasoning insofar as the truth or falsity of the uncertain proposition is not logically determined by what is known. Statistical inference is a formalised form of inductive reasoning where observations are quantified as data and the rules of probability and statistical theory are applied to this data to make inferences.
Statistical theory is (in part) a normative theory telling you how you should undertake inductive reasoning. Formal application of this theory requires quantification of data and some technical knowledge, but the theory also gives you broad principles that can be applied in a qualitative way to less formalised contexts. In practice, inductive reasoning is ubiquitous, and statistical theory is time-consuming and hard, so human beings (even expert statisticians) apply the formal apparatus of statistical theory in only a tiny fraction of induction problems they encounter.
Since you are engaging in a talk within the context of formal statistical theory, it probably makes more sense to refer to overfitting within this context (i.e., say “statistical inference” rather than “inductive reasoning”). Overfitting refers to the use of analysis that fails to adequately allow for randomness, and therefore fits the data too closely. If you were to refer to overfitting in the context of statistical inference, you might want to describe this in terms that put it in context of that theory, with an appropriate level of formality (e.g., describing overfitting that occurs with an excessive number of parameters in a model, failure to use a train-test split, etc.).
It is also possible to talk about overfitting within the broader context of inductive reasoning, outside of formal statistical inference. In this broader context, overfitting similarly refers to an overactive pattern-recognition that fails to adequately allow for randomness, and therefore reasons too closely to observation. This general cognitive tendency has been referred to as apophenia and has been studied extensively. There are a number of studies in psychology that test the ability of humans to recognise sequences of random numbers. These show that human beings tend to have an overactive sense of pattern-finding, and tend to perceive patterns even in complete randomness (e.g., they tend to underestimate the likely number of runs, sample correlations, etc., in randomly generated data). This discussion is outside the scope of formal discussion of machine learning, but it is an interesting little tid-bit of information that relates to overfitting in that context.
So, as to what words you should use, I think that depends on the level of generality at which you want to discuss this phenomenon.
(Side note: I agree with the comment by Jacom Socolar that “overfitting” is not the most important aspect of machine learning and statistics. It is very important, but I would say that being able to fit a model in the first place is far more important.)
|
What is the Difference between Inductive Reasoning and Statistical Inference?
Inductive reasoning refers broadly to the general process of making inferences about unknowns from knowns, and usually involves some attempt to measure the evidential support for an uncertain proposit
|
45,265
|
Can you weight observations in a Neural Network?
|
Yes, this is possible and often done. However, it seems to me that it is not currently possible to do using scikit-learn. To certain extent you could simulate this by duplicating samples in the training and validation set to increase their weight, but it is certainly not an efficient way to achieve it.
If you plan using neural networks, I would recommend using some more advanced library such as TensorFlow, which has weighted_cross_entropy_with_logits loss function implemented. Using TensorFlow in combination with Keras might provide a beginner-friendlier interface, even though the learning curve may still be a little steep.
Alternatively, scikit-learn has SVM classifier that supports weighted samples, perhaps it could work for your problem.
|
Can you weight observations in a Neural Network?
|
Yes, this is possible and often done. However, it seems to me that it is not currently possible to do using scikit-learn. To certain extent you could simulate this by duplicating samples in the traini
|
Can you weight observations in a Neural Network?
Yes, this is possible and often done. However, it seems to me that it is not currently possible to do using scikit-learn. To certain extent you could simulate this by duplicating samples in the training and validation set to increase their weight, but it is certainly not an efficient way to achieve it.
If you plan using neural networks, I would recommend using some more advanced library such as TensorFlow, which has weighted_cross_entropy_with_logits loss function implemented. Using TensorFlow in combination with Keras might provide a beginner-friendlier interface, even though the learning curve may still be a little steep.
Alternatively, scikit-learn has SVM classifier that supports weighted samples, perhaps it could work for your problem.
|
Can you weight observations in a Neural Network?
Yes, this is possible and often done. However, it seems to me that it is not currently possible to do using scikit-learn. To certain extent you could simulate this by duplicating samples in the traini
|
45,266
|
Can you weight observations in a Neural Network?
|
I would share a hack: copy data. This hack works on most models.
For example, if you find data point 1 is super important, make 5 copies of it. This hack can also be used to make the loss function more sensitive to certain class.
|
Can you weight observations in a Neural Network?
|
I would share a hack: copy data. This hack works on most models.
For example, if you find data point 1 is super important, make 5 copies of it. This hack can also be used to make the loss function mor
|
Can you weight observations in a Neural Network?
I would share a hack: copy data. This hack works on most models.
For example, if you find data point 1 is super important, make 5 copies of it. This hack can also be used to make the loss function more sensitive to certain class.
|
Can you weight observations in a Neural Network?
I would share a hack: copy data. This hack works on most models.
For example, if you find data point 1 is super important, make 5 copies of it. This hack can also be used to make the loss function mor
|
45,267
|
Can you weight observations in a Neural Network?
|
As @Jan Kukacka mentioned, scikit-learn does not support sample_weights for the MLPClassifier learner. However, the skorch package which wraps PyTorch neural networks to have the same API as sklearn has some support for it built in. You can find more information on how to do it in skorch's FAQ.
|
Can you weight observations in a Neural Network?
|
As @Jan Kukacka mentioned, scikit-learn does not support sample_weights for the MLPClassifier learner. However, the skorch package which wraps PyTorch neural networks to have the same API as sklearn
|
Can you weight observations in a Neural Network?
As @Jan Kukacka mentioned, scikit-learn does not support sample_weights for the MLPClassifier learner. However, the skorch package which wraps PyTorch neural networks to have the same API as sklearn has some support for it built in. You can find more information on how to do it in skorch's FAQ.
|
Can you weight observations in a Neural Network?
As @Jan Kukacka mentioned, scikit-learn does not support sample_weights for the MLPClassifier learner. However, the skorch package which wraps PyTorch neural networks to have the same API as sklearn
|
45,268
|
Covariance, bernoulli distribution and instrumental variables
|
The standard formula does work, just needs a bit of manipulation
$$Cov(y,z) = E(yz) - E(y)E(z) = E(yz\mid z=1)P(z=1) - E(y)p$$
$$[E(y\mid z=1) - E(y)]p = \Big[E(y\mid z=1) - \big[E(y|z=1)p + E(y\mid z=0)(1-p)\big]\Big]p$$
$$=\Big[ E(y \mid z=1)(1-p) - E(y \mid z=0)(1-p) \Big]p$$
$$=\Big[ E(y \mid z=1) - E(y \mid z=0) \Big]p(1-p)$$
|
Covariance, bernoulli distribution and instrumental variables
|
The standard formula does work, just needs a bit of manipulation
$$Cov(y,z) = E(yz) - E(y)E(z) = E(yz\mid z=1)P(z=1) - E(y)p$$
$$[E(y\mid z=1) - E(y)]p = \Big[E(y\mid z=1) - \big[E(y|z=1)p + E(y\mid z
|
Covariance, bernoulli distribution and instrumental variables
The standard formula does work, just needs a bit of manipulation
$$Cov(y,z) = E(yz) - E(y)E(z) = E(yz\mid z=1)P(z=1) - E(y)p$$
$$[E(y\mid z=1) - E(y)]p = \Big[E(y\mid z=1) - \big[E(y|z=1)p + E(y\mid z=0)(1-p)\big]\Big]p$$
$$=\Big[ E(y \mid z=1)(1-p) - E(y \mid z=0)(1-p) \Big]p$$
$$=\Big[ E(y \mid z=1) - E(y \mid z=0) \Big]p(1-p)$$
|
Covariance, bernoulli distribution and instrumental variables
The standard formula does work, just needs a bit of manipulation
$$Cov(y,z) = E(yz) - E(y)E(z) = E(yz\mid z=1)P(z=1) - E(y)p$$
$$[E(y\mid z=1) - E(y)]p = \Big[E(y\mid z=1) - \big[E(y|z=1)p + E(y\mid z
|
45,269
|
Covariance, bernoulli distribution and instrumental variables
|
Consider the ordinary least squares fit of $Y$ to $Z$:
Because the mean of univariate data minimizes the sum of squared residuals, this fit must rise from the mean of the $Y$ values associated with $Z=0$ (left hand red point) to the mean of the $Y$ values associated with $Z=1$ (right hand red point). Since $Z$ changes by $1-0=1$, its slope $\beta$ is the difference of these means:
$$\beta = (E[Y\mid Z=1] - E[Y\mid Z=0]).$$
This formula holds whether the variables refer to data or to a bivariate distribution.
However, the usual formula for the slope asserts it equals the covariance of $(Z,Y)$ divided by the variance of $Z$:
$$\beta = \frac{\operatorname{cov}(Y,Z) }{ \operatorname{Var}(Z) }.$$
When $Z$ is Bernoulli$(p)$, its variance is $p(1-p)$. Solving for the covariance in terms of the slope and the variance of $Z$ gives the stated formula:
$$\operatorname{Cov}(Y,Z) = \beta\, p(1-p) = (E[Y\mid Z=1] - E[Y\mid Z=0])\, p(1-p).$$
|
Covariance, bernoulli distribution and instrumental variables
|
Consider the ordinary least squares fit of $Y$ to $Z$:
Because the mean of univariate data minimizes the sum of squared residuals, this fit must rise from the mean of the $Y$ values associated with $
|
Covariance, bernoulli distribution and instrumental variables
Consider the ordinary least squares fit of $Y$ to $Z$:
Because the mean of univariate data minimizes the sum of squared residuals, this fit must rise from the mean of the $Y$ values associated with $Z=0$ (left hand red point) to the mean of the $Y$ values associated with $Z=1$ (right hand red point). Since $Z$ changes by $1-0=1$, its slope $\beta$ is the difference of these means:
$$\beta = (E[Y\mid Z=1] - E[Y\mid Z=0]).$$
This formula holds whether the variables refer to data or to a bivariate distribution.
However, the usual formula for the slope asserts it equals the covariance of $(Z,Y)$ divided by the variance of $Z$:
$$\beta = \frac{\operatorname{cov}(Y,Z) }{ \operatorname{Var}(Z) }.$$
When $Z$ is Bernoulli$(p)$, its variance is $p(1-p)$. Solving for the covariance in terms of the slope and the variance of $Z$ gives the stated formula:
$$\operatorname{Cov}(Y,Z) = \beta\, p(1-p) = (E[Y\mid Z=1] - E[Y\mid Z=0])\, p(1-p).$$
|
Covariance, bernoulli distribution and instrumental variables
Consider the ordinary least squares fit of $Y$ to $Z$:
Because the mean of univariate data minimizes the sum of squared residuals, this fit must rise from the mean of the $Y$ values associated with $
|
45,270
|
Does scaling a central $\chi^2$ distribution produce a non-central $\chi^2$ distribution?
|
Unfortunately, the Wikipedia article on "F-test of equality of variances" is incorrect. When the variances are unequal, the distribution of $F$ is neither $F$ nor non-central $F$, it is simply scaled $F$.
The non-central chi-squared distribution on k df specifically refers to the distribution of
$$\sum_{i=1}^k (Z_i+\delta_i)^2$$
where the $Z_i$ are independent N(0,1) and at least some of the $\delta_i$ are nonzero. The "non-centrality" refers to the fact that the distributions of the normal random variables $(Z_i+\delta_i)$ are not "centered" at zero.
On the other hand, the distribution of $\sigma^2 X^2$ where $X^2$ is chisquare is simply gamma or "scaled chisquared".
It is not "non-central chi-squared".
The non-central $F$ distribution specifically refers to a ratio of non-central chi-squared distributions, with each divided by its degrees of freedom.
Again, this is something much complex than a mere scaling transformation.
Edit
I have now corrected the Wikipedia page.
|
Does scaling a central $\chi^2$ distribution produce a non-central $\chi^2$ distribution?
|
Unfortunately, the Wikipedia article on "F-test of equality of variances" is incorrect. When the variances are unequal, the distribution of $F$ is neither $F$ nor non-central $F$, it is simply scaled
|
Does scaling a central $\chi^2$ distribution produce a non-central $\chi^2$ distribution?
Unfortunately, the Wikipedia article on "F-test of equality of variances" is incorrect. When the variances are unequal, the distribution of $F$ is neither $F$ nor non-central $F$, it is simply scaled $F$.
The non-central chi-squared distribution on k df specifically refers to the distribution of
$$\sum_{i=1}^k (Z_i+\delta_i)^2$$
where the $Z_i$ are independent N(0,1) and at least some of the $\delta_i$ are nonzero. The "non-centrality" refers to the fact that the distributions of the normal random variables $(Z_i+\delta_i)$ are not "centered" at zero.
On the other hand, the distribution of $\sigma^2 X^2$ where $X^2$ is chisquare is simply gamma or "scaled chisquared".
It is not "non-central chi-squared".
The non-central $F$ distribution specifically refers to a ratio of non-central chi-squared distributions, with each divided by its degrees of freedom.
Again, this is something much complex than a mere scaling transformation.
Edit
I have now corrected the Wikipedia page.
|
Does scaling a central $\chi^2$ distribution produce a non-central $\chi^2$ distribution?
Unfortunately, the Wikipedia article on "F-test of equality of variances" is incorrect. When the variances are unequal, the distribution of $F$ is neither $F$ nor non-central $F$, it is simply scaled
|
45,271
|
Difference between a markov process and a semi- markov process
|
I will discuss only Markov processes on finite or countable state spaces. My answer is based off of this page.
Suppose $s > t_n > ... > t_1$. A Markov process is a stochastic process where the conditional distribution of $X_s$ given $X_{t_1}, X_{t_2}, ... X_{t_n}$ depends only $X_{t_n}$.
One consequence of this definition is that the time until the next jump is exponentially distributed. This property arises because only the exponential distribution satisfies the "memoryless" property $P(X_t | X_s=x) = P(X_{t-\delta s} | X_{s - \delta s}=x)$. Another consequence is that, given a transition occurs at time $s$, the distribution over the next state depends only on the state immediately before. Thus, the upcoming transition's distribution is completely described by a product of an exponential PDF (for the waiting time) and a categorical distribution (for the next state).
For semi-Markov processes, upcoming transition's distribution is described by a product of an arbitrary PDF (for the waiting time) and a categorical distribution (for the next state). The waiting time is no longer required to be exponential; in other words, the process is allowed to "remember" not only the current state, but also how long it has been in the current state. One interesting wrinkle is that, although it remembers how long the current state has lasted, that knowledge must not affect the decision about which state to enter next. This may make semi-Markov models unsuitable for some applications: if someone is getting sicker and sicker of her job, for instance, she might be more apt to take anything that comes up, and the distribution over her next state might flatten.
|
Difference between a markov process and a semi- markov process
|
I will discuss only Markov processes on finite or countable state spaces. My answer is based off of this page.
Suppose $s > t_n > ... > t_1$. A Markov process is a stochastic process where the condit
|
Difference between a markov process and a semi- markov process
I will discuss only Markov processes on finite or countable state spaces. My answer is based off of this page.
Suppose $s > t_n > ... > t_1$. A Markov process is a stochastic process where the conditional distribution of $X_s$ given $X_{t_1}, X_{t_2}, ... X_{t_n}$ depends only $X_{t_n}$.
One consequence of this definition is that the time until the next jump is exponentially distributed. This property arises because only the exponential distribution satisfies the "memoryless" property $P(X_t | X_s=x) = P(X_{t-\delta s} | X_{s - \delta s}=x)$. Another consequence is that, given a transition occurs at time $s$, the distribution over the next state depends only on the state immediately before. Thus, the upcoming transition's distribution is completely described by a product of an exponential PDF (for the waiting time) and a categorical distribution (for the next state).
For semi-Markov processes, upcoming transition's distribution is described by a product of an arbitrary PDF (for the waiting time) and a categorical distribution (for the next state). The waiting time is no longer required to be exponential; in other words, the process is allowed to "remember" not only the current state, but also how long it has been in the current state. One interesting wrinkle is that, although it remembers how long the current state has lasted, that knowledge must not affect the decision about which state to enter next. This may make semi-Markov models unsuitable for some applications: if someone is getting sicker and sicker of her job, for instance, she might be more apt to take anything that comes up, and the distribution over her next state might flatten.
|
Difference between a markov process and a semi- markov process
I will discuss only Markov processes on finite or countable state spaces. My answer is based off of this page.
Suppose $s > t_n > ... > t_1$. A Markov process is a stochastic process where the condit
|
45,272
|
What variables need to be controlled for in regression?
|
If there are theoretical grounds for suspecting a variable is a confounder, then it should be included in the model to correct for its effect. On the other hand, mediators should generally not be included in the model. While it might seem like a good idea to correct for as many potential confounders as possible, there are actually a good number of reasons not to.
When to Correct for a Variable
A good, yet not always helpful answer to this question is:
"When you as an expert in your field believe the variable to affect your outcome."
First, let's discuss why this is a good answer. There are many important reasons why it is a bad idea to correct for a large number of variables. Sure, there may be unlimited variables in the universe, but...
...these do not all have a unique effect on the outcome and the inclusion of variables with high pairwise correlation will result in multicolinearity;
...you don't have unlimited data and everything you model costs you degrees of freedom
...including (too) many variables (which poorly predict the outcome) results in overfitting.;
Multicolinearity occurs when an explanatory variable can itself be explained as a combination of other explanatory variables. In other words, including everything that might affect the outcome means that many of the variables will also have some effect on each other. To make matters worse, there need not even be high correlation between explanatory variables, as long as one or more can be explained in terms of the others.
Degrees of freedom are required to estimate every parameter. Including variables that affect the outcome marginally or not at all still costs you degrees of freedom, without gaining you an improvement in model fit. If you want to report the significance of estimates, this also means you will lose power for everything you try to correct for.
An overfitted model is fitting the stochastic part of the process, rather than the systematic part. In other words, a model with too many parameters will tend to explain variance in the outcome that is simply there due to natural random variability in the sample, rather than due to some underlying process. Overfitted models appear to perform really well on the sample, but have poor out-of-sample performance (i.e. generalize very poorly).
Hence, a theoretical justification for the inclusion of variables is generally preferred over adding more and more variables to correct for.
Another argument in favour of the answer is that there is no simple alternative to choosing the important variables "as an expert in the field". It might seem tempting to include every possibly involved variable and then just narrowing it down through some exhaustive search for the most important ones (known as stepwise regression), but this is actually a very bad idea.
Second, let's discuss why this is not always a useful answer. If expert knowledge can decide the inclusion of variables, this is the way to go.
However, this approach assumes that the data generating process is already well understood and that this choice of variables can be reasonably made. Moreover, it assumes this expert knowledge to be correct! In practice, there is often a lot of uncertainty what can and cannot affect the outcome. Lurking variables which are excluded because they are not known to affect the outcome will not be discovered.
Because of this, there are many proposed alternatives to stepwise regression, most of which are some form of regularization. For example:
The LASSO penalty shrinks certain coefficients to zero, essentially selecting the non-zero ones;
Ridge regression does this in a way that respects pairwise correlation among predictors more, but cannot shrink to zero (i.e. cannot select variables);
Elastic net combines the penalties;
Horseshoe is yet another form of shrinkage intended to be a 'best of both';
Partial Least Squares deconstructs the explanatory variables and adds weights to the principal components based on their correlation with the outcome.
However, do keep in mind that there is no guarantee that LASSO or any other method will choose the right variables. It is still better to choose which to include based on expert knowledge, if possible. If there are enough observations, the predictive accuracy can help decide which model is best.
So does that mean we are forever stuck in a loophole of deciding on which variables to include? I don't think so and I think this is where exploratory analysis can help out. If you are really clueless about the inclusion of a set of candidate variables, perhaps the first study should merely investigate potential relationships and clearly state in the report the analysis is exploratory in nature. In a second study, new, independent dataset(s) can be used to verify which of these found relationships are not spurious. This is not too different from my field (biology), where large sets of genes, proteins or metabolites are studied with some 'shotgun' approach, followed by confirmation using a directed approach on new samples.
|
What variables need to be controlled for in regression?
|
If there are theoretical grounds for suspecting a variable is a confounder, then it should be included in the model to correct for its effect. On the other hand, mediators should generally not be incl
|
What variables need to be controlled for in regression?
If there are theoretical grounds for suspecting a variable is a confounder, then it should be included in the model to correct for its effect. On the other hand, mediators should generally not be included in the model. While it might seem like a good idea to correct for as many potential confounders as possible, there are actually a good number of reasons not to.
When to Correct for a Variable
A good, yet not always helpful answer to this question is:
"When you as an expert in your field believe the variable to affect your outcome."
First, let's discuss why this is a good answer. There are many important reasons why it is a bad idea to correct for a large number of variables. Sure, there may be unlimited variables in the universe, but...
...these do not all have a unique effect on the outcome and the inclusion of variables with high pairwise correlation will result in multicolinearity;
...you don't have unlimited data and everything you model costs you degrees of freedom
...including (too) many variables (which poorly predict the outcome) results in overfitting.;
Multicolinearity occurs when an explanatory variable can itself be explained as a combination of other explanatory variables. In other words, including everything that might affect the outcome means that many of the variables will also have some effect on each other. To make matters worse, there need not even be high correlation between explanatory variables, as long as one or more can be explained in terms of the others.
Degrees of freedom are required to estimate every parameter. Including variables that affect the outcome marginally or not at all still costs you degrees of freedom, without gaining you an improvement in model fit. If you want to report the significance of estimates, this also means you will lose power for everything you try to correct for.
An overfitted model is fitting the stochastic part of the process, rather than the systematic part. In other words, a model with too many parameters will tend to explain variance in the outcome that is simply there due to natural random variability in the sample, rather than due to some underlying process. Overfitted models appear to perform really well on the sample, but have poor out-of-sample performance (i.e. generalize very poorly).
Hence, a theoretical justification for the inclusion of variables is generally preferred over adding more and more variables to correct for.
Another argument in favour of the answer is that there is no simple alternative to choosing the important variables "as an expert in the field". It might seem tempting to include every possibly involved variable and then just narrowing it down through some exhaustive search for the most important ones (known as stepwise regression), but this is actually a very bad idea.
Second, let's discuss why this is not always a useful answer. If expert knowledge can decide the inclusion of variables, this is the way to go.
However, this approach assumes that the data generating process is already well understood and that this choice of variables can be reasonably made. Moreover, it assumes this expert knowledge to be correct! In practice, there is often a lot of uncertainty what can and cannot affect the outcome. Lurking variables which are excluded because they are not known to affect the outcome will not be discovered.
Because of this, there are many proposed alternatives to stepwise regression, most of which are some form of regularization. For example:
The LASSO penalty shrinks certain coefficients to zero, essentially selecting the non-zero ones;
Ridge regression does this in a way that respects pairwise correlation among predictors more, but cannot shrink to zero (i.e. cannot select variables);
Elastic net combines the penalties;
Horseshoe is yet another form of shrinkage intended to be a 'best of both';
Partial Least Squares deconstructs the explanatory variables and adds weights to the principal components based on their correlation with the outcome.
However, do keep in mind that there is no guarantee that LASSO or any other method will choose the right variables. It is still better to choose which to include based on expert knowledge, if possible. If there are enough observations, the predictive accuracy can help decide which model is best.
So does that mean we are forever stuck in a loophole of deciding on which variables to include? I don't think so and I think this is where exploratory analysis can help out. If you are really clueless about the inclusion of a set of candidate variables, perhaps the first study should merely investigate potential relationships and clearly state in the report the analysis is exploratory in nature. In a second study, new, independent dataset(s) can be used to verify which of these found relationships are not spurious. This is not too different from my field (biology), where large sets of genes, proteins or metabolites are studied with some 'shotgun' approach, followed by confirmation using a directed approach on new samples.
|
What variables need to be controlled for in regression?
If there are theoretical grounds for suspecting a variable is a confounder, then it should be included in the model to correct for its effect. On the other hand, mediators should generally not be incl
|
45,273
|
What variables need to be controlled for in regression?
|
However, there exists unlimited variables in the universe. And in
psychology/epidemiology research, there are a lot of demographic
variables (e.g., age, gender, income, marital status, number of
children, etc). When do we need to control for them? Is there a rule
of thumb?
If you are worried about observational prediction, then variable selection is a natural consequence of your model selection criteria based on predictive performance. But you seem to be worried about bias for making causal inference. That is, you want to make scientific causal claims based on your results.
If that's the case, the problem of knowing which variables to select for the identification of a causal claim via adjustment has been (mathematically) solved: you should include in your regression the variables that satisfy the backdoor criterion --- that is, these are variables that block all the backdoor (confounding) paths from $X$ to $Y$, do not open other spurious paths, and do not mediate the effect you are trying to measure. You should also take a look here and here.
The backdoor is about identification. After that you have to consider efficiency. There might be variables which are not "confounders" but will help you get more precise estimates, so you might want to adjust for them. And if you have too many variables you know you need to control for, but too little data relative to the amount of variables, you might want to resort to regularization techniques, trading-off some bias for less variance --- but keeping in mind you're doing the regularization to optimize the inference with respect to a specific causal quantity, not overall observational prediction. For example, you might want to check double/debiased machine learning methods.
|
What variables need to be controlled for in regression?
|
However, there exists unlimited variables in the universe. And in
psychology/epidemiology research, there are a lot of demographic
variables (e.g., age, gender, income, marital status, number of
|
What variables need to be controlled for in regression?
However, there exists unlimited variables in the universe. And in
psychology/epidemiology research, there are a lot of demographic
variables (e.g., age, gender, income, marital status, number of
children, etc). When do we need to control for them? Is there a rule
of thumb?
If you are worried about observational prediction, then variable selection is a natural consequence of your model selection criteria based on predictive performance. But you seem to be worried about bias for making causal inference. That is, you want to make scientific causal claims based on your results.
If that's the case, the problem of knowing which variables to select for the identification of a causal claim via adjustment has been (mathematically) solved: you should include in your regression the variables that satisfy the backdoor criterion --- that is, these are variables that block all the backdoor (confounding) paths from $X$ to $Y$, do not open other spurious paths, and do not mediate the effect you are trying to measure. You should also take a look here and here.
The backdoor is about identification. After that you have to consider efficiency. There might be variables which are not "confounders" but will help you get more precise estimates, so you might want to adjust for them. And if you have too many variables you know you need to control for, but too little data relative to the amount of variables, you might want to resort to regularization techniques, trading-off some bias for less variance --- but keeping in mind you're doing the regularization to optimize the inference with respect to a specific causal quantity, not overall observational prediction. For example, you might want to check double/debiased machine learning methods.
|
What variables need to be controlled for in regression?
However, there exists unlimited variables in the universe. And in
psychology/epidemiology research, there are a lot of demographic
variables (e.g., age, gender, income, marital status, number of
|
45,274
|
What variables need to be controlled for in regression?
|
Just to add one remark to @Frans Rodenburg's answer: Overadjustment might also be an issue. I.e. you don't want to control for variables for which it is not meaningful to keep them fixed when the variable of interested is varied. This is typical if the variable lies in the causal pathway from the exposure to the endpoint. For instance, if you model infant mortality with maternal age, you possibly don't want to control for birth weight, because the impact of maternal age is specifically due to the fact that it affects birth weight. The ceteris paribus would mean here that you vary maternal age with birth weight fixed which just not what we are interested in. Of course it might happen that maternal age has some indirect effect - i.e. something which is not mediated through birth weight - in that case the model is still meaningful.
|
What variables need to be controlled for in regression?
|
Just to add one remark to @Frans Rodenburg's answer: Overadjustment might also be an issue. I.e. you don't want to control for variables for which it is not meaningful to keep them fixed when the vari
|
What variables need to be controlled for in regression?
Just to add one remark to @Frans Rodenburg's answer: Overadjustment might also be an issue. I.e. you don't want to control for variables for which it is not meaningful to keep them fixed when the variable of interested is varied. This is typical if the variable lies in the causal pathway from the exposure to the endpoint. For instance, if you model infant mortality with maternal age, you possibly don't want to control for birth weight, because the impact of maternal age is specifically due to the fact that it affects birth weight. The ceteris paribus would mean here that you vary maternal age with birth weight fixed which just not what we are interested in. Of course it might happen that maternal age has some indirect effect - i.e. something which is not mediated through birth weight - in that case the model is still meaningful.
|
What variables need to be controlled for in regression?
Just to add one remark to @Frans Rodenburg's answer: Overadjustment might also be an issue. I.e. you don't want to control for variables for which it is not meaningful to keep them fixed when the vari
|
45,275
|
When is $E[X|Y]= \frac{E[XY]Y}{E[Y^2]} $ true?
|
Here's one case: $X,Y$ are bivariate Normal, each with mean $0$.
\begin{align*}
E[X \mid Y] &= EX + \rho \frac{\sigma_X}{\sigma_Y}[Y - EY] \\
&= \frac{E[XY]}{EY^2 - [EY]^2}Y\\
&= \frac{E[XY]Y}{E[Y^2]}.
\end{align*}
|
When is $E[X|Y]= \frac{E[XY]Y}{E[Y^2]} $ true?
|
Here's one case: $X,Y$ are bivariate Normal, each with mean $0$.
\begin{align*}
E[X \mid Y] &= EX + \rho \frac{\sigma_X}{\sigma_Y}[Y - EY] \\
&= \frac{E[XY]}{EY^2 - [EY]^2}Y\\
&= \frac{E[XY]Y}{E[Y^2]
|
When is $E[X|Y]= \frac{E[XY]Y}{E[Y^2]} $ true?
Here's one case: $X,Y$ are bivariate Normal, each with mean $0$.
\begin{align*}
E[X \mid Y] &= EX + \rho \frac{\sigma_X}{\sigma_Y}[Y - EY] \\
&= \frac{E[XY]}{EY^2 - [EY]^2}Y\\
&= \frac{E[XY]Y}{E[Y^2]}.
\end{align*}
|
When is $E[X|Y]= \frac{E[XY]Y}{E[Y^2]} $ true?
Here's one case: $X,Y$ are bivariate Normal, each with mean $0$.
\begin{align*}
E[X \mid Y] &= EX + \rho \frac{\sigma_X}{\sigma_Y}[Y - EY] \\
&= \frac{E[XY]}{EY^2 - [EY]^2}Y\\
&= \frac{E[XY]Y}{E[Y^2]
|
45,276
|
When is $E[X|Y]= \frac{E[XY]Y}{E[Y^2]} $ true?
|
$E[X \mid Y]$ is a random variable that is a function of the random variable $Y$ (not $X$), say $g(Y)$ and it is the minimum mean-square error (MMSE) estimator of $X$ in terms of $Y$. That is, $g(\cdot)$ is the (measurable) function that minimizes the mean-square error $E[(X-h(Y))^2]$ over all choices of (measurable) functions $h(\cdot)$ that we might use to estimate $X$ in terms of $Y$. Thus, the property in question
$$ E[X \mid Y] = \frac{E[XY]Y}{E[Y^2]} = \left(\frac{E[XY]}{E[Y^2]}\right)Y\tag{1}$$
holds whenever the function $g(\cdot)$ is just a scalar multiple of $Y$. Now, if we restrict the functions $h(y)$ to be linear functions (more correctly, affine functions) of the form $ay+b$, then the function $g_L(Y)$ that minimizes $E[(X-h(Y))^2]$ over all choices of linear functions $h(\cdot)$ is the linear MMSE estimator of $X$ in terms of $Y$
and is known to be
$$E[X] + \left.\left.\rho\frac{\sigma_X}{\sigma_Y}\right(Y - E[Y]\right) = E[X] + \left.\left.\frac{\operatorname{cov}(X,Y)}{\operatorname{var}(Y)}\right(Y - E[Y]\right).\tag{2}$$
Thus, $(1)$ holds when the MMSE estimate of $X$ given $Y$ is proportional to $Y$ (is a linear estimate) and so is the same as the linear MMSE estimate. But, $(1)$ has no constant term as in $(2)$ and so it must be that
$$E[X] = \frac{\operatorname{cov}(X,Y)}{\operatorname{var}(Y)}E[Y]\tag{3}$$ to make the constant term in $(2)$ vanish. But more is needed since whenever $(3)$ holds, $(2)$ becomes
$$\left(\frac{\operatorname{cov}(X,Y)}{\operatorname{var}(Y)}\right)Y =
\left(\frac{E[XY]-E[X]E[Y]}{E[Y^2]-(E[Y])^2}\right)Y \neq
\left(\frac{E[XY]}{E[Y^2]}\right)Y
$$
unless $E[X]=E[Y]=0$ (and so $(3)$ continues to be satisfied). In short, $(1)$ holds whenever
$X$ and $Y$ are zero-mean random variables
and
$E[X\mid Y]$, the MMSE estimator of $X$ given $Y$ is a linear estimator $E[X\mid Y] = aY$.
A standard example when these conditions hold is when $X$ and $Y$ are zero-mean random variables enjoying a bivariate normal distribution as in @Taylor's answer, but this is by no means the only possible example. Consider $(X,Y)$ uniformly distributed on the interior or the parallelogram with vertices $(-1,-1)$, $(0,-1)$, $(1,1)$ and $(0,1)$. It is easily verified that $E[X] = E[Y] = 0$. Note also that for any $y \in (-1,1)$, the conditional distribution of $X$ given that $Y = y$ is $\mathcal U\left(-\frac 12 + \frac y2, \frac 12 + \frac y2\right)$ and so $E[X\mid Y] = Y$. Verification that $E[XY] = E[Y^2]$ is left as an exercise for the skeptical reader.
|
When is $E[X|Y]= \frac{E[XY]Y}{E[Y^2]} $ true?
|
$E[X \mid Y]$ is a random variable that is a function of the random variable $Y$ (not $X$), say $g(Y)$ and it is the minimum mean-square error (MMSE) estimator of $X$ in terms of $Y$. That is, $g(\cdo
|
When is $E[X|Y]= \frac{E[XY]Y}{E[Y^2]} $ true?
$E[X \mid Y]$ is a random variable that is a function of the random variable $Y$ (not $X$), say $g(Y)$ and it is the minimum mean-square error (MMSE) estimator of $X$ in terms of $Y$. That is, $g(\cdot)$ is the (measurable) function that minimizes the mean-square error $E[(X-h(Y))^2]$ over all choices of (measurable) functions $h(\cdot)$ that we might use to estimate $X$ in terms of $Y$. Thus, the property in question
$$ E[X \mid Y] = \frac{E[XY]Y}{E[Y^2]} = \left(\frac{E[XY]}{E[Y^2]}\right)Y\tag{1}$$
holds whenever the function $g(\cdot)$ is just a scalar multiple of $Y$. Now, if we restrict the functions $h(y)$ to be linear functions (more correctly, affine functions) of the form $ay+b$, then the function $g_L(Y)$ that minimizes $E[(X-h(Y))^2]$ over all choices of linear functions $h(\cdot)$ is the linear MMSE estimator of $X$ in terms of $Y$
and is known to be
$$E[X] + \left.\left.\rho\frac{\sigma_X}{\sigma_Y}\right(Y - E[Y]\right) = E[X] + \left.\left.\frac{\operatorname{cov}(X,Y)}{\operatorname{var}(Y)}\right(Y - E[Y]\right).\tag{2}$$
Thus, $(1)$ holds when the MMSE estimate of $X$ given $Y$ is proportional to $Y$ (is a linear estimate) and so is the same as the linear MMSE estimate. But, $(1)$ has no constant term as in $(2)$ and so it must be that
$$E[X] = \frac{\operatorname{cov}(X,Y)}{\operatorname{var}(Y)}E[Y]\tag{3}$$ to make the constant term in $(2)$ vanish. But more is needed since whenever $(3)$ holds, $(2)$ becomes
$$\left(\frac{\operatorname{cov}(X,Y)}{\operatorname{var}(Y)}\right)Y =
\left(\frac{E[XY]-E[X]E[Y]}{E[Y^2]-(E[Y])^2}\right)Y \neq
\left(\frac{E[XY]}{E[Y^2]}\right)Y
$$
unless $E[X]=E[Y]=0$ (and so $(3)$ continues to be satisfied). In short, $(1)$ holds whenever
$X$ and $Y$ are zero-mean random variables
and
$E[X\mid Y]$, the MMSE estimator of $X$ given $Y$ is a linear estimator $E[X\mid Y] = aY$.
A standard example when these conditions hold is when $X$ and $Y$ are zero-mean random variables enjoying a bivariate normal distribution as in @Taylor's answer, but this is by no means the only possible example. Consider $(X,Y)$ uniformly distributed on the interior or the parallelogram with vertices $(-1,-1)$, $(0,-1)$, $(1,1)$ and $(0,1)$. It is easily verified that $E[X] = E[Y] = 0$. Note also that for any $y \in (-1,1)$, the conditional distribution of $X$ given that $Y = y$ is $\mathcal U\left(-\frac 12 + \frac y2, \frac 12 + \frac y2\right)$ and so $E[X\mid Y] = Y$. Verification that $E[XY] = E[Y^2]$ is left as an exercise for the skeptical reader.
|
When is $E[X|Y]= \frac{E[XY]Y}{E[Y^2]} $ true?
$E[X \mid Y]$ is a random variable that is a function of the random variable $Y$ (not $X$), say $g(Y)$ and it is the minimum mean-square error (MMSE) estimator of $X$ in terms of $Y$. That is, $g(\cdo
|
45,277
|
What is a "benchmark" time-series model?
|
This is not specific to arima, but to all forecasting methods - and indeed to any kind of prediction exercise.
The idea is that it is always easy to cook up an enormously complex and very impressive forecasting/prediction method. The hard part is showing that this shiny contraption actually improves on the forecasts/predictions of established methods. Because if it doesn't, then the wonderful new method is not worth a lot (except for the aspect that we learn from our mistakes).
In the post you link to, Rob Hyndman as the editor-in-chief of the International Journal of Forecasting notes that he will reject any submitted manuscript proposing a new forecasting method that does not do such a comparison.
These established methods are benchmarks.
For instance, it is not unusual for extremely simple methods like the overall mean or median to outperform ARIMA, so these very simple methods should always be used as benchmarks. If your new method cannot even improve on the overall mean, it's probably not all that good.
Similarly, Rob and George Athanasoupoulos called for submissions to a tourism forecasting competition a while back, and since they are both quite capable of fitting ARIMA models, they required that submitted forecasting methods outperform the MASEs of such ARIMA models. In this case, the benchmark is the automatically-fitted ARIMA model.
|
What is a "benchmark" time-series model?
|
This is not specific to arima, but to all forecasting methods - and indeed to any kind of prediction exercise.
The idea is that it is always easy to cook up an enormously complex and very impressive f
|
What is a "benchmark" time-series model?
This is not specific to arima, but to all forecasting methods - and indeed to any kind of prediction exercise.
The idea is that it is always easy to cook up an enormously complex and very impressive forecasting/prediction method. The hard part is showing that this shiny contraption actually improves on the forecasts/predictions of established methods. Because if it doesn't, then the wonderful new method is not worth a lot (except for the aspect that we learn from our mistakes).
In the post you link to, Rob Hyndman as the editor-in-chief of the International Journal of Forecasting notes that he will reject any submitted manuscript proposing a new forecasting method that does not do such a comparison.
These established methods are benchmarks.
For instance, it is not unusual for extremely simple methods like the overall mean or median to outperform ARIMA, so these very simple methods should always be used as benchmarks. If your new method cannot even improve on the overall mean, it's probably not all that good.
Similarly, Rob and George Athanasoupoulos called for submissions to a tourism forecasting competition a while back, and since they are both quite capable of fitting ARIMA models, they required that submitted forecasting methods outperform the MASEs of such ARIMA models. In this case, the benchmark is the automatically-fitted ARIMA model.
|
What is a "benchmark" time-series model?
This is not specific to arima, but to all forecasting methods - and indeed to any kind of prediction exercise.
The idea is that it is always easy to cook up an enormously complex and very impressive f
|
45,278
|
What is a "benchmark" time-series model?
|
Benchmark is a very simple model. I don't know of any standard definition, and I've seen the term applied multiple times with very different meanings. For example, in this competition, for each timeseries, they used the last two points to create a trendline. Here they use the median per series, and here they use S&P500 as benchmark (which almost no one beats).
|
What is a "benchmark" time-series model?
|
Benchmark is a very simple model. I don't know of any standard definition, and I've seen the term applied multiple times with very different meanings. For example, in this competition, for each timese
|
What is a "benchmark" time-series model?
Benchmark is a very simple model. I don't know of any standard definition, and I've seen the term applied multiple times with very different meanings. For example, in this competition, for each timeseries, they used the last two points to create a trendline. Here they use the median per series, and here they use S&P500 as benchmark (which almost no one beats).
|
What is a "benchmark" time-series model?
Benchmark is a very simple model. I don't know of any standard definition, and I've seen the term applied multiple times with very different meanings. For example, in this competition, for each timese
|
45,279
|
What is the meaning of the notation $\theta \sim p(\theta)$ and $y \sim p(y|\theta)$?
|
The notation is overloaded (or abused) so $p$ refers both to the probability density function as well as to the distribution. This seems a lot simpler than to have say capital letters indicate the distribution and lower case letters indicate the pdf/pmf.
Alternatively the $\sim$ notation can be thought of as overloaded so that it means the random variable on the left has the distribution on the right if the quantity on the right is a distribution. But if the quantity on the right is a pdf/pmf then $\sim$ means that the random variable on the left has the pdf/pmf of the quantity on the right.
|
What is the meaning of the notation $\theta \sim p(\theta)$ and $y \sim p(y|\theta)$?
|
The notation is overloaded (or abused) so $p$ refers both to the probability density function as well as to the distribution. This seems a lot simpler than to have say capital letters indicate the dis
|
What is the meaning of the notation $\theta \sim p(\theta)$ and $y \sim p(y|\theta)$?
The notation is overloaded (or abused) so $p$ refers both to the probability density function as well as to the distribution. This seems a lot simpler than to have say capital letters indicate the distribution and lower case letters indicate the pdf/pmf.
Alternatively the $\sim$ notation can be thought of as overloaded so that it means the random variable on the left has the distribution on the right if the quantity on the right is a distribution. But if the quantity on the right is a pdf/pmf then $\sim$ means that the random variable on the left has the pdf/pmf of the quantity on the right.
|
What is the meaning of the notation $\theta \sim p(\theta)$ and $y \sim p(y|\theta)$?
The notation is overloaded (or abused) so $p$ refers both to the probability density function as well as to the distribution. This seems a lot simpler than to have say capital letters indicate the dis
|
45,280
|
What is the meaning of the notation $\theta \sim p(\theta)$ and $y \sim p(y|\theta)$?
|
The notation is very misleading with $p(\cdot)$ being heavily overloaded with multiple meanings and complete disregard for the difference between random variables and the values that they take on.
There is a parameter $\theta$ of unknown value which is modeled as a random variable $\Theta$, discrete or continuous depending on what $\theta$ is believed to be. Assuming that $\theta$ is believed to take on discrete values, $$\Theta \sim p_\Theta(\theta)\tag{1}$$ is saying that $\Theta$ is being modeled as a discrete random variable with probability mass function $p_\Theta(\theta)$, or to paint refined gold and gild the lily, the function $p_\Theta(\cdot)$ has the property that $$P\{\Theta = \theta_i\} = p_\Theta(\theta_i).$$ There are $n$ observations $x_1, x_2, \ldots, x_n$ which are also modeled as random variables $X_1$, $X_2$, $\ldots$, $X_n$. Assuming that everything is discrete, on a trial of the experiment, these random variables $\Theta, X_1, X_2, \ldots, X_n$ have values $\theta, x_1, x_2, \ldots, x_n$ of which we can observe only $x_1, x_2, \ldots, x_n$. Now, the conditional probability mass function of the $X_i$ given that $\Theta$ has value $\theta$ is $$p_{X_1, X_2, \ldots, Xn \mid \Theta = \theta}(x_1, x_2, \ldots, x_n \mid \Theta = \theta)\tag{2}$$
meaning that
$$P\big\{X_1 = x_1, X_2 = x_2, \ldots, X_n = x_n \mid \Theta = \theta_i
\big\} = p_{X_1, X_2, \ldots, Xn \mid \Theta = \theta_i}(x_1, x_2, \ldots, x_n \mid \Theta = \theta_i).$$
Notice that $p$ has different subscripts in $(1)$ and $(2)$ to emphasize that there are two different functions being used here; one with just one argument and another with $n$ arguments, a far better arrangement than $p$ meaning different things depending on where it occurs and also better than the "canonical"
Let $X \sim f(x)$ and $Y \sim f(y)$ be random variables $\ldots$
or the physicists'
$X \sim f(X), Y \sim f(Y), X,Y \sim f(X,Y)$
where the density of $X$ can be quite different from the density of $Y$ and one is supposed to figure out from the letter used as the argument of $f\cdot)$ as to whether the density function of $x$ is meant or the density function of $Y$.
|
What is the meaning of the notation $\theta \sim p(\theta)$ and $y \sim p(y|\theta)$?
|
The notation is very misleading with $p(\cdot)$ being heavily overloaded with multiple meanings and complete disregard for the difference between random variables and the values that they take on.
The
|
What is the meaning of the notation $\theta \sim p(\theta)$ and $y \sim p(y|\theta)$?
The notation is very misleading with $p(\cdot)$ being heavily overloaded with multiple meanings and complete disregard for the difference between random variables and the values that they take on.
There is a parameter $\theta$ of unknown value which is modeled as a random variable $\Theta$, discrete or continuous depending on what $\theta$ is believed to be. Assuming that $\theta$ is believed to take on discrete values, $$\Theta \sim p_\Theta(\theta)\tag{1}$$ is saying that $\Theta$ is being modeled as a discrete random variable with probability mass function $p_\Theta(\theta)$, or to paint refined gold and gild the lily, the function $p_\Theta(\cdot)$ has the property that $$P\{\Theta = \theta_i\} = p_\Theta(\theta_i).$$ There are $n$ observations $x_1, x_2, \ldots, x_n$ which are also modeled as random variables $X_1$, $X_2$, $\ldots$, $X_n$. Assuming that everything is discrete, on a trial of the experiment, these random variables $\Theta, X_1, X_2, \ldots, X_n$ have values $\theta, x_1, x_2, \ldots, x_n$ of which we can observe only $x_1, x_2, \ldots, x_n$. Now, the conditional probability mass function of the $X_i$ given that $\Theta$ has value $\theta$ is $$p_{X_1, X_2, \ldots, Xn \mid \Theta = \theta}(x_1, x_2, \ldots, x_n \mid \Theta = \theta)\tag{2}$$
meaning that
$$P\big\{X_1 = x_1, X_2 = x_2, \ldots, X_n = x_n \mid \Theta = \theta_i
\big\} = p_{X_1, X_2, \ldots, Xn \mid \Theta = \theta_i}(x_1, x_2, \ldots, x_n \mid \Theta = \theta_i).$$
Notice that $p$ has different subscripts in $(1)$ and $(2)$ to emphasize that there are two different functions being used here; one with just one argument and another with $n$ arguments, a far better arrangement than $p$ meaning different things depending on where it occurs and also better than the "canonical"
Let $X \sim f(x)$ and $Y \sim f(y)$ be random variables $\ldots$
or the physicists'
$X \sim f(X), Y \sim f(Y), X,Y \sim f(X,Y)$
where the density of $X$ can be quite different from the density of $Y$ and one is supposed to figure out from the letter used as the argument of $f\cdot)$ as to whether the density function of $x$ is meant or the density function of $Y$.
|
What is the meaning of the notation $\theta \sim p(\theta)$ and $y \sim p(y|\theta)$?
The notation is very misleading with $p(\cdot)$ being heavily overloaded with multiple meanings and complete disregard for the difference between random variables and the values that they take on.
The
|
45,281
|
What is the expected length of an iid sequence that is monotonically increasing when drawn from a uniform [0,1] distribution?
|
First we formulate the question in the notation of a probability. We are looking for $p(x_1<x_2, x_3<x_2)$. Now we can simply expand this based on the rules of conditional probability as:
$$p(x_1<x_2, x_3<x_2) = \int_0^1 p(x_1<x_2, x_3<x_2|x_2)p(x_2) dx_2$$
We also know that, given we are working with uniform[0,1] variables, the first term in the integrand can be written simply
$$p(x_1<x_2, x_3<x_2|x_2) = x_2^2$$
We also know that $p(x_2) = 1$ on the interval we care about.
Therefore we have:
$$p(x_1<x_2, x_3<x_2) = \left. \int_0^1 x_2^2 dx_2 = \frac{x^3}{3}\right|_0^1 = 1/3$$
Just to double check:
> set.seed(4)
> x <- runif(300000)
> x <- matrix(x, ncol=3)
> sum(x[,1] < x[,2] & x[,3] < x[,2])/nrow(x)
[1] 0.33189
|
What is the expected length of an iid sequence that is monotonically increasing when drawn from a un
|
First we formulate the question in the notation of a probability. We are looking for $p(x_1<x_2, x_3<x_2)$. Now we can simply expand this based on the rules of conditional probability as:
$$p(x_1<x_2
|
What is the expected length of an iid sequence that is monotonically increasing when drawn from a uniform [0,1] distribution?
First we formulate the question in the notation of a probability. We are looking for $p(x_1<x_2, x_3<x_2)$. Now we can simply expand this based on the rules of conditional probability as:
$$p(x_1<x_2, x_3<x_2) = \int_0^1 p(x_1<x_2, x_3<x_2|x_2)p(x_2) dx_2$$
We also know that, given we are working with uniform[0,1] variables, the first term in the integrand can be written simply
$$p(x_1<x_2, x_3<x_2|x_2) = x_2^2$$
We also know that $p(x_2) = 1$ on the interval we care about.
Therefore we have:
$$p(x_1<x_2, x_3<x_2) = \left. \int_0^1 x_2^2 dx_2 = \frac{x^3}{3}\right|_0^1 = 1/3$$
Just to double check:
> set.seed(4)
> x <- runif(300000)
> x <- matrix(x, ncol=3)
> sum(x[,1] < x[,2] & x[,3] < x[,2])/nrow(x)
[1] 0.33189
|
What is the expected length of an iid sequence that is monotonically increasing when drawn from a un
First we formulate the question in the notation of a probability. We are looking for $p(x_1<x_2, x_3<x_2)$. Now we can simply expand this based on the rules of conditional probability as:
$$p(x_1<x_2
|
45,282
|
What is the expected length of an iid sequence that is monotonically increasing when drawn from a uniform [0,1] distribution?
|
Let $F$ be the joint multivariate distribution. You seek, by definition,
$$\Pr(X_1\lt X_2; X_3 \lt X_2) = \iiint_{x_1\lt x_2; x_3\lt x_2}dF(x_1,x_2,x_3).$$
To compute it, notice that
The variables, being iid, are exchangeable;
The event $\mathcal{E}_2 = X_1 \lt X_2; X_3 \lt X_2$ is converted into $\mathcal{E}_1 = X_3 \lt X_1; X_2 \lt X_1$ via the cyclic permutation $3\to2\to1\to3$ and is converted into $\mathcal{E}_3 = X_2 \lt X_3; X_1 \lt X_3$ via its inverse $1\to2\to3\to1$; and
Apart from a set of zero probability (relative to $F$), where ties occur, $\mathcal{E}_1\cup \mathcal{E}_2\cup\mathcal{E}_3$ is the entirety of $\mathbb{R}^3$.
It is immediate from $(1)$ and $(2)$ that all three events have the same chance and then $(3)$ and the Law of Total Probability imply those chances sum to $1$; the integral must evaluate to $1/3$.
|
What is the expected length of an iid sequence that is monotonically increasing when drawn from a un
|
Let $F$ be the joint multivariate distribution. You seek, by definition,
$$\Pr(X_1\lt X_2; X_3 \lt X_2) = \iiint_{x_1\lt x_2; x_3\lt x_2}dF(x_1,x_2,x_3).$$
To compute it, notice that
The variables,
|
What is the expected length of an iid sequence that is monotonically increasing when drawn from a uniform [0,1] distribution?
Let $F$ be the joint multivariate distribution. You seek, by definition,
$$\Pr(X_1\lt X_2; X_3 \lt X_2) = \iiint_{x_1\lt x_2; x_3\lt x_2}dF(x_1,x_2,x_3).$$
To compute it, notice that
The variables, being iid, are exchangeable;
The event $\mathcal{E}_2 = X_1 \lt X_2; X_3 \lt X_2$ is converted into $\mathcal{E}_1 = X_3 \lt X_1; X_2 \lt X_1$ via the cyclic permutation $3\to2\to1\to3$ and is converted into $\mathcal{E}_3 = X_2 \lt X_3; X_1 \lt X_3$ via its inverse $1\to2\to3\to1$; and
Apart from a set of zero probability (relative to $F$), where ties occur, $\mathcal{E}_1\cup \mathcal{E}_2\cup\mathcal{E}_3$ is the entirety of $\mathbb{R}^3$.
It is immediate from $(1)$ and $(2)$ that all three events have the same chance and then $(3)$ and the Law of Total Probability imply those chances sum to $1$; the integral must evaluate to $1/3$.
|
What is the expected length of an iid sequence that is monotonically increasing when drawn from a un
Let $F$ be the joint multivariate distribution. You seek, by definition,
$$\Pr(X_1\lt X_2; X_3 \lt X_2) = \iiint_{x_1\lt x_2; x_3\lt x_2}dF(x_1,x_2,x_3).$$
To compute it, notice that
The variables,
|
45,283
|
For independent RVs $X_1,X_2,X_3$, does $X_1+X_2\stackrel{d}{=}X_1+X_3$ imply $X_2\stackrel{d}{=}X_3$?
|
OK, for this answer I will assume the independent random variables have moment generating functions (mgf) existing in some open interval containing zero. To dispel one possible doubt, mgf's can never be zero, since they are given by expectation of an exponential function $\DeclareMathOperator{\E}{\mathbb{E}} M_X(t) = \E e^{t X}$. Exponential functions are everywhere positive so that expectation can never be zero (or negative).
So, the assumption is that $X_1 +X_2$ have the same distribution as $X_1+X_3$. Write the mgf's as $M_i(t)=M_{X_i}(t)$. It follows that
$$
M_1(t) M_2(t) = M_1(t) M_3(t)
$$ for all $t$ (where all three are defined, which will be some open interval containing zero). Since these functions can never be zero, we can divide on both sides by $M_1(t)$, obtaining $M_2(t)=M_3(t)$. We can conclude that $X_2$ and $X_3$ have the same distribution. For a nice review of properties of mgf's, see Existence of the moment generating function and variance
Now, what to do if mgf's do not exist? Replace the mgf's in the proof with characteristic functions. That becomes somewhat more involved, since that involves complex numbers, and my proof above that mgf's can never take the value zero do not work in that case. But we can save the argument in that case in the following way: a characteristic function is always (uniformly) continuous, on the entire space, see https://en.wikipedia.org/wiki/Characteristic_function_(probability_theory) . Since it always take the value 1 at the argument zero, we can find an open interval containing zero where none of the three characteristic functions have zeros, so the cancellation works as above (this argument also works for moment generating functions).
|
For independent RVs $X_1,X_2,X_3$, does $X_1+X_2\stackrel{d}{=}X_1+X_3$ imply $X_2\stackrel{d}{=}X_3
|
OK, for this answer I will assume the independent random variables have moment generating functions (mgf) existing in some open interval containing zero. To dispel one possible doubt, mgf's can never
|
For independent RVs $X_1,X_2,X_3$, does $X_1+X_2\stackrel{d}{=}X_1+X_3$ imply $X_2\stackrel{d}{=}X_3$?
OK, for this answer I will assume the independent random variables have moment generating functions (mgf) existing in some open interval containing zero. To dispel one possible doubt, mgf's can never be zero, since they are given by expectation of an exponential function $\DeclareMathOperator{\E}{\mathbb{E}} M_X(t) = \E e^{t X}$. Exponential functions are everywhere positive so that expectation can never be zero (or negative).
So, the assumption is that $X_1 +X_2$ have the same distribution as $X_1+X_3$. Write the mgf's as $M_i(t)=M_{X_i}(t)$. It follows that
$$
M_1(t) M_2(t) = M_1(t) M_3(t)
$$ for all $t$ (where all three are defined, which will be some open interval containing zero). Since these functions can never be zero, we can divide on both sides by $M_1(t)$, obtaining $M_2(t)=M_3(t)$. We can conclude that $X_2$ and $X_3$ have the same distribution. For a nice review of properties of mgf's, see Existence of the moment generating function and variance
Now, what to do if mgf's do not exist? Replace the mgf's in the proof with characteristic functions. That becomes somewhat more involved, since that involves complex numbers, and my proof above that mgf's can never take the value zero do not work in that case. But we can save the argument in that case in the following way: a characteristic function is always (uniformly) continuous, on the entire space, see https://en.wikipedia.org/wiki/Characteristic_function_(probability_theory) . Since it always take the value 1 at the argument zero, we can find an open interval containing zero where none of the three characteristic functions have zeros, so the cancellation works as above (this argument also works for moment generating functions).
|
For independent RVs $X_1,X_2,X_3$, does $X_1+X_2\stackrel{d}{=}X_1+X_3$ imply $X_2\stackrel{d}{=}X_3
OK, for this answer I will assume the independent random variables have moment generating functions (mgf) existing in some open interval containing zero. To dispel one possible doubt, mgf's can never
|
45,284
|
For independent RVs $X_1,X_2,X_3$, does $X_1+X_2\stackrel{d}{=}X_1+X_3$ imply $X_2\stackrel{d}{=}X_3$?
|
In general, no.
The proof given by @kjetil b halvorsen is fine, as long as the moment generating function exists.
However, there are counter examples when it does not. First, we need to recall a theorem by Polya. (More details can be found in the article Remarks on characterisic functions by G. Polya)
If φ is a real-valued, even, continuous function which satisfies the conditions
$\varphi(0) = 1$
$\varphi$ is convex for $ t<0$,
$\varphi(\infty) = 0 $,
then φ(t) is the characteristic function of an absolutely continuous symmetric distribution.
Now from this theorem, the two functions below are characteristic functions of some random variables, call them $X_1$ and $X_2$.
Now call $X$ the random variable whose characteristic function is
$ x \rightarrow (1-|x|)^+$ (again, using Polya's theorem).
Now, $\phi_{X_1}\phi_{X}=\phi_{X_2}\phi_{X}$ everywhere, so that $X_1+X\stackrel{d}=X_2+X$ but $X_1$ and $X_2$ have different distributions.
|
For independent RVs $X_1,X_2,X_3$, does $X_1+X_2\stackrel{d}{=}X_1+X_3$ imply $X_2\stackrel{d}{=}X_3
|
In general, no.
The proof given by @kjetil b halvorsen is fine, as long as the moment generating function exists.
However, there are counter examples when it does not. First, we need to recall a theor
|
For independent RVs $X_1,X_2,X_3$, does $X_1+X_2\stackrel{d}{=}X_1+X_3$ imply $X_2\stackrel{d}{=}X_3$?
In general, no.
The proof given by @kjetil b halvorsen is fine, as long as the moment generating function exists.
However, there are counter examples when it does not. First, we need to recall a theorem by Polya. (More details can be found in the article Remarks on characterisic functions by G. Polya)
If φ is a real-valued, even, continuous function which satisfies the conditions
$\varphi(0) = 1$
$\varphi$ is convex for $ t<0$,
$\varphi(\infty) = 0 $,
then φ(t) is the characteristic function of an absolutely continuous symmetric distribution.
Now from this theorem, the two functions below are characteristic functions of some random variables, call them $X_1$ and $X_2$.
Now call $X$ the random variable whose characteristic function is
$ x \rightarrow (1-|x|)^+$ (again, using Polya's theorem).
Now, $\phi_{X_1}\phi_{X}=\phi_{X_2}\phi_{X}$ everywhere, so that $X_1+X\stackrel{d}=X_2+X$ but $X_1$ and $X_2$ have different distributions.
|
For independent RVs $X_1,X_2,X_3$, does $X_1+X_2\stackrel{d}{=}X_1+X_3$ imply $X_2\stackrel{d}{=}X_3
In general, no.
The proof given by @kjetil b halvorsen is fine, as long as the moment generating function exists.
However, there are counter examples when it does not. First, we need to recall a theor
|
45,285
|
Proof of MSE is unbiased estimator in Regression
|
Martijn Weterings's commnet is very useful. Your derivation of term 2 is wrong.
$\epsilon'X (\beta - \hat \beta) \\= \epsilon'X(\beta - (X'X)^{-1}X'Y) \\=\epsilon'X\left\{\beta - (X'X)^{-1}X'(X\beta+\epsilon)\right\}\\=\epsilon'X \left\{\beta-(X'X)^{-1}X'X\beta -(X'X)^{-1}X'\epsilon\right\}\\=-\epsilon'X(X'X)^{-1}X'\epsilon$
Now
$\Sigma (Y_i - \hat Y_i)^2\\=\epsilon'X(X'X)^{-1}X'\epsilon-\epsilon'X(X'X)^{-1}X'\epsilon-\epsilon'X(X'X)^{-1}X'\epsilon+\epsilon'\epsilon\\=\epsilon'\epsilon-\epsilon'X(X'X)^{-1}X'\epsilon\\=\epsilon'\epsilon-\epsilon'P\epsilon$
$P$ is the projection matrix which is symmetric and idempotent
Now calculate the expectation.
$E[\Sigma (Y_i - \hat Y_i)^2]\\=E(\epsilon'\epsilon-\epsilon'P\epsilon)\\=E(\epsilon'\epsilon)-E(\epsilon'P\epsilon)\\=n\sigma^2-\sigma^2trace(P) \\\text{(Suppose tarace(P)}=k)$
$=(n-k)\sigma^2$
$\therefore \frac{\Sigma (Y_i - \hat Y_i)^2}{n-k}$ is the unbiased estimator of $\sigma^2$, $k$ is the number of parameters you want to estimate,such as you want to estimate $\beta_0$ for intercept and $\beta_1$ for one predictor, the $k$ will be equal to 2.
|
Proof of MSE is unbiased estimator in Regression
|
Martijn Weterings's commnet is very useful. Your derivation of term 2 is wrong.
$\epsilon'X (\beta - \hat \beta) \\= \epsilon'X(\beta - (X'X)^{-1}X'Y) \\=\epsilon'X\left\{\beta - (X'X)^{-1}X'(X\beta+\
|
Proof of MSE is unbiased estimator in Regression
Martijn Weterings's commnet is very useful. Your derivation of term 2 is wrong.
$\epsilon'X (\beta - \hat \beta) \\= \epsilon'X(\beta - (X'X)^{-1}X'Y) \\=\epsilon'X\left\{\beta - (X'X)^{-1}X'(X\beta+\epsilon)\right\}\\=\epsilon'X \left\{\beta-(X'X)^{-1}X'X\beta -(X'X)^{-1}X'\epsilon\right\}\\=-\epsilon'X(X'X)^{-1}X'\epsilon$
Now
$\Sigma (Y_i - \hat Y_i)^2\\=\epsilon'X(X'X)^{-1}X'\epsilon-\epsilon'X(X'X)^{-1}X'\epsilon-\epsilon'X(X'X)^{-1}X'\epsilon+\epsilon'\epsilon\\=\epsilon'\epsilon-\epsilon'X(X'X)^{-1}X'\epsilon\\=\epsilon'\epsilon-\epsilon'P\epsilon$
$P$ is the projection matrix which is symmetric and idempotent
Now calculate the expectation.
$E[\Sigma (Y_i - \hat Y_i)^2]\\=E(\epsilon'\epsilon-\epsilon'P\epsilon)\\=E(\epsilon'\epsilon)-E(\epsilon'P\epsilon)\\=n\sigma^2-\sigma^2trace(P) \\\text{(Suppose tarace(P)}=k)$
$=(n-k)\sigma^2$
$\therefore \frac{\Sigma (Y_i - \hat Y_i)^2}{n-k}$ is the unbiased estimator of $\sigma^2$, $k$ is the number of parameters you want to estimate,such as you want to estimate $\beta_0$ for intercept and $\beta_1$ for one predictor, the $k$ will be equal to 2.
|
Proof of MSE is unbiased estimator in Regression
Martijn Weterings's commnet is very useful. Your derivation of term 2 is wrong.
$\epsilon'X (\beta - \hat \beta) \\= \epsilon'X(\beta - (X'X)^{-1}X'Y) \\=\epsilon'X\left\{\beta - (X'X)^{-1}X'(X\beta+\
|
45,286
|
Proof of MSE is unbiased estimator in Regression
|
A less computationally intensive method would be
$$
\begin{aligned}
e&=y-\hat{y}\\
\Sigma(y[k]-\hat{y}[k])^2&=e^Te\\
y-\hat{y}&=\phi\theta-\phi\hat{\theta}+\epsilon\\
&=\phi\theta-\phi(\phi^T\phi)^{-1}\phi^Ty+\epsilon\\
&=\phi\theta-\phi(\phi^T\phi)^{-1}\phi^T(\phi\theta+\epsilon)+\epsilon\\
&=-\phi(\phi^T\phi)^{-1}\phi^T\epsilon+\epsilon\\
e&=(I-P)\epsilon\\
e^Te&=\epsilon^T(I-P^T-P+P^TP),\;\{P=P^T=P^TP\}\\
&=\epsilon^T\epsilon-\epsilon^TP\epsilon
\end{aligned}
$$
This is an easier method to get to the necessary step. You can then proceed further as explained by the previous answer.
|
Proof of MSE is unbiased estimator in Regression
|
A less computationally intensive method would be
$$
\begin{aligned}
e&=y-\hat{y}\\
\Sigma(y[k]-\hat{y}[k])^2&=e^Te\\
y-\hat{y}&=\phi\theta-\phi\hat{\theta}+\epsilon\\
&=\phi\theta-\phi(\phi^T\phi)^{-1
|
Proof of MSE is unbiased estimator in Regression
A less computationally intensive method would be
$$
\begin{aligned}
e&=y-\hat{y}\\
\Sigma(y[k]-\hat{y}[k])^2&=e^Te\\
y-\hat{y}&=\phi\theta-\phi\hat{\theta}+\epsilon\\
&=\phi\theta-\phi(\phi^T\phi)^{-1}\phi^Ty+\epsilon\\
&=\phi\theta-\phi(\phi^T\phi)^{-1}\phi^T(\phi\theta+\epsilon)+\epsilon\\
&=-\phi(\phi^T\phi)^{-1}\phi^T\epsilon+\epsilon\\
e&=(I-P)\epsilon\\
e^Te&=\epsilon^T(I-P^T-P+P^TP),\;\{P=P^T=P^TP\}\\
&=\epsilon^T\epsilon-\epsilon^TP\epsilon
\end{aligned}
$$
This is an easier method to get to the necessary step. You can then proceed further as explained by the previous answer.
|
Proof of MSE is unbiased estimator in Regression
A less computationally intensive method would be
$$
\begin{aligned}
e&=y-\hat{y}\\
\Sigma(y[k]-\hat{y}[k])^2&=e^Te\\
y-\hat{y}&=\phi\theta-\phi\hat{\theta}+\epsilon\\
&=\phi\theta-\phi(\phi^T\phi)^{-1
|
45,287
|
Defining gradient function argument in optim function-R
|
In R, the default method used in optim is Nelder-Mead, which does not use gradients for optimization. As such, it's pretty slow. ?optim states that this method is robust...but I'd say that's false advertising; it can often return a sub-optimal solution for easy problems with no warnings.
Because this method does not use gradients, supplying the gradient function with the default setting of Nelder-Mead will not actually change the procedure at all.
On the other hand, if you use the quasi-Newton methods, (BFGS or L-BFGS-B) or conjugate gradient, these methods do require evaluation of the gradient during optimization. If these are not supplied in the gradient function, they are estimated numerically, i.e.
$f'(x) \approx \frac{f(x+h) - f(x-h)}{2h}$
for some small $h$.
If the function you are evaluating is relatively cheap to evaluate, or the number of parameters is not too high, this is typically fine to use and you can save yourself the time of writing out the full gradient.
On the other hand, for many problems with large numbers of parameters, calculating the full vector of gradients numerically can be prohibitively slow. Remember, if you have $k$ parameters, the above calculation needs to be calculated $k$ times. Also, for problems with large second order derivatives, this numerical approximation may be unstable, so supplying a function that analytically evaluates the derivative may stabilize the algorithm. But typically, speed in computing a single gradient is the motivation for supplying the analytic function for the gradient.
|
Defining gradient function argument in optim function-R
|
In R, the default method used in optim is Nelder-Mead, which does not use gradients for optimization. As such, it's pretty slow. ?optim states that this method is robust...but I'd say that's false adv
|
Defining gradient function argument in optim function-R
In R, the default method used in optim is Nelder-Mead, which does not use gradients for optimization. As such, it's pretty slow. ?optim states that this method is robust...but I'd say that's false advertising; it can often return a sub-optimal solution for easy problems with no warnings.
Because this method does not use gradients, supplying the gradient function with the default setting of Nelder-Mead will not actually change the procedure at all.
On the other hand, if you use the quasi-Newton methods, (BFGS or L-BFGS-B) or conjugate gradient, these methods do require evaluation of the gradient during optimization. If these are not supplied in the gradient function, they are estimated numerically, i.e.
$f'(x) \approx \frac{f(x+h) - f(x-h)}{2h}$
for some small $h$.
If the function you are evaluating is relatively cheap to evaluate, or the number of parameters is not too high, this is typically fine to use and you can save yourself the time of writing out the full gradient.
On the other hand, for many problems with large numbers of parameters, calculating the full vector of gradients numerically can be prohibitively slow. Remember, if you have $k$ parameters, the above calculation needs to be calculated $k$ times. Also, for problems with large second order derivatives, this numerical approximation may be unstable, so supplying a function that analytically evaluates the derivative may stabilize the algorithm. But typically, speed in computing a single gradient is the motivation for supplying the analytic function for the gradient.
|
Defining gradient function argument in optim function-R
In R, the default method used in optim is Nelder-Mead, which does not use gradients for optimization. As such, it's pretty slow. ?optim states that this method is robust...but I'd say that's false adv
|
45,288
|
How many ways to make a straight flush in 7 card poker? (53 card deck with joker)
|
I found 210,964 hands of 7 cards that contain at least one 5-card straight flush, using the following Python 3 program, which takes about 21 minutes to run on my laptop.
from itertools import combinations
from functools import lru_cache
JACK, QUEEN, KING, ACE = 11, 12, 13, 14
N_HANDS = 154143080 # 53 choose 7
deck = ["JOKER"] + [(rank, suit)
for rank in range(2, ACE + 1)
for suit in range(4)]
assert len(deck) == 53
no_joker_straights = {
tuple(range(i, i + 5)) for i in range(2, ACE + 1) if i + 4 <= ACE}
no_joker_straights.add((2, 3, 4, 5, ACE))
joker_straights = {
tuple(sorted(set(hand) - set([x])))
for hand in no_joker_straights
for x in hand}
found = 0
divisor = N_HANDS // 100
@lru_cache(maxsize=None)
def is_straight_flush(hand):
joker = False
if "JOKER" in hand:
joker = True
hand = list(hand)
hand.remove("JOKER")
# Check that it's a flush.
if len({suit for (_, suit) in hand}) != 1:
return False
# Check that it's a straight.
return (tuple(rank for rank, _ in hand) in
(joker_straights if joker else no_joker_straights))
for i, hand in enumerate(combinations(deck, 7)):
if i % divisor == 0:
print("{}% complete ({:,})".format(i // divisor, found))
for subhand in combinations(hand, 5):
if is_straight_flush(subhand):
found += 1
break
print("{:,} straight flushes in {:,} hands".format(found, N_HANDS))
|
How many ways to make a straight flush in 7 card poker? (53 card deck with joker)
|
I found 210,964 hands of 7 cards that contain at least one 5-card straight flush, using the following Python 3 program, which takes about 21 minutes to run on my laptop.
from itertools import combinat
|
How many ways to make a straight flush in 7 card poker? (53 card deck with joker)
I found 210,964 hands of 7 cards that contain at least one 5-card straight flush, using the following Python 3 program, which takes about 21 minutes to run on my laptop.
from itertools import combinations
from functools import lru_cache
JACK, QUEEN, KING, ACE = 11, 12, 13, 14
N_HANDS = 154143080 # 53 choose 7
deck = ["JOKER"] + [(rank, suit)
for rank in range(2, ACE + 1)
for suit in range(4)]
assert len(deck) == 53
no_joker_straights = {
tuple(range(i, i + 5)) for i in range(2, ACE + 1) if i + 4 <= ACE}
no_joker_straights.add((2, 3, 4, 5, ACE))
joker_straights = {
tuple(sorted(set(hand) - set([x])))
for hand in no_joker_straights
for x in hand}
found = 0
divisor = N_HANDS // 100
@lru_cache(maxsize=None)
def is_straight_flush(hand):
joker = False
if "JOKER" in hand:
joker = True
hand = list(hand)
hand.remove("JOKER")
# Check that it's a flush.
if len({suit for (_, suit) in hand}) != 1:
return False
# Check that it's a straight.
return (tuple(rank for rank, _ in hand) in
(joker_straights if joker else no_joker_straights))
for i, hand in enumerate(combinations(deck, 7)):
if i % divisor == 0:
print("{}% complete ({:,})".format(i // divisor, found))
for subhand in combinations(hand, 5):
if is_straight_flush(subhand):
found += 1
break
print("{:,} straight flushes in {:,} hands".format(found, N_HANDS))
|
How many ways to make a straight flush in 7 card poker? (53 card deck with joker)
I found 210,964 hands of 7 cards that contain at least one 5-card straight flush, using the following Python 3 program, which takes about 21 minutes to run on my laptop.
from itertools import combinat
|
45,289
|
How many ways to make a straight flush in 7 card poker? (53 card deck with joker)
|
If you think about how you might go about writing efficient code to enumerate all the straight flushes, you can develop a mathematical formula--which is the ultimate efficiency! I will not in fact bring you all the way to such a formula, because it's a nuisance. Instead, I will show how to short-circuit both the complicated combinatorial maneuvers and computationally-intensive brute-force searches to find a happy medium in which you can be reasonably certain of getting the correct answer while not having to work too hard to do so.
First, note that it's not possible for a seven-card hand to hold straight flushes (SF) of two different suits, because (apart from a possible Joker) there have to be at least four suited cards in the SF. Therefore we need only count the straight flushes of a given suit, and multiply that count by four to get the total.
Pick a suit, once and for all. Let's divide the problem of finding all the SFs in that suit according to how many cards of that suit (counting the Joker) actually appear in the hand. Since a SF consists of five cards, the (mutually exclusive) possibilities are $7$, $6$, and $5$ cards. Let's count each case. To simplify the notation, let the ranks be 1 (the ace also written as A), 2, ..., 9, T=10, J=11, Q=12, and K=13. The ace can count as rank 14 if that helps to form a SF.
With $5$ cards, they are the SF. Without the Joker, their sorted ranks can be 12345, 23456, ... through TJQKA, of which there are $10$ possibilities. If one of them is the Joker, we have to take care not to double-count. Sort them lexicographically, replacing the Joker (*) with the smallest value that can create a SF. For instance, 3456* is interpreted as 23456 rather than 34567. In this fashion we obtain five more possible ways of forming 12345 (namely, *2345, 1*345, 12*45, 123*5, and 1234*), but only four additional ways of forming the other SFs. (E.g., the five SFs beginning with 3 are 34567, *4567, 3*567, 34*67, and 345*7: the set 3456* would be interpreted as *3456, which begins with 2!) That produces $10 + 4(10) + 1 = 51$ distinct possibilities. There are, independently of these possibilities, $\binom{39}{2}$ ways to select the cards in one of the other three suits.
With $6$ cards, the counting gets more complicated but is not fundamentally different. Note that we cannot blithely count the SFs without a Joker and then multiply that by $6$ to account for the six possible positions a Joker could substitute for. (This is where other attempts at a solution have foundered.) The problem is that this counts some hands multiple times. As an example, consider the hands 89TJQK and 8TJQKA. By substituting a Joker (*) for the 9 in the first and for the Ace in the second, we obtain identical hands 8TJQK*. Instead, we can order the SFs as before, by the start of the lowest SF that can be formed from the cards, but this time we have to multiply the counts by the number of value which that spare sixth card can have without creating a SF with a lower starting value. The resulting count is $356$. It breaks down into $49$ ways to product a SF beginning with an ace, $35$ SF's beginning with 2, and $34$ each of all the rest. As before, this value of $356$ has to be multiplied by the $\binom{39}{1}$ ways to select the seventh card from the other $39$ cards not in the suit.
With $7$ cards, the counting is further complicated because there are two spare cards floating around, but no new ideas are needed. The actual count is $1066$. It breaks down, ordered by the start of the SF, into $176, 105, 99,$ and $98$ each of the remaining SFs (beginning with 4 or greater).
What's the point of just quoting these counts? Well, if we wish, we can obtain the two difficult counts (for $6$ and $7$ suited cards) by brute force enumeration. The number of seven-card hands that can be drawn from a Joker and only the $13$ cards of one suit is a mere $\binom{13+1}{7} = 3432$. Instead of having to search through hundreds of millions of possibilities ($\binom{53}{7} = 154\ 143\ 080$), we can perform an almost instantaneous search, once. The searches over six-card and five-card hands are even shorter.
The total number of SFs, allowing one Joker, therefore is
$$k = 4\left(51\binom{39}{2} + 356\binom{39}{1} + 1066\right) = 210\ 964.$$
From this we obtain the chance of drawing a straight flush as
$$\frac{k}{\binom{53}{7}} = \frac{210\ 964}{154\ 143\ 080} = \frac{4057}{2\ 964\ 290} = 0.00136883\ldots\ .$$
Because it's rather a nuisance to work out the values $356$ and $1066$ with formulas, this solution offers a nice combination of tools: use a little combinatorial reasoning to (greatly) reduce the computation, and then use the computer to avoid working too hard.
Readers who have come this far will be pleased to note that this answer agrees with the one posted earlier by Kodiologist.
|
How many ways to make a straight flush in 7 card poker? (53 card deck with joker)
|
If you think about how you might go about writing efficient code to enumerate all the straight flushes, you can develop a mathematical formula--which is the ultimate efficiency! I will not in fact br
|
How many ways to make a straight flush in 7 card poker? (53 card deck with joker)
If you think about how you might go about writing efficient code to enumerate all the straight flushes, you can develop a mathematical formula--which is the ultimate efficiency! I will not in fact bring you all the way to such a formula, because it's a nuisance. Instead, I will show how to short-circuit both the complicated combinatorial maneuvers and computationally-intensive brute-force searches to find a happy medium in which you can be reasonably certain of getting the correct answer while not having to work too hard to do so.
First, note that it's not possible for a seven-card hand to hold straight flushes (SF) of two different suits, because (apart from a possible Joker) there have to be at least four suited cards in the SF. Therefore we need only count the straight flushes of a given suit, and multiply that count by four to get the total.
Pick a suit, once and for all. Let's divide the problem of finding all the SFs in that suit according to how many cards of that suit (counting the Joker) actually appear in the hand. Since a SF consists of five cards, the (mutually exclusive) possibilities are $7$, $6$, and $5$ cards. Let's count each case. To simplify the notation, let the ranks be 1 (the ace also written as A), 2, ..., 9, T=10, J=11, Q=12, and K=13. The ace can count as rank 14 if that helps to form a SF.
With $5$ cards, they are the SF. Without the Joker, their sorted ranks can be 12345, 23456, ... through TJQKA, of which there are $10$ possibilities. If one of them is the Joker, we have to take care not to double-count. Sort them lexicographically, replacing the Joker (*) with the smallest value that can create a SF. For instance, 3456* is interpreted as 23456 rather than 34567. In this fashion we obtain five more possible ways of forming 12345 (namely, *2345, 1*345, 12*45, 123*5, and 1234*), but only four additional ways of forming the other SFs. (E.g., the five SFs beginning with 3 are 34567, *4567, 3*567, 34*67, and 345*7: the set 3456* would be interpreted as *3456, which begins with 2!) That produces $10 + 4(10) + 1 = 51$ distinct possibilities. There are, independently of these possibilities, $\binom{39}{2}$ ways to select the cards in one of the other three suits.
With $6$ cards, the counting gets more complicated but is not fundamentally different. Note that we cannot blithely count the SFs without a Joker and then multiply that by $6$ to account for the six possible positions a Joker could substitute for. (This is where other attempts at a solution have foundered.) The problem is that this counts some hands multiple times. As an example, consider the hands 89TJQK and 8TJQKA. By substituting a Joker (*) for the 9 in the first and for the Ace in the second, we obtain identical hands 8TJQK*. Instead, we can order the SFs as before, by the start of the lowest SF that can be formed from the cards, but this time we have to multiply the counts by the number of value which that spare sixth card can have without creating a SF with a lower starting value. The resulting count is $356$. It breaks down into $49$ ways to product a SF beginning with an ace, $35$ SF's beginning with 2, and $34$ each of all the rest. As before, this value of $356$ has to be multiplied by the $\binom{39}{1}$ ways to select the seventh card from the other $39$ cards not in the suit.
With $7$ cards, the counting is further complicated because there are two spare cards floating around, but no new ideas are needed. The actual count is $1066$. It breaks down, ordered by the start of the SF, into $176, 105, 99,$ and $98$ each of the remaining SFs (beginning with 4 or greater).
What's the point of just quoting these counts? Well, if we wish, we can obtain the two difficult counts (for $6$ and $7$ suited cards) by brute force enumeration. The number of seven-card hands that can be drawn from a Joker and only the $13$ cards of one suit is a mere $\binom{13+1}{7} = 3432$. Instead of having to search through hundreds of millions of possibilities ($\binom{53}{7} = 154\ 143\ 080$), we can perform an almost instantaneous search, once. The searches over six-card and five-card hands are even shorter.
The total number of SFs, allowing one Joker, therefore is
$$k = 4\left(51\binom{39}{2} + 356\binom{39}{1} + 1066\right) = 210\ 964.$$
From this we obtain the chance of drawing a straight flush as
$$\frac{k}{\binom{53}{7}} = \frac{210\ 964}{154\ 143\ 080} = \frac{4057}{2\ 964\ 290} = 0.00136883\ldots\ .$$
Because it's rather a nuisance to work out the values $356$ and $1066$ with formulas, this solution offers a nice combination of tools: use a little combinatorial reasoning to (greatly) reduce the computation, and then use the computer to avoid working too hard.
Readers who have come this far will be pleased to note that this answer agrees with the one posted earlier by Kodiologist.
|
How many ways to make a straight flush in 7 card poker? (53 card deck with joker)
If you think about how you might go about writing efficient code to enumerate all the straight flushes, you can develop a mathematical formula--which is the ultimate efficiency! I will not in fact br
|
45,290
|
How many ways to make a straight flush in 7 card poker? (53 card deck with joker)
|
Start with how many ways to make a straight
There are 10 as an Ace can be used as low (wheel)
No blocker on an Ace high straight
On any other straight you cannot have the next higher card above or it turns into another straight
1 2 3 4 5 6 7 8 9 10
A x b
K x x b
Q x x x b
J x x x x b
T x x x x x b
9 x x x x x b
8 x x x x x b
7 x x x x x b
6 x x x x x b
5 x x x x x
4 x x x x
3 x x x
2 x x
A x
start withOUT the joker
$$\frac {\binom{4}{1} \binom{47}{2} + \binom{4}{1} \binom{9}{1} \binom{46}{2} } { \binom{52}{7} } = \frac {41584} {133784560} = 0.00031083 \approx \frac {1} {3217}$$
The number for no joker is correct.
Now for the joker
Now have 53 cards
Joker can be used in any straight
Now have 6 ways - raw and joker in any of the five positions
With jokers the possibilities are:
1 2 3 4 5 6 7 8 9 10
A x j x x x x
K x x j x x x
Q x x x j x x
J x x x x j x
T x x x x x j
9
8
7
6
5
4
3
2
A
1 2 3 4 5 6 7 8 9 10
A j
K x j x x x x
Q x x j x x x
J x x x j x x
T x x x x j x
9 x x x x x
8
7
6
5
4
3
2
A
1 2 3 4 5 6 7 8 9 10
A
K j
Q x j x x x x
J x x j x x x
T x x x j x x
9 x x x x j x
8 x x x x x
7
6
5
4
3
2
A
Notice under ace high replacing the bottom card with a joker would make a different straight as then would use the joker as high card and that hand was used in the set above. So joker only adds 4 more hands to the raw.
Also have different number of blockers. Don't use the joker then two blockers to make the next higher. Use the joker and only one blocker.
$$\frac { \binom{4}{1} \binom{6}{1} \binom{48}{2} + \binom{4}{1} \binom{1}{1} \binom{9}{1} \binom{46}{2} + \binom{4}{1} \binom{4}{1} \binom{9}{1} \binom{47}{2} } { \binom{53}{7} } = \frac {27072 + 37260 + 155664} {154143080} = \frac {219996} {154143080} = 0.0014272194 \approx \frac {1}{700.66}$$
Pointed out in a comment this is missing blockers on the bottom
23 56 89 *
23*56
56*89
Note sure if this is the correct way to look at blockers on the bottom but it is a start
1 2 3 4 5 6 7 8 9 10
A x j x x x x
K x x j x x x
Q x x x j x x
J x x x x j x
T x x x x x j
9 b b b b
8 b b b
7 b b
6 b
5
4
3
2
A
1 2 3 4 5 6 7 8 9 10
A bb b b b b j
K x j x x x x
Q x x j x x x
J x x x j x x
T x x x x j x
9 x x x x x
8 b b b b
7 b b b
6 b b
5 b
4
3
2
A
1 2 3 4 5 6 7 8 9 10
A
K bb b b b b j
Q x j x x x x
J x x j x x x
T x x x j x x
9 x x x x j x
8 x x x x x
7 b b b
6 b b
5 b
4
3
2
A
1 2 3 4 5 6 7 8 9 10
A
K
Q
J
T
9 bb b b b b j
8 x j x x x x
7 x x j x x x
6 x x x j x x
5 x x x x j x
4 x x x x x
3 b b b
2 b b
A b
1 2 3 4 5 6 7 8 9 10
A
K
Q
J
T
9
8 bb b b b b j
7 x j x x x x
6 x x j x x x
6 x x x j x x
4 x x x x j x
3 x x x x x
2 b b
A b
1 2 3 4 5 6 7 8 9 10
A
K
Q
J
T
9
8
7 bb b b b b j
6 x j x x x x
5 x x j x x x
4 x x x j x x
3 x x x x j x
2 x x x x x
A b
1 2 3 4 5 6 7 8 9 10
A
K
Q
J
T
9
8
7
6 bb b b b b j
5 x j x x x x
4 x x j x x x
3 x x x j x x
2 x x x x j x
A x x x x x
|
How many ways to make a straight flush in 7 card poker? (53 card deck with joker)
|
Start with how many ways to make a straight
There are 10 as an Ace can be used as low (wheel)
No blocker on an Ace high straight
On any other straight you cannot have the next higher card above or it
|
How many ways to make a straight flush in 7 card poker? (53 card deck with joker)
Start with how many ways to make a straight
There are 10 as an Ace can be used as low (wheel)
No blocker on an Ace high straight
On any other straight you cannot have the next higher card above or it turns into another straight
1 2 3 4 5 6 7 8 9 10
A x b
K x x b
Q x x x b
J x x x x b
T x x x x x b
9 x x x x x b
8 x x x x x b
7 x x x x x b
6 x x x x x b
5 x x x x x
4 x x x x
3 x x x
2 x x
A x
start withOUT the joker
$$\frac {\binom{4}{1} \binom{47}{2} + \binom{4}{1} \binom{9}{1} \binom{46}{2} } { \binom{52}{7} } = \frac {41584} {133784560} = 0.00031083 \approx \frac {1} {3217}$$
The number for no joker is correct.
Now for the joker
Now have 53 cards
Joker can be used in any straight
Now have 6 ways - raw and joker in any of the five positions
With jokers the possibilities are:
1 2 3 4 5 6 7 8 9 10
A x j x x x x
K x x j x x x
Q x x x j x x
J x x x x j x
T x x x x x j
9
8
7
6
5
4
3
2
A
1 2 3 4 5 6 7 8 9 10
A j
K x j x x x x
Q x x j x x x
J x x x j x x
T x x x x j x
9 x x x x x
8
7
6
5
4
3
2
A
1 2 3 4 5 6 7 8 9 10
A
K j
Q x j x x x x
J x x j x x x
T x x x j x x
9 x x x x j x
8 x x x x x
7
6
5
4
3
2
A
Notice under ace high replacing the bottom card with a joker would make a different straight as then would use the joker as high card and that hand was used in the set above. So joker only adds 4 more hands to the raw.
Also have different number of blockers. Don't use the joker then two blockers to make the next higher. Use the joker and only one blocker.
$$\frac { \binom{4}{1} \binom{6}{1} \binom{48}{2} + \binom{4}{1} \binom{1}{1} \binom{9}{1} \binom{46}{2} + \binom{4}{1} \binom{4}{1} \binom{9}{1} \binom{47}{2} } { \binom{53}{7} } = \frac {27072 + 37260 + 155664} {154143080} = \frac {219996} {154143080} = 0.0014272194 \approx \frac {1}{700.66}$$
Pointed out in a comment this is missing blockers on the bottom
23 56 89 *
23*56
56*89
Note sure if this is the correct way to look at blockers on the bottom but it is a start
1 2 3 4 5 6 7 8 9 10
A x j x x x x
K x x j x x x
Q x x x j x x
J x x x x j x
T x x x x x j
9 b b b b
8 b b b
7 b b
6 b
5
4
3
2
A
1 2 3 4 5 6 7 8 9 10
A bb b b b b j
K x j x x x x
Q x x j x x x
J x x x j x x
T x x x x j x
9 x x x x x
8 b b b b
7 b b b
6 b b
5 b
4
3
2
A
1 2 3 4 5 6 7 8 9 10
A
K bb b b b b j
Q x j x x x x
J x x j x x x
T x x x j x x
9 x x x x j x
8 x x x x x
7 b b b
6 b b
5 b
4
3
2
A
1 2 3 4 5 6 7 8 9 10
A
K
Q
J
T
9 bb b b b b j
8 x j x x x x
7 x x j x x x
6 x x x j x x
5 x x x x j x
4 x x x x x
3 b b b
2 b b
A b
1 2 3 4 5 6 7 8 9 10
A
K
Q
J
T
9
8 bb b b b b j
7 x j x x x x
6 x x j x x x
6 x x x j x x
4 x x x x j x
3 x x x x x
2 b b
A b
1 2 3 4 5 6 7 8 9 10
A
K
Q
J
T
9
8
7 bb b b b b j
6 x j x x x x
5 x x j x x x
4 x x x j x x
3 x x x x j x
2 x x x x x
A b
1 2 3 4 5 6 7 8 9 10
A
K
Q
J
T
9
8
7
6 bb b b b b j
5 x j x x x x
4 x x j x x x
3 x x x j x x
2 x x x x j x
A x x x x x
|
How many ways to make a straight flush in 7 card poker? (53 card deck with joker)
Start with how many ways to make a straight
There are 10 as an Ace can be used as low (wheel)
No blocker on an Ace high straight
On any other straight you cannot have the next higher card above or it
|
45,291
|
Tune alpha and lambda parameters of elastic nets in an optimal way
|
Cross-validation is a noisy process and you shouldn't expect the results from two runs to be similar, even if everything is working fine. You can try repeating your experiment several times and see what happens.
That said, here's a narrow answer to this specific question:
Question: How could I tune alpha and lambda for an elastic net in R?
My glmnetUtils package includes a function cva.glmnet to do exactly this. It does cross-validation for both alpha and lambda, with the validation folds held constant (as per the recommendation in ?cv.glmnet).
Sample code:
# it also includes a formula interface: no more messing around with model.matrix()
cva <- cva.glmnet(y ~ ., data=data)
|
Tune alpha and lambda parameters of elastic nets in an optimal way
|
Cross-validation is a noisy process and you shouldn't expect the results from two runs to be similar, even if everything is working fine. You can try repeating your experiment several times and see wh
|
Tune alpha and lambda parameters of elastic nets in an optimal way
Cross-validation is a noisy process and you shouldn't expect the results from two runs to be similar, even if everything is working fine. You can try repeating your experiment several times and see what happens.
That said, here's a narrow answer to this specific question:
Question: How could I tune alpha and lambda for an elastic net in R?
My glmnetUtils package includes a function cva.glmnet to do exactly this. It does cross-validation for both alpha and lambda, with the validation folds held constant (as per the recommendation in ?cv.glmnet).
Sample code:
# it also includes a formula interface: no more messing around with model.matrix()
cva <- cva.glmnet(y ~ ., data=data)
|
Tune alpha and lambda parameters of elastic nets in an optimal way
Cross-validation is a noisy process and you shouldn't expect the results from two runs to be similar, even if everything is working fine. You can try repeating your experiment several times and see wh
|
45,292
|
How to understand the definition of empirical distribution function
|
Why is $\frac{1}{n}$ called mass?
The term "mass" refers to an amount of probability at a single discrete point, as distinct from "density" in relation to continuous distributions.
The CDF puts mass $\frac{1}{n}$ to each data point $X_i$, then, by my understanding, it should be $\frac{1}{n}X_1+\frac{1}{n}X_2+...+\frac{1}{n}X_n$.
That isn't a question, it's a statement -- but your understanding given there is mistaken in a couple of ways at once, so I can discuss that.
First the expression $\frac{1}{n}X_1+\frac{1}{n}X_2+...+\frac{1}{n}X_n$ is actually an expression for the sample mean (as a random variable) -- it literally means to average the values. I presume that you meant instead to write an expression for the empirical probability function here -- but keep in mind that we're meant to be dealing with a distribution function, not the probability function, so you need to find the proportion of the empirical probability that's at or to the left of each possible value of $x$ -- that's how a distribution function represents probability 1/n at each point:
These are two different representations of the same underlying object. You can see that the empirical pmf shows a mass of 1/n at each observed value, while the ecdf shows a height that increases by 1/n at each observed value (and that this corresponds to 1/n times the sum of indicator functions you mentioned)
What is the meaning of "puts" something "at each data point"?
I'm not quite sure exactly what causes the difficulty here, the words essentially take their ordinary meanings; see the images above which show a proportion of $1/n$ at each observed value $x_i$; if you treat the epmf and the ecdf as a pmf and a cdf respectively, those are probabilities. Possibly it is treating $\hat{F}$ as an active entity (one that can "put" things somewhere) that is confusing you -- would it be easier to understand if it said "has" rather than "puts"? If that doesn't help, you'll have to make it clearer what you need explained there.
|
How to understand the definition of empirical distribution function
|
Why is $\frac{1}{n}$ called mass?
The term "mass" refers to an amount of probability at a single discrete point, as distinct from "density" in relation to continuous distributions.
The CDF puts mass
|
How to understand the definition of empirical distribution function
Why is $\frac{1}{n}$ called mass?
The term "mass" refers to an amount of probability at a single discrete point, as distinct from "density" in relation to continuous distributions.
The CDF puts mass $\frac{1}{n}$ to each data point $X_i$, then, by my understanding, it should be $\frac{1}{n}X_1+\frac{1}{n}X_2+...+\frac{1}{n}X_n$.
That isn't a question, it's a statement -- but your understanding given there is mistaken in a couple of ways at once, so I can discuss that.
First the expression $\frac{1}{n}X_1+\frac{1}{n}X_2+...+\frac{1}{n}X_n$ is actually an expression for the sample mean (as a random variable) -- it literally means to average the values. I presume that you meant instead to write an expression for the empirical probability function here -- but keep in mind that we're meant to be dealing with a distribution function, not the probability function, so you need to find the proportion of the empirical probability that's at or to the left of each possible value of $x$ -- that's how a distribution function represents probability 1/n at each point:
These are two different representations of the same underlying object. You can see that the empirical pmf shows a mass of 1/n at each observed value, while the ecdf shows a height that increases by 1/n at each observed value (and that this corresponds to 1/n times the sum of indicator functions you mentioned)
What is the meaning of "puts" something "at each data point"?
I'm not quite sure exactly what causes the difficulty here, the words essentially take their ordinary meanings; see the images above which show a proportion of $1/n$ at each observed value $x_i$; if you treat the epmf and the ecdf as a pmf and a cdf respectively, those are probabilities. Possibly it is treating $\hat{F}$ as an active entity (one that can "put" things somewhere) that is confusing you -- would it be easier to understand if it said "has" rather than "puts"? If that doesn't help, you'll have to make it clearer what you need explained there.
|
How to understand the definition of empirical distribution function
Why is $\frac{1}{n}$ called mass?
The term "mass" refers to an amount of probability at a single discrete point, as distinct from "density" in relation to continuous distributions.
The CDF puts mass
|
45,293
|
Probability of gaussian being smaller than multiple other gaussians
|
Let $C = \{X_1 < \min\{X_2,X_3\}\} = \{(X_1 < X_2)\cap (X_1 < X_3)\}$. Even if the $X_i$ are independent random variables (a condition that the OP has not included), the events $(X_1 < X_2)$ and $(X_1 < X_3)$ are not independent events, and so $P(C) \neq P((X_1 < X_2)P(X_1 < X_3)$. However, continuing to assume independence,
\begin{align}P(C\mid X_1 = a) &= P\{X_1 < \min\{X_2,X_3\}\mid X_1=a\}\\
&= P\{(X_1 < X_2)\cap (X_1 < X_3)\mid X_1=a\}\\
&= P\{(a < X_2)\cap (a < X_3)\}\\
&= P\{a < X_2\}P\{a < X_3\}\\
&= \left[1-\Phi\left(\frac{a-\mu_2}{\sigma_2}\right)\right]\left[1-\Phi\left(\frac{a-\mu_3}{\sigma_3}\right)\right]\end{align}
and so we can write
\begin{align}P(C) &= \int_{-\infty}^\infty P(C\mid X_1 = a)f_{X_1}(a)
\,\mathrm da\\
&= \int_{-\infty}^\infty\left[1-\Phi\left(\frac{a-\mu_2}{\sigma_2}\right)\right]\left[1-\Phi\left(\frac{a-\mu_3}{\sigma_3}\right)\right]\frac{e^{-(a-\mu_1)^2/2\sigma_1^2}}{\sigma_1\sqrt{2\pi}}\,\mathrm da.\end{align}
To the best of my knowledge, there is no closed-form expression for the value of this integral, and so numerical integration, or simulation, must be used to determine the numerical value of $P(C)$.
|
Probability of gaussian being smaller than multiple other gaussians
|
Let $C = \{X_1 < \min\{X_2,X_3\}\} = \{(X_1 < X_2)\cap (X_1 < X_3)\}$. Even if the $X_i$ are independent random variables (a condition that the OP has not included), the events $(X_1 < X_2)$ and $(X_1
|
Probability of gaussian being smaller than multiple other gaussians
Let $C = \{X_1 < \min\{X_2,X_3\}\} = \{(X_1 < X_2)\cap (X_1 < X_3)\}$. Even if the $X_i$ are independent random variables (a condition that the OP has not included), the events $(X_1 < X_2)$ and $(X_1 < X_3)$ are not independent events, and so $P(C) \neq P((X_1 < X_2)P(X_1 < X_3)$. However, continuing to assume independence,
\begin{align}P(C\mid X_1 = a) &= P\{X_1 < \min\{X_2,X_3\}\mid X_1=a\}\\
&= P\{(X_1 < X_2)\cap (X_1 < X_3)\mid X_1=a\}\\
&= P\{(a < X_2)\cap (a < X_3)\}\\
&= P\{a < X_2\}P\{a < X_3\}\\
&= \left[1-\Phi\left(\frac{a-\mu_2}{\sigma_2}\right)\right]\left[1-\Phi\left(\frac{a-\mu_3}{\sigma_3}\right)\right]\end{align}
and so we can write
\begin{align}P(C) &= \int_{-\infty}^\infty P(C\mid X_1 = a)f_{X_1}(a)
\,\mathrm da\\
&= \int_{-\infty}^\infty\left[1-\Phi\left(\frac{a-\mu_2}{\sigma_2}\right)\right]\left[1-\Phi\left(\frac{a-\mu_3}{\sigma_3}\right)\right]\frac{e^{-(a-\mu_1)^2/2\sigma_1^2}}{\sigma_1\sqrt{2\pi}}\,\mathrm da.\end{align}
To the best of my knowledge, there is no closed-form expression for the value of this integral, and so numerical integration, or simulation, must be used to determine the numerical value of $P(C)$.
|
Probability of gaussian being smaller than multiple other gaussians
Let $C = \{X_1 < \min\{X_2,X_3\}\} = \{(X_1 < X_2)\cap (X_1 < X_3)\}$. Even if the $X_i$ are independent random variables (a condition that the OP has not included), the events $(X_1 < X_2)$ and $(X_1
|
45,294
|
Probability of gaussian being smaller than multiple other gaussians
|
In general, your answer is not correct because $P(X<Y)$ and $P(X<Z)$ are not independent and therefore you can't multiply them to get the probability of the intersection.
I'll show a counterexample.
Let $X$, $Y$ and $Z$ be independent random variables with the same distribution. Then all possible permutations are equally probable:
$$P(X<Y<Z)=P(X<Z<Y)=P(Y<X<Z)=P(Y<Z<X)=$$
$$=P(Z<X<Y)=P(Z<Y<X)=\frac{1}{6}$$
You can see that:
$$P(X<Y)=P(X<Z)=\frac{1}{2}$$
But:
$$P(X<Y\text{ and }X<Z)=P(X<Y<Z)+P(X<Z<Y) =\frac{1}{3} \ne$$
$$ \ne P(X<Y) · P(X<Z)=\frac{1}{4}$$
|
Probability of gaussian being smaller than multiple other gaussians
|
In general, your answer is not correct because $P(X<Y)$ and $P(X<Z)$ are not independent and therefore you can't multiply them to get the probability of the intersection.
I'll show a counterexample.
L
|
Probability of gaussian being smaller than multiple other gaussians
In general, your answer is not correct because $P(X<Y)$ and $P(X<Z)$ are not independent and therefore you can't multiply them to get the probability of the intersection.
I'll show a counterexample.
Let $X$, $Y$ and $Z$ be independent random variables with the same distribution. Then all possible permutations are equally probable:
$$P(X<Y<Z)=P(X<Z<Y)=P(Y<X<Z)=P(Y<Z<X)=$$
$$=P(Z<X<Y)=P(Z<Y<X)=\frac{1}{6}$$
You can see that:
$$P(X<Y)=P(X<Z)=\frac{1}{2}$$
But:
$$P(X<Y\text{ and }X<Z)=P(X<Y<Z)+P(X<Z<Y) =\frac{1}{3} \ne$$
$$ \ne P(X<Y) · P(X<Z)=\frac{1}{4}$$
|
Probability of gaussian being smaller than multiple other gaussians
In general, your answer is not correct because $P(X<Y)$ and $P(X<Z)$ are not independent and therefore you can't multiply them to get the probability of the intersection.
I'll show a counterexample.
L
|
45,295
|
Comparing a clustering algorithm partition to a "ground truth" one
|
The Adjusted Rand index could work. It's a popular method for measuring the similarity of two ways of assigning discrete labels to the data, ignoring permutations of the labels themselves. Instead of checking whether the raw class/cluster labels match, you'd look at pairs of points and ask: to what extent are pairs in the same class assigned to the same cluster, and pairs in different classes assigned to different clusters?
To compute the Rand index, you'd measure:
$a$ = Number of pairs that have the same class label and same cluster assignment
$b$ = Number of pairs that have different class labels and different cluster assignments
The raw Rand index is:
$$RI = \frac{a + b}{\binom{n}{2}}$$
where $\binom{n}{2}$ is the number of possible pairs of points. $RI$ ranges from 0 to 1, with 1 indicating total agreement.
However, a random assignment of labels probably wouldn't produce a Rand index of zero. Therefore, it's better to use the adjusted Rand index (ARI), which makes it easier to identify this type of null result. ARI ranges from -1 to 1, where negative and near-zero values indicate chance-level labelings, positive values indicate similar labelings, and 1 indicates perfect agreement.
You can also take a look at other clustering performance metrics here. The metrics that might be useful to you are the ones that compare cluster assignments to ground truth labels (i.e. your class labels): normalized/adjusted mutual information, homogeneity/completeness/v-measure, Fowlkes-Mallows score.
|
Comparing a clustering algorithm partition to a "ground truth" one
|
The Adjusted Rand index could work. It's a popular method for measuring the similarity of two ways of assigning discrete labels to the data, ignoring permutations of the labels themselves. Instead of
|
Comparing a clustering algorithm partition to a "ground truth" one
The Adjusted Rand index could work. It's a popular method for measuring the similarity of two ways of assigning discrete labels to the data, ignoring permutations of the labels themselves. Instead of checking whether the raw class/cluster labels match, you'd look at pairs of points and ask: to what extent are pairs in the same class assigned to the same cluster, and pairs in different classes assigned to different clusters?
To compute the Rand index, you'd measure:
$a$ = Number of pairs that have the same class label and same cluster assignment
$b$ = Number of pairs that have different class labels and different cluster assignments
The raw Rand index is:
$$RI = \frac{a + b}{\binom{n}{2}}$$
where $\binom{n}{2}$ is the number of possible pairs of points. $RI$ ranges from 0 to 1, with 1 indicating total agreement.
However, a random assignment of labels probably wouldn't produce a Rand index of zero. Therefore, it's better to use the adjusted Rand index (ARI), which makes it easier to identify this type of null result. ARI ranges from -1 to 1, where negative and near-zero values indicate chance-level labelings, positive values indicate similar labelings, and 1 indicates perfect agreement.
You can also take a look at other clustering performance metrics here. The metrics that might be useful to you are the ones that compare cluster assignments to ground truth labels (i.e. your class labels): normalized/adjusted mutual information, homogeneity/completeness/v-measure, Fowlkes-Mallows score.
|
Comparing a clustering algorithm partition to a "ground truth" one
The Adjusted Rand index could work. It's a popular method for measuring the similarity of two ways of assigning discrete labels to the data, ignoring permutations of the labels themselves. Instead of
|
45,296
|
SVM - number of dimensions greater than number of samples would give good or bad performance?
|
SVMs, like many other linear models, are based on empirical risk minimization, which leads us to an optimization of this sort:
$$\min_w\sum\ell(x_i, y_i, w)+\lambda\cdot r(w)$$
Where $\ell$ is a loss function (the Hinge-loss in SVMs) and $r$ is a regularization function.
The SVM is a squared $\ell_2$-regularized linear model, i.e. $r(w) = \|w\|^2_2$. This guards against huge coefficients, as one would say in regression terms, as the coefficient magnitudes are themselves penalized in the optimization.
Besides that, the regularization allows for a unique solution in the $p> n$
situation, so the 1st statement is true.
The problem when $p \gg n$ is that the bias introduced by regularization can be so large towards the training data the model heavily underperforms. It doesn't mean SVMs can't be used in that scenario (they are usually employed in gene expression data, for example, where $p$ can be thousands times larger than $n$).
So I see no contradiction in statements. The 2nd statement is more likely a warning against overfitting.
|
SVM - number of dimensions greater than number of samples would give good or bad performance?
|
SVMs, like many other linear models, are based on empirical risk minimization, which leads us to an optimization of this sort:
$$\min_w\sum\ell(x_i, y_i, w)+\lambda\cdot r(w)$$
Where $\ell$ is a loss
|
SVM - number of dimensions greater than number of samples would give good or bad performance?
SVMs, like many other linear models, are based on empirical risk minimization, which leads us to an optimization of this sort:
$$\min_w\sum\ell(x_i, y_i, w)+\lambda\cdot r(w)$$
Where $\ell$ is a loss function (the Hinge-loss in SVMs) and $r$ is a regularization function.
The SVM is a squared $\ell_2$-regularized linear model, i.e. $r(w) = \|w\|^2_2$. This guards against huge coefficients, as one would say in regression terms, as the coefficient magnitudes are themselves penalized in the optimization.
Besides that, the regularization allows for a unique solution in the $p> n$
situation, so the 1st statement is true.
The problem when $p \gg n$ is that the bias introduced by regularization can be so large towards the training data the model heavily underperforms. It doesn't mean SVMs can't be used in that scenario (they are usually employed in gene expression data, for example, where $p$ can be thousands times larger than $n$).
So I see no contradiction in statements. The 2nd statement is more likely a warning against overfitting.
|
SVM - number of dimensions greater than number of samples would give good or bad performance?
SVMs, like many other linear models, are based on empirical risk minimization, which leads us to an optimization of this sort:
$$\min_w\sum\ell(x_i, y_i, w)+\lambda\cdot r(w)$$
Where $\ell$ is a loss
|
45,297
|
SVM - number of dimensions greater than number of samples would give good or bad performance?
|
Still effective in cases where number of dimensions is greater than the number of samples
If the number of features is much greater than the number of samples, the method is likely to give poor performances.
These two points are pretty much contradictory, as one feature is typically one-dimensional (some features may be multidimensional but it is less common).
The first point is the correct one, see SVM, Overfitting, curse of dimensionality and Number of features vs. number of observations for more details.
|
SVM - number of dimensions greater than number of samples would give good or bad performance?
|
Still effective in cases where number of dimensions is greater than the number of samples
If the number of features is much greater than the number of samples, the method is likely to give poor perfor
|
SVM - number of dimensions greater than number of samples would give good or bad performance?
Still effective in cases where number of dimensions is greater than the number of samples
If the number of features is much greater than the number of samples, the method is likely to give poor performances.
These two points are pretty much contradictory, as one feature is typically one-dimensional (some features may be multidimensional but it is less common).
The first point is the correct one, see SVM, Overfitting, curse of dimensionality and Number of features vs. number of observations for more details.
|
SVM - number of dimensions greater than number of samples would give good or bad performance?
Still effective in cases where number of dimensions is greater than the number of samples
If the number of features is much greater than the number of samples, the method is likely to give poor perfor
|
45,298
|
What is the discrete equivalent of the powerlaw distribution?
|
If you want a discrete distribution where $P(X=x)\propto x^{-\alpha}$ for $x=1,2,3,...$ then you would have a zeta distribution.
If you want a discrete distribution where $P(X=x)\propto x^{-\alpha}$ for $x=1,2,3,...,N$ then you would have a truncated zeta distribution, also known as Zipf's law.
On the other hand, if (as at least some authors do) you define a power law up to a slowly varying function, $L(x)$ -- i.e. where say
$P(X=x) = L(x)\cdot x^{-\alpha}\,,\quad x=1,2,3,...$
or
$P(X\gt x) = L(x)\cdot x^{-\alpha}\,,\quad x=1,2,3,...$
then neither of these is a zeta unless $L$ is the identity. Indeed, this definition encompasses an infinity of distributions
|
What is the discrete equivalent of the powerlaw distribution?
|
If you want a discrete distribution where $P(X=x)\propto x^{-\alpha}$ for $x=1,2,3,...$ then you would have a zeta distribution.
If you want a discrete distribution where $P(X=x)\propto x^{-\alpha}$ f
|
What is the discrete equivalent of the powerlaw distribution?
If you want a discrete distribution where $P(X=x)\propto x^{-\alpha}$ for $x=1,2,3,...$ then you would have a zeta distribution.
If you want a discrete distribution where $P(X=x)\propto x^{-\alpha}$ for $x=1,2,3,...,N$ then you would have a truncated zeta distribution, also known as Zipf's law.
On the other hand, if (as at least some authors do) you define a power law up to a slowly varying function, $L(x)$ -- i.e. where say
$P(X=x) = L(x)\cdot x^{-\alpha}\,,\quad x=1,2,3,...$
or
$P(X\gt x) = L(x)\cdot x^{-\alpha}\,,\quad x=1,2,3,...$
then neither of these is a zeta unless $L$ is the identity. Indeed, this definition encompasses an infinity of distributions
|
What is the discrete equivalent of the powerlaw distribution?
If you want a discrete distribution where $P(X=x)\propto x^{-\alpha}$ for $x=1,2,3,...$ then you would have a zeta distribution.
If you want a discrete distribution where $P(X=x)\propto x^{-\alpha}$ f
|
45,299
|
How do gamma distributions add and what would that model?
|
A procedural solution for $n$ tuple convolution is given here.
Q1: The two gamma distribution convolution (GDC) in closed form is only given here
$\mathrm{G}\mathrm{D}\mathrm{C}\left(\mathrm{a}\kern0.1em ,\mathrm{b}\kern0.1em ,\alpha, \beta; \tau \right)=\left\{\begin{array}{cc}\hfill \frac{{\mathrm{b}}^{\mathrm{a}}{\beta}^{\alpha }}{\Gamma \left(\mathrm{a}+\alpha \right)}{e}^{-\mathrm{b}\tau }{\tau^{\mathrm{a}+\alpha-1}}{}_1F_1\left[\alpha, \mathrm{a}+\alpha, \left(\mathrm{b}-\beta \right)\tau \right],\hfill & \hfill \tau >0\hfill \\ {}\hfill \kern2em 0\kern6.6em ,\hfill \kern5.4em \tau \kern0.30em \le \kern0.30em 0\hfill \end{array}\right.,$
which is a density function consisting of a gamma variate multiplied by $_1 F _1(A; B; Z)$, where the latter is a confluent hypergeometric function of the first kind, and see end note below. For $\text{b} = β$, this equation reduces to the well known result
$$\text{iff b}=\beta\text{;}\;{\mathrm{GD}}\left(\mathrm{a},\mathrm{b};\;\tau \right)\otimes {\mathrm{GD}}\left(\alpha, \text{b}; \tau \right)=\text{GD}(\text{a}+α,\text{b} ;τ)$$
An even more general solution with weights is given in Eq. (2) here. Furthermore, that reference lists a non-closed form solution for the sum of $n$ weighted gamma distributions.
Q2: No applications for the GDC have been posted on CV prior to this. Most recently, the GDC has been used in medicine for the first time to model radioactive tracer activity in time in the thyroid gland. GDC models have also been applied for ecological water storage I/O, waiting times in queuing theory, and in the evaluation of aggregate economic risk of portfolios.
End note: The fast computation of the confluent hypergeometric function of the first kind uses the Euler's integral identity ${}_1F_1\left(A;B;Z\right)=\frac{\Gamma \left(B\right)}{\Gamma \left(B-A\right)\Gamma \left(\mathrm{A}\right)}{\displaystyle {\int}_0^1{\mathrm{e}}^{Z\;u}{u}^{A-1}{\left(1-u\right)}^{B-A-1}du}$.
|
How do gamma distributions add and what would that model?
|
A procedural solution for $n$ tuple convolution is given here.
Q1: The two gamma distribution convolution (GDC) in closed form is only given here
$\mathrm{G}\mathrm{D}\mathrm{C}\left(\mathrm{a}\kern
|
How do gamma distributions add and what would that model?
A procedural solution for $n$ tuple convolution is given here.
Q1: The two gamma distribution convolution (GDC) in closed form is only given here
$\mathrm{G}\mathrm{D}\mathrm{C}\left(\mathrm{a}\kern0.1em ,\mathrm{b}\kern0.1em ,\alpha, \beta; \tau \right)=\left\{\begin{array}{cc}\hfill \frac{{\mathrm{b}}^{\mathrm{a}}{\beta}^{\alpha }}{\Gamma \left(\mathrm{a}+\alpha \right)}{e}^{-\mathrm{b}\tau }{\tau^{\mathrm{a}+\alpha-1}}{}_1F_1\left[\alpha, \mathrm{a}+\alpha, \left(\mathrm{b}-\beta \right)\tau \right],\hfill & \hfill \tau >0\hfill \\ {}\hfill \kern2em 0\kern6.6em ,\hfill \kern5.4em \tau \kern0.30em \le \kern0.30em 0\hfill \end{array}\right.,$
which is a density function consisting of a gamma variate multiplied by $_1 F _1(A; B; Z)$, where the latter is a confluent hypergeometric function of the first kind, and see end note below. For $\text{b} = β$, this equation reduces to the well known result
$$\text{iff b}=\beta\text{;}\;{\mathrm{GD}}\left(\mathrm{a},\mathrm{b};\;\tau \right)\otimes {\mathrm{GD}}\left(\alpha, \text{b}; \tau \right)=\text{GD}(\text{a}+α,\text{b} ;τ)$$
An even more general solution with weights is given in Eq. (2) here. Furthermore, that reference lists a non-closed form solution for the sum of $n$ weighted gamma distributions.
Q2: No applications for the GDC have been posted on CV prior to this. Most recently, the GDC has been used in medicine for the first time to model radioactive tracer activity in time in the thyroid gland. GDC models have also been applied for ecological water storage I/O, waiting times in queuing theory, and in the evaluation of aggregate economic risk of portfolios.
End note: The fast computation of the confluent hypergeometric function of the first kind uses the Euler's integral identity ${}_1F_1\left(A;B;Z\right)=\frac{\Gamma \left(B\right)}{\Gamma \left(B-A\right)\Gamma \left(\mathrm{A}\right)}{\displaystyle {\int}_0^1{\mathrm{e}}^{Z\;u}{u}^{A-1}{\left(1-u\right)}^{B-A-1}du}$.
|
How do gamma distributions add and what would that model?
A procedural solution for $n$ tuple convolution is given here.
Q1: The two gamma distribution convolution (GDC) in closed form is only given here
$\mathrm{G}\mathrm{D}\mathrm{C}\left(\mathrm{a}\kern
|
45,300
|
Correlated variables in Cox model - which one is best
|
There is no rule against including correlated predictors in a Cox or a standard multiple regression. In practice it is almost inevitable, particularly in clinical work where there can be multiple standard measures of the severity of disease.
Determining which of 2 "measures of the same thing" is better, however, is difficult. When you have 2 predictors essentially measuring the same thing, the particular predictor that seems to work the best may depend heavily on the particular sample of data that you have on hand.
Bootstrapping as suggested by @smndpln can help show the difficulty. If you run a model including both predictors on multiple bootstrap samples, you might well find that only 1 of the 2 is "significant" in any one bootstrap, but the particular predictor found "significant" is likely to vary from bootstrap to bootstrap. This is an inherent problem with highly correlated predictors, whether in Cox regression or standard multiple regression.
You could try LASSO to see whether either or both of the predictors is maintained in a final model that minimizes cross-validation error, but the particular predictor maintained is also likely to vary among bootstrap sample.
You could try comparing nested models. Run the Cox regression first with the standard predictor, then see whether adding your novel predictor adds significant information with anova() in R or a similar function in other software. Then reverse the order, starting with your novel predictor and seeing whether adding the standard predictor adds anything. But if the 2 predictors are highly correlated, it's unlikely that either will add to what's already provided by the other.
You could also compare the 2 models differing only in which of the 2 predictors is included with the Akaike Information Criterion (AIC). This can show which model is "better" on a particular sample. There are, however, no statistical tests to show how big a difference in AIC is "significant." I suppose you could do this comparison on multiple bootstrap samples to get some measure of "significance," but even then you may be unlikely to find a "significant" difference unless your novel predictor is substantially better than the standard predictor that already measures the same thing. And I would worry about whether any differences you find would necessarily hold in other data samples.
Finally, you might consider proposing a model that includes both measures of the phenomenon in question. For prediction, your model need not be restricted to independent variables that are "significant" by some arbitrary test (unless you have so many predictors that you are in danger of over-fitting). Or you could use ridge regression, which can handle correlated predictors fairly well and minimizes the danger of over-fitting.
|
Correlated variables in Cox model - which one is best
|
There is no rule against including correlated predictors in a Cox or a standard multiple regression. In practice it is almost inevitable, particularly in clinical work where there can be multiple stan
|
Correlated variables in Cox model - which one is best
There is no rule against including correlated predictors in a Cox or a standard multiple regression. In practice it is almost inevitable, particularly in clinical work where there can be multiple standard measures of the severity of disease.
Determining which of 2 "measures of the same thing" is better, however, is difficult. When you have 2 predictors essentially measuring the same thing, the particular predictor that seems to work the best may depend heavily on the particular sample of data that you have on hand.
Bootstrapping as suggested by @smndpln can help show the difficulty. If you run a model including both predictors on multiple bootstrap samples, you might well find that only 1 of the 2 is "significant" in any one bootstrap, but the particular predictor found "significant" is likely to vary from bootstrap to bootstrap. This is an inherent problem with highly correlated predictors, whether in Cox regression or standard multiple regression.
You could try LASSO to see whether either or both of the predictors is maintained in a final model that minimizes cross-validation error, but the particular predictor maintained is also likely to vary among bootstrap sample.
You could try comparing nested models. Run the Cox regression first with the standard predictor, then see whether adding your novel predictor adds significant information with anova() in R or a similar function in other software. Then reverse the order, starting with your novel predictor and seeing whether adding the standard predictor adds anything. But if the 2 predictors are highly correlated, it's unlikely that either will add to what's already provided by the other.
You could also compare the 2 models differing only in which of the 2 predictors is included with the Akaike Information Criterion (AIC). This can show which model is "better" on a particular sample. There are, however, no statistical tests to show how big a difference in AIC is "significant." I suppose you could do this comparison on multiple bootstrap samples to get some measure of "significance," but even then you may be unlikely to find a "significant" difference unless your novel predictor is substantially better than the standard predictor that already measures the same thing. And I would worry about whether any differences you find would necessarily hold in other data samples.
Finally, you might consider proposing a model that includes both measures of the phenomenon in question. For prediction, your model need not be restricted to independent variables that are "significant" by some arbitrary test (unless you have so many predictors that you are in danger of over-fitting). Or you could use ridge regression, which can handle correlated predictors fairly well and minimizes the danger of over-fitting.
|
Correlated variables in Cox model - which one is best
There is no rule against including correlated predictors in a Cox or a standard multiple regression. In practice it is almost inevitable, particularly in clinical work where there can be multiple stan
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.