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 |
|---|---|---|---|---|---|---|
24,001 | Why is Moran's I not equal to "-1" in perfectly dispersed point pattern | Wikipedia, specifically http://en.wikipedia.org/wiki/Moran's_I as I write,
is very wrong on this point.
Although $I$ is a measure of autocorrelation, it is not an exact analogue of any correlation coefficient bounded by $-1$ and $1$. The bounds, unfortunately, are much more complicated.
For a much more careful analysis, see
de Jong, P., Sprenger, C., van Veen, F. 1984.
On extreme Values of Moran's $I$ and Geary's $c$.
Geographical Analysis 16: 17-24.
http://onlinelibrary.wiley.com/doi/10.1111/j.1538-4632.1984.tb00797.x/pdf
I haven't tried to check your calculation. | Why is Moran's I not equal to "-1" in perfectly dispersed point pattern | Wikipedia, specifically http://en.wikipedia.org/wiki/Moran's_I as I write,
is very wrong on this point.
Although $I$ is a measure of autocorrelation, it is not an exact analogue of any correlation c | Why is Moran's I not equal to "-1" in perfectly dispersed point pattern
Wikipedia, specifically http://en.wikipedia.org/wiki/Moran's_I as I write,
is very wrong on this point.
Although $I$ is a measure of autocorrelation, it is not an exact analogue of any correlation coefficient bounded by $-1$ and $1$. The bounds, unfortunately, are much more complicated.
For a much more careful analysis, see
de Jong, P., Sprenger, C., van Veen, F. 1984.
On extreme Values of Moran's $I$ and Geary's $c$.
Geographical Analysis 16: 17-24.
http://onlinelibrary.wiley.com/doi/10.1111/j.1538-4632.1984.tb00797.x/pdf
I haven't tried to check your calculation. | Why is Moran's I not equal to "-1" in perfectly dispersed point pattern
Wikipedia, specifically http://en.wikipedia.org/wiki/Moran's_I as I write,
is very wrong on this point.
Although $I$ is a measure of autocorrelation, it is not an exact analogue of any correlation c |
24,002 | Why is Moran's I not equal to "-1" in perfectly dispersed point pattern | When using Queens contiguity based spatial weights matrix, that is neighbors are only considered to be away by a distance of 1 (and not the same color on the diagonals $\sqrt{2}$ distance away) you get the observed value of Moran's I to be $-1$.
my.dists.bin <- (my.dists == 1)
diag(my.dists.bin) <- 0
library(ape)
Moran.I(my.values, my.dists.bin)
Here is your original image so people understand what I am talking about. This construction makes it so only orange are neighbors to purple and vice versa only purple are neighbors of orange.
I would be impressed if you could concoct a perfect negative auto-correlation with an inverse distance weighted matrix, even with the bounds listed in the citation in Nick Cox's answer. Much of the theory used by economists uses binary contiguity matrices that are row standardized to develop distributions (see Local indicators of spatial association-LISA (Anselin, 1995) from the same Geographical Analysis journal). So in short, many of the results are only proven for particular forms of a weights matrix, which don't tend to be exactly portable for inverse distance weighted (or more exotic) spatial weights matrices. | Why is Moran's I not equal to "-1" in perfectly dispersed point pattern | When using Queens contiguity based spatial weights matrix, that is neighbors are only considered to be away by a distance of 1 (and not the same color on the diagonals $\sqrt{2}$ distance away) you ge | Why is Moran's I not equal to "-1" in perfectly dispersed point pattern
When using Queens contiguity based spatial weights matrix, that is neighbors are only considered to be away by a distance of 1 (and not the same color on the diagonals $\sqrt{2}$ distance away) you get the observed value of Moran's I to be $-1$.
my.dists.bin <- (my.dists == 1)
diag(my.dists.bin) <- 0
library(ape)
Moran.I(my.values, my.dists.bin)
Here is your original image so people understand what I am talking about. This construction makes it so only orange are neighbors to purple and vice versa only purple are neighbors of orange.
I would be impressed if you could concoct a perfect negative auto-correlation with an inverse distance weighted matrix, even with the bounds listed in the citation in Nick Cox's answer. Much of the theory used by economists uses binary contiguity matrices that are row standardized to develop distributions (see Local indicators of spatial association-LISA (Anselin, 1995) from the same Geographical Analysis journal). So in short, many of the results are only proven for particular forms of a weights matrix, which don't tend to be exactly portable for inverse distance weighted (or more exotic) spatial weights matrices. | Why is Moran's I not equal to "-1" in perfectly dispersed point pattern
When using Queens contiguity based spatial weights matrix, that is neighbors are only considered to be away by a distance of 1 (and not the same color on the diagonals $\sqrt{2}$ distance away) you ge |
24,003 | What does bandwidth mean? | The bandwidth is a measure of how closely you want the density to match the distribution.
See help(density):
bw the smoothing bandwidth to be used. The kernels are scaled such
that this is the standard deviation of the smoothing kernel. (Note
this differs from the reference books cited below, and from S-PLUS.)
See also
adjust the bandwidth used is actually adjust*bw. This makes it easy to
specify values like ‘half the default’ bandwidth.
At least for me, bandwidth doesn't match any particular intuition, but you can see the effect of changing it:
set.seed(201010)
x <- rnorm(1000, 10, 2)
par(mfrow = c(2,2))
plot(density(x)) #A bit bumpy
plot(density(x,adjust = 10)) #Very smmoth
plot(density(x,adjust = .1)) #crazy bumpy | What does bandwidth mean? | The bandwidth is a measure of how closely you want the density to match the distribution.
See help(density):
bw the smoothing bandwidth to be used. The kernels are scaled such
that this is the | What does bandwidth mean?
The bandwidth is a measure of how closely you want the density to match the distribution.
See help(density):
bw the smoothing bandwidth to be used. The kernels are scaled such
that this is the standard deviation of the smoothing kernel. (Note
this differs from the reference books cited below, and from S-PLUS.)
See also
adjust the bandwidth used is actually adjust*bw. This makes it easy to
specify values like ‘half the default’ bandwidth.
At least for me, bandwidth doesn't match any particular intuition, but you can see the effect of changing it:
set.seed(201010)
x <- rnorm(1000, 10, 2)
par(mfrow = c(2,2))
plot(density(x)) #A bit bumpy
plot(density(x,adjust = 10)) #Very smmoth
plot(density(x,adjust = .1)) #crazy bumpy | What does bandwidth mean?
The bandwidth is a measure of how closely you want the density to match the distribution.
See help(density):
bw the smoothing bandwidth to be used. The kernels are scaled such
that this is the |
24,004 | Omitted variable bias in linear regression | The main issue here is the nature of the omitted variable bias. Wikipedia states:
Two conditions must hold true for omitted-variable bias to exist in
linear regression:
the omitted variable must be a determinant of the dependent variable (i.e., its true regression coefficient is not zero); and
the omitted variable must be correlated with one or more of the included independent variables (i.e. cov(z,x) is not equal to zero).
It's important to carefully note the second criterion. Your betas will only be biased under certain circumstances. Specifically, if there are two variables that contribute to the response that are correlated with each other, but you only include one of them, then (in essence) the effects of both will be attributed to the included variable, causing bias in the estimation of that parameter. So perhaps only some of your betas are biased, not necessarily all of them.
Another disturbing possibility is that if your sample is not representative of the population (which it rarely really is), and you omit a relevant variable, even if it's uncorrelated with the other variables, this could cause a vertical shift which biases your estimate of the intercept. For example, imagine a variable, $Z$, increases the level of the response, and that your sample is drawn from the upper half of the $Z$ distribution, but $Z$ is not included in your model. Then, your estimate of the population mean response (and the intercept) will be biased high despite the fact that $Z$ is uncorrelated with the other variables. Additionally, there is the possibility that there is an interaction between $Z$ and variables in your model. This can also cause bias without $Z$ being correlated with your variables (I discuss this idea in my answer here.)
Now, given that in its equilibrium state, everything is ultimately correlated with everything in the world, we might find this all very troubling. Indeed, when doing observational research, it is best to always assume that every variable is endogenous.
There are, however, limits to this (c.f., Cornfield's Inequality). First, conducting true experiments breaks the correlation between a focal variable (the treatment) and any otherwise relevant, but unobserved, explanatory variables. There are some statistical techniques that can be used with observational data to account for such unobserved confounds (prototypically: instrumental variables regression, but also others).
Setting these possibilities aside (they probably do represent a minority of modeling approaches), what is the long-run prospect for science? This depends on the magnitude of the bias, and the volume of exploratory research that gets done. Even if the numbers are somewhat off, they may often be in the neighborhood, and sufficiently close that relationships can be discovered. Then, in the long run, researchers can become clearer on which variables are relevant. Indeed, modelers sometimes explicitly trade off increased bias for decreased variance in the sampling distributions of their parameters (c.f., my answer here). In the short run, it's worth always remembering the famous quote from Box:
All models are wrong, but some are useful.
There is also a potentially deeper philosophical question here: What does it mean that the estimate is being biased? What is supposed to be the 'correct' answer? If you gather some observational data about the association between two variables (call them $X$ & $Y$), what you are getting is ultimately the marginal correlation between those two variables. This is only the 'wrong' number if you think you are doing something else, and getting the direct association instead. Likewise, in a study to develop a predictive model, what you care about is whether, in the future, you will be able to accurately guess the value of an unknown $Y$ from a known $X$. If you can, it doesn't matter if that's (in part) because $X$ is correlated with $Z$ which is contributing to the resulting value of $Y$. You wanted to be able to predict $Y$, and you can. | Omitted variable bias in linear regression | The main issue here is the nature of the omitted variable bias. Wikipedia states:
Two conditions must hold true for omitted-variable bias to exist in
linear regression:
the omitted variable must be | Omitted variable bias in linear regression
The main issue here is the nature of the omitted variable bias. Wikipedia states:
Two conditions must hold true for omitted-variable bias to exist in
linear regression:
the omitted variable must be a determinant of the dependent variable (i.e., its true regression coefficient is not zero); and
the omitted variable must be correlated with one or more of the included independent variables (i.e. cov(z,x) is not equal to zero).
It's important to carefully note the second criterion. Your betas will only be biased under certain circumstances. Specifically, if there are two variables that contribute to the response that are correlated with each other, but you only include one of them, then (in essence) the effects of both will be attributed to the included variable, causing bias in the estimation of that parameter. So perhaps only some of your betas are biased, not necessarily all of them.
Another disturbing possibility is that if your sample is not representative of the population (which it rarely really is), and you omit a relevant variable, even if it's uncorrelated with the other variables, this could cause a vertical shift which biases your estimate of the intercept. For example, imagine a variable, $Z$, increases the level of the response, and that your sample is drawn from the upper half of the $Z$ distribution, but $Z$ is not included in your model. Then, your estimate of the population mean response (and the intercept) will be biased high despite the fact that $Z$ is uncorrelated with the other variables. Additionally, there is the possibility that there is an interaction between $Z$ and variables in your model. This can also cause bias without $Z$ being correlated with your variables (I discuss this idea in my answer here.)
Now, given that in its equilibrium state, everything is ultimately correlated with everything in the world, we might find this all very troubling. Indeed, when doing observational research, it is best to always assume that every variable is endogenous.
There are, however, limits to this (c.f., Cornfield's Inequality). First, conducting true experiments breaks the correlation between a focal variable (the treatment) and any otherwise relevant, but unobserved, explanatory variables. There are some statistical techniques that can be used with observational data to account for such unobserved confounds (prototypically: instrumental variables regression, but also others).
Setting these possibilities aside (they probably do represent a minority of modeling approaches), what is the long-run prospect for science? This depends on the magnitude of the bias, and the volume of exploratory research that gets done. Even if the numbers are somewhat off, they may often be in the neighborhood, and sufficiently close that relationships can be discovered. Then, in the long run, researchers can become clearer on which variables are relevant. Indeed, modelers sometimes explicitly trade off increased bias for decreased variance in the sampling distributions of their parameters (c.f., my answer here). In the short run, it's worth always remembering the famous quote from Box:
All models are wrong, but some are useful.
There is also a potentially deeper philosophical question here: What does it mean that the estimate is being biased? What is supposed to be the 'correct' answer? If you gather some observational data about the association between two variables (call them $X$ & $Y$), what you are getting is ultimately the marginal correlation between those two variables. This is only the 'wrong' number if you think you are doing something else, and getting the direct association instead. Likewise, in a study to develop a predictive model, what you care about is whether, in the future, you will be able to accurately guess the value of an unknown $Y$ from a known $X$. If you can, it doesn't matter if that's (in part) because $X$ is correlated with $Z$ which is contributing to the resulting value of $Y$. You wanted to be able to predict $Y$, and you can. | Omitted variable bias in linear regression
The main issue here is the nature of the omitted variable bias. Wikipedia states:
Two conditions must hold true for omitted-variable bias to exist in
linear regression:
the omitted variable must be |
24,005 | If a tennis match was a single large set, how many games would give the same accuracy? | If you play games to $4$ points, where you have to win by $2$, you can assume the players play 6 points. If no player wins by $2$, then the score is tied $3-3$, and then you play pairs of points until one player wins both. This means the the chance to win a game to $4$ points, when your chance to win each point is $p$, is
$$p^6 + 6p^5(1-p) + 15p^4(1-p)^2 + 20 p^3(1-p)^3 \frac{p^2}{p^2 + (1-p)^2}$$.
In top level men's play, $p$ might be about $0.65$ for the server. (It would be $0.66$ if men didn't ease off on the second serve.) According to this formula, the chance to hold serve is about $82.96\%$.
Suppose you are playing a tiebreaker to $7$ points. You can assume that the points are played in pairs where each player serves one of each pair. Who serves first doesn't matter. You can assume the players play $12$ points. If they are tied at that point, then they play pair until one player wins both of a pair, which means the conditional chance to win is $p_sp_r/(p_sp_r + (1-p_s)(1-p_r))$. If I calculate correctly, the chance to win a tiebreaker to $7$ points is
$$ 6 p_r^6 ps + 90 p_r^5 p_s^2 - 105 p_r^6 p_s^2 + 300 p_r^4 p_s^3 -
840 p_r^5 p_s^3 + 560 p_r^6 p_s^3 + 300 p_r^3 p_s^4 - 1575 p_r^4 p_s^4 +
2520 p_r^5 p_s^4 - 1260 p_r^6 p_s^4 + 90 p_r^2 p_s^5 - 840 p_r^3 p_s^5 +
2520 p_r^4 p_s^5 - 3024 p_r^5 p_s^5 + 1260 p_r^6 p_s^5 + 6 p_r p_s^6 -
105 p_r^2 p_s^6 + 560 p_r^3 p_s^6 - 1260 p_r^4 p_s^6 + 1260 p_r^5 p_s^6 -
462 p_r^6 p_s^6 + \frac{p_r p_s}{p_r p_s + (1-p_r)(1-p_s)}(p_r^6 + 36 p_r^5 p_s - 42 p_r^6 p_s + 225 p_r^4 p_s^2 - 630 p_r^5 p_s^2 +
420 p_r^6 p_s^2 + 400 p_r^3 p_s^3 - 2100 p_r^4 p_s^3 + 3360 p_r^5 p_s^3 -
1680 p_r^6 p_s^3 + 225 p_r^2 p_s^4 - 2100 p_r^3 p_s^4 + 6300 p_r^4 p_s^4 -
7560 p_r^5 p_s^4 + 3150 p_r^6 p_s^4 + 36 p_r p_s^5 - 630 p_r^2 p_s^5 +
3360 p_r^3 p_s^5 - 7560 p_r^4 p_s^5 + 7560 p_r^5 p_s^5 -
2772 p_r^6 p_s^5 + p_s^6 - 42 p_r p_s^6 + 420 p_r^2 p_s^6 -
1680 p_r^3 p_s^6 + 3150 p_r^4 p_s^6 - 2772 p_r^5 p_s^6 + 924 p_r^6 p_s^6)$$
If $p_s=0.65, p_r=0.36$ then the chance to win the tie-breaker is about $51.67\%$.
Next, consider a set. It doesn't matter who serves first, which is convenient because otherwise we would have to consider winning the set while having the serve next versys winning the set without keeping the serve. To win a set to $6$ games, you can imagine that $10$ games are played first. If the score is tied $5-5$ then play $2$ more games. If those do not determine the winner, then play a tie-breaker, or in the fifth set just repeat playing pairs of games. Let $p_h$ be the probability of holding serve, and let $p_b$ be the probability of breaking your opponent's serve, which may be calculated above from the probability to win a game. The chance to win a set without a tiebreak follows the same basic formula as the chance to win a tie-breaker, except that we are playing to $6$ games instead of to $7$ points, and we replace $p_s$ by $p_h$ and $p_r$ by $p_b$.
The conditional chance to win a fifth set (a set with no tie-breaker) with $p_s=0.65$ and $p_r=0.36$ is $53.59\%$.
The chance to win a set with a tie-breaker with $p_s=0.65$ and $p_r=0.36$ is $53.30\%$.
The chance to win a best of $5$ sets match, with no tie-breaker in the fifth set, with $p_s=0.65$ and $p_r=0.36$ is $56.28\%$.
So, for these win rates, how many games would there have to be in one set for it to have the same discriminatory power? With $p_s=0.65, p_r=0.36$, you win a set to $24$ games with the usual tiebreaker $56.22\%$, and you win a set to $25$ game with a tie-breaker possible $56.34\%$ of the time. With no tie-breaker, the chance to win a normal match is between sets of length $23$ and $24$. If you simply play one big tie-breaker, the chance to win a tie-breaker of length $113$ is $56.27\%$ and of length $114$ is $56.29\%$.
This suggests that playing one giant set is not more efficient than a best of 5 matches, but playing one giant tie-breaker would be more efficient, at least for closely matched competitors who have an advantage serving.
Here is an excerpt from my March 2013 GammonVillage column, "Game, Set, and Match." I considered coin flips with a fixed advantage ($51\%$) and asked whether it is more efficient to play one big match or a series of shorter matches:
... If a best of three is less efficient than a single long match, we
might expect a best of five to be worse. You win a best of five $13$
point matches with probability $57.51\%$, very close to the chance to win
a single match to $45$. The average number of matches in a best of five
is $4.115$, so the average number of games is $4.115 \times 21.96 = 90.37$. Of
course this is more than the maximum number of games possible in a
match to $45$, and the average is $82.35$. It looks like a longer series
of matches is even less efficient.
How about another level, a best of three series of best of three
matches to $13$? Since each series would be like a match to $29$, this
series of series would be like a best of three matches to $29$, only
less efficient, and one long match would be better than that. So, one
long match would be more efficient than a series of series.
What makes a series of matches less efficient than one long match?
Consider these as statistical tests for collecting evidence to decide
which player is stronger. In a best of three matches, you can lose a
series with scores of $13-7 ~~ 12-13 ~~ 11-13$. This means you would win $36$
games to your opponent's $33$, but your opponent would win the series.
If you toss a coin and get $36$ heads and $33$ tails, you have evidence
that heads is more likely than tails, not that tails is more likely
than heads. So, a best of three matches is inefficient because it
wastes information. A series of matches requires more data on average
because it sometimes awards victory to the player who has won fewer
games. | If a tennis match was a single large set, how many games would give the same accuracy? | If you play games to $4$ points, where you have to win by $2$, you can assume the players play 6 points. If no player wins by $2$, then the score is tied $3-3$, and then you play pairs of points until | If a tennis match was a single large set, how many games would give the same accuracy?
If you play games to $4$ points, where you have to win by $2$, you can assume the players play 6 points. If no player wins by $2$, then the score is tied $3-3$, and then you play pairs of points until one player wins both. This means the the chance to win a game to $4$ points, when your chance to win each point is $p$, is
$$p^6 + 6p^5(1-p) + 15p^4(1-p)^2 + 20 p^3(1-p)^3 \frac{p^2}{p^2 + (1-p)^2}$$.
In top level men's play, $p$ might be about $0.65$ for the server. (It would be $0.66$ if men didn't ease off on the second serve.) According to this formula, the chance to hold serve is about $82.96\%$.
Suppose you are playing a tiebreaker to $7$ points. You can assume that the points are played in pairs where each player serves one of each pair. Who serves first doesn't matter. You can assume the players play $12$ points. If they are tied at that point, then they play pair until one player wins both of a pair, which means the conditional chance to win is $p_sp_r/(p_sp_r + (1-p_s)(1-p_r))$. If I calculate correctly, the chance to win a tiebreaker to $7$ points is
$$ 6 p_r^6 ps + 90 p_r^5 p_s^2 - 105 p_r^6 p_s^2 + 300 p_r^4 p_s^3 -
840 p_r^5 p_s^3 + 560 p_r^6 p_s^3 + 300 p_r^3 p_s^4 - 1575 p_r^4 p_s^4 +
2520 p_r^5 p_s^4 - 1260 p_r^6 p_s^4 + 90 p_r^2 p_s^5 - 840 p_r^3 p_s^5 +
2520 p_r^4 p_s^5 - 3024 p_r^5 p_s^5 + 1260 p_r^6 p_s^5 + 6 p_r p_s^6 -
105 p_r^2 p_s^6 + 560 p_r^3 p_s^6 - 1260 p_r^4 p_s^6 + 1260 p_r^5 p_s^6 -
462 p_r^6 p_s^6 + \frac{p_r p_s}{p_r p_s + (1-p_r)(1-p_s)}(p_r^6 + 36 p_r^5 p_s - 42 p_r^6 p_s + 225 p_r^4 p_s^2 - 630 p_r^5 p_s^2 +
420 p_r^6 p_s^2 + 400 p_r^3 p_s^3 - 2100 p_r^4 p_s^3 + 3360 p_r^5 p_s^3 -
1680 p_r^6 p_s^3 + 225 p_r^2 p_s^4 - 2100 p_r^3 p_s^4 + 6300 p_r^4 p_s^4 -
7560 p_r^5 p_s^4 + 3150 p_r^6 p_s^4 + 36 p_r p_s^5 - 630 p_r^2 p_s^5 +
3360 p_r^3 p_s^5 - 7560 p_r^4 p_s^5 + 7560 p_r^5 p_s^5 -
2772 p_r^6 p_s^5 + p_s^6 - 42 p_r p_s^6 + 420 p_r^2 p_s^6 -
1680 p_r^3 p_s^6 + 3150 p_r^4 p_s^6 - 2772 p_r^5 p_s^6 + 924 p_r^6 p_s^6)$$
If $p_s=0.65, p_r=0.36$ then the chance to win the tie-breaker is about $51.67\%$.
Next, consider a set. It doesn't matter who serves first, which is convenient because otherwise we would have to consider winning the set while having the serve next versys winning the set without keeping the serve. To win a set to $6$ games, you can imagine that $10$ games are played first. If the score is tied $5-5$ then play $2$ more games. If those do not determine the winner, then play a tie-breaker, or in the fifth set just repeat playing pairs of games. Let $p_h$ be the probability of holding serve, and let $p_b$ be the probability of breaking your opponent's serve, which may be calculated above from the probability to win a game. The chance to win a set without a tiebreak follows the same basic formula as the chance to win a tie-breaker, except that we are playing to $6$ games instead of to $7$ points, and we replace $p_s$ by $p_h$ and $p_r$ by $p_b$.
The conditional chance to win a fifth set (a set with no tie-breaker) with $p_s=0.65$ and $p_r=0.36$ is $53.59\%$.
The chance to win a set with a tie-breaker with $p_s=0.65$ and $p_r=0.36$ is $53.30\%$.
The chance to win a best of $5$ sets match, with no tie-breaker in the fifth set, with $p_s=0.65$ and $p_r=0.36$ is $56.28\%$.
So, for these win rates, how many games would there have to be in one set for it to have the same discriminatory power? With $p_s=0.65, p_r=0.36$, you win a set to $24$ games with the usual tiebreaker $56.22\%$, and you win a set to $25$ game with a tie-breaker possible $56.34\%$ of the time. With no tie-breaker, the chance to win a normal match is between sets of length $23$ and $24$. If you simply play one big tie-breaker, the chance to win a tie-breaker of length $113$ is $56.27\%$ and of length $114$ is $56.29\%$.
This suggests that playing one giant set is not more efficient than a best of 5 matches, but playing one giant tie-breaker would be more efficient, at least for closely matched competitors who have an advantage serving.
Here is an excerpt from my March 2013 GammonVillage column, "Game, Set, and Match." I considered coin flips with a fixed advantage ($51\%$) and asked whether it is more efficient to play one big match or a series of shorter matches:
... If a best of three is less efficient than a single long match, we
might expect a best of five to be worse. You win a best of five $13$
point matches with probability $57.51\%$, very close to the chance to win
a single match to $45$. The average number of matches in a best of five
is $4.115$, so the average number of games is $4.115 \times 21.96 = 90.37$. Of
course this is more than the maximum number of games possible in a
match to $45$, and the average is $82.35$. It looks like a longer series
of matches is even less efficient.
How about another level, a best of three series of best of three
matches to $13$? Since each series would be like a match to $29$, this
series of series would be like a best of three matches to $29$, only
less efficient, and one long match would be better than that. So, one
long match would be more efficient than a series of series.
What makes a series of matches less efficient than one long match?
Consider these as statistical tests for collecting evidence to decide
which player is stronger. In a best of three matches, you can lose a
series with scores of $13-7 ~~ 12-13 ~~ 11-13$. This means you would win $36$
games to your opponent's $33$, but your opponent would win the series.
If you toss a coin and get $36$ heads and $33$ tails, you have evidence
that heads is more likely than tails, not that tails is more likely
than heads. So, a best of three matches is inefficient because it
wastes information. A series of matches requires more data on average
because it sometimes awards victory to the player who has won fewer
games. | If a tennis match was a single large set, how many games would give the same accuracy?
If you play games to $4$ points, where you have to win by $2$, you can assume the players play 6 points. If no player wins by $2$, then the score is tied $3-3$, and then you play pairs of points until |
24,006 | How can you detect if a Gaussian process is over-fitting? | The simplest thing to do would be to fit a Gaussian process with the non-ARD equivalent covariance function (usually the RBF) and compare the test error rates. For many problems an ARD covariance function performs worse than a non-ARD covariance function because of over-fitting in tuning the hyper-parameters. As the RBF covariance is a special case of the ARD covariance, if the RBF performs better, it is a strong indication that the ARD kernel is over-fitting (start optimising the ARD coefficients at the optimal values for the corresponding RBF covariance, this is faster, and also helps to ensure that the problem with the ARD covariance is not just due to local minima in the marginal likelihood). This is a much bigger problem than is generally appreciated.
I've written a couple of papers on this:
G. C. Cawley and N. L. C. Talbot, Preventing over-fitting during model selection via Bayesian regularisation of the hyper-parameters, Journal of Machine Learning Research, volume 8, pages 841-861, April 2007 (pdf)
and
G. C. Cawley and N. L. C. Talbot, Over-fitting in model selection and subsequent selection bias in performance evaluation, Journal of Machine Learning Research, 2010. Research, vol. 11, pp. 2079-2107, July 2010 (pdf)
The first includes some experiments with GPs, which show that over-fitting in model selection is also a problem for GPs with marginal likelihood maximisation based model selection.
A more thorough analysis would be to evaluate the test error of the GP at each step in the process of optimising the marginal likelihood. It is highly likely that you will get the classic hall mark of over-fitting, where the model selection criterion is monotonically decreasing, but the test error initially decreases, but then starts to rise again as the model selection criterion is over-optimised (c.f. Figure 2a in the 2010 JMLR paper). | How can you detect if a Gaussian process is over-fitting? | The simplest thing to do would be to fit a Gaussian process with the non-ARD equivalent covariance function (usually the RBF) and compare the test error rates. For many problems an ARD covariance fun | How can you detect if a Gaussian process is over-fitting?
The simplest thing to do would be to fit a Gaussian process with the non-ARD equivalent covariance function (usually the RBF) and compare the test error rates. For many problems an ARD covariance function performs worse than a non-ARD covariance function because of over-fitting in tuning the hyper-parameters. As the RBF covariance is a special case of the ARD covariance, if the RBF performs better, it is a strong indication that the ARD kernel is over-fitting (start optimising the ARD coefficients at the optimal values for the corresponding RBF covariance, this is faster, and also helps to ensure that the problem with the ARD covariance is not just due to local minima in the marginal likelihood). This is a much bigger problem than is generally appreciated.
I've written a couple of papers on this:
G. C. Cawley and N. L. C. Talbot, Preventing over-fitting during model selection via Bayesian regularisation of the hyper-parameters, Journal of Machine Learning Research, volume 8, pages 841-861, April 2007 (pdf)
and
G. C. Cawley and N. L. C. Talbot, Over-fitting in model selection and subsequent selection bias in performance evaluation, Journal of Machine Learning Research, 2010. Research, vol. 11, pp. 2079-2107, July 2010 (pdf)
The first includes some experiments with GPs, which show that over-fitting in model selection is also a problem for GPs with marginal likelihood maximisation based model selection.
A more thorough analysis would be to evaluate the test error of the GP at each step in the process of optimising the marginal likelihood. It is highly likely that you will get the classic hall mark of over-fitting, where the model selection criterion is monotonically decreasing, but the test error initially decreases, but then starts to rise again as the model selection criterion is over-optimised (c.f. Figure 2a in the 2010 JMLR paper). | How can you detect if a Gaussian process is over-fitting?
The simplest thing to do would be to fit a Gaussian process with the non-ARD equivalent covariance function (usually the RBF) and compare the test error rates. For many problems an ARD covariance fun |
24,007 | Difference between Matrix Factorization and PCA | In a sense, PCA is a kind of matrix factorization, since it decomposes a matrix $\bf{X}$ into $\bf{W{\Sigma}V^T}$. However, matrix factorization is a very general term.
Also, see this answer on math.stackexchange. | Difference between Matrix Factorization and PCA | In a sense, PCA is a kind of matrix factorization, since it decomposes a matrix $\bf{X}$ into $\bf{W{\Sigma}V^T}$. However, matrix factorization is a very general term.
Also, see this answer on math.s | Difference between Matrix Factorization and PCA
In a sense, PCA is a kind of matrix factorization, since it decomposes a matrix $\bf{X}$ into $\bf{W{\Sigma}V^T}$. However, matrix factorization is a very general term.
Also, see this answer on math.stackexchange. | Difference between Matrix Factorization and PCA
In a sense, PCA is a kind of matrix factorization, since it decomposes a matrix $\bf{X}$ into $\bf{W{\Sigma}V^T}$. However, matrix factorization is a very general term.
Also, see this answer on math.s |
24,008 | Difference between Matrix Factorization and PCA | PCA, as far as I can tell, is just looking at and doing stuff with the output of factorisation through the Singular Value Decomposition. $\bf{X=U \Sigma V^T}$.
Just in case the question was about factorisation generally. Factorisation would be any breaking up / decomposing of a matrix into a product of other matrices. A different factorisation is the LU, $\bf{X=LU}$, which helps solve systems of equations through elimination. | Difference between Matrix Factorization and PCA | PCA, as far as I can tell, is just looking at and doing stuff with the output of factorisation through the Singular Value Decomposition. $\bf{X=U \Sigma V^T}$.
Just in case the question was about fact | Difference between Matrix Factorization and PCA
PCA, as far as I can tell, is just looking at and doing stuff with the output of factorisation through the Singular Value Decomposition. $\bf{X=U \Sigma V^T}$.
Just in case the question was about factorisation generally. Factorisation would be any breaking up / decomposing of a matrix into a product of other matrices. A different factorisation is the LU, $\bf{X=LU}$, which helps solve systems of equations through elimination. | Difference between Matrix Factorization and PCA
PCA, as far as I can tell, is just looking at and doing stuff with the output of factorisation through the Singular Value Decomposition. $\bf{X=U \Sigma V^T}$.
Just in case the question was about fact |
24,009 | Difference between Matrix Factorization and PCA | There are indeed many Matrix Factorization techniques. You might be interested in this page: https://sites.google.com/site/igorcarron2/matrixfactorizations and thyen let us know which matrix factorization you want to compare with PCA. | Difference between Matrix Factorization and PCA | There are indeed many Matrix Factorization techniques. You might be interested in this page: https://sites.google.com/site/igorcarron2/matrixfactorizations and thyen let us know which matrix factoriza | Difference between Matrix Factorization and PCA
There are indeed many Matrix Factorization techniques. You might be interested in this page: https://sites.google.com/site/igorcarron2/matrixfactorizations and thyen let us know which matrix factorization you want to compare with PCA. | Difference between Matrix Factorization and PCA
There are indeed many Matrix Factorization techniques. You might be interested in this page: https://sites.google.com/site/igorcarron2/matrixfactorizations and thyen let us know which matrix factoriza |
24,010 | Confidence intervals vs sample size? | In addition to Peter's great answer, here are some answers to your specific questions:
Who to trust will depend also on who is doing the poll and what effort they put into getting a good quality poll. A bigger sample size is not better if the sample is not representative, taking a huge poll, but only in one, non-swing state would not give very good results.
There is a relationship between sample size and the width of the confidence interval, but other things also influence the width, such as how close the percentage is to 0, 1, or 0.5; what bias adjustments were used, how the sample was taken (clustering, stratification, etc.). The general rule is that the width of the confidence interval will be proportional to $\frac{1}{\sqrt{n}}$, so to halve the interval you need 4 times the sample size.
If you know enough about how the sample was collected and what formula was used to compute the interval then you could solve for the standard deviation (you also need to know the confidence level being used, usually 0.05). But the formula is different for stratified vs. cluster samples. Also most polls look at percentages, so would use the binomial distribution.
There are ways to combine the information, but you would generally need to know something about how the samples were collected, or be willing to make some form of assumptions about how the intervals were constructed. A Bayesian approach is one way. | Confidence intervals vs sample size? | In addition to Peter's great answer, here are some answers to your specific questions:
Who to trust will depend also on who is doing the poll and what effort they put into getting a good quality poll | Confidence intervals vs sample size?
In addition to Peter's great answer, here are some answers to your specific questions:
Who to trust will depend also on who is doing the poll and what effort they put into getting a good quality poll. A bigger sample size is not better if the sample is not representative, taking a huge poll, but only in one, non-swing state would not give very good results.
There is a relationship between sample size and the width of the confidence interval, but other things also influence the width, such as how close the percentage is to 0, 1, or 0.5; what bias adjustments were used, how the sample was taken (clustering, stratification, etc.). The general rule is that the width of the confidence interval will be proportional to $\frac{1}{\sqrt{n}}$, so to halve the interval you need 4 times the sample size.
If you know enough about how the sample was collected and what formula was used to compute the interval then you could solve for the standard deviation (you also need to know the confidence level being used, usually 0.05). But the formula is different for stratified vs. cluster samples. Also most polls look at percentages, so would use the binomial distribution.
There are ways to combine the information, but you would generally need to know something about how the samples were collected, or be willing to make some form of assumptions about how the intervals were constructed. A Bayesian approach is one way. | Confidence intervals vs sample size?
In addition to Peter's great answer, here are some answers to your specific questions:
Who to trust will depend also on who is doing the poll and what effort they put into getting a good quality poll |
24,011 | Confidence intervals vs sample size? | This is a huge topic, but basically there are two issues:
1) Precision - this is determined by the sample size. Larger samples give more precise estimates with lower standard error and tighter confidence intervals
2) Bias - which, in statistics, doesn't necessarily have the negative connotations it does elsewhere. In polls, they try to get a random sample of XXXX (sometimes likely voters, sometimes registered voters). But, they don't. Some polls only use land lines. Different groups of people are more or less likely to answer. Different groups are more or less likely to just hang up.
So, all pollsters weight their responses. That is, they try to adjust their results to match known facts about voters. But they all do it a little differently. So, even with the same polling input data, they will give different numbers.
Who to trust? Well, if you look at Nate Silver's work on 538, he has ratings of how accurate pollsters were in previous elections. But that doesn't mean they will be equally accurate now. | Confidence intervals vs sample size? | This is a huge topic, but basically there are two issues:
1) Precision - this is determined by the sample size. Larger samples give more precise estimates with lower standard error and tighter confide | Confidence intervals vs sample size?
This is a huge topic, but basically there are two issues:
1) Precision - this is determined by the sample size. Larger samples give more precise estimates with lower standard error and tighter confidence intervals
2) Bias - which, in statistics, doesn't necessarily have the negative connotations it does elsewhere. In polls, they try to get a random sample of XXXX (sometimes likely voters, sometimes registered voters). But, they don't. Some polls only use land lines. Different groups of people are more or less likely to answer. Different groups are more or less likely to just hang up.
So, all pollsters weight their responses. That is, they try to adjust their results to match known facts about voters. But they all do it a little differently. So, even with the same polling input data, they will give different numbers.
Who to trust? Well, if you look at Nate Silver's work on 538, he has ratings of how accurate pollsters were in previous elections. But that doesn't mean they will be equally accurate now. | Confidence intervals vs sample size?
This is a huge topic, but basically there are two issues:
1) Precision - this is determined by the sample size. Larger samples give more precise estimates with lower standard error and tighter confide |
24,012 | Confidence intervals vs sample size? | This falls in the area of survey sampling. In principle, the methods work because randomization is used. Here are the things that can differ in polls based on subjective decisions.
Sampling frame. What group of voters should I draw my sample from?
How do I handle the volatility of the undecided voter who may change his opinion on Obama vs Romney based on yesterday's poll or next week?
Peter has touched on the bias. The literary digest poll of 1936 was a disaster. It picked the Republican candidate over FDR because the sampling frame was based on a random selection of telephone numbers. In 1936 only the upper middle class and the wealthy had phones. That group was dominated by Republicans who tend to vote for the Republican candidate. Roosevelt won by a landslide getting his votes from the poor and the middle class which tended to be very much a group of Democrats! That illustrates bias due to the subtly poor choice of a sampling frame.
Survey sampling deals with finite populations. The population size is N. Say a simple random sample is drawn from that population and has size n. For simplicity assume only Obama and Romney are running. The proportion of votes Obama would get for this sampling frame is an average of binary variables (say 1 if the respondent picks Obama and 0 for Romney). The variance of the sample mean for this variable is [p(1-p)/n][N-n]/N
where p is the true population proportion that would pick Obama. [N-n]/N is the finite population correction. in most polls, N is much bigger than N and the correct can be ignored. Looking at p(1-p)/n we see the variance goes down with n. So if n is large the confidence interval at a given confidence level will get small. It is this variance (really its square root) that is used to get the margin of error that gets quoted.
Pollsters other survey samplers and statisticians at the US Census Bureau all have these statistical tools at their disposal and they do more complex and accurate methods (cluster random sample and stratified random sampling to mention a couple of methods).
When their modeling assumptions are valid the methods work remarkably well. Exit polling is a prime example. On election day you will see the networks accurately project winner in almost every state long before a near-final count. That is because preelection day variability is gone. They know historically how people tended to vote and they can determine selected precincts in a way that avoids bias. The networks sometimes differ. This can be due to a competition to pick the winner ahead of the others' mentality. It also can in rare instances be because the vote is extremely close (e.g Presidential Election 2000 in Florida).
I hope this gives you a clearer picture of what goes on. We no longer see gross mistakes like "Dewey defeats Truman" in 1948 or the Literary Digest fiasco of 1936. But statistics is not perfect and statisticians can never say that they are certain. | Confidence intervals vs sample size? | This falls in the area of survey sampling. In principle, the methods work because randomization is used. Here are the things that can differ in polls based on subjective decisions.
Sampling frame. | Confidence intervals vs sample size?
This falls in the area of survey sampling. In principle, the methods work because randomization is used. Here are the things that can differ in polls based on subjective decisions.
Sampling frame. What group of voters should I draw my sample from?
How do I handle the volatility of the undecided voter who may change his opinion on Obama vs Romney based on yesterday's poll or next week?
Peter has touched on the bias. The literary digest poll of 1936 was a disaster. It picked the Republican candidate over FDR because the sampling frame was based on a random selection of telephone numbers. In 1936 only the upper middle class and the wealthy had phones. That group was dominated by Republicans who tend to vote for the Republican candidate. Roosevelt won by a landslide getting his votes from the poor and the middle class which tended to be very much a group of Democrats! That illustrates bias due to the subtly poor choice of a sampling frame.
Survey sampling deals with finite populations. The population size is N. Say a simple random sample is drawn from that population and has size n. For simplicity assume only Obama and Romney are running. The proportion of votes Obama would get for this sampling frame is an average of binary variables (say 1 if the respondent picks Obama and 0 for Romney). The variance of the sample mean for this variable is [p(1-p)/n][N-n]/N
where p is the true population proportion that would pick Obama. [N-n]/N is the finite population correction. in most polls, N is much bigger than N and the correct can be ignored. Looking at p(1-p)/n we see the variance goes down with n. So if n is large the confidence interval at a given confidence level will get small. It is this variance (really its square root) that is used to get the margin of error that gets quoted.
Pollsters other survey samplers and statisticians at the US Census Bureau all have these statistical tools at their disposal and they do more complex and accurate methods (cluster random sample and stratified random sampling to mention a couple of methods).
When their modeling assumptions are valid the methods work remarkably well. Exit polling is a prime example. On election day you will see the networks accurately project winner in almost every state long before a near-final count. That is because preelection day variability is gone. They know historically how people tended to vote and they can determine selected precincts in a way that avoids bias. The networks sometimes differ. This can be due to a competition to pick the winner ahead of the others' mentality. It also can in rare instances be because the vote is extremely close (e.g Presidential Election 2000 in Florida).
I hope this gives you a clearer picture of what goes on. We no longer see gross mistakes like "Dewey defeats Truman" in 1948 or the Literary Digest fiasco of 1936. But statistics is not perfect and statisticians can never say that they are certain. | Confidence intervals vs sample size?
This falls in the area of survey sampling. In principle, the methods work because randomization is used. Here are the things that can differ in polls based on subjective decisions.
Sampling frame. |
24,013 | Can I assume (log-)normality for this sample? | These data have a short tail compared to a lognormal distribution, not unlike a Gamma distribution:
set.seed(17)
par(mfcol=c(1,1))
x <- rgamma(500, 1.9)
qqnorm(log(x), pch=20, cex=.8, asp=1)
abline(mean(log(x)) + .1,1.2*sd(log(x)), col="Gray", lwd=2)
Nevertheless, because the data are strongly right-skewed, we can expect the largest values to play an important role in estimating the mean and its confidence interval. Therefore we should anticipate that a lognormal (LN) estimator will tend to overestimate the mean and the two confidence limits.
Let's check and, for comparison, use the usual estimators: that is, the sample mean and its normal-theory confidence interval. Note that the usual estimators rely only on the approximate normality of the sample mean, not of the data, and--with such a large dataset--can be expected to work well. To do this, we need a slight modification of the ci function:
ci <- function (x, alpha=.05) {
z <- -qnorm(alpha / 2)
y <- log(x); n <- length(y); s2 <- var(y)
m <- mean(y) + s2 / 2
d <- z * sqrt(s2 / n + s2 * s2 / (2 * (n - 1)))
exp(c(mean=m, lcl=m-d, ucl=m+d))
}
Here is a parallel function for the normal-theory estimates:
ci.u <- function(x, alpha=.05) {
mean(x) + sd(x) * c(mean=0, lcl=1, ucl=-1) / sqrt(length(x)) * qnorm(alpha/2)
}
Applied to this simulated dataset, the outputs are
> ci(x)
mean lcl ucl
2.03965 1.87712 2.21626
> ci.u(x)
mean lcl ucl
1.94301 1.81382 2.07219
The normal-theory estimates produced by ci.u look a little closer to the true mean of $1.9$, but it's hard to tell from one dataset which procedure tends to work better. To find out, let's simulate a lot of datasets:
trial <- function(n=500, k=1.9) {
x <- rgamma(n, k)
cbind(ci(x), ci.u(x))
}
set.seed(17)
sim <- replicate(5000, trial())
We are interested in comparing the outputs to the true mean of $1.9$. A panel of histograms is revealing in that regard:
xmin <- min(sim)
xmax <- max(sim)
h <- function(i, ...) {
b <- seq(from=floor(xmin*10)/10, to=ceiling(xmax*10)/10, by=0.1)
hist(sim[i,], freq=TRUE, breaks=b, col="#a0a0FF", xlab="x", xlim=c(xmin, xmax), ...)
hist(sim[i,sim[i,] >= 1.9], add=TRUE,freq=TRUE, breaks=b, col="#FFa0a0",
xlab="x", xlim=c(xmin, xmax), ...)
}
par(mfcol=c(2,3))
h(1, main="LN Estimate of Mean")
h(4, main="Sample Mean")
h(2, main="LN LCL")
h(5, main="LCL")
h(3, main="LN UCL")
h(6, main="UCL")
It is now clear that the lognormal procedures tend to overestimate the mean and the confidence limits, whereas the usual procedures do a good job. We can estimate the coverages of the confidence interval procedures:
> sapply(c(LNLCL=2, LCL=5, LNUCL=3, UCL=6), function(i) sum(sim[i,] > 1.9)/dim(sim)[2])
LNLCL LCL LNUCL UCL
0.2230 0.0234 1.0000 0.9648
This calculation says:
The LN lower limit will fail to cover the true mean about 22.3% of the time (instead of the intended 2.5%).
The usual lower limit will fail to cover the true mean about 2.3% of the time, close to the intended 2.5%.
The LN upper limit will always exceed the true mean (instead of falling below it 2.5% of the time as intended). This makes it a two-sided 100% - (22.3% + 0%) = 77.7% confidence interval instead of a 95% confidence interval.
The usual upper limit will fail to cover the true mean about 100 - 96.5 = 3.5% of the time. This is a little greater than the intended value of 2.5%. The usual limits therefore comprise a two-sided 100% - (2.3% + 3.5%) = 94.2% confidence interval instead of a 95% confidence interval.
The reduction of the nominal coverage from 95% to 77.7% for the lognormal interval is terrible. The reduction to 94.2% for the usual interval is not bad at all and can be attributed to the effect of the skewness (of the raw data, not of their logarithms).
We have to conclude that further analyses of the mean should not assume lognormality.
Be careful! Some procedures (such as prediction limits) will be more sensitive to skewness than these confidence limits for the mean, so their skewed distribution may need to be accounted for. However, it looks unlikely that lognormal procedures will perform well with these data for practically any intended analysis. | Can I assume (log-)normality for this sample? | These data have a short tail compared to a lognormal distribution, not unlike a Gamma distribution:
set.seed(17)
par(mfcol=c(1,1))
x <- rgamma(500, 1.9)
qqnorm(log(x), pch=20, cex=.8, asp=1)
abline(me | Can I assume (log-)normality for this sample?
These data have a short tail compared to a lognormal distribution, not unlike a Gamma distribution:
set.seed(17)
par(mfcol=c(1,1))
x <- rgamma(500, 1.9)
qqnorm(log(x), pch=20, cex=.8, asp=1)
abline(mean(log(x)) + .1,1.2*sd(log(x)), col="Gray", lwd=2)
Nevertheless, because the data are strongly right-skewed, we can expect the largest values to play an important role in estimating the mean and its confidence interval. Therefore we should anticipate that a lognormal (LN) estimator will tend to overestimate the mean and the two confidence limits.
Let's check and, for comparison, use the usual estimators: that is, the sample mean and its normal-theory confidence interval. Note that the usual estimators rely only on the approximate normality of the sample mean, not of the data, and--with such a large dataset--can be expected to work well. To do this, we need a slight modification of the ci function:
ci <- function (x, alpha=.05) {
z <- -qnorm(alpha / 2)
y <- log(x); n <- length(y); s2 <- var(y)
m <- mean(y) + s2 / 2
d <- z * sqrt(s2 / n + s2 * s2 / (2 * (n - 1)))
exp(c(mean=m, lcl=m-d, ucl=m+d))
}
Here is a parallel function for the normal-theory estimates:
ci.u <- function(x, alpha=.05) {
mean(x) + sd(x) * c(mean=0, lcl=1, ucl=-1) / sqrt(length(x)) * qnorm(alpha/2)
}
Applied to this simulated dataset, the outputs are
> ci(x)
mean lcl ucl
2.03965 1.87712 2.21626
> ci.u(x)
mean lcl ucl
1.94301 1.81382 2.07219
The normal-theory estimates produced by ci.u look a little closer to the true mean of $1.9$, but it's hard to tell from one dataset which procedure tends to work better. To find out, let's simulate a lot of datasets:
trial <- function(n=500, k=1.9) {
x <- rgamma(n, k)
cbind(ci(x), ci.u(x))
}
set.seed(17)
sim <- replicate(5000, trial())
We are interested in comparing the outputs to the true mean of $1.9$. A panel of histograms is revealing in that regard:
xmin <- min(sim)
xmax <- max(sim)
h <- function(i, ...) {
b <- seq(from=floor(xmin*10)/10, to=ceiling(xmax*10)/10, by=0.1)
hist(sim[i,], freq=TRUE, breaks=b, col="#a0a0FF", xlab="x", xlim=c(xmin, xmax), ...)
hist(sim[i,sim[i,] >= 1.9], add=TRUE,freq=TRUE, breaks=b, col="#FFa0a0",
xlab="x", xlim=c(xmin, xmax), ...)
}
par(mfcol=c(2,3))
h(1, main="LN Estimate of Mean")
h(4, main="Sample Mean")
h(2, main="LN LCL")
h(5, main="LCL")
h(3, main="LN UCL")
h(6, main="UCL")
It is now clear that the lognormal procedures tend to overestimate the mean and the confidence limits, whereas the usual procedures do a good job. We can estimate the coverages of the confidence interval procedures:
> sapply(c(LNLCL=2, LCL=5, LNUCL=3, UCL=6), function(i) sum(sim[i,] > 1.9)/dim(sim)[2])
LNLCL LCL LNUCL UCL
0.2230 0.0234 1.0000 0.9648
This calculation says:
The LN lower limit will fail to cover the true mean about 22.3% of the time (instead of the intended 2.5%).
The usual lower limit will fail to cover the true mean about 2.3% of the time, close to the intended 2.5%.
The LN upper limit will always exceed the true mean (instead of falling below it 2.5% of the time as intended). This makes it a two-sided 100% - (22.3% + 0%) = 77.7% confidence interval instead of a 95% confidence interval.
The usual upper limit will fail to cover the true mean about 100 - 96.5 = 3.5% of the time. This is a little greater than the intended value of 2.5%. The usual limits therefore comprise a two-sided 100% - (2.3% + 3.5%) = 94.2% confidence interval instead of a 95% confidence interval.
The reduction of the nominal coverage from 95% to 77.7% for the lognormal interval is terrible. The reduction to 94.2% for the usual interval is not bad at all and can be attributed to the effect of the skewness (of the raw data, not of their logarithms).
We have to conclude that further analyses of the mean should not assume lognormality.
Be careful! Some procedures (such as prediction limits) will be more sensitive to skewness than these confidence limits for the mean, so their skewed distribution may need to be accounted for. However, it looks unlikely that lognormal procedures will perform well with these data for practically any intended analysis. | Can I assume (log-)normality for this sample?
These data have a short tail compared to a lognormal distribution, not unlike a Gamma distribution:
set.seed(17)
par(mfcol=c(1,1))
x <- rgamma(500, 1.9)
qqnorm(log(x), pch=20, cex=.8, asp=1)
abline(me |
24,014 | Feature selection and parameter tuning with caret for random forest | One thing you might want to look into are regularized random forests, which are specifically designed for feature selection. This paper explains the concept, and how they differ from normal random forests
Feature Selection via Regularized Trees
There's also a CRAN package RRF that's build on the randomForest that will allow you to implement them easily in R. I've had good luck with this methodology myself.
Regarding your initial question, the only advice I can give is that if you have a lot of collinearity then you need to use smaller tree sizes. This allows the algorithm to determine importance with less interference from collinearity effects. | Feature selection and parameter tuning with caret for random forest | One thing you might want to look into are regularized random forests, which are specifically designed for feature selection. This paper explains the concept, and how they differ from normal random for | Feature selection and parameter tuning with caret for random forest
One thing you might want to look into are regularized random forests, which are specifically designed for feature selection. This paper explains the concept, and how they differ from normal random forests
Feature Selection via Regularized Trees
There's also a CRAN package RRF that's build on the randomForest that will allow you to implement them easily in R. I've had good luck with this methodology myself.
Regarding your initial question, the only advice I can give is that if you have a lot of collinearity then you need to use smaller tree sizes. This allows the algorithm to determine importance with less interference from collinearity effects. | Feature selection and parameter tuning with caret for random forest
One thing you might want to look into are regularized random forests, which are specifically designed for feature selection. This paper explains the concept, and how they differ from normal random for |
24,015 | Feature selection and parameter tuning with caret for random forest | You might be able to use caretFuncs
Something like this:
myRFE <- caretFuncs
myRFE$summary <- twoClassSummary (default is defaultSummary)
rctrl <- rfeControl(method='repeatedcv', repeats=5, number=10,
functions=myRFE)
tctrl <- trainControl(method = "cv",
classProbs = TRUE,
summaryFunction = twoClassSummary)
rfeObj = rfe(x,y,sizes=seq(1,ncol(x),2),
rfeControl=rctrl,
# to be passed to train()
method='rf',
importance=T, # do not forget this
ntree=1000,
metric = "ROC",
tuneLength = 10,
# mtry=c(1,3,5,50),
# specify the exact mtry, or tuneLength
# can auto truncate the grid to minimal sizes (with or without warning)
# p <- ncol(x) ... if (mtry < 1 || mtry > p) warning("invalid try: reset to within valid range") try <- max(1, min(p, round(try)))
trControl=tctrl)
Also, one may check valSelRF package. Not sure how it differs from regularized random forest mentioned here. | Feature selection and parameter tuning with caret for random forest | You might be able to use caretFuncs
Something like this:
myRFE <- caretFuncs
myRFE$summary <- twoClassSummary (default is defaultSummary)
rctrl <- rfeControl(method='repeatedcv', repeats=5, number=1 | Feature selection and parameter tuning with caret for random forest
You might be able to use caretFuncs
Something like this:
myRFE <- caretFuncs
myRFE$summary <- twoClassSummary (default is defaultSummary)
rctrl <- rfeControl(method='repeatedcv', repeats=5, number=10,
functions=myRFE)
tctrl <- trainControl(method = "cv",
classProbs = TRUE,
summaryFunction = twoClassSummary)
rfeObj = rfe(x,y,sizes=seq(1,ncol(x),2),
rfeControl=rctrl,
# to be passed to train()
method='rf',
importance=T, # do not forget this
ntree=1000,
metric = "ROC",
tuneLength = 10,
# mtry=c(1,3,5,50),
# specify the exact mtry, or tuneLength
# can auto truncate the grid to minimal sizes (with or without warning)
# p <- ncol(x) ... if (mtry < 1 || mtry > p) warning("invalid try: reset to within valid range") try <- max(1, min(p, round(try)))
trControl=tctrl)
Also, one may check valSelRF package. Not sure how it differs from regularized random forest mentioned here. | Feature selection and parameter tuning with caret for random forest
You might be able to use caretFuncs
Something like this:
myRFE <- caretFuncs
myRFE$summary <- twoClassSummary (default is defaultSummary)
rctrl <- rfeControl(method='repeatedcv', repeats=5, number=1 |
24,016 | Fisher Test in R | greater (or less) refers to a one-sided test comparing a null hypothesis
that p1=p2 to the alternative p1>p2 (or p1<p2). In contrast, a two-sided
test compares the null hypotheses to the alternative that p1 is not equal to
p2.
For your table the proportion of dieters that are male is 1/4 = 0.25 (10 out
of 40) in your sample. On the other hand, the proportion of non-dieters that are
male is 1/13 or (5 out of 65) equal to 0.077 in the sample. So then the
estimate for p1 is 0.25 and for p2 is 0.077. Therefore it appears that
p1>p2.
That is why for the one-sided alternative p1>p2 the p-value is 0.01588.
(Small p-values indicate the null hypothesis is unlikely and the alternative is
likely.)
When the alternative is p1<p2 we see that your data indicated that the
difference is in the wrong (or unanticipated) direction.
That is why in that case the p-value is so high 0.9967. For the two-sided
alternative the p-value should be a little higher than for the one-sided
alternative p1>p2. And indeed, it is with p-value equal to 0.02063. | Fisher Test in R | greater (or less) refers to a one-sided test comparing a null hypothesis
that p1=p2 to the alternative p1>p2 (or p1<p2). In contrast, a two-sided
test compares the null hypotheses to the alternative t | Fisher Test in R
greater (or less) refers to a one-sided test comparing a null hypothesis
that p1=p2 to the alternative p1>p2 (or p1<p2). In contrast, a two-sided
test compares the null hypotheses to the alternative that p1 is not equal to
p2.
For your table the proportion of dieters that are male is 1/4 = 0.25 (10 out
of 40) in your sample. On the other hand, the proportion of non-dieters that are
male is 1/13 or (5 out of 65) equal to 0.077 in the sample. So then the
estimate for p1 is 0.25 and for p2 is 0.077. Therefore it appears that
p1>p2.
That is why for the one-sided alternative p1>p2 the p-value is 0.01588.
(Small p-values indicate the null hypothesis is unlikely and the alternative is
likely.)
When the alternative is p1<p2 we see that your data indicated that the
difference is in the wrong (or unanticipated) direction.
That is why in that case the p-value is so high 0.9967. For the two-sided
alternative the p-value should be a little higher than for the one-sided
alternative p1>p2. And indeed, it is with p-value equal to 0.02063. | Fisher Test in R
greater (or less) refers to a one-sided test comparing a null hypothesis
that p1=p2 to the alternative p1>p2 (or p1<p2). In contrast, a two-sided
test compares the null hypotheses to the alternative t |
24,017 | Domain-agnostic feature engineering that retains semantic meaning? | I am aware of one decomposition method (but maybe there are more...) that can be useful in a scenarios like you describe. It is like 2D-PCA - a high order decomposition method where the decomposition (i.e the factors) have some meaning. You can see examples and read about it here and here and try to here | Domain-agnostic feature engineering that retains semantic meaning? | I am aware of one decomposition method (but maybe there are more...) that can be useful in a scenarios like you describe. It is like 2D-PCA - a high order decomposition method where the decomposition | Domain-agnostic feature engineering that retains semantic meaning?
I am aware of one decomposition method (but maybe there are more...) that can be useful in a scenarios like you describe. It is like 2D-PCA - a high order decomposition method where the decomposition (i.e the factors) have some meaning. You can see examples and read about it here and here and try to here | Domain-agnostic feature engineering that retains semantic meaning?
I am aware of one decomposition method (but maybe there are more...) that can be useful in a scenarios like you describe. It is like 2D-PCA - a high order decomposition method where the decomposition |
24,018 | Domain-agnostic feature engineering that retains semantic meaning? | Recent deep learning methods using Restricted Boltzmann Machine have shown nice features on several data types (audio, images, text).
Since these methods create a generative model, you can often generate really nice samples from the model.
Check out Hinton's publications.
http://www.cs.toronto.edu/~hinton/
These methods aren't totally general (run same code on every data), but the underlying model is usually similar. | Domain-agnostic feature engineering that retains semantic meaning? | Recent deep learning methods using Restricted Boltzmann Machine have shown nice features on several data types (audio, images, text).
Since these methods create a generative model, you can often gener | Domain-agnostic feature engineering that retains semantic meaning?
Recent deep learning methods using Restricted Boltzmann Machine have shown nice features on several data types (audio, images, text).
Since these methods create a generative model, you can often generate really nice samples from the model.
Check out Hinton's publications.
http://www.cs.toronto.edu/~hinton/
These methods aren't totally general (run same code on every data), but the underlying model is usually similar. | Domain-agnostic feature engineering that retains semantic meaning?
Recent deep learning methods using Restricted Boltzmann Machine have shown nice features on several data types (audio, images, text).
Since these methods create a generative model, you can often gener |
24,019 | Applying machine learning for DDoS filtering | How about anomaly detection algorithms? As you mention Andrew Ng's class you'd probably seen the "XV. ANOMALY DETECTION" section on ml-class.org, but anyway.
Anomaly detection will be superior to a supervised classification in scenarios similar to yours because:
normally you have very few anomalies (ie., too little "positive" examples)
normally you have very different types of anomalies
future anomalies may look nothing like the ones you've had so far
Important point in anomaly detection is, which features to choose. Two common advices here are to choose features with
Gaussian distribution (or distort them to be like that)
probability p(anomaly) be incomparable to p(normal) - say, anomalous values being very large while normal ones being very small (or vice versa).
I'm not sure if geolocation would help for your scenario, but client behavior would definitely matter - although it would probably differ from application to application. You may find that a ratio of GETs/POSTs matters. Or a ratio of response size to request count. Or number of single page hits. If you have such info in logs - definietly you can use the data for retrospective analysis, followed by IP blacklisting :) | Applying machine learning for DDoS filtering | How about anomaly detection algorithms? As you mention Andrew Ng's class you'd probably seen the "XV. ANOMALY DETECTION" section on ml-class.org, but anyway.
Anomaly detection will be superior to a | Applying machine learning for DDoS filtering
How about anomaly detection algorithms? As you mention Andrew Ng's class you'd probably seen the "XV. ANOMALY DETECTION" section on ml-class.org, but anyway.
Anomaly detection will be superior to a supervised classification in scenarios similar to yours because:
normally you have very few anomalies (ie., too little "positive" examples)
normally you have very different types of anomalies
future anomalies may look nothing like the ones you've had so far
Important point in anomaly detection is, which features to choose. Two common advices here are to choose features with
Gaussian distribution (or distort them to be like that)
probability p(anomaly) be incomparable to p(normal) - say, anomalous values being very large while normal ones being very small (or vice versa).
I'm not sure if geolocation would help for your scenario, but client behavior would definitely matter - although it would probably differ from application to application. You may find that a ratio of GETs/POSTs matters. Or a ratio of response size to request count. Or number of single page hits. If you have such info in logs - definietly you can use the data for retrospective analysis, followed by IP blacklisting :) | Applying machine learning for DDoS filtering
How about anomaly detection algorithms? As you mention Andrew Ng's class you'd probably seen the "XV. ANOMALY DETECTION" section on ml-class.org, but anyway.
Anomaly detection will be superior to a |
24,020 | Applying machine learning for DDoS filtering | This is a tough problem, here are a few observations:
This paper might be of some help to you - it relies on the supervised learning techniques (in the context of multi-class classification) to detect adversarial ads. Since the adversarial strategies evolve, the authors have to rely on human experts who annotate rare "anomalies". They use SVM-based ranking techniques among others.
As noted by others, you could try non-supervised-learning-based anomaly/outlier detection but that would require a lot of tuning to get the balance of false-positives and false-negatives right.
Having a good set of features is very important - the choice of methodology is secondary (i.e. a simple technique such as Naive Bayes or logistic regression is often enough given a good feature set) | Applying machine learning for DDoS filtering | This is a tough problem, here are a few observations:
This paper might be of some help to you - it relies on the supervised learning techniques (in the context of multi-class classification) to detec | Applying machine learning for DDoS filtering
This is a tough problem, here are a few observations:
This paper might be of some help to you - it relies on the supervised learning techniques (in the context of multi-class classification) to detect adversarial ads. Since the adversarial strategies evolve, the authors have to rely on human experts who annotate rare "anomalies". They use SVM-based ranking techniques among others.
As noted by others, you could try non-supervised-learning-based anomaly/outlier detection but that would require a lot of tuning to get the balance of false-positives and false-negatives right.
Having a good set of features is very important - the choice of methodology is secondary (i.e. a simple technique such as Naive Bayes or logistic regression is often enough given a good feature set) | Applying machine learning for DDoS filtering
This is a tough problem, here are a few observations:
This paper might be of some help to you - it relies on the supervised learning techniques (in the context of multi-class classification) to detec |
24,021 | Cross validation and ordinal logistic regression | Concentrate on a few of the indexes right now. index.orig is the apparent predictive ability/accuracy score when you evaluate it on the data used to fit the model. index.corrected is the cross-validation-corrected version of the same index, i.e., corrected for overfitting (de-biased). Dxy is Somers' $D_{xy}$ rank correlation coefficient - a measure of pure discrimination. See original paper or nonparametric texts for details. $D_{xy} = 2(C - \frac{1}{2})$ where $C$ is the generalized ROC area (concordance probability). Intercept and Slope pertain to the calibration curve on the logit scale. Emax is the estimated maximum calibration error using that slope and intercept. B is the Brier accuracy score (combines discrimination and calibration).
Methods are described in my book or the course notes on the book's web site: http://biostat.mc.vanderbilt.edu/rms | Cross validation and ordinal logistic regression | Concentrate on a few of the indexes right now. index.orig is the apparent predictive ability/accuracy score when you evaluate it on the data used to fit the model. index.corrected is the cross-valid | Cross validation and ordinal logistic regression
Concentrate on a few of the indexes right now. index.orig is the apparent predictive ability/accuracy score when you evaluate it on the data used to fit the model. index.corrected is the cross-validation-corrected version of the same index, i.e., corrected for overfitting (de-biased). Dxy is Somers' $D_{xy}$ rank correlation coefficient - a measure of pure discrimination. See original paper or nonparametric texts for details. $D_{xy} = 2(C - \frac{1}{2})$ where $C$ is the generalized ROC area (concordance probability). Intercept and Slope pertain to the calibration curve on the logit scale. Emax is the estimated maximum calibration error using that slope and intercept. B is the Brier accuracy score (combines discrimination and calibration).
Methods are described in my book or the course notes on the book's web site: http://biostat.mc.vanderbilt.edu/rms | Cross validation and ordinal logistic regression
Concentrate on a few of the indexes right now. index.orig is the apparent predictive ability/accuracy score when you evaluate it on the data used to fit the model. index.corrected is the cross-valid |
24,022 | Cross validation and ordinal logistic regression | To your first question: they are different model performance measurements. You want some of them to be big, others to be small. In fact they are somehow related so suggest you focus on one or two
To your second question: what you have in your first R output is your model performance on training sample. When you do validation by cross-validation, you get those measurements on multiple test samples and their average. This give you more realistic estimate of how your model performs.
HTH | Cross validation and ordinal logistic regression | To your first question: they are different model performance measurements. You want some of them to be big, others to be small. In fact they are somehow related so suggest you focus on one or two
To y | Cross validation and ordinal logistic regression
To your first question: they are different model performance measurements. You want some of them to be big, others to be small. In fact they are somehow related so suggest you focus on one or two
To your second question: what you have in your first R output is your model performance on training sample. When you do validation by cross-validation, you get those measurements on multiple test samples and their average. This give you more realistic estimate of how your model performs.
HTH | Cross validation and ordinal logistic regression
To your first question: they are different model performance measurements. You want some of them to be big, others to be small. In fact they are somehow related so suggest you focus on one or two
To y |
24,023 | What might be a clear, practical definition for a "family of hypotheses" (with respect to familywise error rate)? | The issue of multiple comparisons is a really big topic. There have been many opinions and many disagreements. This is due to many things; among others, it is partly because the issue is really important, and partly because there really is no ultimate rule or criterion. Take a prototypical case: You conduct an experiment with $k$ treatments and get a significant ANOVA, so now you wonder which treatment means differ. How should you go about this, run $k(k-1)/2$ t-tests? Although these tests would individually hold $\alpha$ at .05, the 'familywise' $\alpha$ (i.e., the probability that at least 1 type I error will occur) will explode. In fact, the familywise error rate will be $1-(1-\alpha)^k$. The question is, what defines a 'family'? And there is no ultimate answer, beyond the trivial one that a 'family' is a set of contrasts. Whether any particular set of contrasts should be considered a family is a subjective decision. The 3rd, 17th, and 42nd analyses that I ever conducted in my life are a set of contrasts, and I could have adjusted my $\alpha$ threshold to insure that the probability of type I errors amongst them was held at 5%, but no one would find this sensical. The question for you is whether you consider your contrasts to be a set in a meaningful sense, and only you can make that judgment. I will offer some standard approaches. Many analysts believe that if a set of contrasts come from the same experiment / data set, they should be treated as a family, and procedures (such as $\alpha$ adjustment) are necessary. Others believe that even when contrasts come from the same experiment, if they are a-priori and orthogonal, special procedures are not required. Both of these positions can be defended. Finally, note also that procedures to control familywise error rates come at a cost--viz. increased type II error rates. | What might be a clear, practical definition for a "family of hypotheses" (with respect to familywise | The issue of multiple comparisons is a really big topic. There have been many opinions and many disagreements. This is due to many things; among others, it is partly because the issue is really impo | What might be a clear, practical definition for a "family of hypotheses" (with respect to familywise error rate)?
The issue of multiple comparisons is a really big topic. There have been many opinions and many disagreements. This is due to many things; among others, it is partly because the issue is really important, and partly because there really is no ultimate rule or criterion. Take a prototypical case: You conduct an experiment with $k$ treatments and get a significant ANOVA, so now you wonder which treatment means differ. How should you go about this, run $k(k-1)/2$ t-tests? Although these tests would individually hold $\alpha$ at .05, the 'familywise' $\alpha$ (i.e., the probability that at least 1 type I error will occur) will explode. In fact, the familywise error rate will be $1-(1-\alpha)^k$. The question is, what defines a 'family'? And there is no ultimate answer, beyond the trivial one that a 'family' is a set of contrasts. Whether any particular set of contrasts should be considered a family is a subjective decision. The 3rd, 17th, and 42nd analyses that I ever conducted in my life are a set of contrasts, and I could have adjusted my $\alpha$ threshold to insure that the probability of type I errors amongst them was held at 5%, but no one would find this sensical. The question for you is whether you consider your contrasts to be a set in a meaningful sense, and only you can make that judgment. I will offer some standard approaches. Many analysts believe that if a set of contrasts come from the same experiment / data set, they should be treated as a family, and procedures (such as $\alpha$ adjustment) are necessary. Others believe that even when contrasts come from the same experiment, if they are a-priori and orthogonal, special procedures are not required. Both of these positions can be defended. Finally, note also that procedures to control familywise error rates come at a cost--viz. increased type II error rates. | What might be a clear, practical definition for a "family of hypotheses" (with respect to familywise
The issue of multiple comparisons is a really big topic. There have been many opinions and many disagreements. This is due to many things; among others, it is partly because the issue is really impo |
24,024 | What might be a clear, practical definition for a "family of hypotheses" (with respect to familywise error rate)? | The criterion is that the hypotheses are interdependent in the sense that if one of them breaks then the whole your conclusion or theory breaks. Hence you need a guarantee that if all the tests are significant none of them is significant falsely. | What might be a clear, practical definition for a "family of hypotheses" (with respect to familywise | The criterion is that the hypotheses are interdependent in the sense that if one of them breaks then the whole your conclusion or theory breaks. Hence you need a guarantee that if all the tests are si | What might be a clear, practical definition for a "family of hypotheses" (with respect to familywise error rate)?
The criterion is that the hypotheses are interdependent in the sense that if one of them breaks then the whole your conclusion or theory breaks. Hence you need a guarantee that if all the tests are significant none of them is significant falsely. | What might be a clear, practical definition for a "family of hypotheses" (with respect to familywise
The criterion is that the hypotheses are interdependent in the sense that if one of them breaks then the whole your conclusion or theory breaks. Hence you need a guarantee that if all the tests are si |
24,025 | What might be a clear, practical definition for a "family of hypotheses" (with respect to familywise error rate)? | A discussion on researchgate (http://www.researchgate.net/post/Bonferroni-how_is_the_family_of_hypotheses_defined) provided a list of papers, which might help collecting opinions - the papers actually start from the question "when to apply corrections in a multiple testing situation". The papers -all cited often - are:
1) Rothman KJ. No adjustments are needed for multiple comparisons. Epidemiology.1990;1(1):43-6. http://psg-mac43.ucsf.edu/ticr/syllabus/courses/9/2003/02/27/Lecture/readings/Rothman.pdf
2) Perneger TV. What´s wrong with Bonferroni adjustments. BMJ. 1998;316(7139):1236-8.http://static.sdu.dk/mediafiles/D/1/F/%7BD1F06030-8FA7-4EE2-BB7D-60D683B18EAA%7DWhat_s-wrong%20_with_Bonferroni_adjustments.BMJ.1998.pdf
3) Bender R, Lange S. Adjusting for multiple testing- when and how? J Clin Epidemiol. 2001;54:343-9. http://www.rbsd.de/PDF/multiple.pdf
Summary:
1) and 2) focus on "all null hypotheses are true", called the general null hypothesis. It can be more properly rejected (i.e. no alpha-cummulation) if adjustments for multiple comparisons are applied. However, both 1) and 2) oppose, that the general null hypothesis is rarely fully used in the process of scientific research - so the "whole theory breaks" criterion does not automatically apply, when one/some of the null hypotheses in one's data analysis are rejected by chance. 1) adds, that it is naive to think of single null hypotheses, which were (falsely) rejected will never be revisited by the scientific community again.
3) states that once single hypotheses melt in one argument, the adjustments must be done.
From my point of view 1), 2), 3) together just mirror, how carefully we must the "whole theory breaks" criterion. Neither is there a way to just put all null hypotheses in one big sausage - nor a way to rely on the slices of the sausage presented as many single hypotheses. This is, where empirical work really meets working with theory from the domain under research. | What might be a clear, practical definition for a "family of hypotheses" (with respect to familywise | A discussion on researchgate (http://www.researchgate.net/post/Bonferroni-how_is_the_family_of_hypotheses_defined) provided a list of papers, which might help collecting opinions - the papers actually | What might be a clear, practical definition for a "family of hypotheses" (with respect to familywise error rate)?
A discussion on researchgate (http://www.researchgate.net/post/Bonferroni-how_is_the_family_of_hypotheses_defined) provided a list of papers, which might help collecting opinions - the papers actually start from the question "when to apply corrections in a multiple testing situation". The papers -all cited often - are:
1) Rothman KJ. No adjustments are needed for multiple comparisons. Epidemiology.1990;1(1):43-6. http://psg-mac43.ucsf.edu/ticr/syllabus/courses/9/2003/02/27/Lecture/readings/Rothman.pdf
2) Perneger TV. What´s wrong with Bonferroni adjustments. BMJ. 1998;316(7139):1236-8.http://static.sdu.dk/mediafiles/D/1/F/%7BD1F06030-8FA7-4EE2-BB7D-60D683B18EAA%7DWhat_s-wrong%20_with_Bonferroni_adjustments.BMJ.1998.pdf
3) Bender R, Lange S. Adjusting for multiple testing- when and how? J Clin Epidemiol. 2001;54:343-9. http://www.rbsd.de/PDF/multiple.pdf
Summary:
1) and 2) focus on "all null hypotheses are true", called the general null hypothesis. It can be more properly rejected (i.e. no alpha-cummulation) if adjustments for multiple comparisons are applied. However, both 1) and 2) oppose, that the general null hypothesis is rarely fully used in the process of scientific research - so the "whole theory breaks" criterion does not automatically apply, when one/some of the null hypotheses in one's data analysis are rejected by chance. 1) adds, that it is naive to think of single null hypotheses, which were (falsely) rejected will never be revisited by the scientific community again.
3) states that once single hypotheses melt in one argument, the adjustments must be done.
From my point of view 1), 2), 3) together just mirror, how carefully we must the "whole theory breaks" criterion. Neither is there a way to just put all null hypotheses in one big sausage - nor a way to rely on the slices of the sausage presented as many single hypotheses. This is, where empirical work really meets working with theory from the domain under research. | What might be a clear, practical definition for a "family of hypotheses" (with respect to familywise
A discussion on researchgate (http://www.researchgate.net/post/Bonferroni-how_is_the_family_of_hypotheses_defined) provided a list of papers, which might help collecting opinions - the papers actually |
24,026 | SOM clustering for nominal/circular variables | Background:
The most logical way to transform hour is into two variables that swing back and forth out of sync. Imagine the position of the end of the hour hand of a 24-hour clock. The x position swings back and forth out of sync with the y position. For a 24-hour clock you can accomplish this with x=sin(2pi*hour/24),y=cos(2pi*hour/24).
You need both variables or the proper movement through time is lost. This is due to the fact that the derivative of either sin or cos changes in time whereas the (x,y) position varies smoothly as it travels around the unit circle.
Finally, consider whether it is worthwhile to add a third feature to trace linear time, which can be constructed as hours (or minutes or seconds) from the start of the first record or a Unix time stamp or something similar. These three features then provide proxies for both the cyclic and linear progression of time e.g. you can pull out cyclic phenomena like sleep cycles in people's movement and also linear growth like population vs. time.
Example of if being accomplished:
# Enable inline plotting
%matplotlib inline
#Import everything I need...
import numpy as np
import matplotlib as mp
import matplotlib.pyplot as plt
import pandas as pd
# Grab some random times from here: https://www.random.org/clock-times/
# put them into a csv.
from pandas import DataFrame, read_csv
df = read_csv('/Users/angus/Machine_Learning/ipython_notebooks/times.csv',delimiter=':')
df['hourfloat']=df.hour+df.minute/60.0
df['x']=np.sin(2.*np.pi*df.hourfloat/24.)
df['y']=np.cos(2.*np.pi*df.hourfloat/24.)
df
def kmeansshow(k,X):
from sklearn import cluster
from matplotlib import pyplot
import numpy as np
kmeans = cluster.KMeans(n_clusters=k)
kmeans.fit(X)
labels = kmeans.labels_
centroids = kmeans.cluster_centers_
#print centroids
for i in range(k):
# select only data observations with cluster label == i
ds = X[np.where(labels==i)]
# plot the data observations
pyplot.plot(ds[:,0],ds[:,1],'o')
# plot the centroids
lines = pyplot.plot(centroids[i,0],centroids[i,1],'kx')
# make the centroid x's bigger
pyplot.setp(lines,ms=15.0)
pyplot.setp(lines,mew=2.0)
pyplot.show()
return centroids
Now let's try it out:
kmeansshow(6,df[['x', 'y']].values)
You can just barely see that there are some after midnight times included with the before midnight green cluster. Now let's reduce the number of clusters and show that before and after midnight can be connected in a single cluster in more detail:
kmeansshow(3,df[['x', 'y']].values)
See how the blue cluster contains times that are from before and after midnight that are clustered together in the same cluster...
You can do this for time, or day of week, or week of month, or day of month, or season, or anything. | SOM clustering for nominal/circular variables | Background:
The most logical way to transform hour is into two variables that swing back and forth out of sync. Imagine the position of the end of the hour hand of a 24-hour clock. The x position swin | SOM clustering for nominal/circular variables
Background:
The most logical way to transform hour is into two variables that swing back and forth out of sync. Imagine the position of the end of the hour hand of a 24-hour clock. The x position swings back and forth out of sync with the y position. For a 24-hour clock you can accomplish this with x=sin(2pi*hour/24),y=cos(2pi*hour/24).
You need both variables or the proper movement through time is lost. This is due to the fact that the derivative of either sin or cos changes in time whereas the (x,y) position varies smoothly as it travels around the unit circle.
Finally, consider whether it is worthwhile to add a third feature to trace linear time, which can be constructed as hours (or minutes or seconds) from the start of the first record or a Unix time stamp or something similar. These three features then provide proxies for both the cyclic and linear progression of time e.g. you can pull out cyclic phenomena like sleep cycles in people's movement and also linear growth like population vs. time.
Example of if being accomplished:
# Enable inline plotting
%matplotlib inline
#Import everything I need...
import numpy as np
import matplotlib as mp
import matplotlib.pyplot as plt
import pandas as pd
# Grab some random times from here: https://www.random.org/clock-times/
# put them into a csv.
from pandas import DataFrame, read_csv
df = read_csv('/Users/angus/Machine_Learning/ipython_notebooks/times.csv',delimiter=':')
df['hourfloat']=df.hour+df.minute/60.0
df['x']=np.sin(2.*np.pi*df.hourfloat/24.)
df['y']=np.cos(2.*np.pi*df.hourfloat/24.)
df
def kmeansshow(k,X):
from sklearn import cluster
from matplotlib import pyplot
import numpy as np
kmeans = cluster.KMeans(n_clusters=k)
kmeans.fit(X)
labels = kmeans.labels_
centroids = kmeans.cluster_centers_
#print centroids
for i in range(k):
# select only data observations with cluster label == i
ds = X[np.where(labels==i)]
# plot the data observations
pyplot.plot(ds[:,0],ds[:,1],'o')
# plot the centroids
lines = pyplot.plot(centroids[i,0],centroids[i,1],'kx')
# make the centroid x's bigger
pyplot.setp(lines,ms=15.0)
pyplot.setp(lines,mew=2.0)
pyplot.show()
return centroids
Now let's try it out:
kmeansshow(6,df[['x', 'y']].values)
You can just barely see that there are some after midnight times included with the before midnight green cluster. Now let's reduce the number of clusters and show that before and after midnight can be connected in a single cluster in more detail:
kmeansshow(3,df[['x', 'y']].values)
See how the blue cluster contains times that are from before and after midnight that are clustered together in the same cluster...
You can do this for time, or day of week, or week of month, or day of month, or season, or anything. | SOM clustering for nominal/circular variables
Background:
The most logical way to transform hour is into two variables that swing back and forth out of sync. Imagine the position of the end of the hour hand of a 24-hour clock. The x position swin |
24,027 | SOM clustering for nominal/circular variables | Commonly nominal variables are dummy coded when used in SOM (e.g., one variable for with a 1 for Monday 0 for not Monday, another for Tuesday, etc.).
You can incorporate additional information by creating combined categories of adjacent days. For example: Monday&Tuesday, Tuesday&Wednesday, etc. However, if your data relates to human behaviour it is often more useful to use Weekday and Weekend as categories. | SOM clustering for nominal/circular variables | Commonly nominal variables are dummy coded when used in SOM (e.g., one variable for with a 1 for Monday 0 for not Monday, another for Tuesday, etc.).
You can incorporate additional information by crea | SOM clustering for nominal/circular variables
Commonly nominal variables are dummy coded when used in SOM (e.g., one variable for with a 1 for Monday 0 for not Monday, another for Tuesday, etc.).
You can incorporate additional information by creating combined categories of adjacent days. For example: Monday&Tuesday, Tuesday&Wednesday, etc. However, if your data relates to human behaviour it is often more useful to use Weekday and Weekend as categories. | SOM clustering for nominal/circular variables
Commonly nominal variables are dummy coded when used in SOM (e.g., one variable for with a 1 for Monday 0 for not Monday, another for Tuesday, etc.).
You can incorporate additional information by crea |
24,028 | SOM clustering for nominal/circular variables | For nominal variables, the typical encoding in a neural network or electrical engineering context is called "one-hot" -- a vector of all 0s, with one 1 in the appropriate position for the value for the variable. For the days of the week, for example, there are seven days, so your one-hot vectors would be of length seven. Then Monday would be represented as [1 0 0 0 0 0 0], Tuesday as [0 1 0 0 0 0 0], etc.
As Tim hinted, this approach can be generalized easily to encompass arbitrary boolean feature vectors, where each position in the vector corresponds to a feature of interest in your data, and the position is set to 1 or 0 to indicate the presence or absence of that feature.
Once you have binary vectors, the Hamming distance becomes a natural metric, though Euclidean distance is used as well. For one-hot binary vectors, the SOM (or other function approximator) will naturally interpolate between 0 and 1 for each vector position. In this case, these vectors are often treated as the parameters of a Boltzmann or softmax distribution over the space of the nominal variable ; this treatment gives a way to use the vectors in some sort of KL divergence scenario as well.
Cyclic variables are much trickier. As Arthur said in the comments, you'd need to define a distance metric yourself that incorporates the cyclic nature of the variable. | SOM clustering for nominal/circular variables | For nominal variables, the typical encoding in a neural network or electrical engineering context is called "one-hot" -- a vector of all 0s, with one 1 in the appropriate position for the value for th | SOM clustering for nominal/circular variables
For nominal variables, the typical encoding in a neural network or electrical engineering context is called "one-hot" -- a vector of all 0s, with one 1 in the appropriate position for the value for the variable. For the days of the week, for example, there are seven days, so your one-hot vectors would be of length seven. Then Monday would be represented as [1 0 0 0 0 0 0], Tuesday as [0 1 0 0 0 0 0], etc.
As Tim hinted, this approach can be generalized easily to encompass arbitrary boolean feature vectors, where each position in the vector corresponds to a feature of interest in your data, and the position is set to 1 or 0 to indicate the presence or absence of that feature.
Once you have binary vectors, the Hamming distance becomes a natural metric, though Euclidean distance is used as well. For one-hot binary vectors, the SOM (or other function approximator) will naturally interpolate between 0 and 1 for each vector position. In this case, these vectors are often treated as the parameters of a Boltzmann or softmax distribution over the space of the nominal variable ; this treatment gives a way to use the vectors in some sort of KL divergence scenario as well.
Cyclic variables are much trickier. As Arthur said in the comments, you'd need to define a distance metric yourself that incorporates the cyclic nature of the variable. | SOM clustering for nominal/circular variables
For nominal variables, the typical encoding in a neural network or electrical engineering context is called "one-hot" -- a vector of all 0s, with one 1 in the appropriate position for the value for th |
24,029 | SOM clustering for nominal/circular variables | Assuming day of week (dow) goes from [0, 6], instead of projecting data onto a circle another option is to use:
dist = min(abs(dow_diff), 7 - abs(dow_diff))
To understand why, consider the dow as a clock
6 0
5 1
4 2
3
diff between 6 and 1 could be 6 - 1 = 5 (going clockwise from 1 to 6) or 7 - (6 - 1) = 2. Taking min of both options should do the trick.
In general you can use: min(abs(diff), range - abs(diff)) | SOM clustering for nominal/circular variables | Assuming day of week (dow) goes from [0, 6], instead of projecting data onto a circle another option is to use:
dist = min(abs(dow_diff), 7 - abs(dow_diff))
To understand why, consider the dow as a | SOM clustering for nominal/circular variables
Assuming day of week (dow) goes from [0, 6], instead of projecting data onto a circle another option is to use:
dist = min(abs(dow_diff), 7 - abs(dow_diff))
To understand why, consider the dow as a clock
6 0
5 1
4 2
3
diff between 6 and 1 could be 6 - 1 = 5 (going clockwise from 1 to 6) or 7 - (6 - 1) = 2. Taking min of both options should do the trick.
In general you can use: min(abs(diff), range - abs(diff)) | SOM clustering for nominal/circular variables
Assuming day of week (dow) goes from [0, 6], instead of projecting data onto a circle another option is to use:
dist = min(abs(dow_diff), 7 - abs(dow_diff))
To understand why, consider the dow as a |
24,030 | SOM clustering for nominal/circular variables | I have successfully encoded Days of the week (and Months of the year) as tuple of (cos,sin) as whuber highlighted in his comment. Than used Euclidean distance.
This is an example of code in r:
circularVariable = function(n, r = 4){
#Transform a circular variable (e.g. Month so the year or day of the week) into two new variables (tuple).
#n = upper limit of the sequence. E.g. for days of the week this is 7.
#r = number of digits to round generated variables.
#Return
#
coord = function(y){
angle = ((2*pi)/n) *y
cs = round(cos(angle),r)
s = round(sin(angle),r)
c(cs,s)
}
do.call("rbind", lapply((0:(n-1)), coord))
}
Euclidean distance between 0 and 6 is equal to 0 and 1. | SOM clustering for nominal/circular variables | I have successfully encoded Days of the week (and Months of the year) as tuple of (cos,sin) as whuber highlighted in his comment. Than used Euclidean distance.
This is an example of code in r:
circula | SOM clustering for nominal/circular variables
I have successfully encoded Days of the week (and Months of the year) as tuple of (cos,sin) as whuber highlighted in his comment. Than used Euclidean distance.
This is an example of code in r:
circularVariable = function(n, r = 4){
#Transform a circular variable (e.g. Month so the year or day of the week) into two new variables (tuple).
#n = upper limit of the sequence. E.g. for days of the week this is 7.
#r = number of digits to round generated variables.
#Return
#
coord = function(y){
angle = ((2*pi)/n) *y
cs = round(cos(angle),r)
s = round(sin(angle),r)
c(cs,s)
}
do.call("rbind", lapply((0:(n-1)), coord))
}
Euclidean distance between 0 and 6 is equal to 0 and 1. | SOM clustering for nominal/circular variables
I have successfully encoded Days of the week (and Months of the year) as tuple of (cos,sin) as whuber highlighted in his comment. Than used Euclidean distance.
This is an example of code in r:
circula |
24,031 | Markowitz portfolio mean variance optimization in R | You might look at the following:
http://cran.r-project.org/web/packages/tawny/index.html
http://www.rinfinance.com/RinFinance2009/presentations/yollin_slides.pdf
http://nurometic.com/quantitative-finance/tawny/portfolio-optimization-with-tawny
http://quantivity.wordpress.com/2011/04/17/minimum-variance-portfolios/ | Markowitz portfolio mean variance optimization in R | You might look at the following:
http://cran.r-project.org/web/packages/tawny/index.html
http://www.rinfinance.com/RinFinance2009/presentations/yollin_slides.pdf
http://nurometic.com/quantitative-fina | Markowitz portfolio mean variance optimization in R
You might look at the following:
http://cran.r-project.org/web/packages/tawny/index.html
http://www.rinfinance.com/RinFinance2009/presentations/yollin_slides.pdf
http://nurometic.com/quantitative-finance/tawny/portfolio-optimization-with-tawny
http://quantivity.wordpress.com/2011/04/17/minimum-variance-portfolios/ | Markowitz portfolio mean variance optimization in R
You might look at the following:
http://cran.r-project.org/web/packages/tawny/index.html
http://www.rinfinance.com/RinFinance2009/presentations/yollin_slides.pdf
http://nurometic.com/quantitative-fina |
24,032 | Markowitz portfolio mean variance optimization in R | Concerning this topic there was quite recently a fantastic Coursera MOOC from Professor Eric Zivot from the University of Washington:
Introduction to computational finance and Financial Econometrics
In case you don't have access there they will offer this course again starting Dec 17th 2012:
https://www.coursera.org/course/compfinance
Meanwhile most of the material can be found here too:
http://faculty.washington.edu/ezivot/econ424/econ424.htm | Markowitz portfolio mean variance optimization in R | Concerning this topic there was quite recently a fantastic Coursera MOOC from Professor Eric Zivot from the University of Washington:
Introduction to computational finance and Financial Econometrics
I | Markowitz portfolio mean variance optimization in R
Concerning this topic there was quite recently a fantastic Coursera MOOC from Professor Eric Zivot from the University of Washington:
Introduction to computational finance and Financial Econometrics
In case you don't have access there they will offer this course again starting Dec 17th 2012:
https://www.coursera.org/course/compfinance
Meanwhile most of the material can be found here too:
http://faculty.washington.edu/ezivot/econ424/econ424.htm | Markowitz portfolio mean variance optimization in R
Concerning this topic there was quite recently a fantastic Coursera MOOC from Professor Eric Zivot from the University of Washington:
Introduction to computational finance and Financial Econometrics
I |
24,033 | Hypothesis testing on zero-inflated continuous data | @msp, I think you are looking at a two stage model in that attachment (I did not have time to read it), but zero inflated continuous data is the type I work with a lot. To fit a parametric model to this data (to allow hypothesis tests) you can fit a two stage but then you have two models (Y is the target and X are covariates): P(Y=0 |X) and P(Y|X;Y>0). You have to use simulation to "bring" these together. Gelmans book (and the arm package in R) shows this process for this exact model (using logistic regression and ordinary linear regression with a log link).
The other option I have seen and like better is to fit a zero inflated gamma regression, which is the same as above (but gamma as the error instead of guassian) and you can bring them together for hypothesis tests on P(Y|X). I dont know how to do this in R, but you can in SAS NLMIXED. See this post, it works well. | Hypothesis testing on zero-inflated continuous data | @msp, I think you are looking at a two stage model in that attachment (I did not have time to read it), but zero inflated continuous data is the type I work with a lot. To fit a parametric model to th | Hypothesis testing on zero-inflated continuous data
@msp, I think you are looking at a two stage model in that attachment (I did not have time to read it), but zero inflated continuous data is the type I work with a lot. To fit a parametric model to this data (to allow hypothesis tests) you can fit a two stage but then you have two models (Y is the target and X are covariates): P(Y=0 |X) and P(Y|X;Y>0). You have to use simulation to "bring" these together. Gelmans book (and the arm package in R) shows this process for this exact model (using logistic regression and ordinary linear regression with a log link).
The other option I have seen and like better is to fit a zero inflated gamma regression, which is the same as above (but gamma as the error instead of guassian) and you can bring them together for hypothesis tests on P(Y|X). I dont know how to do this in R, but you can in SAS NLMIXED. See this post, it works well. | Hypothesis testing on zero-inflated continuous data
@msp, I think you are looking at a two stage model in that attachment (I did not have time to read it), but zero inflated continuous data is the type I work with a lot. To fit a parametric model to th |
24,034 | Hypothesis testing on zero-inflated continuous data | A similar approach to the Fletcher paper is used in marketing testing, where we can arbitrarily separate the effects of interventions (such as advertising) into (a) a change in the number buying the brand (i.e. proportion of zeroes) and (b) a change in the frequency of buying the band (sales given sales occur at all). This is a solid approach and conceptually meaningful in the marketing context and in the ecological context Fletcher discusses. In fact, this can be extended to (c) a change in the size of each purchase. | Hypothesis testing on zero-inflated continuous data | A similar approach to the Fletcher paper is used in marketing testing, where we can arbitrarily separate the effects of interventions (such as advertising) into (a) a change in the number buying the b | Hypothesis testing on zero-inflated continuous data
A similar approach to the Fletcher paper is used in marketing testing, where we can arbitrarily separate the effects of interventions (such as advertising) into (a) a change in the number buying the brand (i.e. proportion of zeroes) and (b) a change in the frequency of buying the band (sales given sales occur at all). This is a solid approach and conceptually meaningful in the marketing context and in the ecological context Fletcher discusses. In fact, this can be extended to (c) a change in the size of each purchase. | Hypothesis testing on zero-inflated continuous data
A similar approach to the Fletcher paper is used in marketing testing, where we can arbitrarily separate the effects of interventions (such as advertising) into (a) a change in the number buying the b |
24,035 | Hypothesis testing on zero-inflated continuous data | You could treat the exact number of zeros unknown, but constrained between 0 and the observed number of zeros. This can surely be handled using a Bayesian formulation of the model. Maybe a multiple imputation method can also be tweaked to appropriately vary the weights (between 0 and 1) of the zero observations… | Hypothesis testing on zero-inflated continuous data | You could treat the exact number of zeros unknown, but constrained between 0 and the observed number of zeros. This can surely be handled using a Bayesian formulation of the model. Maybe a multiple im | Hypothesis testing on zero-inflated continuous data
You could treat the exact number of zeros unknown, but constrained between 0 and the observed number of zeros. This can surely be handled using a Bayesian formulation of the model. Maybe a multiple imputation method can also be tweaked to appropriately vary the weights (between 0 and 1) of the zero observations… | Hypothesis testing on zero-inflated continuous data
You could treat the exact number of zeros unknown, but constrained between 0 and the observed number of zeros. This can surely be handled using a Bayesian formulation of the model. Maybe a multiple im |
24,036 | Overall type I error when repeatedly testing accumulating data | The following slides, through 14, explain the idea. The point, as you note, is that the sequence of statistics is correlated.
The context is a z-test with known standard deviation. The first test statistic $z_1$, suitably standardized, has a Normal(0,1) distribution with cdf $\Phi$. So does the second statistic $z_2$, but--because the first uses a subset of the data used for the second--the two statistics are correlated with correlation coefficient $\sqrt{1/2}$. Therefore $(z_1, z_2)$ has a binormal distribution. The probability of a type I error (under the null hypothesis) equals the probability that either (a) a type I error occurs in the first test or (b) a type I error does not occur in the first test but does occur in the second test. Let $c = \Phi^{-1}(1 - 0.05/2)$ be the critical value (for a two-sided test with nominal size $\alpha$ = 0.05). Then the chance of a type I error after two analyses equals the chance that $|z_1| > c$ or $|z_1| \le c$ and $|z_2| > c$. Numeric integration gives the value 0.0831178 for this probability, agreeing with the table. Subsequent values in the table are obtained with similar reasoning (and more complicated integrations).
This graphic depicts the binormal pdf and the region of integration (solid surface). | Overall type I error when repeatedly testing accumulating data | The following slides, through 14, explain the idea. The point, as you note, is that the sequence of statistics is correlated.
The context is a z-test with known standard deviation. The first test st | Overall type I error when repeatedly testing accumulating data
The following slides, through 14, explain the idea. The point, as you note, is that the sequence of statistics is correlated.
The context is a z-test with known standard deviation. The first test statistic $z_1$, suitably standardized, has a Normal(0,1) distribution with cdf $\Phi$. So does the second statistic $z_2$, but--because the first uses a subset of the data used for the second--the two statistics are correlated with correlation coefficient $\sqrt{1/2}$. Therefore $(z_1, z_2)$ has a binormal distribution. The probability of a type I error (under the null hypothesis) equals the probability that either (a) a type I error occurs in the first test or (b) a type I error does not occur in the first test but does occur in the second test. Let $c = \Phi^{-1}(1 - 0.05/2)$ be the critical value (for a two-sided test with nominal size $\alpha$ = 0.05). Then the chance of a type I error after two analyses equals the chance that $|z_1| > c$ or $|z_1| \le c$ and $|z_2| > c$. Numeric integration gives the value 0.0831178 for this probability, agreeing with the table. Subsequent values in the table are obtained with similar reasoning (and more complicated integrations).
This graphic depicts the binormal pdf and the region of integration (solid surface). | Overall type I error when repeatedly testing accumulating data
The following slides, through 14, explain the idea. The point, as you note, is that the sequence of statistics is correlated.
The context is a z-test with known standard deviation. The first test st |
24,037 | Can I use multiple regression when I have mixed categorical and continuous predictors? | If this is an SPSS syntax question, the answer is just put the categorical variable, coded appropriately, into the variable list for "independent variables" along with the continuous one.
On the statistics: Is your categorical variable binary? If so, you need to use a dummy or other valid contrast code. If it is not binary, is your categorical variable ordinal or nominal? If nominal, then again, you must use some contrasting code strategy--in effect modeling the impact of each level of the variable on the outcome or "dependent" variable. If the categorical variable is ordinal, then most likely the sensible thing to do is to enter it as-is into the model, just as you would with a continuous predictor (i.e., "independent") variable. You would be assuming, in that case, that the increments between levels of the categorical predictor ("indepdent") variable; only rarely will this be a mistake, but when it is, you should again use a contrast code & model the impact of each level. This question comes up in this forum quite often -- here is a good analaysis
How to handle missing data is, in my view, a completely separate matter. My understanding is that pairwise deletion is not viewed as a valid approach for multivariate regression. Listwise is pretty common but can can also bias results & certainly is a shame. Multiple imputation is a thing of beauty. | Can I use multiple regression when I have mixed categorical and continuous predictors? | If this is an SPSS syntax question, the answer is just put the categorical variable, coded appropriately, into the variable list for "independent variables" along with the continuous one.
On the stat | Can I use multiple regression when I have mixed categorical and continuous predictors?
If this is an SPSS syntax question, the answer is just put the categorical variable, coded appropriately, into the variable list for "independent variables" along with the continuous one.
On the statistics: Is your categorical variable binary? If so, you need to use a dummy or other valid contrast code. If it is not binary, is your categorical variable ordinal or nominal? If nominal, then again, you must use some contrasting code strategy--in effect modeling the impact of each level of the variable on the outcome or "dependent" variable. If the categorical variable is ordinal, then most likely the sensible thing to do is to enter it as-is into the model, just as you would with a continuous predictor (i.e., "independent") variable. You would be assuming, in that case, that the increments between levels of the categorical predictor ("indepdent") variable; only rarely will this be a mistake, but when it is, you should again use a contrast code & model the impact of each level. This question comes up in this forum quite often -- here is a good analaysis
How to handle missing data is, in my view, a completely separate matter. My understanding is that pairwise deletion is not viewed as a valid approach for multivariate regression. Listwise is pretty common but can can also bias results & certainly is a shame. Multiple imputation is a thing of beauty. | Can I use multiple regression when I have mixed categorical and continuous predictors?
If this is an SPSS syntax question, the answer is just put the categorical variable, coded appropriately, into the variable list for "independent variables" along with the continuous one.
On the stat |
24,038 | Can I use multiple regression when I have mixed categorical and continuous predictors? | You definitely can, by following the same method you'd use for the first categorical predictor. Create dummy variables just as you would for the first such variable. But it's often easier to use SPSS's Unianova command. You can look this up in any printed or pdf'd Syntax Guide, or you can access it through Analyze...General Linear Model...Univariate.
Despite being a little more complicated, the Regression command has a number of advantages over Unianova, though. The chief one is that you can choose 'missing pairwise' (you don't have to lose a case simply because it's missing a value for one or two predictors). You can also get many valuable diagnostics such as partial plots and influence statistics. | Can I use multiple regression when I have mixed categorical and continuous predictors? | You definitely can, by following the same method you'd use for the first categorical predictor. Create dummy variables just as you would for the first such variable. But it's often easier to use SPSS | Can I use multiple regression when I have mixed categorical and continuous predictors?
You definitely can, by following the same method you'd use for the first categorical predictor. Create dummy variables just as you would for the first such variable. But it's often easier to use SPSS's Unianova command. You can look this up in any printed or pdf'd Syntax Guide, or you can access it through Analyze...General Linear Model...Univariate.
Despite being a little more complicated, the Regression command has a number of advantages over Unianova, though. The chief one is that you can choose 'missing pairwise' (you don't have to lose a case simply because it's missing a value for one or two predictors). You can also get many valuable diagnostics such as partial plots and influence statistics. | Can I use multiple regression when I have mixed categorical and continuous predictors?
You definitely can, by following the same method you'd use for the first categorical predictor. Create dummy variables just as you would for the first such variable. But it's often easier to use SPSS |
24,039 | Can I use multiple regression when I have mixed categorical and continuous predictors? | A simple way to turn categorical variables into a set of dummy variables for use in models in SPSS is using the do repeat syntax. This is the simplest to use if your categorical variables are in numeric order.
*making vector of dummy variables.
vector dummy(3,F1.0).
*looping through dummy variables using do repeat, in this example category would be the categorical variable to recode.
do repeat dummy = dummy1 to dummy3 /#i = 1 to 3.
compute dummy = 0.
if category = #i dummy = 1.
end repeat.
execute.
Otherwise you can simply run a set of if statements to make your dummy variables. My current version (16) has no native ability to specify a set of dummy variables automatically in the regression command (like you can in Stata using the xi command) but I wouldn't be surprised if this is available in some newer version. Also take note of dmk38's point #2, this coding scheme is assuming nominal categories. If your variable is ordinal more discretion can be used.
I also agree with dmk38 and the talk about regression being better because of its ability to specify missing data in a particular manner is a completely separate issue. | Can I use multiple regression when I have mixed categorical and continuous predictors? | A simple way to turn categorical variables into a set of dummy variables for use in models in SPSS is using the do repeat syntax. This is the simplest to use if your categorical variables are in numer | Can I use multiple regression when I have mixed categorical and continuous predictors?
A simple way to turn categorical variables into a set of dummy variables for use in models in SPSS is using the do repeat syntax. This is the simplest to use if your categorical variables are in numeric order.
*making vector of dummy variables.
vector dummy(3,F1.0).
*looping through dummy variables using do repeat, in this example category would be the categorical variable to recode.
do repeat dummy = dummy1 to dummy3 /#i = 1 to 3.
compute dummy = 0.
if category = #i dummy = 1.
end repeat.
execute.
Otherwise you can simply run a set of if statements to make your dummy variables. My current version (16) has no native ability to specify a set of dummy variables automatically in the regression command (like you can in Stata using the xi command) but I wouldn't be surprised if this is available in some newer version. Also take note of dmk38's point #2, this coding scheme is assuming nominal categories. If your variable is ordinal more discretion can be used.
I also agree with dmk38 and the talk about regression being better because of its ability to specify missing data in a particular manner is a completely separate issue. | Can I use multiple regression when I have mixed categorical and continuous predictors?
A simple way to turn categorical variables into a set of dummy variables for use in models in SPSS is using the do repeat syntax. This is the simplest to use if your categorical variables are in numer |
24,040 | How can one do an MCMC hypothesis test on a mixed effect regression model with random slopes? | It looks like your error message isn't about varying slopes, it is about correlated random effects. You can fit the uncorrelated as well; that is, a mixed-effects model with independent random effects:
Linear mixed model fit by REML
Formula: Reaction ~ Days + (1 | Subject) + (0 + Days | Subject)
Data: sleepstudy
from http://www.stat.wisc.edu/~bates/IMPS2008/lme4D.pdf | How can one do an MCMC hypothesis test on a mixed effect regression model with random slopes? | It looks like your error message isn't about varying slopes, it is about correlated random effects. You can fit the uncorrelated as well; that is, a mixed-effects model with independent random effects | How can one do an MCMC hypothesis test on a mixed effect regression model with random slopes?
It looks like your error message isn't about varying slopes, it is about correlated random effects. You can fit the uncorrelated as well; that is, a mixed-effects model with independent random effects:
Linear mixed model fit by REML
Formula: Reaction ~ Days + (1 | Subject) + (0 + Days | Subject)
Data: sleepstudy
from http://www.stat.wisc.edu/~bates/IMPS2008/lme4D.pdf | How can one do an MCMC hypothesis test on a mixed effect regression model with random slopes?
It looks like your error message isn't about varying slopes, it is about correlated random effects. You can fit the uncorrelated as well; that is, a mixed-effects model with independent random effects |
24,041 | How can one do an MCMC hypothesis test on a mixed effect regression model with random slopes? | Here's (at least most of) a solution with MCMCglmm.
First fit the equivalent intercept-variance-only model with MCMCglmm:
library(MCMCglmm)
primingHeid.MCMCglmm = MCMCglmm(fixed=RT ~ RTtoPrime * ResponseToPrime + Condition,
random=~Subject+Word, data = primingHeid)
Comparing fits between MCMCglmm and lmer, first retrieving my hacked version of arm::coefplot:
source(url("http://www.math.mcmaster.ca/bolker/R/misc/coefplot_new.R"))
## combine estimates of fixed effects and variance components
pp <- as.mcmc(with(primingHeid.MCMCglmm, cbind(Sol, VCV)))
## extract coefficient table
cc1 <- coeftab(primingHeid.MCMCglmm,ptype=c("fixef", "vcov"))
## strip fixed/vcov indicators to make names match with lmer output
rownames(cc1) <- gsub("(Sol|VCV).", "", rownames(cc1))
## fixed effects -- v. similar
coefplot(list(cc1[1:5,], primingHeid.lmer))
## variance components -- quite different. Worth further exploration?
coefplot(list(cc1[6:8,], coeftab(primingHeid.lmer, ptype="vcov")),
xlim=c(0,0.16), cex.pts=1.5)
Now try it with random slopes:
primingHeid.rs.MCMCglmm = MCMCglmm(fixed=RT ~ RTtoPrime * ResponseToPrime + Condition,
random=~Subject+Subject:Condition+Word,
data = primingHeid)
summary(primingHeid.rs.MCMCglmm)
This does give some sort of "MCMC p-values" ... you'll have to explore for yourself and see whether the whole thing makes sense ... | How can one do an MCMC hypothesis test on a mixed effect regression model with random slopes? | Here's (at least most of) a solution with MCMCglmm.
First fit the equivalent intercept-variance-only model with MCMCglmm:
library(MCMCglmm)
primingHeid.MCMCglmm = MCMCglmm(fixed=RT ~ RTtoPrime * Respo | How can one do an MCMC hypothesis test on a mixed effect regression model with random slopes?
Here's (at least most of) a solution with MCMCglmm.
First fit the equivalent intercept-variance-only model with MCMCglmm:
library(MCMCglmm)
primingHeid.MCMCglmm = MCMCglmm(fixed=RT ~ RTtoPrime * ResponseToPrime + Condition,
random=~Subject+Word, data = primingHeid)
Comparing fits between MCMCglmm and lmer, first retrieving my hacked version of arm::coefplot:
source(url("http://www.math.mcmaster.ca/bolker/R/misc/coefplot_new.R"))
## combine estimates of fixed effects and variance components
pp <- as.mcmc(with(primingHeid.MCMCglmm, cbind(Sol, VCV)))
## extract coefficient table
cc1 <- coeftab(primingHeid.MCMCglmm,ptype=c("fixef", "vcov"))
## strip fixed/vcov indicators to make names match with lmer output
rownames(cc1) <- gsub("(Sol|VCV).", "", rownames(cc1))
## fixed effects -- v. similar
coefplot(list(cc1[1:5,], primingHeid.lmer))
## variance components -- quite different. Worth further exploration?
coefplot(list(cc1[6:8,], coeftab(primingHeid.lmer, ptype="vcov")),
xlim=c(0,0.16), cex.pts=1.5)
Now try it with random slopes:
primingHeid.rs.MCMCglmm = MCMCglmm(fixed=RT ~ RTtoPrime * ResponseToPrime + Condition,
random=~Subject+Subject:Condition+Word,
data = primingHeid)
summary(primingHeid.rs.MCMCglmm)
This does give some sort of "MCMC p-values" ... you'll have to explore for yourself and see whether the whole thing makes sense ... | How can one do an MCMC hypothesis test on a mixed effect regression model with random slopes?
Here's (at least most of) a solution with MCMCglmm.
First fit the equivalent intercept-variance-only model with MCMCglmm:
library(MCMCglmm)
primingHeid.MCMCglmm = MCMCglmm(fixed=RT ~ RTtoPrime * Respo |
24,042 | Estimating parameters of a dynamic linear model | If you have time varying parameters and want to do things sequentially (filtering), then SMC makes the most sense. MCMC is better when you want to condition on all of the data, or you have unknown static parameters that you want to estimate. Particle filters have issues with static parameters (degeneracy). | Estimating parameters of a dynamic linear model | If you have time varying parameters and want to do things sequentially (filtering), then SMC makes the most sense. MCMC is better when you want to condition on all of the data, or you have unknown sta | Estimating parameters of a dynamic linear model
If you have time varying parameters and want to do things sequentially (filtering), then SMC makes the most sense. MCMC is better when you want to condition on all of the data, or you have unknown static parameters that you want to estimate. Particle filters have issues with static parameters (degeneracy). | Estimating parameters of a dynamic linear model
If you have time varying parameters and want to do things sequentially (filtering), then SMC makes the most sense. MCMC is better when you want to condition on all of the data, or you have unknown sta |
24,043 | Estimating parameters of a dynamic linear model | Have a look at the dlm package and its vignette. I think you might find what you are looking for from the vignette. The package authors have also written a book Dynamic Linear Models with R. | Estimating parameters of a dynamic linear model | Have a look at the dlm package and its vignette. I think you might find what you are looking for from the vignette. The package authors have also written a book Dynamic Linear Models with R. | Estimating parameters of a dynamic linear model
Have a look at the dlm package and its vignette. I think you might find what you are looking for from the vignette. The package authors have also written a book Dynamic Linear Models with R. | Estimating parameters of a dynamic linear model
Have a look at the dlm package and its vignette. I think you might find what you are looking for from the vignette. The package authors have also written a book Dynamic Linear Models with R. |
24,044 | Estimating parameters of a dynamic linear model | I've read Dynamic Linear Models with R (good book), the final chapter deals with sequential Monte Carlo / particle filtering. It also includes some R code; however, in the concluding remarks of chapter 5 they explicitly warn that SMC becomes increasingly unreliable as additional time passes because the errors accumulate. Thus, they recommend "refreshing" the particle filter with the posterior distribution from a full MCMC sample every $T$ periods. Perhaps I misread their warnings, but this would seem to imply that you are better off with the rolling window MCMC. However, I would think there are substantial computer processing constraints with that method. For example, assuming you had 1,000 different univariate time series with 50 observations each and it took you 10 minutes to run a full MCMC Gibbs sampler. Then, it would take you 340 days ($(1000 \times (50-1) \times 10) \div 60 \div 24$) of continuous processing to estimate the parameters without look-ahead bias. Maybe my estimate of the time it takes to run the MCMC is wildly off, but I think it's a conservative but reasonable estimate.
It's been several years since you asked the question, so I'd be curious if you yourself have an answer now. | Estimating parameters of a dynamic linear model | I've read Dynamic Linear Models with R (good book), the final chapter deals with sequential Monte Carlo / particle filtering. It also includes some R code; however, in the concluding remarks of chapte | Estimating parameters of a dynamic linear model
I've read Dynamic Linear Models with R (good book), the final chapter deals with sequential Monte Carlo / particle filtering. It also includes some R code; however, in the concluding remarks of chapter 5 they explicitly warn that SMC becomes increasingly unreliable as additional time passes because the errors accumulate. Thus, they recommend "refreshing" the particle filter with the posterior distribution from a full MCMC sample every $T$ periods. Perhaps I misread their warnings, but this would seem to imply that you are better off with the rolling window MCMC. However, I would think there are substantial computer processing constraints with that method. For example, assuming you had 1,000 different univariate time series with 50 observations each and it took you 10 minutes to run a full MCMC Gibbs sampler. Then, it would take you 340 days ($(1000 \times (50-1) \times 10) \div 60 \div 24$) of continuous processing to estimate the parameters without look-ahead bias. Maybe my estimate of the time it takes to run the MCMC is wildly off, but I think it's a conservative but reasonable estimate.
It's been several years since you asked the question, so I'd be curious if you yourself have an answer now. | Estimating parameters of a dynamic linear model
I've read Dynamic Linear Models with R (good book), the final chapter deals with sequential Monte Carlo / particle filtering. It also includes some R code; however, in the concluding remarks of chapte |
24,045 | Quantifying QQ plot | As I say in response to your comment on your previous question, check out the Kolmogorov-Smirnov test. It uses the maximum absolute distance between two cumulative distribution functions (alternatively conceived as the maximum absolute distance of the curve in the QQ plot from the 45-degree line) as a statistic. The KS test can be found in R using the command ks.test() in the 'stats' library. Here's more information about its R usage. | Quantifying QQ plot | As I say in response to your comment on your previous question, check out the Kolmogorov-Smirnov test. It uses the maximum absolute distance between two cumulative distribution functions (alternativel | Quantifying QQ plot
As I say in response to your comment on your previous question, check out the Kolmogorov-Smirnov test. It uses the maximum absolute distance between two cumulative distribution functions (alternatively conceived as the maximum absolute distance of the curve in the QQ plot from the 45-degree line) as a statistic. The KS test can be found in R using the command ks.test() in the 'stats' library. Here's more information about its R usage. | Quantifying QQ plot
As I say in response to your comment on your previous question, check out the Kolmogorov-Smirnov test. It uses the maximum absolute distance between two cumulative distribution functions (alternativel |
24,046 | Quantifying QQ plot | I recently used the correlation between the empirical CDF and the fitted CDF to quantify goodness-of-fit, and I wonder if this approach might also be useful in the current case, which as I understand it involves comparing two empirical data sets. Interpolation might be necessary if there are different numbers of observations between the sets. | Quantifying QQ plot | I recently used the correlation between the empirical CDF and the fitted CDF to quantify goodness-of-fit, and I wonder if this approach might also be useful in the current case, which as I understand | Quantifying QQ plot
I recently used the correlation between the empirical CDF and the fitted CDF to quantify goodness-of-fit, and I wonder if this approach might also be useful in the current case, which as I understand it involves comparing two empirical data sets. Interpolation might be necessary if there are different numbers of observations between the sets. | Quantifying QQ plot
I recently used the correlation between the empirical CDF and the fitted CDF to quantify goodness-of-fit, and I wonder if this approach might also be useful in the current case, which as I understand |
24,047 | Quantifying QQ plot | I would say that the more or less canonical way to compare two distributions would be a chi-squared test. The statistic is not normalized, though, and it depends on how you choose the bins. The last point can of course be seen as a feature, not a bug: choosing bins appropriately allows you to look more closely for similarity in the tails than in the middle of the distributions, for instance. | Quantifying QQ plot | I would say that the more or less canonical way to compare two distributions would be a chi-squared test. The statistic is not normalized, though, and it depends on how you choose the bins. The last p | Quantifying QQ plot
I would say that the more or less canonical way to compare two distributions would be a chi-squared test. The statistic is not normalized, though, and it depends on how you choose the bins. The last point can of course be seen as a feature, not a bug: choosing bins appropriately allows you to look more closely for similarity in the tails than in the middle of the distributions, for instance. | Quantifying QQ plot
I would say that the more or less canonical way to compare two distributions would be a chi-squared test. The statistic is not normalized, though, and it depends on how you choose the bins. The last p |
24,048 | Quantifying QQ plot | A pretty direct measure of the "closeness" to linearity in a Q-Q plot would be a Shapiro-Francia test statistic (which is closely related to the better known Shapiro-Wilk and can be regarded as a simple approximation to it).
The Shapiro-Francia statistic is the squared correlation between the ordered data values and the expected normal order statistics (sometimes labelled "theoretical quantiles") -- that is, it should be the square of the correlation you see in the plot, a pretty direct summary measure.
(The Shapiro-Wilk is similar but takes into account correlations between the order statistics; it has a similar interpretation to the Shapiro-Francia and is pretty much equally as useful as a summary of the Q-Q plot.)
Either way, for a single number summary of what the Q-Q plot shows, one of those could be a suitable way to summarize the plot.
Personally I tend to look more for deviation from linearity rather than nearness to it (which would suggest looking at $1-W'$). This scale tends to leave you with fairly constant values for a given amount of non-normality.
[Sometimes I multiply by $n$ ($1-W')$ tends to get smaller with $n$ if sampling a normal). Under sampling from a normal, the mean or median of $n(1-W')$ tend to be fairly stable as $n$ changes. Multiplication by $n$ is still not quite right though, it fractionally overcorrects -- the result increases with $n$ somewhere between $\log(n)$ and $\sqrt{\log(n)}$ -- but this variation is small compared to the sorts of values you tend to get with any kind of substantial deviation from normality. Getting to a scale where the distribution doesn't change much with $n$ makes it more like a transformed p-value (less useful as a measure of amount of non-normality, more useful if you're interested in something more like judging if it's not merely random variation).] | Quantifying QQ plot | A pretty direct measure of the "closeness" to linearity in a Q-Q plot would be a Shapiro-Francia test statistic (which is closely related to the better known Shapiro-Wilk and can be regarded as a simp | Quantifying QQ plot
A pretty direct measure of the "closeness" to linearity in a Q-Q plot would be a Shapiro-Francia test statistic (which is closely related to the better known Shapiro-Wilk and can be regarded as a simple approximation to it).
The Shapiro-Francia statistic is the squared correlation between the ordered data values and the expected normal order statistics (sometimes labelled "theoretical quantiles") -- that is, it should be the square of the correlation you see in the plot, a pretty direct summary measure.
(The Shapiro-Wilk is similar but takes into account correlations between the order statistics; it has a similar interpretation to the Shapiro-Francia and is pretty much equally as useful as a summary of the Q-Q plot.)
Either way, for a single number summary of what the Q-Q plot shows, one of those could be a suitable way to summarize the plot.
Personally I tend to look more for deviation from linearity rather than nearness to it (which would suggest looking at $1-W'$). This scale tends to leave you with fairly constant values for a given amount of non-normality.
[Sometimes I multiply by $n$ ($1-W')$ tends to get smaller with $n$ if sampling a normal). Under sampling from a normal, the mean or median of $n(1-W')$ tend to be fairly stable as $n$ changes. Multiplication by $n$ is still not quite right though, it fractionally overcorrects -- the result increases with $n$ somewhere between $\log(n)$ and $\sqrt{\log(n)}$ -- but this variation is small compared to the sorts of values you tend to get with any kind of substantial deviation from normality. Getting to a scale where the distribution doesn't change much with $n$ makes it more like a transformed p-value (less useful as a measure of amount of non-normality, more useful if you're interested in something more like judging if it's not merely random variation).] | Quantifying QQ plot
A pretty direct measure of the "closeness" to linearity in a Q-Q plot would be a Shapiro-Francia test statistic (which is closely related to the better known Shapiro-Wilk and can be regarded as a simp |
24,049 | Where can I find good statistics quizzes? | I wrote a post compiling links of Practice Questions for Statistics in Psychology (Undergraduate Level).
http://jeromyanglim.blogspot.com/2009/12/practice-questions-for-statistics-in.html
The questions would fall into the introductory category. | Where can I find good statistics quizzes? | I wrote a post compiling links of Practice Questions for Statistics in Psychology (Undergraduate Level).
http://jeromyanglim.blogspot.com/2009/12/practice-questions-for-statistics-in.html
The questio | Where can I find good statistics quizzes?
I wrote a post compiling links of Practice Questions for Statistics in Psychology (Undergraduate Level).
http://jeromyanglim.blogspot.com/2009/12/practice-questions-for-statistics-in.html
The questions would fall into the introductory category. | Where can I find good statistics quizzes?
I wrote a post compiling links of Practice Questions for Statistics in Psychology (Undergraduate Level).
http://jeromyanglim.blogspot.com/2009/12/practice-questions-for-statistics-in.html
The questio |
24,050 | Where can I find good statistics quizzes? | Tests and thousands of sample questions are available on the ARTIST ("Assessment Resource Tools for Improving Statistical Thinking") site, https://app.gen.umn.edu/artist/tests/index.html . Most are appropriate for an intro stats course. | Where can I find good statistics quizzes? | Tests and thousands of sample questions are available on the ARTIST ("Assessment Resource Tools for Improving Statistical Thinking") site, https://app.gen.umn.edu/artist/tests/index.html . Most are a | Where can I find good statistics quizzes?
Tests and thousands of sample questions are available on the ARTIST ("Assessment Resource Tools for Improving Statistical Thinking") site, https://app.gen.umn.edu/artist/tests/index.html . Most are appropriate for an intro stats course. | Where can I find good statistics quizzes?
Tests and thousands of sample questions are available on the ARTIST ("Assessment Resource Tools for Improving Statistical Thinking") site, https://app.gen.umn.edu/artist/tests/index.html . Most are a |
24,051 | Does the use of OLS imply the model is linear in parameters? | Ordinary least squares regression is a special case of least squares regression.
With least squares regression we try to find a fit $\hat{y}_i({\bf{x}}_i,\boldsymbol{\beta})$ to datapoints $y_i$ by minimising the sum of (weighted) squared residuals.
$$\text{given data $\bf{x}_i$ and $y_i$, and weights $w_i$ find $\boldsymbol{\beta}$ that minimises:} \quad L = \sum_{i = 1}^n w_i [y_i-\hat{y}_i({\bf{x}}_i,\boldsymbol{\beta})]^2$$
OLS is the special case when the weights are equal $w_i = 1$ and the model is a linear combination
$$\hat{y}_i({\bf{x}}_i,\boldsymbol{\beta}) = \beta_1 f_1({\bf x}) + \beta_2 f_2({\bf x}) + \dots +\beta_p f_p({\bf x}). $$
OLS is by definition using a linear model.
But not all methods that use linear models are OLS. For instance think of GLM, quantile regression, lasso/ridge or Bayesian modelling, which can use a linear model but with a different cost function. | Does the use of OLS imply the model is linear in parameters? | Ordinary least squares regression is a special case of least squares regression.
With least squares regression we try to find a fit $\hat{y}_i({\bf{x}}_i,\boldsymbol{\beta})$ to datapoints $y_i$ by mi | Does the use of OLS imply the model is linear in parameters?
Ordinary least squares regression is a special case of least squares regression.
With least squares regression we try to find a fit $\hat{y}_i({\bf{x}}_i,\boldsymbol{\beta})$ to datapoints $y_i$ by minimising the sum of (weighted) squared residuals.
$$\text{given data $\bf{x}_i$ and $y_i$, and weights $w_i$ find $\boldsymbol{\beta}$ that minimises:} \quad L = \sum_{i = 1}^n w_i [y_i-\hat{y}_i({\bf{x}}_i,\boldsymbol{\beta})]^2$$
OLS is the special case when the weights are equal $w_i = 1$ and the model is a linear combination
$$\hat{y}_i({\bf{x}}_i,\boldsymbol{\beta}) = \beta_1 f_1({\bf x}) + \beta_2 f_2({\bf x}) + \dots +\beta_p f_p({\bf x}). $$
OLS is by definition using a linear model.
But not all methods that use linear models are OLS. For instance think of GLM, quantile regression, lasso/ridge or Bayesian modelling, which can use a linear model but with a different cost function. | Does the use of OLS imply the model is linear in parameters?
Ordinary least squares regression is a special case of least squares regression.
With least squares regression we try to find a fit $\hat{y}_i({\bf{x}}_i,\boldsymbol{\beta})$ to datapoints $y_i$ by mi |
24,052 | Does the use of OLS imply the model is linear in parameters? | By means of OLS one can estimate non linear relations provided they are purely additive or purely multiplicative (log-additive). For instance, quadratic relations like this:
$$
y_t = a + bx_t + cx^2_t + e_t,
$$
are perfectly fitted within the OLS framework and of course, their variants and extenions; but not like this:
$$
y_t = a\log b^{2x_{1,t}}+ cx_{2,t}^{b}e_t.
$$
The latter can arise in structural specifications where typically the parameters a,b,c is what you can get from data, so that reduced version models are simply ill designed to make good forecasts. | Does the use of OLS imply the model is linear in parameters? | By means of OLS one can estimate non linear relations provided they are purely additive or purely multiplicative (log-additive). For instance, quadratic relations like this:
$$
y_t = a + bx_t + cx^2_t | Does the use of OLS imply the model is linear in parameters?
By means of OLS one can estimate non linear relations provided they are purely additive or purely multiplicative (log-additive). For instance, quadratic relations like this:
$$
y_t = a + bx_t + cx^2_t + e_t,
$$
are perfectly fitted within the OLS framework and of course, their variants and extenions; but not like this:
$$
y_t = a\log b^{2x_{1,t}}+ cx_{2,t}^{b}e_t.
$$
The latter can arise in structural specifications where typically the parameters a,b,c is what you can get from data, so that reduced version models are simply ill designed to make good forecasts. | Does the use of OLS imply the model is linear in parameters?
By means of OLS one can estimate non linear relations provided they are purely additive or purely multiplicative (log-additive). For instance, quadratic relations like this:
$$
y_t = a + bx_t + cx^2_t |
24,053 | Use of Complex Numbers in Statistics | There are two broad classes of use of complex numbers in statistics, one being when the underlying problem uses complex numbers (leading to complex random variables), and the other being when tools using complex numbers are used to describe statistical problems involving only real random variables. (I will leave aside theories of probability that use complex probabilities - these are pretty crazy and I have never been able to see the use in them.)
Problems involving complex random variables: Complex numbers arise in statistics whenever you are dealing with an underlying problem where the random variables of interest are complex numbers themselves (i.e., complex random variables). These applications tend to arise in the context of engineering and physics problems where complex numbers are used to describe some phenomena of interest, and we wish to add randomness to the description of that phenomena. In particular, they often come up in the context of dealing with circular motion that is described by complex numbers, or in electrical circuits. There is already a substantial statistical literature on this field, including results for complex versions of normal random variables, etc. (for an overview, see e.g., Eriksson et al 2009, Eriksson et al 2010). (Note: Since your friend is an electrical engineer, it might be worth pointing him to various works published in IEEE that deal with complex random variables. These are often used in electrical engineering work when the analyst wishes to add randomness to some aspect of an underlying electrical problem that uses complex numbers.)
Another common example of this kind of situation is whenever you have polynomials with randomly generated real coefficients, where the distribution of the coefficients is continuous. In this case, even though the initial random variables are real, this gives rise to complex roots of the polynomial, so when you write the polynomial in its factorised form, this involves complex random variables (see e.g., Shepp and Vanderbei 1995, Ibragimov and Zeitouni 1997, Kabluchko and Zaporozhets 2014). This is a simple example where random objects involving real numbers give rise to complex random variables.
Complex tools for dealing with real random variables: The most common set of statistical tools that deal with real random variables, but use complex numbers, are tools that are applications of the Fourier transform to various statistical problems. This includes the characteristic function used to describe a distribution in Fourier-space, frequency-space periodograms used for identifying signal frequencies in time-series analysis, and the various spectral densities in time-series analysis. These are all examples where a standard mathematical tool using complex numbers is applied in a probability problem where the underlying random variables are real numbers. These methods are often used in time-series analysis, but also crop up sometimes when dealing with tricky probability problems involving convolutions. (In fact, the simplest proof of the central limit theorem uses the characteristic function of the normal distribution, so it involves the use of complex numbers.) | Use of Complex Numbers in Statistics | There are two broad classes of use of complex numbers in statistics, one being when the underlying problem uses complex numbers (leading to complex random variables), and the other being when tools us | Use of Complex Numbers in Statistics
There are two broad classes of use of complex numbers in statistics, one being when the underlying problem uses complex numbers (leading to complex random variables), and the other being when tools using complex numbers are used to describe statistical problems involving only real random variables. (I will leave aside theories of probability that use complex probabilities - these are pretty crazy and I have never been able to see the use in them.)
Problems involving complex random variables: Complex numbers arise in statistics whenever you are dealing with an underlying problem where the random variables of interest are complex numbers themselves (i.e., complex random variables). These applications tend to arise in the context of engineering and physics problems where complex numbers are used to describe some phenomena of interest, and we wish to add randomness to the description of that phenomena. In particular, they often come up in the context of dealing with circular motion that is described by complex numbers, or in electrical circuits. There is already a substantial statistical literature on this field, including results for complex versions of normal random variables, etc. (for an overview, see e.g., Eriksson et al 2009, Eriksson et al 2010). (Note: Since your friend is an electrical engineer, it might be worth pointing him to various works published in IEEE that deal with complex random variables. These are often used in electrical engineering work when the analyst wishes to add randomness to some aspect of an underlying electrical problem that uses complex numbers.)
Another common example of this kind of situation is whenever you have polynomials with randomly generated real coefficients, where the distribution of the coefficients is continuous. In this case, even though the initial random variables are real, this gives rise to complex roots of the polynomial, so when you write the polynomial in its factorised form, this involves complex random variables (see e.g., Shepp and Vanderbei 1995, Ibragimov and Zeitouni 1997, Kabluchko and Zaporozhets 2014). This is a simple example where random objects involving real numbers give rise to complex random variables.
Complex tools for dealing with real random variables: The most common set of statistical tools that deal with real random variables, but use complex numbers, are tools that are applications of the Fourier transform to various statistical problems. This includes the characteristic function used to describe a distribution in Fourier-space, frequency-space periodograms used for identifying signal frequencies in time-series analysis, and the various spectral densities in time-series analysis. These are all examples where a standard mathematical tool using complex numbers is applied in a probability problem where the underlying random variables are real numbers. These methods are often used in time-series analysis, but also crop up sometimes when dealing with tricky probability problems involving convolutions. (In fact, the simplest proof of the central limit theorem uses the characteristic function of the normal distribution, so it involves the use of complex numbers.) | Use of Complex Numbers in Statistics
There are two broad classes of use of complex numbers in statistics, one being when the underlying problem uses complex numbers (leading to complex random variables), and the other being when tools us |
24,054 | Why is logistic regression well calibrated, and how to ruin its calibration? | Although this question and its first answer seems to be focused on theoretical issues of logistic regression model calibration, the issue of:
How could one ruin the calibration of a logistic regression...?
deserves some attention with respect to real-world applications, for future readers of this page. We shouldn't forget that the logistic regression model has to be well specified, and that this issue can be particularly troublesome for logistic regression.
First, if the log-odds of class membership is not linearly related to the predictors included in the model then it will not be well calibrated. Harrell's chapter 10 on Binary Logistic Regression devotes about 20 pages to "Assessment of Model Fit" so that one can take advantage of the "asymptotic unbiasedness of the maximum likelihood estimator," as @whuber put it, in practice.
Second, model specification is a particular issue in logistic regression, as it has an inherent omitted variable bias that can be surprising to those with a background in ordinary linear regression. As that page puts it:
Omitted variables will bias the coefficients on included variables even if the omitted variables are uncorrelated with the included variables.
That page also has a useful explanation of why this behavior is to be expected, with a theoretical explanation for related, analytically tractable, probit models. So unless you know that you have included all predictors related to class membership, you might run into dangers of misspecification and poor calibration in practice.
With respect to model specification, it's quite possible that tree-based methods like random forest, which do not assume linearity over an entire range of predictor values and inherently provide the possibility of finding and including interactions among predictors, will end up with a better-calibrated model in practice than a logistic regression model that does not take interaction terms or non-linearity sufficiently into account. With respect to omitted-variable bias, it's not clear to me whether any method for evaluating class-membership probabilities can deal with that issue adequately. | Why is logistic regression well calibrated, and how to ruin its calibration? | Although this question and its first answer seems to be focused on theoretical issues of logistic regression model calibration, the issue of:
How could one ruin the calibration of a logistic regressi | Why is logistic regression well calibrated, and how to ruin its calibration?
Although this question and its first answer seems to be focused on theoretical issues of logistic regression model calibration, the issue of:
How could one ruin the calibration of a logistic regression...?
deserves some attention with respect to real-world applications, for future readers of this page. We shouldn't forget that the logistic regression model has to be well specified, and that this issue can be particularly troublesome for logistic regression.
First, if the log-odds of class membership is not linearly related to the predictors included in the model then it will not be well calibrated. Harrell's chapter 10 on Binary Logistic Regression devotes about 20 pages to "Assessment of Model Fit" so that one can take advantage of the "asymptotic unbiasedness of the maximum likelihood estimator," as @whuber put it, in practice.
Second, model specification is a particular issue in logistic regression, as it has an inherent omitted variable bias that can be surprising to those with a background in ordinary linear regression. As that page puts it:
Omitted variables will bias the coefficients on included variables even if the omitted variables are uncorrelated with the included variables.
That page also has a useful explanation of why this behavior is to be expected, with a theoretical explanation for related, analytically tractable, probit models. So unless you know that you have included all predictors related to class membership, you might run into dangers of misspecification and poor calibration in practice.
With respect to model specification, it's quite possible that tree-based methods like random forest, which do not assume linearity over an entire range of predictor values and inherently provide the possibility of finding and including interactions among predictors, will end up with a better-calibrated model in practice than a logistic regression model that does not take interaction terms or non-linearity sufficiently into account. With respect to omitted-variable bias, it's not clear to me whether any method for evaluating class-membership probabilities can deal with that issue adequately. | Why is logistic regression well calibrated, and how to ruin its calibration?
Although this question and its first answer seems to be focused on theoretical issues of logistic regression model calibration, the issue of:
How could one ruin the calibration of a logistic regressi |
24,055 | Why is logistic regression well calibrated, and how to ruin its calibration? | Logistic regression is a classification method that basically learns a probability function $\pi_\theta(x)$ over the input space by fitting the parameters $\theta$. If the predicted probabilities are learned with the appropriate loss function, than logistic regression has the potential to learn an unbiased estimation of the binary event probabilities, whenever its has sufficient capacity (input features).
The log loss allows such unbiased estimation. Consider the fact that the log loss function is simply the negative log likelihood of a Bernoulli distribution $z \thicksim \text{Ber}(p)$. The maximum likelihood estimation for $p$ is unbiased given a set of observations for variable $z$. In the case of classification over some input space $\mathcal{X}$, one can imagine having one Bernoulli distribution for all points in $\mathcal{X}$. Most often, you will only have 1 observation $y_i$ per Bernoulli distribution, which is located at $x_i$. Jointly applying maximum likelihood estimation for all observed Bernoulli distributions $y_i \thicksim \text{Ber}(\pi(x_i))$ will apply several constraints to $\pi_\theta$. Since all these constraints leads to unbiased estimations, and as long as the function $\pi_\theta$ is sufficently flexible to fit the true underlying probability function $\pi^*$, then the learning procedure is consistent and will converge to the optimal model as you get more data. Thus, limiting the model capacity (fewer features for instance) can hinder the calibration of a logistic regression by increasing the distance between the best learnable model and the true model.
Using an incorrect observation model with the logistic regression will lead to uncalibrated probabilities. Modeling binary events with a normal distribution is inappropriate, and should not be used in combination with logistic regression. The loss function corresponding to the normal distribution observation model is the Mean Squared Error. Thus, using an MSE loss would certaintly hinder its calibration. | Why is logistic regression well calibrated, and how to ruin its calibration? | Logistic regression is a classification method that basically learns a probability function $\pi_\theta(x)$ over the input space by fitting the parameters $\theta$. If the predicted probabilities are | Why is logistic regression well calibrated, and how to ruin its calibration?
Logistic regression is a classification method that basically learns a probability function $\pi_\theta(x)$ over the input space by fitting the parameters $\theta$. If the predicted probabilities are learned with the appropriate loss function, than logistic regression has the potential to learn an unbiased estimation of the binary event probabilities, whenever its has sufficient capacity (input features).
The log loss allows such unbiased estimation. Consider the fact that the log loss function is simply the negative log likelihood of a Bernoulli distribution $z \thicksim \text{Ber}(p)$. The maximum likelihood estimation for $p$ is unbiased given a set of observations for variable $z$. In the case of classification over some input space $\mathcal{X}$, one can imagine having one Bernoulli distribution for all points in $\mathcal{X}$. Most often, you will only have 1 observation $y_i$ per Bernoulli distribution, which is located at $x_i$. Jointly applying maximum likelihood estimation for all observed Bernoulli distributions $y_i \thicksim \text{Ber}(\pi(x_i))$ will apply several constraints to $\pi_\theta$. Since all these constraints leads to unbiased estimations, and as long as the function $\pi_\theta$ is sufficently flexible to fit the true underlying probability function $\pi^*$, then the learning procedure is consistent and will converge to the optimal model as you get more data. Thus, limiting the model capacity (fewer features for instance) can hinder the calibration of a logistic regression by increasing the distance between the best learnable model and the true model.
Using an incorrect observation model with the logistic regression will lead to uncalibrated probabilities. Modeling binary events with a normal distribution is inappropriate, and should not be used in combination with logistic regression. The loss function corresponding to the normal distribution observation model is the Mean Squared Error. Thus, using an MSE loss would certaintly hinder its calibration. | Why is logistic regression well calibrated, and how to ruin its calibration?
Logistic regression is a classification method that basically learns a probability function $\pi_\theta(x)$ over the input space by fitting the parameters $\theta$. If the predicted probabilities are |
24,056 | Regression and causality in econometrics | In the context of the Pearl paper you've given, what most econometricians would call a true model is input I-1 to the Structural Causal Model: a set of assumptions $A$ and a model $M_A$ that encodes these assumptions, written as a system of structural equations (as in Models 1 and 2) and a list of statistical assumptions relating the variables. In general, the true model need not be recursive, so the corresponding graph can have cycles.
What's an example of a true model? Consider the relationship between schooling and earnings, described in Angrist and Pischke (2009), section 3.2. For individual $i$, what econometricians would call the true model is an assumed function mapping any level of schooling $s$ to an outcome $y_{si}$:
$$
y_{si} = f_i(s).
$$
This is exactly the potential outcome. One could go further and assume a parametric functional form for $f_i(s)$. For example, the linear constant effects causal model:
$$
f_i(s) = \alpha + \rho s + \eta_i.
$$
Here, $\alpha$ and $\rho$ are unobserved parameters. By writing it this way, we assume that $\eta_i$ does not depend on $s$. In Pearl's language, this tells us what happens to expected earnings if we fix an individual's schooling at $s_i = s_0$, but we don't observe $\eta_i$:
$$
E[y_{si} \mid do(s_i = s_0)] = E[f_i(s_0)] = \alpha + \rho s_0 + E[\eta_i].
$$
We haven't said what queries we're interested in, or what data we have. So the "true model" is not a full SCM. (This is generally true, not just in this example.)
What's the connection between a true model and a randomized experiment? Suppose an econometrician wants to estimate $\rho$. Just observing $(s_i, y_i)$ for a bunch of individuals isn't sufficient. This is identical to Pearl's point about statistical conditioning. Here
$$
E[y_{si} \mid s_i = s_0] = E[f_i(s_0) \mid s_i = s_0] = \alpha + \rho s_0 + E[\eta_i \mid s_i = s_0].
$$
As Angrist and Pischke point out, $\eta_i$ may be correlated with $s_i$ in observational data, due to selection bias: an individual's decision about schooling might depend on her value of $\eta_i$.
Randomized experiments are one way to correct for this correlation. Using Pearl's notation loosely here, if we randomly assign our subjects to $do(s_i = s_0)$ and $do(s_i = s_1)$ then we can estimate $E[y_{si} \mid do(s_i = s_1)]$ and $E[y_{si} \mid do(s_i = s_0)]$. Then $\rho$ is given by:
$$
E[y_{si} \mid do(s_i = s_1)] - E[y_{si} \mid do(s_i = s_0)] = \rho(s_1 - s_0).
$$
With additional assumptions and data, there are other ways to correct for the correlation. A randomized experiment is only considered the "best" because we may not believe the other assumptions. For example, with the Conditional Independence Assumption and additional data, we could estimate $\rho$ by OLS; or we could bring in instrumental variables.
Edit 2 (CIA): This is mainly a philosophical point, and Angrist and Pischke may disagree with my presentation here. The Conditional Independence Assumption (selection on observables) lets us correct for selection bias. It adds an assumption about joint distributions: that
$$
f_i(s) \perp\!\!\!\perp s_i \mid X_i
$$
for all $s$. Using just conditional expectation algebra (see the derivation in Angrist and Pischke) it follows that we can write
$$
y_i = f_i(s_i) = \alpha + \rho s_i + X_i' \gamma + v_i
$$
with $E[v_i \mid X_i, s_i] = 0$. This equation allows us to estimate $\rho$ in the data using OLS.
Neither randomization nor the CIA goes into the system of equations that defines the true model. They are statistical assumptions that give us ways to estimate parameters of a model we've already defined, using the data we have. Econometricians wouldn't typically consider the CIA part of the true model, but Pearl would include it in $A$. | Regression and causality in econometrics | In the context of the Pearl paper you've given, what most econometricians would call a true model is input I-1 to the Structural Causal Model: a set of assumptions $A$ and a model $M_A$ that encodes t | Regression and causality in econometrics
In the context of the Pearl paper you've given, what most econometricians would call a true model is input I-1 to the Structural Causal Model: a set of assumptions $A$ and a model $M_A$ that encodes these assumptions, written as a system of structural equations (as in Models 1 and 2) and a list of statistical assumptions relating the variables. In general, the true model need not be recursive, so the corresponding graph can have cycles.
What's an example of a true model? Consider the relationship between schooling and earnings, described in Angrist and Pischke (2009), section 3.2. For individual $i$, what econometricians would call the true model is an assumed function mapping any level of schooling $s$ to an outcome $y_{si}$:
$$
y_{si} = f_i(s).
$$
This is exactly the potential outcome. One could go further and assume a parametric functional form for $f_i(s)$. For example, the linear constant effects causal model:
$$
f_i(s) = \alpha + \rho s + \eta_i.
$$
Here, $\alpha$ and $\rho$ are unobserved parameters. By writing it this way, we assume that $\eta_i$ does not depend on $s$. In Pearl's language, this tells us what happens to expected earnings if we fix an individual's schooling at $s_i = s_0$, but we don't observe $\eta_i$:
$$
E[y_{si} \mid do(s_i = s_0)] = E[f_i(s_0)] = \alpha + \rho s_0 + E[\eta_i].
$$
We haven't said what queries we're interested in, or what data we have. So the "true model" is not a full SCM. (This is generally true, not just in this example.)
What's the connection between a true model and a randomized experiment? Suppose an econometrician wants to estimate $\rho$. Just observing $(s_i, y_i)$ for a bunch of individuals isn't sufficient. This is identical to Pearl's point about statistical conditioning. Here
$$
E[y_{si} \mid s_i = s_0] = E[f_i(s_0) \mid s_i = s_0] = \alpha + \rho s_0 + E[\eta_i \mid s_i = s_0].
$$
As Angrist and Pischke point out, $\eta_i$ may be correlated with $s_i$ in observational data, due to selection bias: an individual's decision about schooling might depend on her value of $\eta_i$.
Randomized experiments are one way to correct for this correlation. Using Pearl's notation loosely here, if we randomly assign our subjects to $do(s_i = s_0)$ and $do(s_i = s_1)$ then we can estimate $E[y_{si} \mid do(s_i = s_1)]$ and $E[y_{si} \mid do(s_i = s_0)]$. Then $\rho$ is given by:
$$
E[y_{si} \mid do(s_i = s_1)] - E[y_{si} \mid do(s_i = s_0)] = \rho(s_1 - s_0).
$$
With additional assumptions and data, there are other ways to correct for the correlation. A randomized experiment is only considered the "best" because we may not believe the other assumptions. For example, with the Conditional Independence Assumption and additional data, we could estimate $\rho$ by OLS; or we could bring in instrumental variables.
Edit 2 (CIA): This is mainly a philosophical point, and Angrist and Pischke may disagree with my presentation here. The Conditional Independence Assumption (selection on observables) lets us correct for selection bias. It adds an assumption about joint distributions: that
$$
f_i(s) \perp\!\!\!\perp s_i \mid X_i
$$
for all $s$. Using just conditional expectation algebra (see the derivation in Angrist and Pischke) it follows that we can write
$$
y_i = f_i(s_i) = \alpha + \rho s_i + X_i' \gamma + v_i
$$
with $E[v_i \mid X_i, s_i] = 0$. This equation allows us to estimate $\rho$ in the data using OLS.
Neither randomization nor the CIA goes into the system of equations that defines the true model. They are statistical assumptions that give us ways to estimate parameters of a model we've already defined, using the data we have. Econometricians wouldn't typically consider the CIA part of the true model, but Pearl would include it in $A$. | Regression and causality in econometrics
In the context of the Pearl paper you've given, what most econometricians would call a true model is input I-1 to the Structural Causal Model: a set of assumptions $A$ and a model $M_A$ that encodes t |
24,057 | Regression and causality in econometrics | I will start with the second part of your question, which pertains to the difference between randomized control studies and observational studies, and will wrap it up with the part of your question pertaining to "true model" vs. "structural causal model".
I will use one of Pearl's examples, which is an easy one to grasp. You notice that when the ice cream sales are highest (in the summer), the crime rate is highest (in the summer), and when the ice cream sales are lowest (in the winter), the crime rate is lowest. This makes you wonder whether the level of ice cream sales is CAUSING the level of crime.
If you could perform a randomized control experiment, you would take many days, suppose 100 days, and on each of these days randomly assign the level of sales of ice cream. Key to this randomization, given the causal structure depicted in the graph below, is that the assignment of the level of ice cream sales is independent of the level of temperature. If such a hypothetical experiment could be performed you should find that on the days when the sales were randomly assigned to be high, the average crime rate is not statistically different than on days when the sales were assigned to be low. If you had your hands on such data, you'd be all set. Most of us, however, have to work with observational data, where randomization did not do the magic it did in the above example. Crucially, in observational data, we do not know whether the level of Ice Cream Sales was determined independently of Temperature or whether it depends on temperature. As a result, we'd have to somehow untangle the causal effect from the merely correlative.
Pearl's claim is that statistics doesn't have a way of representing E[Y|We Set X to equal a particular value], as opposed to E[Y|Conditioning on the values of X as given by the joint distribution of X and Y]. This is why he uses the notation E[Y|do(X=x)] to refer to the expectation of Y, when we intervene on X and set its value equal to x, as opposed to E[Y|X=x], which refers to conditioning on the value of X, and taking it as given.
What exactly does it mean to intervene on variable X or to set X equal to a particular value? And how is it different than conditioning on the value of X?
Intervention is best explained with the graph below, in which Temperature has a causal effect on both Ice Cream Sales and Crime Rate, and Ice Cream Sales has a causal effect on Crime Rate, and the U variables stand for unmeasured factors that affect the variables but we do not care to model these factors. Our interest is in the causal effect of Ice Cream Sales on Crime Rate and suppose that our causal depiction is accurate and complete. See the graph below.
Now suppose that we could set the level of ice cream sales very high and observe whether that would be translated into higher crime rates. To do so we would intervene on Ice Cream Sales, meaning that we do not allow Ice Cream Sales to naturally respond to Temperature, in fact this amounts to us performing what Pearl calls "surgery" on the graph by removing all the edges directed into that variable. In our case, since we're intervening on Ice Cream Sales, we would remove the edge from Temperature to Ice Cream sales, as depicted below. We set the level of Ice Cream Sales to whatever we want, rather than allow it be determined by Temperature. Then imagine that we performed two such experiments, one in which we intervened and set the level of ice cream sales very high and one in which we intervened and set the level of ice cream sales very low, and then observe how Crime Rate responds in each case. Then we'll start to get a sense of whether there is a causal effect between Ice Cream Sales and Crime Rate or not.
Pearl distinguished between intervention and conditioning. Conditioning here refers merely to a filtering of a dataset. Think of conditioning on Temperature as looking in our observational dataset only at cases when the Temperature was the same. Conditioning does not always give us the causal effect we're looking for (it doesn't give us the causal effect most of the time). It happens that conditioning would give us the causal effect in the simplistic picture drawn above, but we can easily modify the graph to illustrate an example when conditioning on Temperature would not give us the causal effect, whereas intervening on Ice Cream Sales would. Imagine that there is another variable which causes Ice Cream Sales, call it Variable X. In the graph is would be represented with an arrow into Ice Cream Sales. In that case, conditioning on Temperature would not give us the causal effect of Ice Cream Sales on Crime Rate because it would leave untouched the path: Variable X -> Ice Cream Sales -> Crime Rate. In contrast, intervening on Ice Cream Sales would, by definition, mean that we remove all arrows into Ice Cream, and that would give us the causal effect of Ice Cream Sales on Crime Rate.
I will just mention that one Pearl's greatest contributions, in my opinion, is the concept of colliders and how conditioning on colliders will cause independent variables to be likely dependent.
Pearl would call a model with causal coefficients (direct effect) as given by E[Y|do(X=x)] the structural causal model. And regressions in which the coefficients are given by E[Y|X] is what he says authors mistakenly call "true model", mistakenly that is, when they are looking to estimate the causal effect of X on Y and not merely to forecast Y.
So, what's the link between the structural models and what we can do empirically? Suppose you wanted to understand the causal effect of variable A on variable B. Pearl suggests 2 ways to do so: Backdoor criterion and Front-door criterion. I will expand on the former.
Backdoor Criterion: First, you need to correctly map out all the causes of each variable and using the Backdoor criterion identify the set of variables that you'd need to condition on (and just as importantly the set of variables you need to make sure you do not condition on - i.e. colliders) in order to isolate the causal effect of A on B. As Pearl points out, this is testable. You can test whether or not you've correctly mapped out the causal model. In practice, this is easier said than done and in my opinion the biggest challenge with Pearl's Backdoor criterion. Second, run the regression, as usual. Now you know what to condition on. The coefficients you'll get would be the direct effects, as mapped out in your causal map. Note that this approach is fundamentally different from the traditional approach used in estimating causality in econometrics - Instrumental Variable regressions. | Regression and causality in econometrics | I will start with the second part of your question, which pertains to the difference between randomized control studies and observational studies, and will wrap it up with the part of your question pe | Regression and causality in econometrics
I will start with the second part of your question, which pertains to the difference between randomized control studies and observational studies, and will wrap it up with the part of your question pertaining to "true model" vs. "structural causal model".
I will use one of Pearl's examples, which is an easy one to grasp. You notice that when the ice cream sales are highest (in the summer), the crime rate is highest (in the summer), and when the ice cream sales are lowest (in the winter), the crime rate is lowest. This makes you wonder whether the level of ice cream sales is CAUSING the level of crime.
If you could perform a randomized control experiment, you would take many days, suppose 100 days, and on each of these days randomly assign the level of sales of ice cream. Key to this randomization, given the causal structure depicted in the graph below, is that the assignment of the level of ice cream sales is independent of the level of temperature. If such a hypothetical experiment could be performed you should find that on the days when the sales were randomly assigned to be high, the average crime rate is not statistically different than on days when the sales were assigned to be low. If you had your hands on such data, you'd be all set. Most of us, however, have to work with observational data, where randomization did not do the magic it did in the above example. Crucially, in observational data, we do not know whether the level of Ice Cream Sales was determined independently of Temperature or whether it depends on temperature. As a result, we'd have to somehow untangle the causal effect from the merely correlative.
Pearl's claim is that statistics doesn't have a way of representing E[Y|We Set X to equal a particular value], as opposed to E[Y|Conditioning on the values of X as given by the joint distribution of X and Y]. This is why he uses the notation E[Y|do(X=x)] to refer to the expectation of Y, when we intervene on X and set its value equal to x, as opposed to E[Y|X=x], which refers to conditioning on the value of X, and taking it as given.
What exactly does it mean to intervene on variable X or to set X equal to a particular value? And how is it different than conditioning on the value of X?
Intervention is best explained with the graph below, in which Temperature has a causal effect on both Ice Cream Sales and Crime Rate, and Ice Cream Sales has a causal effect on Crime Rate, and the U variables stand for unmeasured factors that affect the variables but we do not care to model these factors. Our interest is in the causal effect of Ice Cream Sales on Crime Rate and suppose that our causal depiction is accurate and complete. See the graph below.
Now suppose that we could set the level of ice cream sales very high and observe whether that would be translated into higher crime rates. To do so we would intervene on Ice Cream Sales, meaning that we do not allow Ice Cream Sales to naturally respond to Temperature, in fact this amounts to us performing what Pearl calls "surgery" on the graph by removing all the edges directed into that variable. In our case, since we're intervening on Ice Cream Sales, we would remove the edge from Temperature to Ice Cream sales, as depicted below. We set the level of Ice Cream Sales to whatever we want, rather than allow it be determined by Temperature. Then imagine that we performed two such experiments, one in which we intervened and set the level of ice cream sales very high and one in which we intervened and set the level of ice cream sales very low, and then observe how Crime Rate responds in each case. Then we'll start to get a sense of whether there is a causal effect between Ice Cream Sales and Crime Rate or not.
Pearl distinguished between intervention and conditioning. Conditioning here refers merely to a filtering of a dataset. Think of conditioning on Temperature as looking in our observational dataset only at cases when the Temperature was the same. Conditioning does not always give us the causal effect we're looking for (it doesn't give us the causal effect most of the time). It happens that conditioning would give us the causal effect in the simplistic picture drawn above, but we can easily modify the graph to illustrate an example when conditioning on Temperature would not give us the causal effect, whereas intervening on Ice Cream Sales would. Imagine that there is another variable which causes Ice Cream Sales, call it Variable X. In the graph is would be represented with an arrow into Ice Cream Sales. In that case, conditioning on Temperature would not give us the causal effect of Ice Cream Sales on Crime Rate because it would leave untouched the path: Variable X -> Ice Cream Sales -> Crime Rate. In contrast, intervening on Ice Cream Sales would, by definition, mean that we remove all arrows into Ice Cream, and that would give us the causal effect of Ice Cream Sales on Crime Rate.
I will just mention that one Pearl's greatest contributions, in my opinion, is the concept of colliders and how conditioning on colliders will cause independent variables to be likely dependent.
Pearl would call a model with causal coefficients (direct effect) as given by E[Y|do(X=x)] the structural causal model. And regressions in which the coefficients are given by E[Y|X] is what he says authors mistakenly call "true model", mistakenly that is, when they are looking to estimate the causal effect of X on Y and not merely to forecast Y.
So, what's the link between the structural models and what we can do empirically? Suppose you wanted to understand the causal effect of variable A on variable B. Pearl suggests 2 ways to do so: Backdoor criterion and Front-door criterion. I will expand on the former.
Backdoor Criterion: First, you need to correctly map out all the causes of each variable and using the Backdoor criterion identify the set of variables that you'd need to condition on (and just as importantly the set of variables you need to make sure you do not condition on - i.e. colliders) in order to isolate the causal effect of A on B. As Pearl points out, this is testable. You can test whether or not you've correctly mapped out the causal model. In practice, this is easier said than done and in my opinion the biggest challenge with Pearl's Backdoor criterion. Second, run the regression, as usual. Now you know what to condition on. The coefficients you'll get would be the direct effects, as mapped out in your causal map. Note that this approach is fundamentally different from the traditional approach used in estimating causality in econometrics - Instrumental Variable regressions. | Regression and causality in econometrics
I will start with the second part of your question, which pertains to the difference between randomized control studies and observational studies, and will wrap it up with the part of your question pe |
24,058 | Regression and causality in econometrics | The use of ‘causal’ in such regression/correlation based approaches is misleading, in my opinion. Path analysis, structural equation modeling, Granger causality, etc attempts to license causal inferences by imposing some fairly tenuous assumptions. In the case of Structural equation modeling for instance, the paths are directional and A appears to ‘cause’ B, but this simply means that the model as structured is ‘plausible’ in that it reproduces an observed covariance matrix (in fact, the direction of the paths don’t even matter much - just the constraints). | Regression and causality in econometrics | The use of ‘causal’ in such regression/correlation based approaches is misleading, in my opinion. Path analysis, structural equation modeling, Granger causality, etc attempts to license causal inferen | Regression and causality in econometrics
The use of ‘causal’ in such regression/correlation based approaches is misleading, in my opinion. Path analysis, structural equation modeling, Granger causality, etc attempts to license causal inferences by imposing some fairly tenuous assumptions. In the case of Structural equation modeling for instance, the paths are directional and A appears to ‘cause’ B, but this simply means that the model as structured is ‘plausible’ in that it reproduces an observed covariance matrix (in fact, the direction of the paths don’t even matter much - just the constraints). | Regression and causality in econometrics
The use of ‘causal’ in such regression/correlation based approaches is misleading, in my opinion. Path analysis, structural equation modeling, Granger causality, etc attempts to license causal inferen |
24,059 | Difference between Gaussian process regression and other regression techniques (say linear regression) | A Gaussian Process doesn't have to perfectly interpolate between points, as that Wikipedia link shows; it all depends on the covariance function that you use.
For example, consider the GP of the form $X \sim \mathcal N(0, \Sigma_{k_t})$, where $X$ is a vector of a "dependant variables", and $\Sigma_{k_t}$ is a covariance matrix, where every element $\Sigma_{ij} = k(t_i, t_j)$ for some kernel function $k$, and a set of points of the "independent variable" $t$.
If you specify a kernel with the following property: $Cor(x_i, x_j) \to 1$ as $||t_i - t_j|| \to 0$, notice that you are enforcing continuity. Hence, if you simply use such a kernel, for example, the RBF, it must pass through all the points as there's no "noise" here at all.
Instead, if you decide to specify a kernel that does account for noise, for example: $k(t_i, t_j) = RBF(t_i, t_j) + \sigma^2 \mathcal I(t_i =t_j)$ (the WhiteKernel in scikit-learn, also known as the White Noise kernel), then notice that, even if the two $t$s are close, their correlation isn't 1, i.e. there's some noise here. So the function is not expected to be continuous.
In fact, you can interpret using such a kernel as the traditional smooth RBF GP but with a noise term added on top:
$$X \sim \mathcal N(0, \Sigma_{RBF} + \sigma^2 \mathcal I) $$
$$\stackrel d= \mathcal N(0, \Sigma_{RBF}) + \mathcal N(0, \sigma^2 \mathcal I) $$
$$\Rightarrow X = \bar X +\epsilon$$
... where $\bar X$ is now a continuous GP. Notice how similar this is to the linear regression equation - the only difference really is that you're replacing the mean of the linear regression (which is a parametric line) to a non-parametric GP. | Difference between Gaussian process regression and other regression techniques (say linear regressio | A Gaussian Process doesn't have to perfectly interpolate between points, as that Wikipedia link shows; it all depends on the covariance function that you use.
For example, consider the GP of the form | Difference between Gaussian process regression and other regression techniques (say linear regression)
A Gaussian Process doesn't have to perfectly interpolate between points, as that Wikipedia link shows; it all depends on the covariance function that you use.
For example, consider the GP of the form $X \sim \mathcal N(0, \Sigma_{k_t})$, where $X$ is a vector of a "dependant variables", and $\Sigma_{k_t}$ is a covariance matrix, where every element $\Sigma_{ij} = k(t_i, t_j)$ for some kernel function $k$, and a set of points of the "independent variable" $t$.
If you specify a kernel with the following property: $Cor(x_i, x_j) \to 1$ as $||t_i - t_j|| \to 0$, notice that you are enforcing continuity. Hence, if you simply use such a kernel, for example, the RBF, it must pass through all the points as there's no "noise" here at all.
Instead, if you decide to specify a kernel that does account for noise, for example: $k(t_i, t_j) = RBF(t_i, t_j) + \sigma^2 \mathcal I(t_i =t_j)$ (the WhiteKernel in scikit-learn, also known as the White Noise kernel), then notice that, even if the two $t$s are close, their correlation isn't 1, i.e. there's some noise here. So the function is not expected to be continuous.
In fact, you can interpret using such a kernel as the traditional smooth RBF GP but with a noise term added on top:
$$X \sim \mathcal N(0, \Sigma_{RBF} + \sigma^2 \mathcal I) $$
$$\stackrel d= \mathcal N(0, \Sigma_{RBF}) + \mathcal N(0, \sigma^2 \mathcal I) $$
$$\Rightarrow X = \bar X +\epsilon$$
... where $\bar X$ is now a continuous GP. Notice how similar this is to the linear regression equation - the only difference really is that you're replacing the mean of the linear regression (which is a parametric line) to a non-parametric GP. | Difference between Gaussian process regression and other regression techniques (say linear regressio
A Gaussian Process doesn't have to perfectly interpolate between points, as that Wikipedia link shows; it all depends on the covariance function that you use.
For example, consider the GP of the form |
24,060 | Difference between Gaussian process regression and other regression techniques (say linear regression) | In the process part of the gaussian process regression name, there is a notion of continuity which is constrained by the use of a covariance kernel. The underlying assumption is that the variable is spatially auto-correlated, which means that the knowledge of the outcome at some point will give you information at the nearest locations. This is the main difference between a gaussian process and a simple gaussian variable.
Regarding regression, the main obvious difference between gaussian process regression and "classic" regression techniques, is that you do not force an analytical formula for the predictor, but a covariance structure for the outcomes.
Gaussian process regression is very flexible with respect to interpolation. You can make it an exact interpolator, as long as you don't have two different outcomes for the same input. You can relieve it from the exact interpolation constraint either by bounding the covariance kernel hyperparameters values, or, more usually, by adding some white noise to the covariance kernel.
In your example of linear regression, you have $y = \beta^Tx + \epsilon$ with $\epsilon \sim \mathcal{N}(0,\sigma^2)$. I think you can call it a kind of gaussian process regression as soon as you assume that $\epsilon(x)$ is a gaussian process itself, and not just some random gaussian variable (i.e. you assume that $\epsilon$ is spatially auto-correlated). In the general case of linear regression, the $\epsilon$ term is just assumed to be a white noise, and therefore you cannot call it gaussian process regression.
Using both classical regression and gaussian process regression is a quite usual meta-modelling technique in the industry. The basic idea is to first make a fit by a classical technique (any analytical regression, or a deterministic computer code) which is determined by the prior knowledge of the actual process. Then, with experimental data, you can fit the discrepancy between the model and reality, assuming it follows a gaussian process. This will account for the fact that your analytical model is a simplified version of the true process, along with the measurement uncertainties. This is often referred to as bayesian calibration by gaussian processes. | Difference between Gaussian process regression and other regression techniques (say linear regressio | In the process part of the gaussian process regression name, there is a notion of continuity which is constrained by the use of a covariance kernel. The underlying assumption is that the variable is s | Difference between Gaussian process regression and other regression techniques (say linear regression)
In the process part of the gaussian process regression name, there is a notion of continuity which is constrained by the use of a covariance kernel. The underlying assumption is that the variable is spatially auto-correlated, which means that the knowledge of the outcome at some point will give you information at the nearest locations. This is the main difference between a gaussian process and a simple gaussian variable.
Regarding regression, the main obvious difference between gaussian process regression and "classic" regression techniques, is that you do not force an analytical formula for the predictor, but a covariance structure for the outcomes.
Gaussian process regression is very flexible with respect to interpolation. You can make it an exact interpolator, as long as you don't have two different outcomes for the same input. You can relieve it from the exact interpolation constraint either by bounding the covariance kernel hyperparameters values, or, more usually, by adding some white noise to the covariance kernel.
In your example of linear regression, you have $y = \beta^Tx + \epsilon$ with $\epsilon \sim \mathcal{N}(0,\sigma^2)$. I think you can call it a kind of gaussian process regression as soon as you assume that $\epsilon(x)$ is a gaussian process itself, and not just some random gaussian variable (i.e. you assume that $\epsilon$ is spatially auto-correlated). In the general case of linear regression, the $\epsilon$ term is just assumed to be a white noise, and therefore you cannot call it gaussian process regression.
Using both classical regression and gaussian process regression is a quite usual meta-modelling technique in the industry. The basic idea is to first make a fit by a classical technique (any analytical regression, or a deterministic computer code) which is determined by the prior knowledge of the actual process. Then, with experimental data, you can fit the discrepancy between the model and reality, assuming it follows a gaussian process. This will account for the fact that your analytical model is a simplified version of the true process, along with the measurement uncertainties. This is often referred to as bayesian calibration by gaussian processes. | Difference between Gaussian process regression and other regression techniques (say linear regressio
In the process part of the gaussian process regression name, there is a notion of continuity which is constrained by the use of a covariance kernel. The underlying assumption is that the variable is s |
24,061 | Is the output of a variational autoencoder meant to be a distribution that can be sampled, or a sample directly? | Question 1:
The output of the decoder aims to model the distribution $p(x|t)$, i.e. the distribution of data $x$ given the latent variable $t$. Therefore, in principle, it should always be probabilistic.
However, in some cases, people simply use the mean squared error as the loss and, as you said, the output of the decoder is the actual predicted data points. Note that this approach can also be viewed as probabilistic, in the sense that it is is equivalent to modeling $p(x|t)$ as Gaussian with identity covariance, $p(x|t) = \mathcal{N}(x|\mu(t), I)$. In this case, the output of the decoder is the mean $\mu(t)$ and, therefore, for an example $x_i$, you get the following reconstruction loss:
\begin{align}
-\log(p(x_i | t_i)) &= -\log \left(\frac{1}{\sqrt{(2\pi)^k |I|}} \exp \left(-\frac{1}{2}(x_i-\mu(t_i))^\intercal I (x_i-\mu(t_i))\right)\right) \\
&= \frac{1}{2}||x_i - \mu(t_i)||^2 + \text{const.}
\end{align}
which, as you can see, is proportional to the mean squared error (plus some constant).
Question 2:
Bernoulli distribution makes sense for grey scale pixels.
This is not quite true. The correct statement would be that Bernoulli distribution makes sense for black and white (i.e. binary) images. The Bernoulli distribution is binary, so it assumes that observations may only have two possible outcomes. It is true that people sometimes use it for grayscale images, but this is an abusive interpretation of the VAE. It may work pretty well for datasets that are almost black and white, like MNIST. However, a binarized version of the MNIST dataset exists and, in rigor, this is the version that should be used together with a Bernoulli VAE.
But for something like stock returns, we would want some other distribution, such as a t-distribution. In this case, the output of the encoder would be 3 vectors, 1 for location, 1 for scale, and 1 for degrees of freedom, right?
I would try a Gaussian first, $p(x|t) = \mathcal{N}(x|\mu(t), \sigma^2(t))$, so the decoder would output two values, $\mu(t)$ and $\sigma^2(t)$. But yeah, if you really want a t-distribution, then that is the way to go. | Is the output of a variational autoencoder meant to be a distribution that can be sampled, or a samp | Question 1:
The output of the decoder aims to model the distribution $p(x|t)$, i.e. the distribution of data $x$ given the latent variable $t$. Therefore, in principle, it should always be probabilist | Is the output of a variational autoencoder meant to be a distribution that can be sampled, or a sample directly?
Question 1:
The output of the decoder aims to model the distribution $p(x|t)$, i.e. the distribution of data $x$ given the latent variable $t$. Therefore, in principle, it should always be probabilistic.
However, in some cases, people simply use the mean squared error as the loss and, as you said, the output of the decoder is the actual predicted data points. Note that this approach can also be viewed as probabilistic, in the sense that it is is equivalent to modeling $p(x|t)$ as Gaussian with identity covariance, $p(x|t) = \mathcal{N}(x|\mu(t), I)$. In this case, the output of the decoder is the mean $\mu(t)$ and, therefore, for an example $x_i$, you get the following reconstruction loss:
\begin{align}
-\log(p(x_i | t_i)) &= -\log \left(\frac{1}{\sqrt{(2\pi)^k |I|}} \exp \left(-\frac{1}{2}(x_i-\mu(t_i))^\intercal I (x_i-\mu(t_i))\right)\right) \\
&= \frac{1}{2}||x_i - \mu(t_i)||^2 + \text{const.}
\end{align}
which, as you can see, is proportional to the mean squared error (plus some constant).
Question 2:
Bernoulli distribution makes sense for grey scale pixels.
This is not quite true. The correct statement would be that Bernoulli distribution makes sense for black and white (i.e. binary) images. The Bernoulli distribution is binary, so it assumes that observations may only have two possible outcomes. It is true that people sometimes use it for grayscale images, but this is an abusive interpretation of the VAE. It may work pretty well for datasets that are almost black and white, like MNIST. However, a binarized version of the MNIST dataset exists and, in rigor, this is the version that should be used together with a Bernoulli VAE.
But for something like stock returns, we would want some other distribution, such as a t-distribution. In this case, the output of the encoder would be 3 vectors, 1 for location, 1 for scale, and 1 for degrees of freedom, right?
I would try a Gaussian first, $p(x|t) = \mathcal{N}(x|\mu(t), \sigma^2(t))$, so the decoder would output two values, $\mu(t)$ and $\sigma^2(t)$. But yeah, if you really want a t-distribution, then that is the way to go. | Is the output of a variational autoencoder meant to be a distribution that can be sampled, or a samp
Question 1:
The output of the decoder aims to model the distribution $p(x|t)$, i.e. the distribution of data $x$ given the latent variable $t$. Therefore, in principle, it should always be probabilist |
24,062 | What does Diagonal Rescaling of the gradients mean in ADAM paper? | The original Adam paper briefly explains what it means by "invariant to diagonal rescaling of the gradients" at the end of section 2.1.
I would try to explain it in some more detail.
Like stochastic gradient descent (SGD), Adam is an iterative method that uses gradients in order to find a minimum of a function.
(By "gradients" I mean "the values of the gradient in different locations in parameter space". I later use "partial derivatives" in a similar fashion.)
But in contrast to SGD, Adam doesn't really use gradients. Instead, Adam uses the partial derivatives of each parameter independently.
(By "partial derivative of a parameter $x$" I mean "partial derivative of the cost function $C$ with respect to $x$", i.e. $\frac{\partial C}{\partial x}$.)
Let $\Delta^{(t)}$ be the step that Adam takes in parameter space in the $t^{\text{th}}$ iteration. Then the step it takes in the dimension of the $j^{\text{th}}$ parameter (in the $t^{\text{th}}$ iteration) is $\Delta^{(t)}_j$, which is given by:
$$\Delta^{(t)}_j=-\frac{\alpha}{\sqrt{{\hat v}^{(t)}_j}+\epsilon}\cdot {\hat m}^{(t)}_j$$
while:
$\alpha$ is the learning rate hyperparameter.
$\epsilon$ is a small hyperparameter to prevent division by zero.
${\hat m}^{(t)}_j$ is an exponential moving average of the partial derivatives of the $j^{\text{th}}$ parameter that were calculated in iterations $1$ to $t$.
${\hat v}^{(t)}_j$ is an exponential moving average of the squares of the partial derivatives of the $j^{\text{th}}$ parameter that were calculated in iterations $1$ to $t$.
Now, what happens when we scale the partial derivative of the $j^{\text{th}}$ parameter by a positive factor $c$?
(I.e. the partial derivative of the $j^{\text{th}}$ parameter is just a function whose domain is the parameter space, so we can simply multiply its value by $c$.)
${\hat m}^{(t)}_j$ becomes $c\cdot{\hat m}^{(t)}_j$
${\hat v}^{(t)}_j$ becomes $c^2\cdot{\hat v}^{(t)}_j$
Thus (using the fact that $c>0$), we get that $\Delta^{(t)}_j$ becomes:
$$-\frac{\alpha}{\sqrt{c^2\cdot{\hat v}^{(t)}_j}+\epsilon}\cdot c\cdot{\hat m}^{(t)}_j=-\frac{\alpha}{c\cdot\sqrt{{\hat v}^{(t)}_j}+\epsilon}\cdot c\cdot{\hat m}^{(t)}_j$$
And assuming $\epsilon$ is very small, we get:
$$\begin{gathered}
-\frac{\alpha}{c\cdot\sqrt{{\hat v}^{(t)}_j}+\epsilon}\cdot c\cdot{\hat m}^{(t)}_j\approx -\frac{\alpha}{c\cdot\sqrt{{\hat v}^{(t)}_j}}\cdot c\cdot{\hat m}^{(t)}_j=\\
-\frac{\alpha}{\sqrt{{\hat v}^{(t)}_j}}\cdot{\hat m}^{(t)}_j\approx-\frac{\alpha}{\sqrt{{\hat v}^{(t)}_j}+\epsilon}\cdot{\hat m}^{(t)}_j
\end{gathered}$$
I.e. scaling the partial derivative of the $j^{\text{th}}$ parameter by a positive factor $c$ actually doesn't affect $\Delta^{(t)}_j$.
Finally, let $g=\left(\begin{gathered}g_{1}\\
g_{2}\\
\vdots
\end{gathered}
\right)$ be the gradient. Then $g_j$ is the partial derivative of the $j^{\text{th}}$ parameter.
What happens when we multiply the gradient by a diagonal matrix with only positive elements?
$$\left(\begin{matrix}c_{1}\\
& c_{2}\\
& & \ddots
\end{matrix}\right)g=\left(\begin{matrix}c_{1}\\
& c_{2}\\
& & \ddots
\end{matrix}\right)\left(\begin{gathered}g_{1}\\
g_{2}\\
\vdots
\end{gathered}
\right)=\left(\begin{gathered}c_{1}\cdot g_{1}\\
c_{2}\cdot g_{2}\\
\vdots
\end{gathered}
\right)$$
So it would only scale each partial derivative by a positive factor, but as we have seen above, this won't affect the steps that Adam takes.
In other words, Adam is invariant to multiplying the gradient by a diagonal matrix with only positive factors, which is what the paper means by "invariant to diagonal rescaling of the gradients".
With regard to the quote from the paper Normalized Direction-preserving Adam, it describes the "ill-conditioning problem". (This is how the paper names the problem. Note that it is a different problem from the problem of an ill-conditioned Hessian.)
It seems to me that this problem is unrelated to Adam (and unrelated to the fact that it is invariant to rescaling of the gradient). I deduced that mostly from two other quotes in the paper, that elaborate on the ill-conditioning problem:
Furthermore, even when batch normalization is not used, a network using linear rectifiers (e.g., ReLU, leaky ReLU) as activation functions, is still subject to ill-conditioning of the parameterization (Glorot et al., 2011), and hence the same problem. We refer to this problem as the ill-conditioning problem.
The quote refers to the paper Deep Sparse Rectifier Neural Networks, which never mentions Adam, and also describes the problem of "ill-conditioning of the parametrization", which seems to me very similar (if not identical) to the "ill-conditioning problem".
The ill-conditioning problem occurs when the magnitude change of an input weight vector can be compensated by other parameters, such as the scaling factor of batch normalization, or the output weight vector, without affecting the overall network function. Consequently, suppose we have two DNNs that parameterize the same function, but with some of the input weight vectors having different magnitudes, applying the same SGD or Adam update rule will, in general, change the network functions in different ways. Thus, the ill-conditioning problem makes the training process inconsistent and difficult to control.
If I understand correctly, this quote says that both SGD and Adam suffer from the ill-conditioning problem. I.e. the problem isn't unique to Adam. | What does Diagonal Rescaling of the gradients mean in ADAM paper? | The original Adam paper briefly explains what it means by "invariant to diagonal rescaling of the gradients" at the end of section 2.1.
I would try to explain it in some more detail.
Like stochastic g | What does Diagonal Rescaling of the gradients mean in ADAM paper?
The original Adam paper briefly explains what it means by "invariant to diagonal rescaling of the gradients" at the end of section 2.1.
I would try to explain it in some more detail.
Like stochastic gradient descent (SGD), Adam is an iterative method that uses gradients in order to find a minimum of a function.
(By "gradients" I mean "the values of the gradient in different locations in parameter space". I later use "partial derivatives" in a similar fashion.)
But in contrast to SGD, Adam doesn't really use gradients. Instead, Adam uses the partial derivatives of each parameter independently.
(By "partial derivative of a parameter $x$" I mean "partial derivative of the cost function $C$ with respect to $x$", i.e. $\frac{\partial C}{\partial x}$.)
Let $\Delta^{(t)}$ be the step that Adam takes in parameter space in the $t^{\text{th}}$ iteration. Then the step it takes in the dimension of the $j^{\text{th}}$ parameter (in the $t^{\text{th}}$ iteration) is $\Delta^{(t)}_j$, which is given by:
$$\Delta^{(t)}_j=-\frac{\alpha}{\sqrt{{\hat v}^{(t)}_j}+\epsilon}\cdot {\hat m}^{(t)}_j$$
while:
$\alpha$ is the learning rate hyperparameter.
$\epsilon$ is a small hyperparameter to prevent division by zero.
${\hat m}^{(t)}_j$ is an exponential moving average of the partial derivatives of the $j^{\text{th}}$ parameter that were calculated in iterations $1$ to $t$.
${\hat v}^{(t)}_j$ is an exponential moving average of the squares of the partial derivatives of the $j^{\text{th}}$ parameter that were calculated in iterations $1$ to $t$.
Now, what happens when we scale the partial derivative of the $j^{\text{th}}$ parameter by a positive factor $c$?
(I.e. the partial derivative of the $j^{\text{th}}$ parameter is just a function whose domain is the parameter space, so we can simply multiply its value by $c$.)
${\hat m}^{(t)}_j$ becomes $c\cdot{\hat m}^{(t)}_j$
${\hat v}^{(t)}_j$ becomes $c^2\cdot{\hat v}^{(t)}_j$
Thus (using the fact that $c>0$), we get that $\Delta^{(t)}_j$ becomes:
$$-\frac{\alpha}{\sqrt{c^2\cdot{\hat v}^{(t)}_j}+\epsilon}\cdot c\cdot{\hat m}^{(t)}_j=-\frac{\alpha}{c\cdot\sqrt{{\hat v}^{(t)}_j}+\epsilon}\cdot c\cdot{\hat m}^{(t)}_j$$
And assuming $\epsilon$ is very small, we get:
$$\begin{gathered}
-\frac{\alpha}{c\cdot\sqrt{{\hat v}^{(t)}_j}+\epsilon}\cdot c\cdot{\hat m}^{(t)}_j\approx -\frac{\alpha}{c\cdot\sqrt{{\hat v}^{(t)}_j}}\cdot c\cdot{\hat m}^{(t)}_j=\\
-\frac{\alpha}{\sqrt{{\hat v}^{(t)}_j}}\cdot{\hat m}^{(t)}_j\approx-\frac{\alpha}{\sqrt{{\hat v}^{(t)}_j}+\epsilon}\cdot{\hat m}^{(t)}_j
\end{gathered}$$
I.e. scaling the partial derivative of the $j^{\text{th}}$ parameter by a positive factor $c$ actually doesn't affect $\Delta^{(t)}_j$.
Finally, let $g=\left(\begin{gathered}g_{1}\\
g_{2}\\
\vdots
\end{gathered}
\right)$ be the gradient. Then $g_j$ is the partial derivative of the $j^{\text{th}}$ parameter.
What happens when we multiply the gradient by a diagonal matrix with only positive elements?
$$\left(\begin{matrix}c_{1}\\
& c_{2}\\
& & \ddots
\end{matrix}\right)g=\left(\begin{matrix}c_{1}\\
& c_{2}\\
& & \ddots
\end{matrix}\right)\left(\begin{gathered}g_{1}\\
g_{2}\\
\vdots
\end{gathered}
\right)=\left(\begin{gathered}c_{1}\cdot g_{1}\\
c_{2}\cdot g_{2}\\
\vdots
\end{gathered}
\right)$$
So it would only scale each partial derivative by a positive factor, but as we have seen above, this won't affect the steps that Adam takes.
In other words, Adam is invariant to multiplying the gradient by a diagonal matrix with only positive factors, which is what the paper means by "invariant to diagonal rescaling of the gradients".
With regard to the quote from the paper Normalized Direction-preserving Adam, it describes the "ill-conditioning problem". (This is how the paper names the problem. Note that it is a different problem from the problem of an ill-conditioned Hessian.)
It seems to me that this problem is unrelated to Adam (and unrelated to the fact that it is invariant to rescaling of the gradient). I deduced that mostly from two other quotes in the paper, that elaborate on the ill-conditioning problem:
Furthermore, even when batch normalization is not used, a network using linear rectifiers (e.g., ReLU, leaky ReLU) as activation functions, is still subject to ill-conditioning of the parameterization (Glorot et al., 2011), and hence the same problem. We refer to this problem as the ill-conditioning problem.
The quote refers to the paper Deep Sparse Rectifier Neural Networks, which never mentions Adam, and also describes the problem of "ill-conditioning of the parametrization", which seems to me very similar (if not identical) to the "ill-conditioning problem".
The ill-conditioning problem occurs when the magnitude change of an input weight vector can be compensated by other parameters, such as the scaling factor of batch normalization, or the output weight vector, without affecting the overall network function. Consequently, suppose we have two DNNs that parameterize the same function, but with some of the input weight vectors having different magnitudes, applying the same SGD or Adam update rule will, in general, change the network functions in different ways. Thus, the ill-conditioning problem makes the training process inconsistent and difficult to control.
If I understand correctly, this quote says that both SGD and Adam suffer from the ill-conditioning problem. I.e. the problem isn't unique to Adam. | What does Diagonal Rescaling of the gradients mean in ADAM paper?
The original Adam paper briefly explains what it means by "invariant to diagonal rescaling of the gradients" at the end of section 2.1.
I would try to explain it in some more detail.
Like stochastic g |
24,063 | Variational autoencoder: Why reconstruction term is same to square loss? | For regular Autoencoders, you start from an input, $x$ and encode it to obtain your latent variable (or code), $z$, using some function that satisfy: $z=f(x)$. After getting the latent variable, you aim to reconstruct the input using some other function $\hat{x}=g(f(x))$. The reconstruction loss is yet another function $L(x,\hat{x})$ that you use to back-propagate and update $f$ and $g$.
For Variational Autoencoders, you still interpret the latent variables, $z$, as your code. Hence, $p(x|z)$ serves as a probabilistic decoder, since given a code $z$, it produces a distribution over the possible values of $x$. It thus "makes sense" that the term $\log p_{\theta}(x|z)$ is somehow connected to reconstruction error.
Both encoder and decoder are deterministic functions. Since $p(x|z)$ is such function that maps $z$ into $\hat{x}$ , you can think of this expression as $p(x|\hat{x})$. When you assume (as they assumed in the paper if I understood it correctly) that this distribution have a Gaussian form:
$$
\log P(x|\hat{x}) \sim \log e^{-|x-\hat{x}|^2} \sim (x-\hat{x})^2
$$
The last expression is proportional to the reconstruction error in regular autoencoders. | Variational autoencoder: Why reconstruction term is same to square loss? | For regular Autoencoders, you start from an input, $x$ and encode it to obtain your latent variable (or code), $z$, using some function that satisfy: $z=f(x)$. After getting the latent variable, you a | Variational autoencoder: Why reconstruction term is same to square loss?
For regular Autoencoders, you start from an input, $x$ and encode it to obtain your latent variable (or code), $z$, using some function that satisfy: $z=f(x)$. After getting the latent variable, you aim to reconstruct the input using some other function $\hat{x}=g(f(x))$. The reconstruction loss is yet another function $L(x,\hat{x})$ that you use to back-propagate and update $f$ and $g$.
For Variational Autoencoders, you still interpret the latent variables, $z$, as your code. Hence, $p(x|z)$ serves as a probabilistic decoder, since given a code $z$, it produces a distribution over the possible values of $x$. It thus "makes sense" that the term $\log p_{\theta}(x|z)$ is somehow connected to reconstruction error.
Both encoder and decoder are deterministic functions. Since $p(x|z)$ is such function that maps $z$ into $\hat{x}$ , you can think of this expression as $p(x|\hat{x})$. When you assume (as they assumed in the paper if I understood it correctly) that this distribution have a Gaussian form:
$$
\log P(x|\hat{x}) \sim \log e^{-|x-\hat{x}|^2} \sim (x-\hat{x})^2
$$
The last expression is proportional to the reconstruction error in regular autoencoders. | Variational autoencoder: Why reconstruction term is same to square loss?
For regular Autoencoders, you start from an input, $x$ and encode it to obtain your latent variable (or code), $z$, using some function that satisfy: $z=f(x)$. After getting the latent variable, you a |
24,064 | Variational autoencoder: Why reconstruction term is same to square loss? | $p(x|z) = p(x|x_\text{out}) = x \log x_\text{out} + (1-x) \log (1-x_\text{out})$ because $x_\text{out}$ is a deterministic function of $z$ and the model parameters. | Variational autoencoder: Why reconstruction term is same to square loss? | $p(x|z) = p(x|x_\text{out}) = x \log x_\text{out} + (1-x) \log (1-x_\text{out})$ because $x_\text{out}$ is a deterministic function of $z$ and the model parameters. | Variational autoencoder: Why reconstruction term is same to square loss?
$p(x|z) = p(x|x_\text{out}) = x \log x_\text{out} + (1-x) \log (1-x_\text{out})$ because $x_\text{out}$ is a deterministic function of $z$ and the model parameters. | Variational autoencoder: Why reconstruction term is same to square loss?
$p(x|z) = p(x|x_\text{out}) = x \log x_\text{out} + (1-x) \log (1-x_\text{out})$ because $x_\text{out}$ is a deterministic function of $z$ and the model parameters. |
24,065 | Variational autoencoder: Why reconstruction term is same to square loss? | To answer this one needs to see page 4 eq. 7 of this and text below it:
In our experiments we found that the number of samples L per datapoint can be set to 1 as long as the minibatch size M was large enough, e.g. M = 100.
So stochastic nature of Monte-Carlo sampling from standard normal distribution (sampling $L$ samples of $z^{(i, l)}$ from $\mu^{(i)}$ and $\sigma^{(i)}$) can be neglected with large enough minibatch size. Hence summing over $l$ of $L$ samples turnes into single sample. So what is left is only network output that is parameter $p_{out}^{(i)}$ of Bernoulli distribution (that is deterministic fuction of $z^{(i)}$). And hence:
$$
\log P(x^{(i)}|z^{(i)}) = \log P(x|p_{out}) \\= \log P_{p_{out}}(X=x) \\= \log \left(p_{out}^x (1-p_{out})^{1-x}\right) \\= x \log p_{out} + {(1-x)} \log \left(1-p_{out}\right),
$$
where $x^{(i)}$ is assumed to be from Bernoulli distribution ($\in \left\{0, 1\right\}$) and third equation was exactly The probability mass function of Bernoulli distribution.
As to why this works when x is not from Bernoulli but instead from bounded continuous like ($\in \left[0, 1\right]$) I don't know but may be it's relatred to "Dark Knowledge" refered here. | Variational autoencoder: Why reconstruction term is same to square loss? | To answer this one needs to see page 4 eq. 7 of this and text below it:
In our experiments we found that the number of samples L per datapoint can be set to 1 as long as the minibatch size M was larg | Variational autoencoder: Why reconstruction term is same to square loss?
To answer this one needs to see page 4 eq. 7 of this and text below it:
In our experiments we found that the number of samples L per datapoint can be set to 1 as long as the minibatch size M was large enough, e.g. M = 100.
So stochastic nature of Monte-Carlo sampling from standard normal distribution (sampling $L$ samples of $z^{(i, l)}$ from $\mu^{(i)}$ and $\sigma^{(i)}$) can be neglected with large enough minibatch size. Hence summing over $l$ of $L$ samples turnes into single sample. So what is left is only network output that is parameter $p_{out}^{(i)}$ of Bernoulli distribution (that is deterministic fuction of $z^{(i)}$). And hence:
$$
\log P(x^{(i)}|z^{(i)}) = \log P(x|p_{out}) \\= \log P_{p_{out}}(X=x) \\= \log \left(p_{out}^x (1-p_{out})^{1-x}\right) \\= x \log p_{out} + {(1-x)} \log \left(1-p_{out}\right),
$$
where $x^{(i)}$ is assumed to be from Bernoulli distribution ($\in \left\{0, 1\right\}$) and third equation was exactly The probability mass function of Bernoulli distribution.
As to why this works when x is not from Bernoulli but instead from bounded continuous like ($\in \left[0, 1\right]$) I don't know but may be it's relatred to "Dark Knowledge" refered here. | Variational autoencoder: Why reconstruction term is same to square loss?
To answer this one needs to see page 4 eq. 7 of this and text below it:
In our experiments we found that the number of samples L per datapoint can be set to 1 as long as the minibatch size M was larg |
24,066 | Different definitions of Bayes risk | To quote from my book, The Bayesian Choice (2007, Section 2.3, pp. 63-64)
The Bayesian approach to decision theory integrates on the parameter
space $\Theta$, since $\theta$ is unknown, instead of integrating on
the sampling space ${\cal X}$, as $x$ is observed. It relies on the
posterior expected loss \begin{eqnarray*} \rho(\pi,d|x) & = &
\mathbb{E}^\pi[L(\theta,d)|x] \\ \tag{1}
& = & \int_{\Theta} \mathrm{L}(\theta,d) \pi(\theta|x)\, \text{d}\theta, \end{eqnarray*} which averages the error (i.e., the
loss) according to the posterior distribution of the parameter
$\theta$, conditional on the observed value $x$. Given $x$, the
average error resulting from decision $d$ is actually $\rho(\pi,d|x)$.
The posterior expected loss is thus a function of $x$ but this
dependence is not an issue, as opposed to the frequentist dependence
of the risk on the parameter because $x$, contrary to $\theta$, is known.
Given a prior distribution $\pi$, it is also possible to define the
integrated risk, which is the frequentist risk averaged over the
values of $\theta$ according to their prior distribution
\begin{eqnarray*} r(\pi,\delta) & = & \mathbb{E}^\pi[R(\theta,\delta)]
\\ \tag{2}
& = & \int_{\Theta} \int_{\cal X} \mathrm{L}(\theta,\delta(x))\,
f(x|\theta) \,\text{d}x\ \pi(\theta)\, \text{d}\theta. \end{eqnarray*} One particular appeal of this second
concept is that it associates a real number with every estimator, not
a function of $\theta$. It therefore induces a total ordering on the
set of estimator s, i.e., allows for the direct comparison of
estimators. This implies that, while taking into account the prior
information through the prior distribution, the Bayesian approach is
sufficiently reductive (in a positive sense) to reach an
effective decision. Moreover, the above two notions are equivalent in
that they lead to the same decision.
A bit further, I use the following definition for the Bayes risk:
A Bayes estimator associated with a prior distribution $\pi$ and a loss
function $\mathrm{L}$ is any estimator $\delta^\pi$ which minimizes
$r(\pi,\delta)$. For every $x\in\cal{X}$, it is given by $\delta^\pi(x)$,
argument of $$\min_d \rho(\pi,d|x)$$ The value $$r(\pi) =
r(\pi,\delta^\pi)\tag{3}$$ is then called the Bayes risk. | Different definitions of Bayes risk | To quote from my book, The Bayesian Choice (2007, Section 2.3, pp. 63-64)
The Bayesian approach to decision theory integrates on the parameter
space $\Theta$, since $\theta$ is unknown, instead of in | Different definitions of Bayes risk
To quote from my book, The Bayesian Choice (2007, Section 2.3, pp. 63-64)
The Bayesian approach to decision theory integrates on the parameter
space $\Theta$, since $\theta$ is unknown, instead of integrating on
the sampling space ${\cal X}$, as $x$ is observed. It relies on the
posterior expected loss \begin{eqnarray*} \rho(\pi,d|x) & = &
\mathbb{E}^\pi[L(\theta,d)|x] \\ \tag{1}
& = & \int_{\Theta} \mathrm{L}(\theta,d) \pi(\theta|x)\, \text{d}\theta, \end{eqnarray*} which averages the error (i.e., the
loss) according to the posterior distribution of the parameter
$\theta$, conditional on the observed value $x$. Given $x$, the
average error resulting from decision $d$ is actually $\rho(\pi,d|x)$.
The posterior expected loss is thus a function of $x$ but this
dependence is not an issue, as opposed to the frequentist dependence
of the risk on the parameter because $x$, contrary to $\theta$, is known.
Given a prior distribution $\pi$, it is also possible to define the
integrated risk, which is the frequentist risk averaged over the
values of $\theta$ according to their prior distribution
\begin{eqnarray*} r(\pi,\delta) & = & \mathbb{E}^\pi[R(\theta,\delta)]
\\ \tag{2}
& = & \int_{\Theta} \int_{\cal X} \mathrm{L}(\theta,\delta(x))\,
f(x|\theta) \,\text{d}x\ \pi(\theta)\, \text{d}\theta. \end{eqnarray*} One particular appeal of this second
concept is that it associates a real number with every estimator, not
a function of $\theta$. It therefore induces a total ordering on the
set of estimator s, i.e., allows for the direct comparison of
estimators. This implies that, while taking into account the prior
information through the prior distribution, the Bayesian approach is
sufficiently reductive (in a positive sense) to reach an
effective decision. Moreover, the above two notions are equivalent in
that they lead to the same decision.
A bit further, I use the following definition for the Bayes risk:
A Bayes estimator associated with a prior distribution $\pi$ and a loss
function $\mathrm{L}$ is any estimator $\delta^\pi$ which minimizes
$r(\pi,\delta)$. For every $x\in\cal{X}$, it is given by $\delta^\pi(x)$,
argument of $$\min_d \rho(\pi,d|x)$$ The value $$r(\pi) =
r(\pi,\delta^\pi)\tag{3}$$ is then called the Bayes risk. | Different definitions of Bayes risk
To quote from my book, The Bayesian Choice (2007, Section 2.3, pp. 63-64)
The Bayesian approach to decision theory integrates on the parameter
space $\Theta$, since $\theta$ is unknown, instead of in |
24,067 | How to calculate the probability of a data point belonging to a multivariate normal distribution? | Yeah, that sounds right. If you have parameters $\mu$ and $\Sigma$ and data point $x$, then the set of all data points that are less likely than $x$ are the ones that have less density, or in other words higher Mahalanobis distance:
\begin{align*}
(2\pi)^{-k/2}|\Sigma|^{-1/2}e^{\left[-\frac{1}{2}(y-\mu)^T\Sigma^{-1}(y-\mu) \right]} &\le (2\pi)^{-k/2}|\Sigma|^{-1/2}e^{\left[-\frac{1}{2}(x-\mu)^T\Sigma^{-1}(x-\mu) \right]} \iff\\
e^{\left[-\frac{1}{2}(y-\mu)^T\Sigma^{-1}(y-\mu) \right]} &\le e^{\left[-\frac{1}{2}(x-\mu)^T\Sigma^{-1}(x-\mu) \right]} \iff \\
(y-\mu)^T\Sigma^{-1}(y-\mu) &\ge (x-\mu)^T\Sigma^{-1}(x-\mu).
\end{align*}
So you want the probability of some unseen $Y$ being "better" than your observed $x$, which is the same as $Q = (Y-\mu)^T\Sigma^{-1}(Y-\mu)$ being bigger than $(x-\mu)^T\Sigma^{-1}(x-\mu)$. And you are correct in pointing out that $Q \sim \chi^2(k)$. So
$$
\mathbb{P}\left[(y-\mu)^T\Sigma^{-1}(y-\mu) \ge (x-\mu)^T\Sigma^{-1}(x-\mu)\right] = 1- \mathbb{P}\left[Q \le (x-\mu)^T\Sigma^{-1}(x-\mu)\right].
$$
In python you can calculate that wth something like this:
from scipy import stats
import numpy as np
x = np.array([1,1,1])
mu = np.array([0,0,0])
sigma = np.array([[1,0,0],[0,1,0],[0,0,1]])
m_dist_x = np.dot((x-mu).transpose(),np.linalg.inv(sigma))
m_dist_x = np.dot(m_dist_x, (x-mu))
1-stats.chi2.cdf(m_dist_x, 3) | How to calculate the probability of a data point belonging to a multivariate normal distribution? | Yeah, that sounds right. If you have parameters $\mu$ and $\Sigma$ and data point $x$, then the set of all data points that are less likely than $x$ are the ones that have less density, or in other wo | How to calculate the probability of a data point belonging to a multivariate normal distribution?
Yeah, that sounds right. If you have parameters $\mu$ and $\Sigma$ and data point $x$, then the set of all data points that are less likely than $x$ are the ones that have less density, or in other words higher Mahalanobis distance:
\begin{align*}
(2\pi)^{-k/2}|\Sigma|^{-1/2}e^{\left[-\frac{1}{2}(y-\mu)^T\Sigma^{-1}(y-\mu) \right]} &\le (2\pi)^{-k/2}|\Sigma|^{-1/2}e^{\left[-\frac{1}{2}(x-\mu)^T\Sigma^{-1}(x-\mu) \right]} \iff\\
e^{\left[-\frac{1}{2}(y-\mu)^T\Sigma^{-1}(y-\mu) \right]} &\le e^{\left[-\frac{1}{2}(x-\mu)^T\Sigma^{-1}(x-\mu) \right]} \iff \\
(y-\mu)^T\Sigma^{-1}(y-\mu) &\ge (x-\mu)^T\Sigma^{-1}(x-\mu).
\end{align*}
So you want the probability of some unseen $Y$ being "better" than your observed $x$, which is the same as $Q = (Y-\mu)^T\Sigma^{-1}(Y-\mu)$ being bigger than $(x-\mu)^T\Sigma^{-1}(x-\mu)$. And you are correct in pointing out that $Q \sim \chi^2(k)$. So
$$
\mathbb{P}\left[(y-\mu)^T\Sigma^{-1}(y-\mu) \ge (x-\mu)^T\Sigma^{-1}(x-\mu)\right] = 1- \mathbb{P}\left[Q \le (x-\mu)^T\Sigma^{-1}(x-\mu)\right].
$$
In python you can calculate that wth something like this:
from scipy import stats
import numpy as np
x = np.array([1,1,1])
mu = np.array([0,0,0])
sigma = np.array([[1,0,0],[0,1,0],[0,0,1]])
m_dist_x = np.dot((x-mu).transpose(),np.linalg.inv(sigma))
m_dist_x = np.dot(m_dist_x, (x-mu))
1-stats.chi2.cdf(m_dist_x, 3) | How to calculate the probability of a data point belonging to a multivariate normal distribution?
Yeah, that sounds right. If you have parameters $\mu$ and $\Sigma$ and data point $x$, then the set of all data points that are less likely than $x$ are the ones that have less density, or in other wo |
24,068 | How can adding a feature reduce a model's performance? | It depends.
With your data, make a new variable that is simply random noise. If you add it as a predictor to your model, you will most likely notice that your accuracy drops. This is because, while it is added information, it does not correlate well with the other information you have provided.
It may be difficult to distinguish weekends and holidays from the rest of the days of the week, and it just becomes noise. As a result, you may be able to get better results with weekend/holiday vs rest of the week binary data as a predictor for the crime.
It may also help to create a matrix plot of your data and see if any patterns emerge with "day of week" (and you may want to jitter that data, if possible).
Edit:
I tried this with a sample dataset I had handy.
As it turns out, adding white noise seems to have an interesting side effect. It seems to always improve the model (marginally, and with diminishing returns with additional white noise variables added). It also seems to have an effect on the significant variables in declaring them increasingly more significant (along with any interactions they may have).
That being said, I have also had data that had very little correlation with the desired output and adding that variable into the dataset made the larger model worse. A sample of the data set is below. Previous tests had confirmed a nice linear relationship between FactX2 and RespY when measured several times on a single unit. Measureing the variations over time provided a completely different response.
FactX1 FactX2 RespY
-0.012 0.078 0.033
-0.016 0.059 -0.039
-0.034 0.082 -0.022
NA NA 0.021
-0.055 -0.002 -0.028
-0.057 0.085 0.072
-0.053 -0.012 0.001
-0.053 0.050 0.054
-0.053 0.078 0.007
-0.035 0.061 0.031
If you construct a model with this data, the use of FactX2 always makes the $R^2$ negative. I had previously assumed it was because it had turned into noise and within this dataset was simply not a good predictor of anything. | How can adding a feature reduce a model's performance? | It depends.
With your data, make a new variable that is simply random noise. If you add it as a predictor to your model, you will most likely notice that your accuracy drops. This is because, while | How can adding a feature reduce a model's performance?
It depends.
With your data, make a new variable that is simply random noise. If you add it as a predictor to your model, you will most likely notice that your accuracy drops. This is because, while it is added information, it does not correlate well with the other information you have provided.
It may be difficult to distinguish weekends and holidays from the rest of the days of the week, and it just becomes noise. As a result, you may be able to get better results with weekend/holiday vs rest of the week binary data as a predictor for the crime.
It may also help to create a matrix plot of your data and see if any patterns emerge with "day of week" (and you may want to jitter that data, if possible).
Edit:
I tried this with a sample dataset I had handy.
As it turns out, adding white noise seems to have an interesting side effect. It seems to always improve the model (marginally, and with diminishing returns with additional white noise variables added). It also seems to have an effect on the significant variables in declaring them increasingly more significant (along with any interactions they may have).
That being said, I have also had data that had very little correlation with the desired output and adding that variable into the dataset made the larger model worse. A sample of the data set is below. Previous tests had confirmed a nice linear relationship between FactX2 and RespY when measured several times on a single unit. Measureing the variations over time provided a completely different response.
FactX1 FactX2 RespY
-0.012 0.078 0.033
-0.016 0.059 -0.039
-0.034 0.082 -0.022
NA NA 0.021
-0.055 -0.002 -0.028
-0.057 0.085 0.072
-0.053 -0.012 0.001
-0.053 0.050 0.054
-0.053 0.078 0.007
-0.035 0.061 0.031
If you construct a model with this data, the use of FactX2 always makes the $R^2$ negative. I had previously assumed it was because it had turned into noise and within this dataset was simply not a good predictor of anything. | How can adding a feature reduce a model's performance?
It depends.
With your data, make a new variable that is simply random noise. If you add it as a predictor to your model, you will most likely notice that your accuracy drops. This is because, while |
24,069 | How can adding a feature reduce a model's performance? | I see that you are (wisely) keeping separate training and testing data sets. Without your data, I cannot test it myself, but I expect that if you test on the training data, you get better (or at least no worse) accuracy when you add the extra variable. It is only on the test data that you see this decrease in accuracy. What you are seeing is over-fitting.
Even when you start out with a reasonably large data set, at each split in the decision tree, you are looking at fewer points. By the time that you get to deeper branches of the tree, there may be only a few points to classify. By chance, a (newly added) variable may separate those points into the classes really well, but the split does not generalize to other data. This is exactly why you keep a separate test set. The test set helps you detect this over-fitting. | How can adding a feature reduce a model's performance? | I see that you are (wisely) keeping separate training and testing data sets. Without your data, I cannot test it myself, but I expect that if you test on the training data, you get better (or at leas | How can adding a feature reduce a model's performance?
I see that you are (wisely) keeping separate training and testing data sets. Without your data, I cannot test it myself, but I expect that if you test on the training data, you get better (or at least no worse) accuracy when you add the extra variable. It is only on the test data that you see this decrease in accuracy. What you are seeing is over-fitting.
Even when you start out with a reasonably large data set, at each split in the decision tree, you are looking at fewer points. By the time that you get to deeper branches of the tree, there may be only a few points to classify. By chance, a (newly added) variable may separate those points into the classes really well, but the split does not generalize to other data. This is exactly why you keep a separate test set. The test set helps you detect this over-fitting. | How can adding a feature reduce a model's performance?
I see that you are (wisely) keeping separate training and testing data sets. Without your data, I cannot test it myself, but I expect that if you test on the training data, you get better (or at leas |
24,070 | How can adding a feature reduce a model's performance? | BTW, we are not looking at accuracy here, but precision. Other things being equal, Tuesday has only one seventh of the data that the rest of the week has. Now suppose that we are looking at the standard error of the mean. Then standard error; $\sigma_{\mu}=\frac{\sigma}{\sqrt{N}}$. So, let's put some numbers in. Suppose $\sigma_{\mu}=0.5$ and $N=196$, and $N_{Tues}=28$. Then $\sigma=\sigma_{\mu}\sqrt{N}=7$, and $\sigma_{\mu Tues}=\frac{\sigma}{\sqrt{N_{Tues}}}=\frac{7}{\sqrt{28}}\approx 1.323$ or $\sigma_{\mu Tues}=2.65\sigma_{\mu}$, that is, the standard error of estimating a mean value for the whole week's data, in this assumed case, is a lot less inaccurate (by a factor of $\frac{1}{\sqrt{7}}$), than using only one day's worth of data. | How can adding a feature reduce a model's performance? | BTW, we are not looking at accuracy here, but precision. Other things being equal, Tuesday has only one seventh of the data that the rest of the week has. Now suppose that we are looking at the standa | How can adding a feature reduce a model's performance?
BTW, we are not looking at accuracy here, but precision. Other things being equal, Tuesday has only one seventh of the data that the rest of the week has. Now suppose that we are looking at the standard error of the mean. Then standard error; $\sigma_{\mu}=\frac{\sigma}{\sqrt{N}}$. So, let's put some numbers in. Suppose $\sigma_{\mu}=0.5$ and $N=196$, and $N_{Tues}=28$. Then $\sigma=\sigma_{\mu}\sqrt{N}=7$, and $\sigma_{\mu Tues}=\frac{\sigma}{\sqrt{N_{Tues}}}=\frac{7}{\sqrt{28}}\approx 1.323$ or $\sigma_{\mu Tues}=2.65\sigma_{\mu}$, that is, the standard error of estimating a mean value for the whole week's data, in this assumed case, is a lot less inaccurate (by a factor of $\frac{1}{\sqrt{7}}$), than using only one day's worth of data. | How can adding a feature reduce a model's performance?
BTW, we are not looking at accuracy here, but precision. Other things being equal, Tuesday has only one seventh of the data that the rest of the week has. Now suppose that we are looking at the standa |
24,071 | Reliability of a fitted curve? | This is an ordinary least squares problem!
Defining
$$x = V^{-2/3}, \ w = V_0^{1/3},$$
the model can be rewritten
$$\mathbb{E}(E|V) = \beta_0 + \beta_1 x + \beta_2 x^2 + \beta_3 x^3$$
where the coefficients $\beta=(\beta_i)^\prime$ are algebraically related to the original coefficients via
$$16 \beta = \pmatrix{16 E_0 + 54 B_0 w^3 - 9 B_0 B_0^\prime w^3\\
-144 B_0 w^5 + 27 B_0 B_0^\prime w^5\\
126 B_0 w^7 - 27 B_0 B_0^\prime w^7\\
-36 B_0 w^9 + 9 B_0 B_0^\prime w^9}.$$
This is straightforward to solve algebraically or numerically: pick the solution for which $B_0, B_0^\prime$, and $w$ are positive. The only reason to do this is to obtain estimates of $B_0, B_0^\prime, w$, and $E_0$ and to verify they are physically meaningful. All analyses of the fit can be carried out in terms of $\beta$.
This approach is not only much simpler than nonlinear fitting, it is also more accurate: the variance-covariance matrix for $(E_0, B_0, B_0^\prime, V_0)$ returned by a nonlinear fit is only a local quadratic approximation to the sampling distribution of these parameters, whereas (for normally distributed errors in measuring $E$, anyway) the OLS results are not approximations.
Confidence intervals, prediction intervals, etc. can be obtained in the usual way without needing to find these values: compute them in terms of the estimates $\hat\beta$ and their variance-covariance matrix. (Even Excel could do this!) Here is an example, followed by the (simple) R code that produced it.
#
# The data.
#
X <- data.frame(V=c(41, 43, 46, 48, 51, 53, 55.5, 58, 60, 62.5),
E=c(-48.05, -48.5, -48.8, -49.03, -49.2, -49.3, -49.35,
-49.34, -49.31, -49.27))
#
# OLS regression.
#
fit <- lm(E ~ I(V^(-2/3)) + I(V^(-4/3)) + I(V^(-6/3)), data=X)
summary(fit)
beta <- coef(fit)
#
# Prediction, including standard errors of prediction.
#
V0 <- seq(40, 65)
y <- predict(fit, se.fit=TRUE, newdata=data.frame(V=V0))
#
# Plot the data, the fit, and a three-SEP band.
#
plot(X$V, X$E, xlab="Volume", ylab="Energy", bty="n", xlim=c(40, 60))
polygon(c(V0, rev(V0)), c(y$fit + 3*y$se.fit, rev(y$fit - 3*y$se.fit)),
border=NA, col="#f0f0f0")
curve(outer(x^(-2/3), 0:3, `^`) %*% beta, add=TRUE, col="Red", lwd=2)
points(X$V, X$E)
If you are interested in the joint distribution of the original parameter estimates, then it is easy to simulate from the OLS solution: simply generate multivariate Normal realizations of $\beta$ and convert those into the parameters. Here is a scatterplot matrix of 2000 such realizations. The strong curvilinearity shows why the Delta method is likely to give poor results. | Reliability of a fitted curve? | This is an ordinary least squares problem!
Defining
$$x = V^{-2/3}, \ w = V_0^{1/3},$$
the model can be rewritten
$$\mathbb{E}(E|V) = \beta_0 + \beta_1 x + \beta_2 x^2 + \beta_3 x^3$$
where the coeffi | Reliability of a fitted curve?
This is an ordinary least squares problem!
Defining
$$x = V^{-2/3}, \ w = V_0^{1/3},$$
the model can be rewritten
$$\mathbb{E}(E|V) = \beta_0 + \beta_1 x + \beta_2 x^2 + \beta_3 x^3$$
where the coefficients $\beta=(\beta_i)^\prime$ are algebraically related to the original coefficients via
$$16 \beta = \pmatrix{16 E_0 + 54 B_0 w^3 - 9 B_0 B_0^\prime w^3\\
-144 B_0 w^5 + 27 B_0 B_0^\prime w^5\\
126 B_0 w^7 - 27 B_0 B_0^\prime w^7\\
-36 B_0 w^9 + 9 B_0 B_0^\prime w^9}.$$
This is straightforward to solve algebraically or numerically: pick the solution for which $B_0, B_0^\prime$, and $w$ are positive. The only reason to do this is to obtain estimates of $B_0, B_0^\prime, w$, and $E_0$ and to verify they are physically meaningful. All analyses of the fit can be carried out in terms of $\beta$.
This approach is not only much simpler than nonlinear fitting, it is also more accurate: the variance-covariance matrix for $(E_0, B_0, B_0^\prime, V_0)$ returned by a nonlinear fit is only a local quadratic approximation to the sampling distribution of these parameters, whereas (for normally distributed errors in measuring $E$, anyway) the OLS results are not approximations.
Confidence intervals, prediction intervals, etc. can be obtained in the usual way without needing to find these values: compute them in terms of the estimates $\hat\beta$ and their variance-covariance matrix. (Even Excel could do this!) Here is an example, followed by the (simple) R code that produced it.
#
# The data.
#
X <- data.frame(V=c(41, 43, 46, 48, 51, 53, 55.5, 58, 60, 62.5),
E=c(-48.05, -48.5, -48.8, -49.03, -49.2, -49.3, -49.35,
-49.34, -49.31, -49.27))
#
# OLS regression.
#
fit <- lm(E ~ I(V^(-2/3)) + I(V^(-4/3)) + I(V^(-6/3)), data=X)
summary(fit)
beta <- coef(fit)
#
# Prediction, including standard errors of prediction.
#
V0 <- seq(40, 65)
y <- predict(fit, se.fit=TRUE, newdata=data.frame(V=V0))
#
# Plot the data, the fit, and a three-SEP band.
#
plot(X$V, X$E, xlab="Volume", ylab="Energy", bty="n", xlim=c(40, 60))
polygon(c(V0, rev(V0)), c(y$fit + 3*y$se.fit, rev(y$fit - 3*y$se.fit)),
border=NA, col="#f0f0f0")
curve(outer(x^(-2/3), 0:3, `^`) %*% beta, add=TRUE, col="Red", lwd=2)
points(X$V, X$E)
If you are interested in the joint distribution of the original parameter estimates, then it is easy to simulate from the OLS solution: simply generate multivariate Normal realizations of $\beta$ and convert those into the parameters. Here is a scatterplot matrix of 2000 such realizations. The strong curvilinearity shows why the Delta method is likely to give poor results. | Reliability of a fitted curve?
This is an ordinary least squares problem!
Defining
$$x = V^{-2/3}, \ w = V_0^{1/3},$$
the model can be rewritten
$$\mathbb{E}(E|V) = \beta_0 + \beta_1 x + \beta_2 x^2 + \beta_3 x^3$$
where the coeffi |
24,072 | Reliability of a fitted curve? | There is a standard approach for this called the delta method.
You form the inverse of the Hessian of the log-likelihood wrt
your four parameters. There is an extra parameter for the variance of
the residuals, but it does not play a role in these calculations.
Then you calculate predicted response for the desired values of the
independent variable and calculate its gradient (the derivative wrt)
these four parameters. Call the inverse of the Hessian $I$ and the
gradient vector $g$. You form the vector matrix product
$$-g^tIg$$
This gives you the estimated variance for that dependent variable.
Take the square root to get the estimated standard deviation. then the
confidence limits are the predicted value +- two standard deviations.
This is standard likelihood stuff. for the special case of a nonlinear regression you can correct for the degrees of freedom. You have 10 observations and 4 parameters so you can increase the estimation of the
variance in the model by multiplying by 10/6. Several software packages will do this for you. I wrote up your model in AD Model
in AD Model Builder and fit it and calculated the (unmodified) variances.
They will be slightly different from yours because I had to guess a bit at the values.
estimate std dev
10 pred_E -4.8495e+01 7.5100e-03
11 pred_E -4.8810e+01 7.9983e-03
12 pred_E -4.9028e+01 7.5675e-03
13 pred_E -4.9224e+01 6.4801e-03
14 pred_E -4.9303e+01 6.8034e-03
15 pred_E -4.9328e+01 7.1726e-03
16 pred_E -4.9329e+01 7.0249e-03
17 pred_E -4.9297e+01 7.1977e-03
18 pred_E -4.9252e+01 1.1615e-02
This can be done for any dependent variable in AD Model Builder. One declares a variable in the appropriate spot in the code like this
sdreport_number dep
and writes the code the evaluate the dependent variable like this
dep=sqrt(V0-cube(Bp0)/(1+2*max(V)));
Note this is evaluated for a value of the independent variable 2 times
the largest one observed in the model fitting. Fit the model and one obtains
the standard deviation for this dependent variable
19 dep 7.2535e+00 1.0980e-01
I have modified the program to include code for calculating the
confidence limits for the enthalpy-volume function
The code (TPL) file looks like
DATA_SECTION
init_int nobs
init_matrix data(1,nobs,1,2)
vector E
vector V
number Vmean
LOC_CALCS
E=column(data,2);
V=column(data,1);
Vmean=mean(V);
PARAMETER_SECTION
init_number E0
init_number log_V0_coff(2)
init_number log_B0(3)
init_number log_Bp0(3)
init_bounded_number a(.9,1.1)
sdreport_number V0
sdreport_number B0
sdreport_number Bp0
sdreport_vector pred_E(1,nobs)
sdreport_vector P(1,nobs)
sdreport_vector H(1,nobs)
sdreport_number dep
objective_function_value f
PROCEDURE_SECTION
V0=exp(log_V0_coff)*Vmean;
B0=exp(log_B0);
Bp0=exp(log_Bp0);
if (current_phase()<4)
f+=square(log_V0_coff) +square(log_B0);
dvar_vector sv=pow(V0/V,0.66666667);
pred_E=E0 + 9*V0*B0*(cube(sv-1.0)*Bp0
+ elem_prod(square(sv-1.0),(6-4*sv)));
dvar_vector r2=square(E-pred_E);
dvariable vhat=sum(r2)/nobs;
dvariable v=a*vhat;
f=0.5*nobs*log(v)+sum(r2)/(2.0*v);
// code to calculate the enthalpy-volume function
double delta=1.e-4;
dvar_vector svp=pow(V0/(V+delta),0.66666667);
dvar_vector svm=pow(V0/(V-delta),0.66666667);
P = -((9*V0*B0*(cube(svp-1.0)*Bp0
+ elem_prod(square(svp-1.0),(6-4*svp))))
-(9*V0*B0*(cube(svm-1.0)*Bp0
+ elem_prod(square(svm-1.0),(6-4*svm)))))/(2.0*delta);
H=E+elem_prod(P,V);
dep=sqrt(V0-cube(Bp0)/(1+2*max(V)));
Then I refitted the model to get the standard devs for the estimates of H.
29 H -3.9550e+01 5.9163e-01
30 H -4.1554e+01 2.8707e-01
31 H -4.3844e+01 1.2333e-01
32 H -4.5212e+01 1.5011e-01
33 H -4.6859e+01 1.5434e-01
34 H -4.7813e+01 1.2679e-01
35 H -4.8808e+01 1.1036e-01
36 H -4.9626e+01 1.8374e-01
37 H -5.0186e+01 2.8421e-01
38 H -5.0806e+01 4.3179e-01
These are calculated for your observed V values, but could be easily calculated for any value of V.
It has been pointed out that this is actually a linear model for which there is simple R code to perform the parameter estimation via OLS. This is very appealing especially to naive users. However since the work of Huber over thirty years ago we know or should know that one should probably almost always replace OLS with a moderately robust alternative. The reason this is not routinely done I believe is that robust methods are inherently nonlinear. From this point of view the simple appealing OLS methods in R are more of a trap, rather than a feature. An advabtage of the AD Model Builder approach is its built in support for nonlinear modelling. To change the least squares code to a robust normal mixture only one line of the
code needs to be changed. The line
f=0.5*nobs*log(v)+sum(r2)/(2.0*v);
is changed to
f=0.5*nobs*log(v)
-sum(log(0.95*exp(-0.5*r2/v) + 0.05/3.0*exp(-0.5*r2/(9.0*v))));
The amount of overdispersion in the models is measured by the parameter
a. If a equals 1.0, the variance is the same as for the normal model. If there is inflation of the variance by outliers we expect that a will be smaller than 1.0. For these data the estimate of a is about 0.23 so that
the variance is about 1/4 the variance for the normal model. The interpretation is that outliers have increased the variance estimate by a factor of about 4. The effect of this is to increase the size of the confidence bounds for parameters for the OLS model. This represents a loss of efficiency. For the normal mixture model the estimated standard deviations for the enthalpy-volume function are
29 H -3.9777e+01 3.3845e-01
30 H -4.1566e+01 1.6179e-01
31 H -4.3688e+01 7.6799e-02
32 H -4.5018e+01 9.4855e-02
33 H -4.6684e+01 9.5829e-02
34 H -4.7688e+01 7.7409e-02
35 H -4.8772e+01 6.2781e-02
36 H -4.9702e+01 1.0411e-01
37 H -5.0362e+01 1.6380e-01
38 H -5.1114e+01 2.5164e-01
One sees that there are small changes in the point estimates,
while the confidence limits have been reduced to about 60%
of the ones produced by OLS.
The main point I want to make is that all the modified calculations occur automatically once one changes the one line of code in the TPL file. | Reliability of a fitted curve? | There is a standard approach for this called the delta method.
You form the inverse of the Hessian of the log-likelihood wrt
your four parameters. There is an extra parameter for the variance of
the r | Reliability of a fitted curve?
There is a standard approach for this called the delta method.
You form the inverse of the Hessian of the log-likelihood wrt
your four parameters. There is an extra parameter for the variance of
the residuals, but it does not play a role in these calculations.
Then you calculate predicted response for the desired values of the
independent variable and calculate its gradient (the derivative wrt)
these four parameters. Call the inverse of the Hessian $I$ and the
gradient vector $g$. You form the vector matrix product
$$-g^tIg$$
This gives you the estimated variance for that dependent variable.
Take the square root to get the estimated standard deviation. then the
confidence limits are the predicted value +- two standard deviations.
This is standard likelihood stuff. for the special case of a nonlinear regression you can correct for the degrees of freedom. You have 10 observations and 4 parameters so you can increase the estimation of the
variance in the model by multiplying by 10/6. Several software packages will do this for you. I wrote up your model in AD Model
in AD Model Builder and fit it and calculated the (unmodified) variances.
They will be slightly different from yours because I had to guess a bit at the values.
estimate std dev
10 pred_E -4.8495e+01 7.5100e-03
11 pred_E -4.8810e+01 7.9983e-03
12 pred_E -4.9028e+01 7.5675e-03
13 pred_E -4.9224e+01 6.4801e-03
14 pred_E -4.9303e+01 6.8034e-03
15 pred_E -4.9328e+01 7.1726e-03
16 pred_E -4.9329e+01 7.0249e-03
17 pred_E -4.9297e+01 7.1977e-03
18 pred_E -4.9252e+01 1.1615e-02
This can be done for any dependent variable in AD Model Builder. One declares a variable in the appropriate spot in the code like this
sdreport_number dep
and writes the code the evaluate the dependent variable like this
dep=sqrt(V0-cube(Bp0)/(1+2*max(V)));
Note this is evaluated for a value of the independent variable 2 times
the largest one observed in the model fitting. Fit the model and one obtains
the standard deviation for this dependent variable
19 dep 7.2535e+00 1.0980e-01
I have modified the program to include code for calculating the
confidence limits for the enthalpy-volume function
The code (TPL) file looks like
DATA_SECTION
init_int nobs
init_matrix data(1,nobs,1,2)
vector E
vector V
number Vmean
LOC_CALCS
E=column(data,2);
V=column(data,1);
Vmean=mean(V);
PARAMETER_SECTION
init_number E0
init_number log_V0_coff(2)
init_number log_B0(3)
init_number log_Bp0(3)
init_bounded_number a(.9,1.1)
sdreport_number V0
sdreport_number B0
sdreport_number Bp0
sdreport_vector pred_E(1,nobs)
sdreport_vector P(1,nobs)
sdreport_vector H(1,nobs)
sdreport_number dep
objective_function_value f
PROCEDURE_SECTION
V0=exp(log_V0_coff)*Vmean;
B0=exp(log_B0);
Bp0=exp(log_Bp0);
if (current_phase()<4)
f+=square(log_V0_coff) +square(log_B0);
dvar_vector sv=pow(V0/V,0.66666667);
pred_E=E0 + 9*V0*B0*(cube(sv-1.0)*Bp0
+ elem_prod(square(sv-1.0),(6-4*sv)));
dvar_vector r2=square(E-pred_E);
dvariable vhat=sum(r2)/nobs;
dvariable v=a*vhat;
f=0.5*nobs*log(v)+sum(r2)/(2.0*v);
// code to calculate the enthalpy-volume function
double delta=1.e-4;
dvar_vector svp=pow(V0/(V+delta),0.66666667);
dvar_vector svm=pow(V0/(V-delta),0.66666667);
P = -((9*V0*B0*(cube(svp-1.0)*Bp0
+ elem_prod(square(svp-1.0),(6-4*svp))))
-(9*V0*B0*(cube(svm-1.0)*Bp0
+ elem_prod(square(svm-1.0),(6-4*svm)))))/(2.0*delta);
H=E+elem_prod(P,V);
dep=sqrt(V0-cube(Bp0)/(1+2*max(V)));
Then I refitted the model to get the standard devs for the estimates of H.
29 H -3.9550e+01 5.9163e-01
30 H -4.1554e+01 2.8707e-01
31 H -4.3844e+01 1.2333e-01
32 H -4.5212e+01 1.5011e-01
33 H -4.6859e+01 1.5434e-01
34 H -4.7813e+01 1.2679e-01
35 H -4.8808e+01 1.1036e-01
36 H -4.9626e+01 1.8374e-01
37 H -5.0186e+01 2.8421e-01
38 H -5.0806e+01 4.3179e-01
These are calculated for your observed V values, but could be easily calculated for any value of V.
It has been pointed out that this is actually a linear model for which there is simple R code to perform the parameter estimation via OLS. This is very appealing especially to naive users. However since the work of Huber over thirty years ago we know or should know that one should probably almost always replace OLS with a moderately robust alternative. The reason this is not routinely done I believe is that robust methods are inherently nonlinear. From this point of view the simple appealing OLS methods in R are more of a trap, rather than a feature. An advabtage of the AD Model Builder approach is its built in support for nonlinear modelling. To change the least squares code to a robust normal mixture only one line of the
code needs to be changed. The line
f=0.5*nobs*log(v)+sum(r2)/(2.0*v);
is changed to
f=0.5*nobs*log(v)
-sum(log(0.95*exp(-0.5*r2/v) + 0.05/3.0*exp(-0.5*r2/(9.0*v))));
The amount of overdispersion in the models is measured by the parameter
a. If a equals 1.0, the variance is the same as for the normal model. If there is inflation of the variance by outliers we expect that a will be smaller than 1.0. For these data the estimate of a is about 0.23 so that
the variance is about 1/4 the variance for the normal model. The interpretation is that outliers have increased the variance estimate by a factor of about 4. The effect of this is to increase the size of the confidence bounds for parameters for the OLS model. This represents a loss of efficiency. For the normal mixture model the estimated standard deviations for the enthalpy-volume function are
29 H -3.9777e+01 3.3845e-01
30 H -4.1566e+01 1.6179e-01
31 H -4.3688e+01 7.6799e-02
32 H -4.5018e+01 9.4855e-02
33 H -4.6684e+01 9.5829e-02
34 H -4.7688e+01 7.7409e-02
35 H -4.8772e+01 6.2781e-02
36 H -4.9702e+01 1.0411e-01
37 H -5.0362e+01 1.6380e-01
38 H -5.1114e+01 2.5164e-01
One sees that there are small changes in the point estimates,
while the confidence limits have been reduced to about 60%
of the ones produced by OLS.
The main point I want to make is that all the modified calculations occur automatically once one changes the one line of code in the TPL file. | Reliability of a fitted curve?
There is a standard approach for this called the delta method.
You form the inverse of the Hessian of the log-likelihood wrt
your four parameters. There is an extra parameter for the variance of
the r |
24,073 | Reliability of a fitted curve? | Cross-validation is a simple way to estimate reliability of your curve:
https://en.wikipedia.org/wiki/Cross-validation_(statistics)
Propagation of uncertainty with partial differentials is great is you really know $\Delta E_{0},\Delta V_{0},\Delta B_{0}$, and $\Delta B'$. However, the program you are using gives only fitting errors(?). Those will be too optimistic (unrealistically small).
You can calculate 1-fold validation error by leaving one of your points away from fitting and using the fitted curve to predict value of the point that was left away. Repeat this for all points so that each is left away once. Then, calculate validation error of your final curve (curve fitted with all points) as an average of prediction errors.
This will only tell you how sensitive your model is for any new data point. For example, it will not tell you how inaccurate your energy model is. However, this will be much more realistic error estimate mere fitting error.
Also, you can plot prediction errors as a function of volume if you want. | Reliability of a fitted curve? | Cross-validation is a simple way to estimate reliability of your curve:
https://en.wikipedia.org/wiki/Cross-validation_(statistics)
Propagation of uncertainty with partial differentials is great is yo | Reliability of a fitted curve?
Cross-validation is a simple way to estimate reliability of your curve:
https://en.wikipedia.org/wiki/Cross-validation_(statistics)
Propagation of uncertainty with partial differentials is great is you really know $\Delta E_{0},\Delta V_{0},\Delta B_{0}$, and $\Delta B'$. However, the program you are using gives only fitting errors(?). Those will be too optimistic (unrealistically small).
You can calculate 1-fold validation error by leaving one of your points away from fitting and using the fitted curve to predict value of the point that was left away. Repeat this for all points so that each is left away once. Then, calculate validation error of your final curve (curve fitted with all points) as an average of prediction errors.
This will only tell you how sensitive your model is for any new data point. For example, it will not tell you how inaccurate your energy model is. However, this will be much more realistic error estimate mere fitting error.
Also, you can plot prediction errors as a function of volume if you want. | Reliability of a fitted curve?
Cross-validation is a simple way to estimate reliability of your curve:
https://en.wikipedia.org/wiki/Cross-validation_(statistics)
Propagation of uncertainty with partial differentials is great is yo |
24,074 | Algorithms for computing multivariate Empirical distribution function (ECDF)? | On further investigation, the following paper gives efficient algorithms for the k-D ECDF problem:
Bentley, J. L. (1980). Multidimensional divide-and-conquer. Communications of the ACM, 23(4), 214-229.
The main data structure introduced is known as a range tree, and is somewhat similar to a k-d tree, but uses a space-for-time tradeoff to achieve faster range queries. The author of the above paper, Jon Bentley (of Programming Pearls fame), is the inventor of both data structures.
Both are binary trees which recursively partition a set of $k$ dimensional points by splitting along a coordinate axis at the median. In a k-d tree the sub-trees of a node are split along the $d$-th dimension, where $d$ cycles through $1\ldots k$ moving down the tree. In a range tree the sub-trees are always split along the first dimension, but each node is augmented with a $k-1$ dimensional range tree defined over the remaining dimensions.
At the time of this writing, the Wikipedia page for "Range Tree" linked above points to a CS lecture (Utrecht U.) comparing these two tree types from circa 2012. This suggests that these data structures are still essentially "state of the art". There is mention of an improved "fractional cascading" variant for range trees, but for the all-points ECDF problem this just allows the performance of Bentley's algorithm to be achieved via repeated queries of the range tree. | Algorithms for computing multivariate Empirical distribution function (ECDF)? | On further investigation, the following paper gives efficient algorithms for the k-D ECDF problem:
Bentley, J. L. (1980). Multidimensional divide-and-conquer. Communications of the ACM, 23(4), 214-229 | Algorithms for computing multivariate Empirical distribution function (ECDF)?
On further investigation, the following paper gives efficient algorithms for the k-D ECDF problem:
Bentley, J. L. (1980). Multidimensional divide-and-conquer. Communications of the ACM, 23(4), 214-229.
The main data structure introduced is known as a range tree, and is somewhat similar to a k-d tree, but uses a space-for-time tradeoff to achieve faster range queries. The author of the above paper, Jon Bentley (of Programming Pearls fame), is the inventor of both data structures.
Both are binary trees which recursively partition a set of $k$ dimensional points by splitting along a coordinate axis at the median. In a k-d tree the sub-trees of a node are split along the $d$-th dimension, where $d$ cycles through $1\ldots k$ moving down the tree. In a range tree the sub-trees are always split along the first dimension, but each node is augmented with a $k-1$ dimensional range tree defined over the remaining dimensions.
At the time of this writing, the Wikipedia page for "Range Tree" linked above points to a CS lecture (Utrecht U.) comparing these two tree types from circa 2012. This suggests that these data structures are still essentially "state of the art". There is mention of an improved "fractional cascading" variant for range trees, but for the all-points ECDF problem this just allows the performance of Bentley's algorithm to be achieved via repeated queries of the range tree. | Algorithms for computing multivariate Empirical distribution function (ECDF)?
On further investigation, the following paper gives efficient algorithms for the k-D ECDF problem:
Bentley, J. L. (1980). Multidimensional divide-and-conquer. Communications of the ACM, 23(4), 214-229 |
24,075 | Algorithms for computing multivariate Empirical distribution function (ECDF)? | I am not sure if there is a more efficient way to compute the ECDF at the data points, but the following brute force approach should be efficient for computing the ECDF over the data "grid". It is a simple generalization of the 1D version.
Assume you have a data set consisting of $N$ points in $d$ dimensions, given in the $N\times d$ matrix $X$. For simplicity I will assume that $X$ consists entirely of unique numbers (i.e. general position*). I will use Matlab notation in the following pseudo-code, as it is how I thought of the algorithm, but I can expand on this if there is interest.
First compute
$[x_{:,k},I_{:,k}]=\text{sort}[X_{:,k}]$ for $k=1:d$,
where $I$ is the coordinate-wise rank matrix, and $x$ is the coordinate-grid axis matrix (both of size $N\times d$).
Then rasterize the data points into the implied data grid, computing an (normalized) histogram as
$P=\text{accumarray}[I,\frac{1}{N},N\times\text{ones[1,d]}]$.
Then integrate this "EPDF" in each dimension to give the ECDF:
$P=\text{cumsum}[P,k]$ for $k=1:d$.
Now $P_{i_1,\ldots,i_d}$ is the ECDF sampled at $x_{i_1,1},\ldots x_{i_d,d}$.
This algorithm takes time $\text{O}[N\log N]$ for each sort and $\text{O}[N^d]$ for each sum, so the total cost is $\text{O}[d(N^d+N\log N)]$. As the gridded ECDF itself has $\text{O}[N^d]$ elements, this should be essentially optimal.
(*The assumption of distinct points can be relaxed by using $\text{unique}[]$ instead of $\text{sort}[]$, along with a bit of book-keeping.) | Algorithms for computing multivariate Empirical distribution function (ECDF)? | I am not sure if there is a more efficient way to compute the ECDF at the data points, but the following brute force approach should be efficient for computing the ECDF over the data "grid". It is a s | Algorithms for computing multivariate Empirical distribution function (ECDF)?
I am not sure if there is a more efficient way to compute the ECDF at the data points, but the following brute force approach should be efficient for computing the ECDF over the data "grid". It is a simple generalization of the 1D version.
Assume you have a data set consisting of $N$ points in $d$ dimensions, given in the $N\times d$ matrix $X$. For simplicity I will assume that $X$ consists entirely of unique numbers (i.e. general position*). I will use Matlab notation in the following pseudo-code, as it is how I thought of the algorithm, but I can expand on this if there is interest.
First compute
$[x_{:,k},I_{:,k}]=\text{sort}[X_{:,k}]$ for $k=1:d$,
where $I$ is the coordinate-wise rank matrix, and $x$ is the coordinate-grid axis matrix (both of size $N\times d$).
Then rasterize the data points into the implied data grid, computing an (normalized) histogram as
$P=\text{accumarray}[I,\frac{1}{N},N\times\text{ones[1,d]}]$.
Then integrate this "EPDF" in each dimension to give the ECDF:
$P=\text{cumsum}[P,k]$ for $k=1:d$.
Now $P_{i_1,\ldots,i_d}$ is the ECDF sampled at $x_{i_1,1},\ldots x_{i_d,d}$.
This algorithm takes time $\text{O}[N\log N]$ for each sort and $\text{O}[N^d]$ for each sum, so the total cost is $\text{O}[d(N^d+N\log N)]$. As the gridded ECDF itself has $\text{O}[N^d]$ elements, this should be essentially optimal.
(*The assumption of distinct points can be relaxed by using $\text{unique}[]$ instead of $\text{sort}[]$, along with a bit of book-keeping.) | Algorithms for computing multivariate Empirical distribution function (ECDF)?
I am not sure if there is a more efficient way to compute the ECDF at the data points, but the following brute force approach should be efficient for computing the ECDF over the data "grid". It is a s |
24,076 | Is the Student-t distribution a Lévy stable distribution? | One of the characterizing features of a Levy-stable distribution is that linear combinations of independent copies have the same distribution, up to location and scaling. So if this property does not hold, the distribution cannot be Levy stable. Equivalently the characteristic function isn't of the Levy form.
In the case of the student t distribution, it has a characteristic function that looks like:
$$\frac{K_{v/2}(\sqrt{v}|t|)(\sqrt{v}|t|)^{v/2}}{\Gamma(v/2)2^{v/2-1}},$$
which in general will not have the Levy form. | Is the Student-t distribution a Lévy stable distribution? | One of the characterizing features of a Levy-stable distribution is that linear combinations of independent copies have the same distribution, up to location and scaling. So if this property does not | Is the Student-t distribution a Lévy stable distribution?
One of the characterizing features of a Levy-stable distribution is that linear combinations of independent copies have the same distribution, up to location and scaling. So if this property does not hold, the distribution cannot be Levy stable. Equivalently the characteristic function isn't of the Levy form.
In the case of the student t distribution, it has a characteristic function that looks like:
$$\frac{K_{v/2}(\sqrt{v}|t|)(\sqrt{v}|t|)^{v/2}}{\Gamma(v/2)2^{v/2-1}},$$
which in general will not have the Levy form. | Is the Student-t distribution a Lévy stable distribution?
One of the characterizing features of a Levy-stable distribution is that linear combinations of independent copies have the same distribution, up to location and scaling. So if this property does not |
24,077 | Is the Student-t distribution a Lévy stable distribution? | case $\nu>2$
To expand Alex's aswer we can make a different type of argument for $\nu>2$:
Lévy-stable distributions have infinite variance for the stability parameter $\alpha < 2$.
But the t-distribution has a finite variance for the degrees of freedom parameter $\nu > 2$.
And the Gaussian distribution is already the (unique) Lévy-stable distribution with $\alpha=2$.
Thus it must be the case that the generalized t-distribution can not be a Lévy stable distribution.
Another way of seeing this is that (due to the finite variance and the CLT) the distribution of a sum of t-distributed variables must converge to the normal distribution. Thus the t-distribution can not be a Lévy stable distribution.
case $1 \leq \nu \leq 2$
In these cases we can not use the argument above. One way to look at is to inspect the characteristic function (as Alex's answer mentions). In the case of the location scale variant this is :
$$\varphi(t) = e^{it\mu} \frac{K_{\frac{\nu}{2}}\left( \sqrt{\nu} \vert \sigma t \vert \right) \left(\sqrt{\nu} \vert \sigma t \vert \right)^{\frac{\nu}{2}} }{\Gamma \left( \frac{\nu}{2}\right) 2^{\frac{\nu}{2}-1} }$$
with $K_{\lambda}(w)$ the modified Bessel function of the second kind.
$$K_{\lambda}(w) = \frac{1}{2} \int_0^\infty x^{\lambda-1} e^{-\frac{1}{2}w\left(x + 1/x \right)} dx$$
See Dae-Kun Song, Hyoung-Jin Park, Hyoung-Moon Kim A Note on the Characteristic Function of Multivariate t
Distribution
In the case of $\mathbf{\nu = 1}$ the t-distribution is the same as the Cauchy distribution which is known to be Lévy stable.
In this special case the term with the modified Bessel function is
$$K_{\frac{1}{2}}(\vert \sigma t \vert) = \sqrt{\frac{2}{\pi \vert
\sigma t \vert }}e^{-\vert \sigma t\vert }$$ and you end up with
$$\varphi(t) = e^{it\mu + \vert \sigma t \vert }$$
In the case of $\mathbf{1 < \nu \leq 2}$ the t-distribution and the function $K_\nu$ are more difficult to evaluate. But, we can make an argument in reverse direction and suppose that $K_\nu$ must be of some form and then see whether is a solution of Bessel's equation.
Suppose some t-distribution with $1 < \nu \leq 2$ is Lévy stable,
then the characteristic function would need to be of the form
$$\varphi(t)=e^{it\mu -ct^\alpha}$$ with $c>0$ and $1 < \alpha < 2$
(in these cases the mean is finite and the variance infinite).
Actually the Holtsmark distribution is the only currently known explicit
distribution that has this form with these conditions.
If a t-distribution for a particular $\nu$ is of such form then the modified Bessel function of the third kind can needs to be of the form: $$K_{\lambda = \frac{\nu}{2}}(w) \propto w^{-\nu/2}e^{-w^\alpha }$$ we can check this by plugging it into the modified Bessel equation $$x^2y'' + xy' - (x^2+\lambda^2)y = 0$$ which becomes $$\alpha x^{2\alpha}-\alpha(\alpha - \nu) x^\alpha - x^2 = 0$$ Which has only the solution $\nu = \alpha = 1$ which is the Cauchy distribution case. Thus, there is no other t-distribution that is Lévy stable. | Is the Student-t distribution a Lévy stable distribution? | case $\nu>2$
To expand Alex's aswer we can make a different type of argument for $\nu>2$:
Lévy-stable distributions have infinite variance for the stability parameter $\alpha < 2$.
But the t-distri | Is the Student-t distribution a Lévy stable distribution?
case $\nu>2$
To expand Alex's aswer we can make a different type of argument for $\nu>2$:
Lévy-stable distributions have infinite variance for the stability parameter $\alpha < 2$.
But the t-distribution has a finite variance for the degrees of freedom parameter $\nu > 2$.
And the Gaussian distribution is already the (unique) Lévy-stable distribution with $\alpha=2$.
Thus it must be the case that the generalized t-distribution can not be a Lévy stable distribution.
Another way of seeing this is that (due to the finite variance and the CLT) the distribution of a sum of t-distributed variables must converge to the normal distribution. Thus the t-distribution can not be a Lévy stable distribution.
case $1 \leq \nu \leq 2$
In these cases we can not use the argument above. One way to look at is to inspect the characteristic function (as Alex's answer mentions). In the case of the location scale variant this is :
$$\varphi(t) = e^{it\mu} \frac{K_{\frac{\nu}{2}}\left( \sqrt{\nu} \vert \sigma t \vert \right) \left(\sqrt{\nu} \vert \sigma t \vert \right)^{\frac{\nu}{2}} }{\Gamma \left( \frac{\nu}{2}\right) 2^{\frac{\nu}{2}-1} }$$
with $K_{\lambda}(w)$ the modified Bessel function of the second kind.
$$K_{\lambda}(w) = \frac{1}{2} \int_0^\infty x^{\lambda-1} e^{-\frac{1}{2}w\left(x + 1/x \right)} dx$$
See Dae-Kun Song, Hyoung-Jin Park, Hyoung-Moon Kim A Note on the Characteristic Function of Multivariate t
Distribution
In the case of $\mathbf{\nu = 1}$ the t-distribution is the same as the Cauchy distribution which is known to be Lévy stable.
In this special case the term with the modified Bessel function is
$$K_{\frac{1}{2}}(\vert \sigma t \vert) = \sqrt{\frac{2}{\pi \vert
\sigma t \vert }}e^{-\vert \sigma t\vert }$$ and you end up with
$$\varphi(t) = e^{it\mu + \vert \sigma t \vert }$$
In the case of $\mathbf{1 < \nu \leq 2}$ the t-distribution and the function $K_\nu$ are more difficult to evaluate. But, we can make an argument in reverse direction and suppose that $K_\nu$ must be of some form and then see whether is a solution of Bessel's equation.
Suppose some t-distribution with $1 < \nu \leq 2$ is Lévy stable,
then the characteristic function would need to be of the form
$$\varphi(t)=e^{it\mu -ct^\alpha}$$ with $c>0$ and $1 < \alpha < 2$
(in these cases the mean is finite and the variance infinite).
Actually the Holtsmark distribution is the only currently known explicit
distribution that has this form with these conditions.
If a t-distribution for a particular $\nu$ is of such form then the modified Bessel function of the third kind can needs to be of the form: $$K_{\lambda = \frac{\nu}{2}}(w) \propto w^{-\nu/2}e^{-w^\alpha }$$ we can check this by plugging it into the modified Bessel equation $$x^2y'' + xy' - (x^2+\lambda^2)y = 0$$ which becomes $$\alpha x^{2\alpha}-\alpha(\alpha - \nu) x^\alpha - x^2 = 0$$ Which has only the solution $\nu = \alpha = 1$ which is the Cauchy distribution case. Thus, there is no other t-distribution that is Lévy stable. | Is the Student-t distribution a Lévy stable distribution?
case $\nu>2$
To expand Alex's aswer we can make a different type of argument for $\nu>2$:
Lévy-stable distributions have infinite variance for the stability parameter $\alpha < 2$.
But the t-distri |
24,078 | Why is feature selection important, for classification tasks? | Your intuition is quite correct. In most situations, feature selection represents a desire for simple explanation that results from three misunderstandings:
The analyst does not realize that the set of "selected" features is quite unstable, i.e., non-robust, and that the process of selection when done on another dataset will result in a quite different set of features. The data often do not possess the information content needed to select the "right" features. This problem gets worse if co-linearities are present.
Pathways, mechanisms, and processes are complex in uncontrolled experiments; human behavior and nature are complex and not parsimoneous.
Predictive accuracy is harmed by asking the data to tell you both what are the important features and what are the relationships with $Y$ for the "important" ones. It is better to "use a little bit of each variable" than to use all of some variables and none for others (i.e., to use shrinkage/penalization).
Some ways to study this:
Do more comparisons of predictive accuracy between the lasso, elastic net, and a standard quadratic penalty (ridge regression)
Bootstrap variable importance measures from a random forest and check their stability
Compute bootstrap confidence intervals on ranks of potential features, e.g., on the ranks of partial $\chi^2$ tests of association (or of things like univariate Spearman $\rho$ or Somers' $D_{xy}$) and see that these confidence intervals are extremely wide, directly informing you of the difficulty of the task. My course notes linked from http://biostat.mc.vanderbilt.edu/rms have an example of bootstrapping rank order of predictors using OLS.
All of this applies to both classification and the more general and useful concept of prediction. | Why is feature selection important, for classification tasks? | Your intuition is quite correct. In most situations, feature selection represents a desire for simple explanation that results from three misunderstandings:
The analyst does not realize that the set | Why is feature selection important, for classification tasks?
Your intuition is quite correct. In most situations, feature selection represents a desire for simple explanation that results from three misunderstandings:
The analyst does not realize that the set of "selected" features is quite unstable, i.e., non-robust, and that the process of selection when done on another dataset will result in a quite different set of features. The data often do not possess the information content needed to select the "right" features. This problem gets worse if co-linearities are present.
Pathways, mechanisms, and processes are complex in uncontrolled experiments; human behavior and nature are complex and not parsimoneous.
Predictive accuracy is harmed by asking the data to tell you both what are the important features and what are the relationships with $Y$ for the "important" ones. It is better to "use a little bit of each variable" than to use all of some variables and none for others (i.e., to use shrinkage/penalization).
Some ways to study this:
Do more comparisons of predictive accuracy between the lasso, elastic net, and a standard quadratic penalty (ridge regression)
Bootstrap variable importance measures from a random forest and check their stability
Compute bootstrap confidence intervals on ranks of potential features, e.g., on the ranks of partial $\chi^2$ tests of association (or of things like univariate Spearman $\rho$ or Somers' $D_{xy}$) and see that these confidence intervals are extremely wide, directly informing you of the difficulty of the task. My course notes linked from http://biostat.mc.vanderbilt.edu/rms have an example of bootstrapping rank order of predictors using OLS.
All of this applies to both classification and the more general and useful concept of prediction. | Why is feature selection important, for classification tasks?
Your intuition is quite correct. In most situations, feature selection represents a desire for simple explanation that results from three misunderstandings:
The analyst does not realize that the set |
24,079 | G-test vs Pearson's chi-squared test | They are asymptotically the same. They are just different ways of getting at the same idea. More specifically, Pearson's chi-squared test is a score test, whereas the G-test is a likelihood ratio test. To get a better sense of those ideas, it may help you to read my answer here: Why do my p-values differ between logistic regression output, chi-squared test, and the confidence interval for the OR? To answer your direct question, if you are computing the p-value by Monte Carlo simulation, it shouldn't matter; you could just use whichever is more convenient for you. Note that there is no problem with low cell counts, only (potentially) low expected cell counts; it is possible to have low cell counts and have expected counts that are just fine. Furthermore, neither low actual counts nor low expected counts matters when the p-value is determined by simulation.
(For what it's worth, I would probably use Pearson's chi-squared, because R has a convenient function for that which includes the option of simulating the p-value.) | G-test vs Pearson's chi-squared test | They are asymptotically the same. They are just different ways of getting at the same idea. More specifically, Pearson's chi-squared test is a score test, whereas the G-test is a likelihood ratio te | G-test vs Pearson's chi-squared test
They are asymptotically the same. They are just different ways of getting at the same idea. More specifically, Pearson's chi-squared test is a score test, whereas the G-test is a likelihood ratio test. To get a better sense of those ideas, it may help you to read my answer here: Why do my p-values differ between logistic regression output, chi-squared test, and the confidence interval for the OR? To answer your direct question, if you are computing the p-value by Monte Carlo simulation, it shouldn't matter; you could just use whichever is more convenient for you. Note that there is no problem with low cell counts, only (potentially) low expected cell counts; it is possible to have low cell counts and have expected counts that are just fine. Furthermore, neither low actual counts nor low expected counts matters when the p-value is determined by simulation.
(For what it's worth, I would probably use Pearson's chi-squared, because R has a convenient function for that which includes the option of simulating the p-value.) | G-test vs Pearson's chi-squared test
They are asymptotically the same. They are just different ways of getting at the same idea. More specifically, Pearson's chi-squared test is a score test, whereas the G-test is a likelihood ratio te |
24,080 | G-test vs Pearson's chi-squared test | Chi-square test and G-test usually produce similar results. But the most important thing here is you have to pick one of two tests and stick with it, not only for your mentioned test but for future tests during the course of your research. It is advisable because if you try to use both tests interchangeably, it is very likely that you will increase the chance of getting false positive. | G-test vs Pearson's chi-squared test | Chi-square test and G-test usually produce similar results. But the most important thing here is you have to pick one of two tests and stick with it, not only for your mentioned test but for future te | G-test vs Pearson's chi-squared test
Chi-square test and G-test usually produce similar results. But the most important thing here is you have to pick one of two tests and stick with it, not only for your mentioned test but for future tests during the course of your research. It is advisable because if you try to use both tests interchangeably, it is very likely that you will increase the chance of getting false positive. | G-test vs Pearson's chi-squared test
Chi-square test and G-test usually produce similar results. But the most important thing here is you have to pick one of two tests and stick with it, not only for your mentioned test but for future te |
24,081 | G-test vs Pearson's chi-squared test | Have a look at Rfast.
https://cran.r-project.org/web/packages/Rfast/index.html
The relevant commands are
g2Test_univariate(data, dc)
g2Test_univariate_perm(data, dc, nperm)
The calculations are extremely fast. And in general prefer the G^2 test as the Chi-square is an approximation to it. | G-test vs Pearson's chi-squared test | Have a look at Rfast.
https://cran.r-project.org/web/packages/Rfast/index.html
The relevant commands are
g2Test_univariate(data, dc)
g2Test_univariate_perm(data, dc, nperm)
The calculations are extre | G-test vs Pearson's chi-squared test
Have a look at Rfast.
https://cran.r-project.org/web/packages/Rfast/index.html
The relevant commands are
g2Test_univariate(data, dc)
g2Test_univariate_perm(data, dc, nperm)
The calculations are extremely fast. And in general prefer the G^2 test as the Chi-square is an approximation to it. | G-test vs Pearson's chi-squared test
Have a look at Rfast.
https://cran.r-project.org/web/packages/Rfast/index.html
The relevant commands are
g2Test_univariate(data, dc)
g2Test_univariate_perm(data, dc, nperm)
The calculations are extre |
24,082 | Evaluate posterior predictive distribution in Bayesian linear regression | If you assume a uniform prior on $\beta$, then the posterior for $\beta$ is
$$ \beta|y \sim N(\hat{\beta},V_\beta). $$
with
$$\hat{\beta} = [X'\Sigma^{-1}X]X'y \quad \mbox{and} \quad V_\beta =[X'\Sigma^{-1}X]^{-1}.$$
To find the predictive distribution, we need more information. If $\tilde{y} \sim N(\tilde{X}\beta,\tilde{\Sigma})$ and is conditionally independent of $y$ given $\beta$, then
$$ \tilde{y}|y \sim N(\tilde{X}\hat{\beta}, \tilde{\Sigma} + V_\beta).$$
But typically for these types of models, $y$ and $\tilde{y}$ are not conditionally independent, instead, we typically have
$$ \left( \begin{array}{c}
y \\ \tilde{y}
\end{array} \right) \sim N\left( \left[\begin{array}{c} X\beta \\ \tilde{X}\beta \end{array}\right],
\left[ \begin{array}{cc}
\Sigma & \Sigma_{12} \\
\Sigma_{21} & \tilde{\Sigma}
\end{array} \right]\right).
$$
If this is the case, then
$$
\tilde{y}|y \sim N(\tilde{X}\hat{\beta} + \Sigma_{21}\Sigma^{-1}(y-X\hat{\beta}),
\tilde{\Sigma} - \Sigma_{21}\Sigma^{-1}\Sigma_{12}).
$$
This assumes $\Sigma, \Sigma_{12},$ and $\tilde{\Sigma}$ are all known. As you point out, typically they are unknown and need to be estimated. For the common models that have this structure, e.g. time series and spatial models, there generally won't be a closed form for the predictive distribution. | Evaluate posterior predictive distribution in Bayesian linear regression | If you assume a uniform prior on $\beta$, then the posterior for $\beta$ is
$$ \beta|y \sim N(\hat{\beta},V_\beta). $$
with
$$\hat{\beta} = [X'\Sigma^{-1}X]X'y \quad \mbox{and} \quad V_\beta =[X'\Si | Evaluate posterior predictive distribution in Bayesian linear regression
If you assume a uniform prior on $\beta$, then the posterior for $\beta$ is
$$ \beta|y \sim N(\hat{\beta},V_\beta). $$
with
$$\hat{\beta} = [X'\Sigma^{-1}X]X'y \quad \mbox{and} \quad V_\beta =[X'\Sigma^{-1}X]^{-1}.$$
To find the predictive distribution, we need more information. If $\tilde{y} \sim N(\tilde{X}\beta,\tilde{\Sigma})$ and is conditionally independent of $y$ given $\beta$, then
$$ \tilde{y}|y \sim N(\tilde{X}\hat{\beta}, \tilde{\Sigma} + V_\beta).$$
But typically for these types of models, $y$ and $\tilde{y}$ are not conditionally independent, instead, we typically have
$$ \left( \begin{array}{c}
y \\ \tilde{y}
\end{array} \right) \sim N\left( \left[\begin{array}{c} X\beta \\ \tilde{X}\beta \end{array}\right],
\left[ \begin{array}{cc}
\Sigma & \Sigma_{12} \\
\Sigma_{21} & \tilde{\Sigma}
\end{array} \right]\right).
$$
If this is the case, then
$$
\tilde{y}|y \sim N(\tilde{X}\hat{\beta} + \Sigma_{21}\Sigma^{-1}(y-X\hat{\beta}),
\tilde{\Sigma} - \Sigma_{21}\Sigma^{-1}\Sigma_{12}).
$$
This assumes $\Sigma, \Sigma_{12},$ and $\tilde{\Sigma}$ are all known. As you point out, typically they are unknown and need to be estimated. For the common models that have this structure, e.g. time series and spatial models, there generally won't be a closed form for the predictive distribution. | Evaluate posterior predictive distribution in Bayesian linear regression
If you assume a uniform prior on $\beta$, then the posterior for $\beta$ is
$$ \beta|y \sim N(\hat{\beta},V_\beta). $$
with
$$\hat{\beta} = [X'\Sigma^{-1}X]X'y \quad \mbox{and} \quad V_\beta =[X'\Si |
24,083 | Evaluate posterior predictive distribution in Bayesian linear regression | Under non-informative or multivariate Normal-Wishart priors, you have the analytical form as a multivariate Student's distribution, for a classical mutlivariate, multiple regression. I guess the developments in this document are related to your question (you may like the Appendix A :-) ). I typically compared the outcome with a posterior predictive distribution obtained using WinBUGS and the analytical form: they are exactly equivalent. The problem only becomes difficult when you have additional random effects in mixed-effect models, especially in unbalanced design.
In general, with classical regressions, y and ỹ are conditionally independent (residuals are i.i.d) ! Of course if it is not the case, then the proposed solution here is not correct.
In R,(here, solution for uniform priors), assuming you made a lm model (named "model") of one of the response in your model, and called it "model", here is how to obtain the multivariate predictive distribution
library(mvtnorm)
Y = as.matrix(datas[,c("resp1","resp2","resp3")])
X = model.matrix(delete.response(terms(model)),
data, model$contrasts)
XprimeX = t(X) %*% X
XprimeXinv = solve(xprimex)
hatB = xprimexinv %*% t(X) %*% Y
A = t(Y - X%*%hatB)%*% (Y-X%*%hatB)
F = ncol(X)
M = ncol(Y)
N = nrow(Y)
nu= N-(M+F)+1 #nu must be positive
C_1 = c(1 + x0 %*% xprimexinv %*% t(x0)) #for a prediction of the factor setting x0 (a vector of size F=ncol(X))
varY = A/(nu)
postmean = x0 %*% hatB
nsim = 2000
ysim = rmvt(n=nsim,delta=postmux0,C_1*varY,df=nu)
Now, quantiles of ysim are beta-expectation tolerance intervals from the predictive distribution, you can of course directly use the sampled distribution to do whatever you want. | Evaluate posterior predictive distribution in Bayesian linear regression | Under non-informative or multivariate Normal-Wishart priors, you have the analytical form as a multivariate Student's distribution, for a classical mutlivariate, multiple regression. I guess the devel | Evaluate posterior predictive distribution in Bayesian linear regression
Under non-informative or multivariate Normal-Wishart priors, you have the analytical form as a multivariate Student's distribution, for a classical mutlivariate, multiple regression. I guess the developments in this document are related to your question (you may like the Appendix A :-) ). I typically compared the outcome with a posterior predictive distribution obtained using WinBUGS and the analytical form: they are exactly equivalent. The problem only becomes difficult when you have additional random effects in mixed-effect models, especially in unbalanced design.
In general, with classical regressions, y and ỹ are conditionally independent (residuals are i.i.d) ! Of course if it is not the case, then the proposed solution here is not correct.
In R,(here, solution for uniform priors), assuming you made a lm model (named "model") of one of the response in your model, and called it "model", here is how to obtain the multivariate predictive distribution
library(mvtnorm)
Y = as.matrix(datas[,c("resp1","resp2","resp3")])
X = model.matrix(delete.response(terms(model)),
data, model$contrasts)
XprimeX = t(X) %*% X
XprimeXinv = solve(xprimex)
hatB = xprimexinv %*% t(X) %*% Y
A = t(Y - X%*%hatB)%*% (Y-X%*%hatB)
F = ncol(X)
M = ncol(Y)
N = nrow(Y)
nu= N-(M+F)+1 #nu must be positive
C_1 = c(1 + x0 %*% xprimexinv %*% t(x0)) #for a prediction of the factor setting x0 (a vector of size F=ncol(X))
varY = A/(nu)
postmean = x0 %*% hatB
nsim = 2000
ysim = rmvt(n=nsim,delta=postmux0,C_1*varY,df=nu)
Now, quantiles of ysim are beta-expectation tolerance intervals from the predictive distribution, you can of course directly use the sampled distribution to do whatever you want. | Evaluate posterior predictive distribution in Bayesian linear regression
Under non-informative or multivariate Normal-Wishart priors, you have the analytical form as a multivariate Student's distribution, for a classical mutlivariate, multiple regression. I guess the devel |
24,084 | Why is the geometric median called the $L_1$ estimator? | Given a collection $\{\mathbf x^{(i)}\}$ of $N$ points in $\mathbb R^m$, their geometric median is a point $\mathbf y$ minimizing the sum of Euclidean distances to each point: $$L = \sum_{i=1}^N \|\mathbf x^{(i)} - \mathbf y\|.$$ Each Euclidean distance in this sum is indeed a $L_2$ norm of a vector in $\mathbb R^m$. But consider a vector $\mathbf{d} \in \mathbb R^N$, whose coordinates are given by these distances: $d_i = \|\mathbf x^{(i)} - \mathbf y\|$. Then the same cost function $L$ can be equivalently written as the $L_1$ norm of this vector: $$L=\sum_{i=1}^N d_i = \sum_{i=1}^N |d_i| = \|\mathbf d\|_1.$$
That is, I believe, why the geometric median is called a $L_1$ estimator. | Why is the geometric median called the $L_1$ estimator? | Given a collection $\{\mathbf x^{(i)}\}$ of $N$ points in $\mathbb R^m$, their geometric median is a point $\mathbf y$ minimizing the sum of Euclidean distances to each point: $$L = \sum_{i=1}^N \|\ma | Why is the geometric median called the $L_1$ estimator?
Given a collection $\{\mathbf x^{(i)}\}$ of $N$ points in $\mathbb R^m$, their geometric median is a point $\mathbf y$ minimizing the sum of Euclidean distances to each point: $$L = \sum_{i=1}^N \|\mathbf x^{(i)} - \mathbf y\|.$$ Each Euclidean distance in this sum is indeed a $L_2$ norm of a vector in $\mathbb R^m$. But consider a vector $\mathbf{d} \in \mathbb R^N$, whose coordinates are given by these distances: $d_i = \|\mathbf x^{(i)} - \mathbf y\|$. Then the same cost function $L$ can be equivalently written as the $L_1$ norm of this vector: $$L=\sum_{i=1}^N d_i = \sum_{i=1}^N |d_i| = \|\mathbf d\|_1.$$
That is, I believe, why the geometric median is called a $L_1$ estimator. | Why is the geometric median called the $L_1$ estimator?
Given a collection $\{\mathbf x^{(i)}\}$ of $N$ points in $\mathbb R^m$, their geometric median is a point $\mathbf y$ minimizing the sum of Euclidean distances to each point: $$L = \sum_{i=1}^N \|\ma |
24,085 | Why is the geometric median called the $L_1$ estimator? | [Response rewritten]
I think I was too confusing, I apologize for that. Now I am trying to give a proper answer.
We know that median minimize the $L_1$ norm. The formula is
$$ L_1 = \underset{y \in \mathbb{R}}{\operatorname{arg\,min}}\sum_{i=1}^{n}|x_i-y|$$
Also the mean minimize the $L_2$ norm. Again, the formula is
$$ L_2 = \underset{y \in \mathbb{R}}{\operatorname{arg\,min}}\sum_{i=1}^{n}(x_i-y)^2$$
In plain English we say that the median minimize the sum of distances and the mean minimize the sum of squares of those distances. We note also that we are in $\mathbb{R}$.
My idea is that because we are in $\mathbb{R}$, the distance function can be any particular case of p-norm, the result would be the same. So I generalize by saying that the distance is p-norm (it might be any type of distance in fact) and to finish quicker we move to $\mathbb{R}^m$ at the same time
$$L_1 = \underset{y \in \mathbb{R}^m}{\operatorname{arg\,min}}\sum_{i=1}^{n}|(\sum_{j=1}^{m}(x_{i,j}^p-y_j^p))^\frac{1}{p}| = \underset{y \in \mathbb{R}^m}{\operatorname{arg\,min}}\sum_{i=1}^{n}\|x_i-y\|_p $$
What is important here is that it does not matter what is the value for $p$, it will be an $L_1$. [Note, as suggested by @amoeba, there are two norms, one inside another; the first one is $L_1$ applied on distances, and a nested one applied on the elements of the vectors in $\mathbb{R}^m$].
Going back to your original question, the geometric median is defined as the point in Euclidean space which minimize the sum of distances. I believe the reason for the word geometric comes from Euclidean space and Euclidean distance (which is $\|.\|_2$) and minimize the sum of distances (not the squares as in the case of an $L_2$ estimator), so
$$GM = L_1 = \underset{y \in \mathbb{R}^m}{\operatorname{arg\,min}}\sum_{i=1}^{n}\|x_i-y\|_2 $$
As a final note we might choose to minimize:
the sum of Manhattan distances ($L_1$ and $\|.\|_1$ as distance)
the sum of squares of Manhattan distances ($L_2$ and $\|.\|_1$ as distance)
the sum of Euclidean distances (geometric median)
the sum of squares of Euclidean distances ($L_2$ and $\|.\|_2$ as distance)
and so on. | Why is the geometric median called the $L_1$ estimator? | [Response rewritten]
I think I was too confusing, I apologize for that. Now I am trying to give a proper answer.
We know that median minimize the $L_1$ norm. The formula is
$$ L_1 = \underset{y \in \m | Why is the geometric median called the $L_1$ estimator?
[Response rewritten]
I think I was too confusing, I apologize for that. Now I am trying to give a proper answer.
We know that median minimize the $L_1$ norm. The formula is
$$ L_1 = \underset{y \in \mathbb{R}}{\operatorname{arg\,min}}\sum_{i=1}^{n}|x_i-y|$$
Also the mean minimize the $L_2$ norm. Again, the formula is
$$ L_2 = \underset{y \in \mathbb{R}}{\operatorname{arg\,min}}\sum_{i=1}^{n}(x_i-y)^2$$
In plain English we say that the median minimize the sum of distances and the mean minimize the sum of squares of those distances. We note also that we are in $\mathbb{R}$.
My idea is that because we are in $\mathbb{R}$, the distance function can be any particular case of p-norm, the result would be the same. So I generalize by saying that the distance is p-norm (it might be any type of distance in fact) and to finish quicker we move to $\mathbb{R}^m$ at the same time
$$L_1 = \underset{y \in \mathbb{R}^m}{\operatorname{arg\,min}}\sum_{i=1}^{n}|(\sum_{j=1}^{m}(x_{i,j}^p-y_j^p))^\frac{1}{p}| = \underset{y \in \mathbb{R}^m}{\operatorname{arg\,min}}\sum_{i=1}^{n}\|x_i-y\|_p $$
What is important here is that it does not matter what is the value for $p$, it will be an $L_1$. [Note, as suggested by @amoeba, there are two norms, one inside another; the first one is $L_1$ applied on distances, and a nested one applied on the elements of the vectors in $\mathbb{R}^m$].
Going back to your original question, the geometric median is defined as the point in Euclidean space which minimize the sum of distances. I believe the reason for the word geometric comes from Euclidean space and Euclidean distance (which is $\|.\|_2$) and minimize the sum of distances (not the squares as in the case of an $L_2$ estimator), so
$$GM = L_1 = \underset{y \in \mathbb{R}^m}{\operatorname{arg\,min}}\sum_{i=1}^{n}\|x_i-y\|_2 $$
As a final note we might choose to minimize:
the sum of Manhattan distances ($L_1$ and $\|.\|_1$ as distance)
the sum of squares of Manhattan distances ($L_2$ and $\|.\|_1$ as distance)
the sum of Euclidean distances (geometric median)
the sum of squares of Euclidean distances ($L_2$ and $\|.\|_2$ as distance)
and so on. | Why is the geometric median called the $L_1$ estimator?
[Response rewritten]
I think I was too confusing, I apologize for that. Now I am trying to give a proper answer.
We know that median minimize the $L_1$ norm. The formula is
$$ L_1 = \underset{y \in \m |
24,086 | How to quantify the Relative Variable Importance in Logistic Regression in terms of p? | For linear models you can use the absolute value of the t-statistics for each model parameter.
Also, you can use something like a random forrest and get a very nice list of feature importances.
If you are using R check out (http://caret.r-forge.r-project.org/varimp.html), if you are using python check out (http://scikit-learn.org/stable/auto_examples/ensemble/plot_forest_importances.html#example-ensemble-plot-forest-importances-py)
EDIT:
Since logit has no direct way to do this you can use a ROC curve for each predictor.
For classification, ROC curve analysis is conducted on each predictor. For two class problems, a series of cutoffs is applied to the predictor data to predict the class. The sensitivity and specificity are computed for each cutoff and the ROC curve is computed. The trapezoidal rule is used to compute the area under the ROC curve. This area is used as the measure of variable importance
An example of how this works in R is:
library(caret)
mydata <- data.frame(y = c(1,0,0,0,1,1),
x1 = c(1,1,0,1,0,0),
x2 = c(1,1,1,0,0,1),
x3 = c(1,0,1,1,0,0))
fit <- glm(y~x1+x2+x3,data=mydata,family=binomial())
summary(fit)
varImp(fit, scale = FALSE) | How to quantify the Relative Variable Importance in Logistic Regression in terms of p? | For linear models you can use the absolute value of the t-statistics for each model parameter.
Also, you can use something like a random forrest and get a very nice list of feature importances.
If yo | How to quantify the Relative Variable Importance in Logistic Regression in terms of p?
For linear models you can use the absolute value of the t-statistics for each model parameter.
Also, you can use something like a random forrest and get a very nice list of feature importances.
If you are using R check out (http://caret.r-forge.r-project.org/varimp.html), if you are using python check out (http://scikit-learn.org/stable/auto_examples/ensemble/plot_forest_importances.html#example-ensemble-plot-forest-importances-py)
EDIT:
Since logit has no direct way to do this you can use a ROC curve for each predictor.
For classification, ROC curve analysis is conducted on each predictor. For two class problems, a series of cutoffs is applied to the predictor data to predict the class. The sensitivity and specificity are computed for each cutoff and the ROC curve is computed. The trapezoidal rule is used to compute the area under the ROC curve. This area is used as the measure of variable importance
An example of how this works in R is:
library(caret)
mydata <- data.frame(y = c(1,0,0,0,1,1),
x1 = c(1,1,0,1,0,0),
x2 = c(1,1,1,0,0,1),
x3 = c(1,0,1,1,0,0))
fit <- glm(y~x1+x2+x3,data=mydata,family=binomial())
summary(fit)
varImp(fit, scale = FALSE) | How to quantify the Relative Variable Importance in Logistic Regression in terms of p?
For linear models you can use the absolute value of the t-statistics for each model parameter.
Also, you can use something like a random forrest and get a very nice list of feature importances.
If yo |
24,087 | How to quantify the Relative Variable Importance in Logistic Regression in terms of p? | Since you were specifically asking for an interpretation on the probability scale: In a logistic regression, the estimated probability of success is given by
$\hat{\pi}(\mathbf{x})=\frac{exp(\beta_0+ \mathbf{\beta x})}{1+exp(\beta_0+ \mathbf{\beta x})}$
With $\beta_0$ the intercept, $\mathbf{\beta}$ a coefficient vector and $\mathbf{x}$ your observed values. So if your coefficients are 0.1, 0.2 and 0.3 and supposing no intercept (most likely incorrect, but for easiness), the probability of a purchase for a person who clicked ad 1 only is:
$\frac{exp(0.1)}{1+exp(0.1)}=0.52$
A person who clicked ad 3 only:
$\frac{exp(0.3)}{1+exp(0.3)}=0.57$
However, if the person clicked ad 1 or ad 3 but also ad 2 (if this is a plasubile scenario), the probabilities becomes
$\frac{exp(0.1+0.2)}{1+exp(0.1+0.2)}=0.57$
$\frac{exp(0.3+0.2)}{1+exp(0.3+0.2)}=0.62$
In this case the change in probability is both 0.05, but usually this change is not the same for different combinations of levels. (You can see this easily if you e.g. use the same approach as above but with coefficients 0.1, 1.5, 0.3.) Thus, the importance of a variable on the probability scale is dependent on the observed levels of the other variables. This may make it hard (impossible?) to come up with an absolute, quantitative variable importance measure on the probability scale. | How to quantify the Relative Variable Importance in Logistic Regression in terms of p? | Since you were specifically asking for an interpretation on the probability scale: In a logistic regression, the estimated probability of success is given by
$\hat{\pi}(\mathbf{x})=\frac{exp(\beta_0+ | How to quantify the Relative Variable Importance in Logistic Regression in terms of p?
Since you were specifically asking for an interpretation on the probability scale: In a logistic regression, the estimated probability of success is given by
$\hat{\pi}(\mathbf{x})=\frac{exp(\beta_0+ \mathbf{\beta x})}{1+exp(\beta_0+ \mathbf{\beta x})}$
With $\beta_0$ the intercept, $\mathbf{\beta}$ a coefficient vector and $\mathbf{x}$ your observed values. So if your coefficients are 0.1, 0.2 and 0.3 and supposing no intercept (most likely incorrect, but for easiness), the probability of a purchase for a person who clicked ad 1 only is:
$\frac{exp(0.1)}{1+exp(0.1)}=0.52$
A person who clicked ad 3 only:
$\frac{exp(0.3)}{1+exp(0.3)}=0.57$
However, if the person clicked ad 1 or ad 3 but also ad 2 (if this is a plasubile scenario), the probabilities becomes
$\frac{exp(0.1+0.2)}{1+exp(0.1+0.2)}=0.57$
$\frac{exp(0.3+0.2)}{1+exp(0.3+0.2)}=0.62$
In this case the change in probability is both 0.05, but usually this change is not the same for different combinations of levels. (You can see this easily if you e.g. use the same approach as above but with coefficients 0.1, 1.5, 0.3.) Thus, the importance of a variable on the probability scale is dependent on the observed levels of the other variables. This may make it hard (impossible?) to come up with an absolute, quantitative variable importance measure on the probability scale. | How to quantify the Relative Variable Importance in Logistic Regression in terms of p?
Since you were specifically asking for an interpretation on the probability scale: In a logistic regression, the estimated probability of success is given by
$\hat{\pi}(\mathbf{x})=\frac{exp(\beta_0+ |
24,088 | Fitted values of ARMA model | To answer your questions, you basically need to know how the residuals i.e. $e_t$ are calculated in an arma model. Because then $\hat{X_{t}}=X_{t}-e_{t}$. Let's first generate a fake data ($X_t$) from arima(.5,.6) and fit the arma model (without mean):
library(forecast)
n=1000
ts_AR <- arima.sim(n = n, list(ar = 0.5,ma=0.6))
f=arima(ts_AR,order=c(1,0,1),include.mean=FALSE)
summary(f)
Series: ts_AR
ARIMA(1,0,1) with zero mean
Coefficients:
ar1 ma1
0.4879 0.5595
s.e. 0.0335 0.0317
sigma^2 estimated as 1.014: log likelihood=-1426.7
AIC=2859.4 AICc=2859.42 BIC=2874.12
Training set error measures:
ME RMSE MAE MPE MAPE MASE
Training set 0.02102758 1.00722 0.8057205 40.05802 160.1078 0.6313145
Now I create the residuals as follows: $e_1=0$ (since there is no residual at 1) and for $t=2,...,n$ we have: $e_t=X_t-Ar*X_{t-1}-Ma*e_{t-1}$, where $Ar$ and $Ma$ are the estimated auto-regressive and moving average part in above fitted model. Here is the code:
e = rep(1,n)
e[1] = 0 ##since there is no residual at 1, e1 = 0
for (t in (2 : n)){
e[t] = ts_AR[t]-coef(f)[1]*ts_AR[t-1]-coef(f)[2]*e[t-1]
}
Once you find the residuals $e_{t}$, the fitted values are just $\hat{X_{t}}=X_{t}-e_{t}$. So in the following, I compared the first 10 fitted values obtained from R and the ones I can calculate from $e_{t}$ I created above (i.e. manually).
cbind(fitted.from.package=fitted(f)[1:10],fitted.calculated.manually=ts_AR[1:10]-e[1:10])
fitted.from.package fitted.calculated.manually
[1,] -0.4193068 -1.1653515
[2,] -0.8395447 -0.5685977
[3,] -0.4386956 -0.6051324
[4,] 0.3594109 0.4403898
[5,] 2.9358336 2.9013738
[6,] 1.3489537 1.3682191
[7,] 0.5329436 0.5219576
[8,] 1.0221220 1.0283511
[9,] 0.6083310 0.6048668
[10,] -0.5371484 -0.5352324
As you see there are close but not exactly the same. The reason is that when I created the residuals I set $e_{1}=0$. There are other choices though. For example based on the help file to arima, the residuals and their variance found by a Kalman filter and therefore their calculation of $e_t$ will be slightly different from me. But as time goes on they are converging.
Now for the Ar(1) model. I fitted the model (without mean) and directly show you how to calculate the fitted values using the coefficients. This time I didn't calculate the residuals. Note that I reported the first 10 fitted values removing the first one (as again it would be different depending on how you define it). As you can see, they are completely the same.
f=arima(ts_AR,order=c(1,0,0),include.mean=FALSE)
cbind(fitted.from.package=fitted(f)[2:10],fitted.calculated.manually=coef(f)*ts_AR[1:9])
fitted.from.package fitted.calculated.manually
[1,] -0.8356307 -0.8356307
[2,] -0.6320580 -0.6320580
[3,] 0.0696877 0.0696877
[4,] 2.1549019 2.1549019
[5,] 2.0480074 2.0480074
[6,] 0.8814094 0.8814094
[7,] 0.9039184 0.9039184
[8,] 0.8079823 0.8079823
[9,] -0.1347165 -0.1347165 | Fitted values of ARMA model | To answer your questions, you basically need to know how the residuals i.e. $e_t$ are calculated in an arma model. Because then $\hat{X_{t}}=X_{t}-e_{t}$. Let's first generate a fake data ($X_t$) fro | Fitted values of ARMA model
To answer your questions, you basically need to know how the residuals i.e. $e_t$ are calculated in an arma model. Because then $\hat{X_{t}}=X_{t}-e_{t}$. Let's first generate a fake data ($X_t$) from arima(.5,.6) and fit the arma model (without mean):
library(forecast)
n=1000
ts_AR <- arima.sim(n = n, list(ar = 0.5,ma=0.6))
f=arima(ts_AR,order=c(1,0,1),include.mean=FALSE)
summary(f)
Series: ts_AR
ARIMA(1,0,1) with zero mean
Coefficients:
ar1 ma1
0.4879 0.5595
s.e. 0.0335 0.0317
sigma^2 estimated as 1.014: log likelihood=-1426.7
AIC=2859.4 AICc=2859.42 BIC=2874.12
Training set error measures:
ME RMSE MAE MPE MAPE MASE
Training set 0.02102758 1.00722 0.8057205 40.05802 160.1078 0.6313145
Now I create the residuals as follows: $e_1=0$ (since there is no residual at 1) and for $t=2,...,n$ we have: $e_t=X_t-Ar*X_{t-1}-Ma*e_{t-1}$, where $Ar$ and $Ma$ are the estimated auto-regressive and moving average part in above fitted model. Here is the code:
e = rep(1,n)
e[1] = 0 ##since there is no residual at 1, e1 = 0
for (t in (2 : n)){
e[t] = ts_AR[t]-coef(f)[1]*ts_AR[t-1]-coef(f)[2]*e[t-1]
}
Once you find the residuals $e_{t}$, the fitted values are just $\hat{X_{t}}=X_{t}-e_{t}$. So in the following, I compared the first 10 fitted values obtained from R and the ones I can calculate from $e_{t}$ I created above (i.e. manually).
cbind(fitted.from.package=fitted(f)[1:10],fitted.calculated.manually=ts_AR[1:10]-e[1:10])
fitted.from.package fitted.calculated.manually
[1,] -0.4193068 -1.1653515
[2,] -0.8395447 -0.5685977
[3,] -0.4386956 -0.6051324
[4,] 0.3594109 0.4403898
[5,] 2.9358336 2.9013738
[6,] 1.3489537 1.3682191
[7,] 0.5329436 0.5219576
[8,] 1.0221220 1.0283511
[9,] 0.6083310 0.6048668
[10,] -0.5371484 -0.5352324
As you see there are close but not exactly the same. The reason is that when I created the residuals I set $e_{1}=0$. There are other choices though. For example based on the help file to arima, the residuals and their variance found by a Kalman filter and therefore their calculation of $e_t$ will be slightly different from me. But as time goes on they are converging.
Now for the Ar(1) model. I fitted the model (without mean) and directly show you how to calculate the fitted values using the coefficients. This time I didn't calculate the residuals. Note that I reported the first 10 fitted values removing the first one (as again it would be different depending on how you define it). As you can see, they are completely the same.
f=arima(ts_AR,order=c(1,0,0),include.mean=FALSE)
cbind(fitted.from.package=fitted(f)[2:10],fitted.calculated.manually=coef(f)*ts_AR[1:9])
fitted.from.package fitted.calculated.manually
[1,] -0.8356307 -0.8356307
[2,] -0.6320580 -0.6320580
[3,] 0.0696877 0.0696877
[4,] 2.1549019 2.1549019
[5,] 2.0480074 2.0480074
[6,] 0.8814094 0.8814094
[7,] 0.9039184 0.9039184
[8,] 0.8079823 0.8079823
[9,] -0.1347165 -0.1347165 | Fitted values of ARMA model
To answer your questions, you basically need to know how the residuals i.e. $e_t$ are calculated in an arma model. Because then $\hat{X_{t}}=X_{t}-e_{t}$. Let's first generate a fake data ($X_t$) fro |
24,089 | Gradient Based Learning Algorithms vs Global Optimization Learning Algorithms for Neural Networks | Reading your question, I understand that you think that "global optimization methods" always give the global optimum whatever the function you are working on. This idea is very wrong. First of all, some of these algorithm indeed give a global optimum, but in practice for most functions they don't... And don't forget about the no free lunch theorem.
Some classes of functions are easy to optimize (convex functions for example), but most of the time, and especially for neural network training criterion, you have : non linearity - non convexity (even though for simple network this is not the case)... These are pretty nasty functions to optimize (mostly because of the pathological curvatures they have). So Why gradient ? Because you have good properties for the first order methods, especially they are scalable. Why not higher order ? Newton method can't be applied because you have too much parameters and because of this you can't hope to effectively inverse the Hessian matrix.
So there are a lot of variants around which are based on second order method, but only rely on first order computations : hessian free optimization, Nesterov gradient, momentum method etc...
So yes, first order methods and approximate second order are the best we can do for now, because everything else doesn't work very well.
I suggest for further detail : "Learning deep architectures for AI" from Y. Bengio. The book : "Neural networks : tricks of the trade" and Ilya Sutskever phd thesis. | Gradient Based Learning Algorithms vs Global Optimization Learning Algorithms for Neural Networks | Reading your question, I understand that you think that "global optimization methods" always give the global optimum whatever the function you are working on. This idea is very wrong. First of all, so | Gradient Based Learning Algorithms vs Global Optimization Learning Algorithms for Neural Networks
Reading your question, I understand that you think that "global optimization methods" always give the global optimum whatever the function you are working on. This idea is very wrong. First of all, some of these algorithm indeed give a global optimum, but in practice for most functions they don't... And don't forget about the no free lunch theorem.
Some classes of functions are easy to optimize (convex functions for example), but most of the time, and especially for neural network training criterion, you have : non linearity - non convexity (even though for simple network this is not the case)... These are pretty nasty functions to optimize (mostly because of the pathological curvatures they have). So Why gradient ? Because you have good properties for the first order methods, especially they are scalable. Why not higher order ? Newton method can't be applied because you have too much parameters and because of this you can't hope to effectively inverse the Hessian matrix.
So there are a lot of variants around which are based on second order method, but only rely on first order computations : hessian free optimization, Nesterov gradient, momentum method etc...
So yes, first order methods and approximate second order are the best we can do for now, because everything else doesn't work very well.
I suggest for further detail : "Learning deep architectures for AI" from Y. Bengio. The book : "Neural networks : tricks of the trade" and Ilya Sutskever phd thesis. | Gradient Based Learning Algorithms vs Global Optimization Learning Algorithms for Neural Networks
Reading your question, I understand that you think that "global optimization methods" always give the global optimum whatever the function you are working on. This idea is very wrong. First of all, so |
24,090 | Gradient Based Learning Algorithms vs Global Optimization Learning Algorithms for Neural Networks | I had a similar question myself and tried reasoning out the advantage of gradient descent than GA with a slightly different perspective than an intensive mathematical analysis like above -
One of the best use-case of "Neural nets" is that they have an inherent advantage of learning from hierarchies. And this is true for MLPs, ConvNets or RNNs. This feature of neural nets enable us to do "Transfer learning" wherein we just plugin the trained weights from any layer in a trained network (vgg16 inception etc.,).
The slow process of "back-propagation and gradient descent" in my opinion, helps the network, during training, to learn such optimal hierarchies and underlying patterns. This in-turn makes the underlying layers do feature extraction and enables us to apply transfer learning as needed. I relate this entire process to an "organic learning process" just like the way we humans typically learn.
Now, assuming we arrive at the optimal weight coefficients using GA or (some other technique), we are interfering with the organic learning process and the optimal learning hierarchies may get disturbed in the process leading to an over-fitting on the trained data with high variance on unseen data. | Gradient Based Learning Algorithms vs Global Optimization Learning Algorithms for Neural Networks | I had a similar question myself and tried reasoning out the advantage of gradient descent than GA with a slightly different perspective than an intensive mathematical analysis like above -
One of the | Gradient Based Learning Algorithms vs Global Optimization Learning Algorithms for Neural Networks
I had a similar question myself and tried reasoning out the advantage of gradient descent than GA with a slightly different perspective than an intensive mathematical analysis like above -
One of the best use-case of "Neural nets" is that they have an inherent advantage of learning from hierarchies. And this is true for MLPs, ConvNets or RNNs. This feature of neural nets enable us to do "Transfer learning" wherein we just plugin the trained weights from any layer in a trained network (vgg16 inception etc.,).
The slow process of "back-propagation and gradient descent" in my opinion, helps the network, during training, to learn such optimal hierarchies and underlying patterns. This in-turn makes the underlying layers do feature extraction and enables us to apply transfer learning as needed. I relate this entire process to an "organic learning process" just like the way we humans typically learn.
Now, assuming we arrive at the optimal weight coefficients using GA or (some other technique), we are interfering with the organic learning process and the optimal learning hierarchies may get disturbed in the process leading to an over-fitting on the trained data with high variance on unseen data. | Gradient Based Learning Algorithms vs Global Optimization Learning Algorithms for Neural Networks
I had a similar question myself and tried reasoning out the advantage of gradient descent than GA with a slightly different perspective than an intensive mathematical analysis like above -
One of the |
24,091 | Gradient Based Learning Algorithms vs Global Optimization Learning Algorithms for Neural Networks | There have been two publications recently providing compelling results using gradient-free optimization for Reinforcement Learning: "Simple random search provides a competitive approach to reinforcement learning" and "Deep Neuroevolution: Genetic Algorithms are a Competitive Alternative for Training Deep Neural Networks for Reinforcement Learning". I implemented both methods for a simulated robotics task and am seeing very good results especially with Random Search, which confirms the good scores the author of the paper observed. GA isn't performing as well, also confirming the observation of the authors seeing it perform astoundingly well in Atari games and much worse in simulated Robotics environments.
Anyway, it's 2018 and it's looking like gradient-free optimization methods have a bright future. | Gradient Based Learning Algorithms vs Global Optimization Learning Algorithms for Neural Networks | There have been two publications recently providing compelling results using gradient-free optimization for Reinforcement Learning: "Simple random search provides a competitive approach to reinforceme | Gradient Based Learning Algorithms vs Global Optimization Learning Algorithms for Neural Networks
There have been two publications recently providing compelling results using gradient-free optimization for Reinforcement Learning: "Simple random search provides a competitive approach to reinforcement learning" and "Deep Neuroevolution: Genetic Algorithms are a Competitive Alternative for Training Deep Neural Networks for Reinforcement Learning". I implemented both methods for a simulated robotics task and am seeing very good results especially with Random Search, which confirms the good scores the author of the paper observed. GA isn't performing as well, also confirming the observation of the authors seeing it perform astoundingly well in Atari games and much worse in simulated Robotics environments.
Anyway, it's 2018 and it's looking like gradient-free optimization methods have a bright future. | Gradient Based Learning Algorithms vs Global Optimization Learning Algorithms for Neural Networks
There have been two publications recently providing compelling results using gradient-free optimization for Reinforcement Learning: "Simple random search provides a competitive approach to reinforceme |
24,092 | Difference in meaning of these terms: Dataset vs Corpus | I think "corpus" mainly appears in NLP area or application domain related to texts/documents, because of its meaning "a collection of written texts, esp. the entire works of a particular author or a body of writing on a particular subject." (https://www.google.com/search?q=define+corpus)
In contrast, dataset appears in every application domain --- a collection of any kind of data is a dataset.
Update:
Please check this webpage , it is said that
"Corpus is a large collection of texts. It is a body of written or spoken material upon which a linguistic analysis is based. " | Difference in meaning of these terms: Dataset vs Corpus | I think "corpus" mainly appears in NLP area or application domain related to texts/documents, because of its meaning "a collection of written texts, esp. the entire works of a particular author or a b | Difference in meaning of these terms: Dataset vs Corpus
I think "corpus" mainly appears in NLP area or application domain related to texts/documents, because of its meaning "a collection of written texts, esp. the entire works of a particular author or a body of writing on a particular subject." (https://www.google.com/search?q=define+corpus)
In contrast, dataset appears in every application domain --- a collection of any kind of data is a dataset.
Update:
Please check this webpage , it is said that
"Corpus is a large collection of texts. It is a body of written or spoken material upon which a linguistic analysis is based. " | Difference in meaning of these terms: Dataset vs Corpus
I think "corpus" mainly appears in NLP area or application domain related to texts/documents, because of its meaning "a collection of written texts, esp. the entire works of a particular author or a b |
24,093 | Difference in meaning of these terms: Dataset vs Corpus | I'll site аn article in the Qualitative Research area: "Data corpus refers to all data collected for a particular research project, while data set refers to all the data from the corpus that is being used for a particular analysis."
see Braun, Virginia and Clarke, Victoria (2006) Using thematic analysis in psychology. Qualitative Research in Psychology, 3 (2). pp. 77-101. ISSN 1478-0887 | Difference in meaning of these terms: Dataset vs Corpus | I'll site аn article in the Qualitative Research area: "Data corpus refers to all data collected for a particular research project, while data set refers to all the data from the corpus that is being | Difference in meaning of these terms: Dataset vs Corpus
I'll site аn article in the Qualitative Research area: "Data corpus refers to all data collected for a particular research project, while data set refers to all the data from the corpus that is being used for a particular analysis."
see Braun, Virginia and Clarke, Victoria (2006) Using thematic analysis in psychology. Qualitative Research in Psychology, 3 (2). pp. 77-101. ISSN 1478-0887 | Difference in meaning of these terms: Dataset vs Corpus
I'll site аn article in the Qualitative Research area: "Data corpus refers to all data collected for a particular research project, while data set refers to all the data from the corpus that is being |
24,094 | Laplace smoothing and Dirichlet prior | Sure. This is essentially the observation that the Dirichlet distribution is a conjugate prior for the multinomial distribution. This means they have the same functional form. The article mentions it, but I'll just emphasize that this follows from the multinomial sampling model. So, getting down to it...
The observation is about the posterior, so let's introduce some data, $x$, which are counts of $K$ distinct items. We observe $N = \sum_{i=1}^K x_i$ samples total. We'll assume $x$ is drawn from an unknown distribution $\pi$ (on which we'll put a $\mathrm{Dir}(\alpha)$ prior on the $K$-simplex).
The posterior probability of $\pi$ given $\alpha$ and data $x$ is
$$p(\pi | x, \alpha) = p(x | \pi) p(\pi|\alpha)$$
The likelihood, $p(x|\pi)$, is the multinomial distribution. Now let's write out the pdf's:
$$p(x|\pi) = \frac{N!}{x_1!\cdots x_k!} \pi_1^{x_1} \cdots \pi_k^{x_k}$$
and
$$p(\pi|\alpha) = \frac{1}{\mathrm{B}(\alpha)} \prod_{i=1}^K \pi_i^{\alpha - 1}$$
where $\mathrm{B}(\alpha) = \frac{\Gamma(\alpha)^K}{\Gamma(K\alpha)}$. Multiplying, we find that,
$$ p(\pi|\alpha,x) = p(x | \pi) p(\pi|\alpha) \propto \prod_{i=1}^K \pi_i^{x_i + \alpha - 1}.$$
In other words, the posterior is also Dirichlet. The question was about the posterior mean. Since the posterior is Dirichlet, we can apply the formula for the mean of a Dirichlet to find that,
$$E[\pi_i | \alpha, x] = \frac{x_i + \alpha}{N + K\alpha}.$$
Hope this helps! | Laplace smoothing and Dirichlet prior | Sure. This is essentially the observation that the Dirichlet distribution is a conjugate prior for the multinomial distribution. This means they have the same functional form. The article mentions it, | Laplace smoothing and Dirichlet prior
Sure. This is essentially the observation that the Dirichlet distribution is a conjugate prior for the multinomial distribution. This means they have the same functional form. The article mentions it, but I'll just emphasize that this follows from the multinomial sampling model. So, getting down to it...
The observation is about the posterior, so let's introduce some data, $x$, which are counts of $K$ distinct items. We observe $N = \sum_{i=1}^K x_i$ samples total. We'll assume $x$ is drawn from an unknown distribution $\pi$ (on which we'll put a $\mathrm{Dir}(\alpha)$ prior on the $K$-simplex).
The posterior probability of $\pi$ given $\alpha$ and data $x$ is
$$p(\pi | x, \alpha) = p(x | \pi) p(\pi|\alpha)$$
The likelihood, $p(x|\pi)$, is the multinomial distribution. Now let's write out the pdf's:
$$p(x|\pi) = \frac{N!}{x_1!\cdots x_k!} \pi_1^{x_1} \cdots \pi_k^{x_k}$$
and
$$p(\pi|\alpha) = \frac{1}{\mathrm{B}(\alpha)} \prod_{i=1}^K \pi_i^{\alpha - 1}$$
where $\mathrm{B}(\alpha) = \frac{\Gamma(\alpha)^K}{\Gamma(K\alpha)}$. Multiplying, we find that,
$$ p(\pi|\alpha,x) = p(x | \pi) p(\pi|\alpha) \propto \prod_{i=1}^K \pi_i^{x_i + \alpha - 1}.$$
In other words, the posterior is also Dirichlet. The question was about the posterior mean. Since the posterior is Dirichlet, we can apply the formula for the mean of a Dirichlet to find that,
$$E[\pi_i | \alpha, x] = \frac{x_i + \alpha}{N + K\alpha}.$$
Hope this helps! | Laplace smoothing and Dirichlet prior
Sure. This is essentially the observation that the Dirichlet distribution is a conjugate prior for the multinomial distribution. This means they have the same functional form. The article mentions it, |
24,095 | Laplace smoothing and Dirichlet prior | As a side note, I would also like to add another point to the above derivation, which it's not really concerning the main question. However, talking about Dirichlet priors on multinomial distribution, I thought it worth to mention that what would be the form of likelihood function if we're going to take probabilities as nuisance variables.
As it's correctly pointed out by by sydeulissie, the $p(\pi | \alpha, x)$ is proportional to $\prod_{i=1}^{K} \, \pi_i^{x_i+\alpha-1}$ . Now here I would like to calculate $p(x|\alpha)$.
\begin{equation}
p(x | \alpha) = \int \prod_{i=1}^{K}p(x | \pi_i, \alpha)p(\pi|\alpha)
\mathrm{d} \pi_1 \mathrm{d} \pi_2 ...\mathrm{d} \pi_K
\end{equation}
Using an integral identity for gamma functions, we have:
\begin{equation}
p(x|\alpha) = \frac{\Gamma(K\alpha)}{\Gamma(N + K\alpha)} \prod_{i=1}^{K} \frac{\Gamma(x_i + \alpha)}{\Gamma(\alpha)}
\end{equation}
The above derivation of the likelihood for categorical data proposes a more robust way of dealing with this data for cases that the sample size $N$ is not so big enough. | Laplace smoothing and Dirichlet prior | As a side note, I would also like to add another point to the above derivation, which it's not really concerning the main question. However, talking about Dirichlet priors on multinomial distribution, | Laplace smoothing and Dirichlet prior
As a side note, I would also like to add another point to the above derivation, which it's not really concerning the main question. However, talking about Dirichlet priors on multinomial distribution, I thought it worth to mention that what would be the form of likelihood function if we're going to take probabilities as nuisance variables.
As it's correctly pointed out by by sydeulissie, the $p(\pi | \alpha, x)$ is proportional to $\prod_{i=1}^{K} \, \pi_i^{x_i+\alpha-1}$ . Now here I would like to calculate $p(x|\alpha)$.
\begin{equation}
p(x | \alpha) = \int \prod_{i=1}^{K}p(x | \pi_i, \alpha)p(\pi|\alpha)
\mathrm{d} \pi_1 \mathrm{d} \pi_2 ...\mathrm{d} \pi_K
\end{equation}
Using an integral identity for gamma functions, we have:
\begin{equation}
p(x|\alpha) = \frac{\Gamma(K\alpha)}{\Gamma(N + K\alpha)} \prod_{i=1}^{K} \frac{\Gamma(x_i + \alpha)}{\Gamma(\alpha)}
\end{equation}
The above derivation of the likelihood for categorical data proposes a more robust way of dealing with this data for cases that the sample size $N$ is not so big enough. | Laplace smoothing and Dirichlet prior
As a side note, I would also like to add another point to the above derivation, which it's not really concerning the main question. However, talking about Dirichlet priors on multinomial distribution, |
24,096 | What examples of lurking variables in controlled experiments are there in publications? | A few examples from clinical research might be variables that arise after randomization - randomization doesn't protect you from those at all. A few off the top of my head, that have been raised as either possibilities or been noted:
Changes in behavior post voluntary adult male circumcision for the prevention of HIV
Differential loss to follow-up between treatment and control arms of an RCT
A more specific example might include the recent "Benefits of Universal Gowning and Gloving" study looking at prevention of hospital acquired infections (blog commentary here, the paper is behind a paywall). In addition to the intervention, and potentially because of it, both hand hygiene rates and contact rates between patients and staff/visitors changed.
Randomization protects against none of those effects, because they arise post-randomization. | What examples of lurking variables in controlled experiments are there in publications? | A few examples from clinical research might be variables that arise after randomization - randomization doesn't protect you from those at all. A few off the top of my head, that have been raised as ei | What examples of lurking variables in controlled experiments are there in publications?
A few examples from clinical research might be variables that arise after randomization - randomization doesn't protect you from those at all. A few off the top of my head, that have been raised as either possibilities or been noted:
Changes in behavior post voluntary adult male circumcision for the prevention of HIV
Differential loss to follow-up between treatment and control arms of an RCT
A more specific example might include the recent "Benefits of Universal Gowning and Gloving" study looking at prevention of hospital acquired infections (blog commentary here, the paper is behind a paywall). In addition to the intervention, and potentially because of it, both hand hygiene rates and contact rates between patients and staff/visitors changed.
Randomization protects against none of those effects, because they arise post-randomization. | What examples of lurking variables in controlled experiments are there in publications?
A few examples from clinical research might be variables that arise after randomization - randomization doesn't protect you from those at all. A few off the top of my head, that have been raised as ei |
24,097 | What examples of lurking variables in controlled experiments are there in publications? | Here is one example I found for microarray data. The measured expression has been reported to be strongly correlated with position on the "chips". This is a case where randomizing the position of the samples may lead to increased chance of making a labeling error so those doing the technical work may choose not to randomize if they do not think it is important.
Random assignment of experimental units to treatments controls the
likelihood that any factor other than the treatment is the cause of
the association (1,2). In some microarray platforms such as Illumina®
and NimbleGenTM, multiple biological samples can be hybridized to a
single chip. Chip and sample position effects may affect accuracy and
reproducibility of microarray experiments unless balance and
randomization is considered in the experimental design (4). Our aim
was to compare the impact of these effects in a confounded and a
randomized experiment.
Importance of Randomization in Microarray
Experimental Designs with Illumina Platforms
Ricardo A. Verdugo, Christian F. Deschepper, and Gary A. Churchill.
The Jackson Laboratory, Bar Harbor, ME 04609,
Institut de Recherches Cliniques, Montreal, QC, Canada. | What examples of lurking variables in controlled experiments are there in publications? | Here is one example I found for microarray data. The measured expression has been reported to be strongly correlated with position on the "chips". This is a case where randomizing the position of the | What examples of lurking variables in controlled experiments are there in publications?
Here is one example I found for microarray data. The measured expression has been reported to be strongly correlated with position on the "chips". This is a case where randomizing the position of the samples may lead to increased chance of making a labeling error so those doing the technical work may choose not to randomize if they do not think it is important.
Random assignment of experimental units to treatments controls the
likelihood that any factor other than the treatment is the cause of
the association (1,2). In some microarray platforms such as Illumina®
and NimbleGenTM, multiple biological samples can be hybridized to a
single chip. Chip and sample position effects may affect accuracy and
reproducibility of microarray experiments unless balance and
randomization is considered in the experimental design (4). Our aim
was to compare the impact of these effects in a confounded and a
randomized experiment.
Importance of Randomization in Microarray
Experimental Designs with Illumina Platforms
Ricardo A. Verdugo, Christian F. Deschepper, and Gary A. Churchill.
The Jackson Laboratory, Bar Harbor, ME 04609,
Institut de Recherches Cliniques, Montreal, QC, Canada. | What examples of lurking variables in controlled experiments are there in publications?
Here is one example I found for microarray data. The measured expression has been reported to be strongly correlated with position on the "chips". This is a case where randomizing the position of the |
24,098 | What examples of lurking variables in controlled experiments are there in publications? | I have an example that might be somewhat different from what you originally intended when you asked this question. The past year or two have given rise to an ongoing discussion in psychology over the cause of the lack of replicability of effects from randomized experiments. Versions of this debate have surfaced for many years, but the debate has become more strident since the publication of a paper showing that many practices that are standard in psychology in the formulation of hypotheses, collection of data, analysis of data, and reporting of results allow researchers to find results supporting even arbitrarily chosen hypotheses (in the original paper, the researchers used these practices to show that listening to "When I'm Sixty-Four" by the Beatles made people younger).
The root of the problem, of course, is the pervasive incentive structures in psychology (and in other sciences) to obtain novel, positive, "publishable" results. These incentives encourage research scientists to adopt practices that, while not as obviously "wrong" as data fabrication, nonetheless lead to an increased rate of false positive results. These practices include:
The collection of multiple, and highly similar, dependent variables. Only the dependent variable that produces the results most consistent with the original hypothesis is reported.
During data collection, testing for significant results multiple times and stopping data collection when significance is obtained.
During analysis, the inclusion of multiple covariates in the statistical model. In the final paper, only the combination of covariates that leads to results most consistent with the original hypothesis is reported.
Dropping conditions that lead to results that are inconsistent with the original hyptoheses and failing to report these conditions in the paper.
And so on.
I would argue that the "lurking variable" in these cases is the incentive structure that rewards researchers for obtaining positive, "publishable" results. In fact, there have already been several high-profile results in psychology (many of which are in my specialty, social psychology) that have failed to replicate. These failures to replicate, many argue, cast doubt on entire subfields of psychology.
Of course, the problem of incentive structures that encourage false positives is not unique to psychology; this is a problem that is endemic to all of science, and thus to all randomized controlled trials.
References
Simmons, J. P., Nelson, L. D., & Simonsohn, U. (2011). False-positive psychology: Undisclosed flexibility in data collection and analysis allows presenting anything as significant. Psychological Science, 17, 1359-1366.
Nosek, B. A., Spies, J. R., & Motyl, M. (2012). Scientific utopia: II. Restructuring incentives and practices to promote truth over publishability. Perspectives on Psychological Science, 7, 615-631.
Yong, E. (2012). Bad copy. Nature, 485, 298-300.
Abbott, A. (2013). Disputed results a fresh blow for social psychology. Nature, 497, 16. | What examples of lurking variables in controlled experiments are there in publications? | I have an example that might be somewhat different from what you originally intended when you asked this question. The past year or two have given rise to an ongoing discussion in psychology over the | What examples of lurking variables in controlled experiments are there in publications?
I have an example that might be somewhat different from what you originally intended when you asked this question. The past year or two have given rise to an ongoing discussion in psychology over the cause of the lack of replicability of effects from randomized experiments. Versions of this debate have surfaced for many years, but the debate has become more strident since the publication of a paper showing that many practices that are standard in psychology in the formulation of hypotheses, collection of data, analysis of data, and reporting of results allow researchers to find results supporting even arbitrarily chosen hypotheses (in the original paper, the researchers used these practices to show that listening to "When I'm Sixty-Four" by the Beatles made people younger).
The root of the problem, of course, is the pervasive incentive structures in psychology (and in other sciences) to obtain novel, positive, "publishable" results. These incentives encourage research scientists to adopt practices that, while not as obviously "wrong" as data fabrication, nonetheless lead to an increased rate of false positive results. These practices include:
The collection of multiple, and highly similar, dependent variables. Only the dependent variable that produces the results most consistent with the original hypothesis is reported.
During data collection, testing for significant results multiple times and stopping data collection when significance is obtained.
During analysis, the inclusion of multiple covariates in the statistical model. In the final paper, only the combination of covariates that leads to results most consistent with the original hypothesis is reported.
Dropping conditions that lead to results that are inconsistent with the original hyptoheses and failing to report these conditions in the paper.
And so on.
I would argue that the "lurking variable" in these cases is the incentive structure that rewards researchers for obtaining positive, "publishable" results. In fact, there have already been several high-profile results in psychology (many of which are in my specialty, social psychology) that have failed to replicate. These failures to replicate, many argue, cast doubt on entire subfields of psychology.
Of course, the problem of incentive structures that encourage false positives is not unique to psychology; this is a problem that is endemic to all of science, and thus to all randomized controlled trials.
References
Simmons, J. P., Nelson, L. D., & Simonsohn, U. (2011). False-positive psychology: Undisclosed flexibility in data collection and analysis allows presenting anything as significant. Psychological Science, 17, 1359-1366.
Nosek, B. A., Spies, J. R., & Motyl, M. (2012). Scientific utopia: II. Restructuring incentives and practices to promote truth over publishability. Perspectives on Psychological Science, 7, 615-631.
Yong, E. (2012). Bad copy. Nature, 485, 298-300.
Abbott, A. (2013). Disputed results a fresh blow for social psychology. Nature, 497, 16. | What examples of lurking variables in controlled experiments are there in publications?
I have an example that might be somewhat different from what you originally intended when you asked this question. The past year or two have given rise to an ongoing discussion in psychology over the |
24,099 | What statistics are preserved under aggregation? | I think the question as in the headline is too broad to be answered in a useful way, the more so as it will probably depend on both the aggregating method and the statistic in question.
This will even apply to the "mean": do you try to preserve signal shape and intensity (e.g. Savitzky-Golay filters), or do you try to preserve the area under the signal (e.g. loess)?
Noise-related statistics are obviously affected: that is usually the purpose of the aggregation.
I've seen at least one paper that then applies some statistics to the aggregated data [...] Is that valid? I would have thought that the averaging process would modify the result a fair bit, due to the reduced noise.
This modification is most probably the purpose of the aggregating.
In general, you are allowed to do a whole lot of things to your data, but you need to
say what you are doing (and preferrably also why you do it)
show the quality of the resulting model (test with independent data)
What is a valid aggregation will also depend on your application.
E.g.: I'm working with spectroscopic data. It is very common to aggregate single spectra into average spectra: the measurement process means certain limits to the quality of spectra I can obtain "in one shot". However, for many applications it is perfectly valid to specify an acquisition procedure that says that always $n$ repeated measurements should be taken and averaged. On the other hand, if the application is real-time/online or inline analytics such as FIA (flow injection analysis) this implies restrictions on possible aggregation schemes. | What statistics are preserved under aggregation? | I think the question as in the headline is too broad to be answered in a useful way, the more so as it will probably depend on both the aggregating method and the statistic in question.
This will ev | What statistics are preserved under aggregation?
I think the question as in the headline is too broad to be answered in a useful way, the more so as it will probably depend on both the aggregating method and the statistic in question.
This will even apply to the "mean": do you try to preserve signal shape and intensity (e.g. Savitzky-Golay filters), or do you try to preserve the area under the signal (e.g. loess)?
Noise-related statistics are obviously affected: that is usually the purpose of the aggregation.
I've seen at least one paper that then applies some statistics to the aggregated data [...] Is that valid? I would have thought that the averaging process would modify the result a fair bit, due to the reduced noise.
This modification is most probably the purpose of the aggregating.
In general, you are allowed to do a whole lot of things to your data, but you need to
say what you are doing (and preferrably also why you do it)
show the quality of the resulting model (test with independent data)
What is a valid aggregation will also depend on your application.
E.g.: I'm working with spectroscopic data. It is very common to aggregate single spectra into average spectra: the measurement process means certain limits to the quality of spectra I can obtain "in one shot". However, for many applications it is perfectly valid to specify an acquisition procedure that says that always $n$ repeated measurements should be taken and averaged. On the other hand, if the application is real-time/online or inline analytics such as FIA (flow injection analysis) this implies restrictions on possible aggregation schemes. | What statistics are preserved under aggregation?
I think the question as in the headline is too broad to be answered in a useful way, the more so as it will probably depend on both the aggregating method and the statistic in question.
This will ev |
24,100 | What statistics are preserved under aggregation? | In a regression setting you can actually test whether the simple aggregation is the correct choice. Suppose you have monthly data $Y_t$ and daily data $X_\tau$ (with the fixed $m$ days in a month). Suppose you are interested in a regression:
$$Y_t=\alpha+\beta \bar X_t +u_t, (1)$$
where
$$\bar X_t=\frac{1}{m}\sum_{h=0}^{m-1}X_{tm-h}.$$
Here we assume that for each month $t$ the daily observations are $X_{30(t-1)+1},...,X_{30t}$. In this case we assumed that each day has the same weight, which clearly is a restriction. So we can assume that more general model holds:
$$Y_t=\alpha+\beta \bar X_{t}^{(w)} +u_t,(2)$$
with
$$X_t^{(w)}=\sum_{h=1}^{m-1}w_hX_{tm-h}.$$
There are a lot of articles which explore different possible choices of $w_h$. Usually it is assumed that $w_h=g(h,\alpha)$, for some function $g$ which depends on parameters $\alpha$. This type of regression model is called MIDAS (MIxed DAta Sampling) regression.
Model (2) nests the model (1) so it is possible to test the hypothesis that $w_h=\frac{1}{m}$. One such test is proposed in this article (I am one of the authors, sorry for the shameless plug, also I wrote an R package midasr for estimating and testing MIDAS regressions where this test is implemented).
In a non-regression setting there are results which show that aggregation can change the properties of the time series. For example if you aggregate AR(1) processes which have short term memory (the correlation between two observations of the time series quickly dies off when the distance between them is increased), you can get a process with long term memory.
So to sum up the answer is that validity of application of statistics on aggregated data is a statistical question. Depending on the model you can construct a hypothesis whether it is a valid application or not. | What statistics are preserved under aggregation? | In a regression setting you can actually test whether the simple aggregation is the correct choice. Suppose you have monthly data $Y_t$ and daily data $X_\tau$ (with the fixed $m$ days in a month). Su | What statistics are preserved under aggregation?
In a regression setting you can actually test whether the simple aggregation is the correct choice. Suppose you have monthly data $Y_t$ and daily data $X_\tau$ (with the fixed $m$ days in a month). Suppose you are interested in a regression:
$$Y_t=\alpha+\beta \bar X_t +u_t, (1)$$
where
$$\bar X_t=\frac{1}{m}\sum_{h=0}^{m-1}X_{tm-h}.$$
Here we assume that for each month $t$ the daily observations are $X_{30(t-1)+1},...,X_{30t}$. In this case we assumed that each day has the same weight, which clearly is a restriction. So we can assume that more general model holds:
$$Y_t=\alpha+\beta \bar X_{t}^{(w)} +u_t,(2)$$
with
$$X_t^{(w)}=\sum_{h=1}^{m-1}w_hX_{tm-h}.$$
There are a lot of articles which explore different possible choices of $w_h$. Usually it is assumed that $w_h=g(h,\alpha)$, for some function $g$ which depends on parameters $\alpha$. This type of regression model is called MIDAS (MIxed DAta Sampling) regression.
Model (2) nests the model (1) so it is possible to test the hypothesis that $w_h=\frac{1}{m}$. One such test is proposed in this article (I am one of the authors, sorry for the shameless plug, also I wrote an R package midasr for estimating and testing MIDAS regressions where this test is implemented).
In a non-regression setting there are results which show that aggregation can change the properties of the time series. For example if you aggregate AR(1) processes which have short term memory (the correlation between two observations of the time series quickly dies off when the distance between them is increased), you can get a process with long term memory.
So to sum up the answer is that validity of application of statistics on aggregated data is a statistical question. Depending on the model you can construct a hypothesis whether it is a valid application or not. | What statistics are preserved under aggregation?
In a regression setting you can actually test whether the simple aggregation is the correct choice. Suppose you have monthly data $Y_t$ and daily data $X_\tau$ (with the fixed $m$ days in a month). Su |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.