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
|
|---|---|---|---|---|---|---|
11,501
|
Coefficient of Determination ($r^2$): I have never fully grasped the interpretation
|
A mathematical demonstration of the relationship between the two is here: Pearson's correlation and least squares regression analysis.
I am not sure if there is a geometric or any other intuition that can be offered apart from the math but if I can think of one I will update this answer.
Update: Geometric Intuition
Here is a geometric intuition I came up with. Suppose that you have two variables $x$ and $y$ which are mean centered. (Assuming mean centered lets us ignore the intercept which simplifies the geometrical intuition a bit.) Let us first consider the geometry of linear regression. In linear regression, we model $y$ as follows:
$y = x\ \beta + \epsilon$.
Consider the situation when we have two observations from the above data generating process given by the pairs ($y_1,y_2$) and ($x_1,x_2$). We can view them as vectors in two-dimensional space as shown in the figure below:
alt text http://a.imageshack.us/img202/669/linearregression1.png
Thus, in terms of the above geometry, our goal is to find a $\beta$ such that the vector $x\ \beta$ is the closest possible to the vector $y$. Note that different choices of $\beta$ scale $x$ appropriately. Let $\hat{\beta}$ be the value of $\beta$ that is our best possible approximation of $y$ and denote $\hat{y} = x\ \hat{\beta}$. Thus,
$y = \hat{y} + \hat{\epsilon}$
From a geometrical perspective we have three vectors. $y$, $\hat{y}$ and $\hat{\epsilon}$. A little thought suggests that we must choose $\hat{\beta}$ such that three vectors look like the one below:
alt text http://a.imageshack.us/img19/9524/intuitionlinearregressi.png
In other words, we need to choose $\beta$ such that the angle between $x\ \beta$ and $\hat{\epsilon}$ is 900.
So, how much variation in $y$ have we explained with this projection of $y$ onto the vector $x$. Since the data is mean centered the variance in $y$ is equals ($y_1^2+y_2^2$) which is the square of the distance between the point represented by the point $y$ and the origin. The variation in $\hat{y}$ is similarly the distance from the point $\hat{y}$ and the origin and so on.
By the Pythagorean theorem, we have:
$y^2 = \hat{y}^2 + \hat{\epsilon}^2$
Therefore, the proportion of the variance explained by $x$ is $\frac{\hat{y}^2}{y^2}$. Notice also that $cos(\theta) = \frac{\hat{y}}{y}$. and the wiki tells us that the geometrical interpretation of correlation is that correlation equals the cosine of the angle between the mean-centered vectors.
Therefore, we have the required relationship:
(Correlation)2 = Proportion of variation in $y$ explained by $x$.
Hope that helps.
|
Coefficient of Determination ($r^2$): I have never fully grasped the interpretation
|
A mathematical demonstration of the relationship between the two is here: Pearson's correlation and least squares regression analysis.
I am not sure if there is a geometric or any other intuition that
|
Coefficient of Determination ($r^2$): I have never fully grasped the interpretation
A mathematical demonstration of the relationship between the two is here: Pearson's correlation and least squares regression analysis.
I am not sure if there is a geometric or any other intuition that can be offered apart from the math but if I can think of one I will update this answer.
Update: Geometric Intuition
Here is a geometric intuition I came up with. Suppose that you have two variables $x$ and $y$ which are mean centered. (Assuming mean centered lets us ignore the intercept which simplifies the geometrical intuition a bit.) Let us first consider the geometry of linear regression. In linear regression, we model $y$ as follows:
$y = x\ \beta + \epsilon$.
Consider the situation when we have two observations from the above data generating process given by the pairs ($y_1,y_2$) and ($x_1,x_2$). We can view them as vectors in two-dimensional space as shown in the figure below:
alt text http://a.imageshack.us/img202/669/linearregression1.png
Thus, in terms of the above geometry, our goal is to find a $\beta$ such that the vector $x\ \beta$ is the closest possible to the vector $y$. Note that different choices of $\beta$ scale $x$ appropriately. Let $\hat{\beta}$ be the value of $\beta$ that is our best possible approximation of $y$ and denote $\hat{y} = x\ \hat{\beta}$. Thus,
$y = \hat{y} + \hat{\epsilon}$
From a geometrical perspective we have three vectors. $y$, $\hat{y}$ and $\hat{\epsilon}$. A little thought suggests that we must choose $\hat{\beta}$ such that three vectors look like the one below:
alt text http://a.imageshack.us/img19/9524/intuitionlinearregressi.png
In other words, we need to choose $\beta$ such that the angle between $x\ \beta$ and $\hat{\epsilon}$ is 900.
So, how much variation in $y$ have we explained with this projection of $y$ onto the vector $x$. Since the data is mean centered the variance in $y$ is equals ($y_1^2+y_2^2$) which is the square of the distance between the point represented by the point $y$ and the origin. The variation in $\hat{y}$ is similarly the distance from the point $\hat{y}$ and the origin and so on.
By the Pythagorean theorem, we have:
$y^2 = \hat{y}^2 + \hat{\epsilon}^2$
Therefore, the proportion of the variance explained by $x$ is $\frac{\hat{y}^2}{y^2}$. Notice also that $cos(\theta) = \frac{\hat{y}}{y}$. and the wiki tells us that the geometrical interpretation of correlation is that correlation equals the cosine of the angle between the mean-centered vectors.
Therefore, we have the required relationship:
(Correlation)2 = Proportion of variation in $y$ explained by $x$.
Hope that helps.
|
Coefficient of Determination ($r^2$): I have never fully grasped the interpretation
A mathematical demonstration of the relationship between the two is here: Pearson's correlation and least squares regression analysis.
I am not sure if there is a geometric or any other intuition that
|
11,502
|
Coefficient of Determination ($r^2$): I have never fully grasped the interpretation
|
The Regression By Eye applet could be of use if you're trying to develop some intuition.
It lets you generate data then guess a value for R, which you can then compare with the actual value.
|
Coefficient of Determination ($r^2$): I have never fully grasped the interpretation
|
The Regression By Eye applet could be of use if you're trying to develop some intuition.
It lets you generate data then guess a value for R, which you can then compare with the actual value.
|
Coefficient of Determination ($r^2$): I have never fully grasped the interpretation
The Regression By Eye applet could be of use if you're trying to develop some intuition.
It lets you generate data then guess a value for R, which you can then compare with the actual value.
|
Coefficient of Determination ($r^2$): I have never fully grasped the interpretation
The Regression By Eye applet could be of use if you're trying to develop some intuition.
It lets you generate data then guess a value for R, which you can then compare with the actual value.
|
11,503
|
The magic money tree problem
|
This is a well-known problem. It is called a Kelly bet. The answer, by the way, is 1/3rd. It is equivalent to maximizing the log utility of wealth.
Kelly began with taking time to infinity and then solving backward. Since you can always express returns in terms of continuous compounding, then you can also reverse the process and express it in logs. I am going to use the log utility explanation, but the log utility is a convenience. If you are maximizing wealth as $n\to\infty$ then you will end up with a function that works out to be the same as log utility. If $b$ is the payout odds, and $p$ is the probability of winning, and $X$ is the percentage of wealth invested, then the following derivation will work.
For a binary bet, $E(\log(X))=p\log(1+bX)+(1-p)\log(1-X)$, for a single period and unit wealth.
$$\frac{d}{dX}{E[\log(x)]}=\frac{d}{dX}[p\log(1+bX)+(1-p)\log(1-X)]$$
$$=\frac{pb}{1+bX}-\frac{1-p}{1-X}$$
Setting the derivative to zero to find the extrema,
$$\frac{pb}{1+bX}-\frac{1-p}{1-X}=0$$
Cross multiplying, you end up with $$pb(1-X)-(1-p)(1+bX)=0$$
$$pb-pbX-1-bX+p+pbX=0$$
$$bX=pb-1+p$$
$$X=\frac{bp-(1-p)}{b}$$
In your case, $$X=\frac{3\times\frac{1}{2}-(1-\frac{1}{2})}{3}=\frac{1}{3}.$$
You can readily expand this to multiple or continuous outcomes by solving the expected utility of wealth over a joint probability distribution, choosing the allocations and subject to any constraints. Interestingly, if you perform it in this manner, by including constraints, such as the ability to meet mortgage payments and so forth, then you have accounted for your total set of risks and so you have a risk-adjusted or at least risk-controlled solution.
Desiderata The actual purpose of the original research had to do with how much to gamble based on a noisy signal. In the specific case, how much to gamble on a noisy electronic signal where it indicated the launch of nuclear weapons by the Soviet Union. There have been several near launches by both the United States and Russia, obviously in error. How much do you gamble on a signal?
|
The magic money tree problem
|
This is a well-known problem. It is called a Kelly bet. The answer, by the way, is 1/3rd. It is equivalent to maximizing the log utility of wealth.
Kelly began with taking time to infinity and then
|
The magic money tree problem
This is a well-known problem. It is called a Kelly bet. The answer, by the way, is 1/3rd. It is equivalent to maximizing the log utility of wealth.
Kelly began with taking time to infinity and then solving backward. Since you can always express returns in terms of continuous compounding, then you can also reverse the process and express it in logs. I am going to use the log utility explanation, but the log utility is a convenience. If you are maximizing wealth as $n\to\infty$ then you will end up with a function that works out to be the same as log utility. If $b$ is the payout odds, and $p$ is the probability of winning, and $X$ is the percentage of wealth invested, then the following derivation will work.
For a binary bet, $E(\log(X))=p\log(1+bX)+(1-p)\log(1-X)$, for a single period and unit wealth.
$$\frac{d}{dX}{E[\log(x)]}=\frac{d}{dX}[p\log(1+bX)+(1-p)\log(1-X)]$$
$$=\frac{pb}{1+bX}-\frac{1-p}{1-X}$$
Setting the derivative to zero to find the extrema,
$$\frac{pb}{1+bX}-\frac{1-p}{1-X}=0$$
Cross multiplying, you end up with $$pb(1-X)-(1-p)(1+bX)=0$$
$$pb-pbX-1-bX+p+pbX=0$$
$$bX=pb-1+p$$
$$X=\frac{bp-(1-p)}{b}$$
In your case, $$X=\frac{3\times\frac{1}{2}-(1-\frac{1}{2})}{3}=\frac{1}{3}.$$
You can readily expand this to multiple or continuous outcomes by solving the expected utility of wealth over a joint probability distribution, choosing the allocations and subject to any constraints. Interestingly, if you perform it in this manner, by including constraints, such as the ability to meet mortgage payments and so forth, then you have accounted for your total set of risks and so you have a risk-adjusted or at least risk-controlled solution.
Desiderata The actual purpose of the original research had to do with how much to gamble based on a noisy signal. In the specific case, how much to gamble on a noisy electronic signal where it indicated the launch of nuclear weapons by the Soviet Union. There have been several near launches by both the United States and Russia, obviously in error. How much do you gamble on a signal?
|
The magic money tree problem
This is a well-known problem. It is called a Kelly bet. The answer, by the way, is 1/3rd. It is equivalent to maximizing the log utility of wealth.
Kelly began with taking time to infinity and then
|
11,504
|
The magic money tree problem
|
I don't think this is much different from the Martingale. In your case, there are no doubling bets, but the winning payout is 3x.
I coded a "living replica" of your tree. I run 10 simulations. In each simulation (trace), you start with 200 coins and try with the tree, 1 coin each time for 20,000 times.
The only conditions that stop the simulation are bankruptcy or having "survived" 20k attempts
I think that whatever the odds, sooner or later bankruptcy awaits you.
The code is improvised javascript but dependency-free: https://repl.it/@cilofrapez/MagicTree-Roulette
It shows you the results straight away. The code is simple to tweak: to run however many simulations, bet amount, however many attempts... Feel free to play!
At the bottom of the code, each simulation's (by default 10) results are saved into a CSV file with two columns: spin number and money. I made that so it could be fed it to an online plotter for the graphs.
It'd be effortless to have it all automated locally using the Google Charts library for example. If you only want to see the results on the screen, you can comment that last part out as I mentioned in the file.
EDIT
Source code:
/**
* License: MIT
* Author: Carles Alcolea, 2019
* Usage: I recommend using an online solution like repl.it to run this code.
* Nonetheless, having node installed, it's as easy as running `node magicTree.js`.
*
* The code will run `simulations` number of scenarios, each scenario is equal in settings
* which are self-descriptive: `betAmount`,`timesWinPayout`, `spinsPerSimulation`, `startingBankRoll`
* and `winningOdds`.
*
* At the end of the code there's a part that will generate a *.csv file for each simulation run.
* This is useful for ploting the resulting data using any such service or graphing library. If you
* wish the code to generate the files for you, just set `saveResultsCSV` to true. All files will
* have two columns: number of spin and current bankroll.
*/
const fs = require('fs'); // Only necessary if `saveResultsCSV` is true
/**
* ==================================
* You can play with the numbers of the following variables all you want:
*/
const betAmount = 0.4, // Percentage of bankroll that is offered to the tree
winningOdds = 0.5,
startingBankRoll = 200,
timesWinPayout = 2,
simulations = 5,
spinsPerSimulation = 20000,
saveResultsCSV = false;
/**
* ==================================
*/
const simWins = [];
let currentSim = 1;
//* Each simulation:
while (currentSim <= simulations) {
let currentBankRoll = startingBankRoll,
spin = 0;
const resultsArr = [],
progressArr = [];
//* Each spin/bet:
while (currentBankRoll > 0 && spin < spinsPerSimulation) {
if (currentBankRoll === Infinity) break; // Can't hold more cash!
let currentBet = Math.ceil(betAmount * currentBankRoll);
if (currentBet > currentBankRoll) break; // Can't afford more bets... bankrupt!
const treeDecision = Math.random() < winningOdds;
resultsArr.push(treeDecision);
if (treeDecision) currentBankRoll += currentBet * timesWinPayout; else currentBankRoll -= currentBet;
progressArr.push(currentBankRoll);
spin++;
}
const wins = resultsArr.filter(el => el === true).length;
const losses = resultsArr.filter(el => el === false).length;
const didTheBankRollHold = (resultsArr.length === spinsPerSimulation) || currentBankRoll === Infinity;
const progressPercent = didTheBankRollHold ? `(100%)` : `(Bankrupt at aprox ${((resultsArr.length / parseFloat(spinsPerSimulation)) * 100).toPrecision(4)}% progress)`;
// Current simulation summary
console.log(`
- Simulation ${currentSim}: ${progressPercent === '(100%)' ? '✔' : '✘︎'}
Total: ${spin} spins out of ${spinsPerSimulation} ${progressPercent}
Wins: ${wins} (aprox ${((wins / parseFloat(resultsArr.length)) * 100).toPrecision(4)}%)
Losses: ${losses} (aprox ${((losses / parseFloat(resultsArr.length)) * 100).toPrecision(4)}%)
Bankroll: ${currentBankRoll}
`);
if (didTheBankRollHold) simWins.push(1);
/**
* ==================================
* Saving data?
*/
if (saveResultsCSV) {
let data = `spinNumber, bankRoll`;
if (!fs.existsSync('CSVresults')) fs.mkdirSync('CSVresults');
progressArr.forEach((el, i) => {
data += `\n${i + 1}, ${el}`;
});
fs.writeFileSync(`./CSVresults/results${currentSim}.csv`, data);
}
/**
* ==================================
*/
currentSim++;
}
// Total summary
console.log(`We ran ${simulations} simulations, with the goal of ${spinsPerSimulation} spins in each one.
Our bankroll (${startingBankRoll}) has survived ${simWins.length} out of ${simulations} simulations, with ${(1 - winningOdds) * 100}% chance of winning.`);
```
|
The magic money tree problem
|
I don't think this is much different from the Martingale. In your case, there are no doubling bets, but the winning payout is 3x.
I coded a "living replica" of your tree. I run 10 simulations. In each
|
The magic money tree problem
I don't think this is much different from the Martingale. In your case, there are no doubling bets, but the winning payout is 3x.
I coded a "living replica" of your tree. I run 10 simulations. In each simulation (trace), you start with 200 coins and try with the tree, 1 coin each time for 20,000 times.
The only conditions that stop the simulation are bankruptcy or having "survived" 20k attempts
I think that whatever the odds, sooner or later bankruptcy awaits you.
The code is improvised javascript but dependency-free: https://repl.it/@cilofrapez/MagicTree-Roulette
It shows you the results straight away. The code is simple to tweak: to run however many simulations, bet amount, however many attempts... Feel free to play!
At the bottom of the code, each simulation's (by default 10) results are saved into a CSV file with two columns: spin number and money. I made that so it could be fed it to an online plotter for the graphs.
It'd be effortless to have it all automated locally using the Google Charts library for example. If you only want to see the results on the screen, you can comment that last part out as I mentioned in the file.
EDIT
Source code:
/**
* License: MIT
* Author: Carles Alcolea, 2019
* Usage: I recommend using an online solution like repl.it to run this code.
* Nonetheless, having node installed, it's as easy as running `node magicTree.js`.
*
* The code will run `simulations` number of scenarios, each scenario is equal in settings
* which are self-descriptive: `betAmount`,`timesWinPayout`, `spinsPerSimulation`, `startingBankRoll`
* and `winningOdds`.
*
* At the end of the code there's a part that will generate a *.csv file for each simulation run.
* This is useful for ploting the resulting data using any such service or graphing library. If you
* wish the code to generate the files for you, just set `saveResultsCSV` to true. All files will
* have two columns: number of spin and current bankroll.
*/
const fs = require('fs'); // Only necessary if `saveResultsCSV` is true
/**
* ==================================
* You can play with the numbers of the following variables all you want:
*/
const betAmount = 0.4, // Percentage of bankroll that is offered to the tree
winningOdds = 0.5,
startingBankRoll = 200,
timesWinPayout = 2,
simulations = 5,
spinsPerSimulation = 20000,
saveResultsCSV = false;
/**
* ==================================
*/
const simWins = [];
let currentSim = 1;
//* Each simulation:
while (currentSim <= simulations) {
let currentBankRoll = startingBankRoll,
spin = 0;
const resultsArr = [],
progressArr = [];
//* Each spin/bet:
while (currentBankRoll > 0 && spin < spinsPerSimulation) {
if (currentBankRoll === Infinity) break; // Can't hold more cash!
let currentBet = Math.ceil(betAmount * currentBankRoll);
if (currentBet > currentBankRoll) break; // Can't afford more bets... bankrupt!
const treeDecision = Math.random() < winningOdds;
resultsArr.push(treeDecision);
if (treeDecision) currentBankRoll += currentBet * timesWinPayout; else currentBankRoll -= currentBet;
progressArr.push(currentBankRoll);
spin++;
}
const wins = resultsArr.filter(el => el === true).length;
const losses = resultsArr.filter(el => el === false).length;
const didTheBankRollHold = (resultsArr.length === spinsPerSimulation) || currentBankRoll === Infinity;
const progressPercent = didTheBankRollHold ? `(100%)` : `(Bankrupt at aprox ${((resultsArr.length / parseFloat(spinsPerSimulation)) * 100).toPrecision(4)}% progress)`;
// Current simulation summary
console.log(`
- Simulation ${currentSim}: ${progressPercent === '(100%)' ? '✔' : '✘︎'}
Total: ${spin} spins out of ${spinsPerSimulation} ${progressPercent}
Wins: ${wins} (aprox ${((wins / parseFloat(resultsArr.length)) * 100).toPrecision(4)}%)
Losses: ${losses} (aprox ${((losses / parseFloat(resultsArr.length)) * 100).toPrecision(4)}%)
Bankroll: ${currentBankRoll}
`);
if (didTheBankRollHold) simWins.push(1);
/**
* ==================================
* Saving data?
*/
if (saveResultsCSV) {
let data = `spinNumber, bankRoll`;
if (!fs.existsSync('CSVresults')) fs.mkdirSync('CSVresults');
progressArr.forEach((el, i) => {
data += `\n${i + 1}, ${el}`;
});
fs.writeFileSync(`./CSVresults/results${currentSim}.csv`, data);
}
/**
* ==================================
*/
currentSim++;
}
// Total summary
console.log(`We ran ${simulations} simulations, with the goal of ${spinsPerSimulation} spins in each one.
Our bankroll (${startingBankRoll}) has survived ${simWins.length} out of ${simulations} simulations, with ${(1 - winningOdds) * 100}% chance of winning.`);
```
|
The magic money tree problem
I don't think this is much different from the Martingale. In your case, there are no doubling bets, but the winning payout is 3x.
I coded a "living replica" of your tree. I run 10 simulations. In each
|
11,505
|
The magic money tree problem
|
I liked the answer given by Dave harris. just though I would come at the problem from a "low risk" perspective, rather than profit maximising
The random walk you are doing, assuming your fraction bet is $q$ and probability of winning $p=0.5$ has is given as
$$Y_t|Y_{t-1}=(1-q+3qX_t)Y_{t-1}$$
where $X_t\sim Bernoulli(p)$. on average you have
$$E(Y_t|Y_{t-1}) = (1-q+3pq)Y_{t-1}$$
You can iteratively apply this to get
$$Y_t|Y_0=Y_0\prod_{j=1}^t (1-q+3qX_t)$$
with expected value
$$E(Y_t|Y_{0}) = (1-q+3pq)^t Y_{0}$$
you can also express the amount at time $t$ as a function of a single random variable $Z_t=\sum_{j=1}^t X_t\sim Binomial(t,p)$, but noting that $Z_t$ is not independent from $Z_{t-1}$
$$Y_t|Y_0=Y_0 (1+2q)^{Z_t}(1-q)^{t-Z_t}$$
possible strategy
you could use this formula to determine a "low risk" value for $q$. Say assuming you wanted to ensure that after $k$ consecutive losses you still had half your original wealth. Then you set $q=1-2^{-k^{-1}}$
Taking the example $k=5$ means we set $q=0.129$, or with $k=15$ we set $q=0.045$.
Also, due to the recursive nature of the strategy, this risk is what you are taking every at every single bet. That is, at time $s$, by continuing to play you are ensuring that at time $k+s$ your wealth will be at least $0.5Y_{s}$
discussion
the above strategy does not depend on the pay off from winning, but rather about setting a boundary on losing. We can get the expected winnings by substituting in the value for $q$ we calculated, and at the time $k$ that was used with the risk in mind.
however, it is interesting to look at the median rather than expected pay off at time $t$, which can be found by assuming $median(Z_t)\approx tp$.
$$Y_k|Y_0=Y_0 (1+2q)^{tp}(1-q)^{t(1-p)}$$
when $p=0.5$ the we have the ratio equal to $(1+q-2q^2)^{0.5t}$. This is maximised when $q=0.25$ and greater than $1$ when $q<0.5$
it is also interesting to calculate the chance you will be ahead at time $t$. to do this we need to determine the value $z$ such that
$$(1+2q)^{z}(1-q)^{t-z}>1$$
doing some rearranging we find that the proportion of wins should satisfy
$$\frac{z}{t}>\frac{\log(1-q)}{\log(1-q)-\log(1+2q)}$$
This can be plugged into a normal approximation (note: mean of $0.5$ and standard error of $\frac{0.5}{\sqrt{t}}$) as
$$Pr(\text{ahead at time t})\approx\Phi\left(\sqrt{t}\frac{\log(1+2q)+\log(1-q)}{\left[\log(1+2q)-\log(1-q)\right]}\right)$$
which clearly shows the game has very good odds. the factor multiplying $\sqrt{t}$ is minimised when $q=0$ (maximised value of $\frac{1}{3}$) and is monotonically decreasing as a function of $q$. so the "low risk" strategy is to bet a very small fraction of your wealth, and play a large number of times.
suppose we compare this with $q=\frac{1}{3}$ and $q=\frac{1}{100}$. the factor for each case is $0.11$ and $0.32$. This means after $38$ games you would have around a 95% chance to be ahead with the small bet, compared to a 75% chance with the larger bet. Additionally, you also have a chance of going broke with the larger bet, assuming you had to round your stake to the nearest 5 cents or dollar. Starting with $20$ this could go $13.35, 8.90,5.95,3.95,2.65,1.75,1.15,0.75,0.50,0.35,0.25,0.15,0.1,0.05,0$.
This is a sequence of $14$ losses out of $38$, and given the game would expect $19$ losses, if you get unlucky with the first few bets, then even winning may not make up for a bad streak (e.g., if most of your wins occur once most of the wealth is gone). going broke with the smaller 1% stake is not possible in $38$ games.
The flip side is that the smaller stake will result in a much smaller profit on average, something like a $350$ fold increase with the large bet compared to $1.2$ increase with the small bet (i.e. you expect to have 24 dollars after 38 rounds with the small bet and 7000 dollars with the large bet).
|
The magic money tree problem
|
I liked the answer given by Dave harris. just though I would come at the problem from a "low risk" perspective, rather than profit maximising
The random walk you are doing, assuming your fraction bet
|
The magic money tree problem
I liked the answer given by Dave harris. just though I would come at the problem from a "low risk" perspective, rather than profit maximising
The random walk you are doing, assuming your fraction bet is $q$ and probability of winning $p=0.5$ has is given as
$$Y_t|Y_{t-1}=(1-q+3qX_t)Y_{t-1}$$
where $X_t\sim Bernoulli(p)$. on average you have
$$E(Y_t|Y_{t-1}) = (1-q+3pq)Y_{t-1}$$
You can iteratively apply this to get
$$Y_t|Y_0=Y_0\prod_{j=1}^t (1-q+3qX_t)$$
with expected value
$$E(Y_t|Y_{0}) = (1-q+3pq)^t Y_{0}$$
you can also express the amount at time $t$ as a function of a single random variable $Z_t=\sum_{j=1}^t X_t\sim Binomial(t,p)$, but noting that $Z_t$ is not independent from $Z_{t-1}$
$$Y_t|Y_0=Y_0 (1+2q)^{Z_t}(1-q)^{t-Z_t}$$
possible strategy
you could use this formula to determine a "low risk" value for $q$. Say assuming you wanted to ensure that after $k$ consecutive losses you still had half your original wealth. Then you set $q=1-2^{-k^{-1}}$
Taking the example $k=5$ means we set $q=0.129$, or with $k=15$ we set $q=0.045$.
Also, due to the recursive nature of the strategy, this risk is what you are taking every at every single bet. That is, at time $s$, by continuing to play you are ensuring that at time $k+s$ your wealth will be at least $0.5Y_{s}$
discussion
the above strategy does not depend on the pay off from winning, but rather about setting a boundary on losing. We can get the expected winnings by substituting in the value for $q$ we calculated, and at the time $k$ that was used with the risk in mind.
however, it is interesting to look at the median rather than expected pay off at time $t$, which can be found by assuming $median(Z_t)\approx tp$.
$$Y_k|Y_0=Y_0 (1+2q)^{tp}(1-q)^{t(1-p)}$$
when $p=0.5$ the we have the ratio equal to $(1+q-2q^2)^{0.5t}$. This is maximised when $q=0.25$ and greater than $1$ when $q<0.5$
it is also interesting to calculate the chance you will be ahead at time $t$. to do this we need to determine the value $z$ such that
$$(1+2q)^{z}(1-q)^{t-z}>1$$
doing some rearranging we find that the proportion of wins should satisfy
$$\frac{z}{t}>\frac{\log(1-q)}{\log(1-q)-\log(1+2q)}$$
This can be plugged into a normal approximation (note: mean of $0.5$ and standard error of $\frac{0.5}{\sqrt{t}}$) as
$$Pr(\text{ahead at time t})\approx\Phi\left(\sqrt{t}\frac{\log(1+2q)+\log(1-q)}{\left[\log(1+2q)-\log(1-q)\right]}\right)$$
which clearly shows the game has very good odds. the factor multiplying $\sqrt{t}$ is minimised when $q=0$ (maximised value of $\frac{1}{3}$) and is monotonically decreasing as a function of $q$. so the "low risk" strategy is to bet a very small fraction of your wealth, and play a large number of times.
suppose we compare this with $q=\frac{1}{3}$ and $q=\frac{1}{100}$. the factor for each case is $0.11$ and $0.32$. This means after $38$ games you would have around a 95% chance to be ahead with the small bet, compared to a 75% chance with the larger bet. Additionally, you also have a chance of going broke with the larger bet, assuming you had to round your stake to the nearest 5 cents or dollar. Starting with $20$ this could go $13.35, 8.90,5.95,3.95,2.65,1.75,1.15,0.75,0.50,0.35,0.25,0.15,0.1,0.05,0$.
This is a sequence of $14$ losses out of $38$, and given the game would expect $19$ losses, if you get unlucky with the first few bets, then even winning may not make up for a bad streak (e.g., if most of your wins occur once most of the wealth is gone). going broke with the smaller 1% stake is not possible in $38$ games.
The flip side is that the smaller stake will result in a much smaller profit on average, something like a $350$ fold increase with the large bet compared to $1.2$ increase with the small bet (i.e. you expect to have 24 dollars after 38 rounds with the small bet and 7000 dollars with the large bet).
|
The magic money tree problem
I liked the answer given by Dave harris. just though I would come at the problem from a "low risk" perspective, rather than profit maximising
The random walk you are doing, assuming your fraction bet
|
11,506
|
The magic money tree problem
|
Problem statement
$\mathbf{M_t}$: the amount of money $M_t$ the gambler has at time $t$
$\mathbf{Y_t}$: Let $Y_t = \log_{10}(M_t)$ be the logarithm of $M_t$.
$\mathbf{Y_0}$: Let $Y_0 = 1$ be the amount of money that the gambler starts with (ten dollars).
$\mathbf{Y_L}$: Let $Y_L=-2$ be the amount of money where the gambler goes bankrupt (below 1 cent).
$\mathbf{Y_W}$: For simplicity we add a rule that the gambler stops gambling when he has passed some amount of money $Y_W$ (we can later lift this rule by taking the limit $Y_W \to \infty$).
$\mathbf{q}$: Let $q$ be the fraction of money that the gambler is betting.
$\mathbf{b}$: Let $b$ be the ratio of payout for a win and a loss. In this case, a win is twice the gamble $q$ and a loss is once the gamble $q$, so $b = 2$.
$\mathbf{X_i}$: The change of the logarithm of the amount of money in the $i$-th gamble. $X_i = Y_t-Y_{t-1}$
$\mathbf{a_w}$: $X$ for a win.
$\mathbf{a_l}$: $X$ for a loss.
Random walk
You can see the growth and decline of the money as an asymmetric random walk. That is you can describe $Y_t$ as:
$$Y_t = Y_0 + \sum_{i=1}^t X_i$$
where
$$\mathbb{P}[X_i= a_w =\log(1+2q)] = \mathbb{P}[X_i= a_l =\log(1-q)] = \frac{1}{2}$$
Probability of bankruptcy
Martingale
The expression
$$Z_t = c^{Y_t}$$
is a martingale when we choose $c$ such that.
$$c^{a_w}+ c^{a_l} = 2$$ (where $c<1$ if $q<0.5$). Since in that case
$$E[Z_{t+1}] = E[Z_t] \frac{1}{2} c^{a_w} + E[Z_t] \frac{1}{2} c^{a_l} = E[Z_t]$$
Probability to end up bankrupt
The stopping time (losing/bankruptcy $Y_t < Y_L$ or winning $Y_t>Y_W$) is almost surely finite since it requires in the worst case a winning streak (or losing streak) of a certain finite length, $\frac{Y_W-Y_L}{a_w}$, which is almost surely gonna happen.
Then, we can use the optional stopping theorem to say $E[Z_\tau]$ at the stopping time $\tau$ equals the expected value $E[Z_0]$ at time zero.
Thus
$$c^{Y_0} = E[Z_0] = E[Z_\tau] \approx \mathbb{P}[Y_\tau<L] c^{Y_L} + (1-\mathbb{P}[Y_\tau<L]) c^{Y_W}$$
and
$$ \mathbb{P}[Y_\tau<Y_L] \approx \frac{c^{Y_0}-c^{Y_W}}{c^{Y_L}-c^{Y_W}}$$
and the limit $Y_W \to \infty$
$$ \mathbb{P}[Y_\tau<Y_L] \approx c^{Y_0-Y_L}$$
Conclusions
Is there an optimal percentage of your cash you can offer without losing it all?
Whichever is the optimal percentage will depend on how you value different profits. However, we can say something about the probability to lose it all.
Only when the gambler is betting zero fraction of his money then he will certainly not go bankrupt.
With increasing $q$ the probability to go bankrupt will increase up to some point where the gambler will almost surely go bankrupt within a finite time (the gambler's ruin mentioned by Robert Long in the comments). This point, $q_{\text{gambler's ruin}}$, is at $$q_{\text{gambler's ruin}} = 1-1/b$$ This is the point where there is no solution for $c$ below one. This is also the point where the increasing steps $a_w$ are smaller than the decreasing steps $a_l$.
Thus, for $b=2$, as long as the gambler bets less than half the money then the gambler will not certainly go bankrupt.
do the odds of losing all your money decrease or increase over time?
The probability to go bankrupt is dependent on the distance from the amount of money where the gambler goes bankrupt. When $q<q_{\text{gambler's ruin}}$ the gambler's money will, on average increase, and the probability to go bankrupt will, on average, decrease.
Bankruptcy probability when using the Kelly criterion.
When you use the Kelly criterion mentioned in Dave Harris answer, $q = 0.5(1-1/b)$, for $b$ being the ratio between loss and profit in a single bet, then independent from $b$ the value of $c$ will be equal to $0.1$ and the probability to go bankrupt will be $0.1^{Y_0-Y_L}$....
Derivation: if $c=0.1$, with $a_w = \log_{10}(1+bq)$ and $a_l = \log_{10}(1-q)$, then $$c^{a_w}+c^{a_l} = 0.1^{\log(1+bq)}+0.1^{\log(1-q)} = \frac{1}{1+bq} + \frac{1}{1-q} $$ which equals 2 when we fill in $q=0.5\frac{b-1}{b}$.
...That is, independent from the assymetry parameter $b$ of the magic tree, the probability to go bankrupt, when using the Kelly criterion, is equal to the ratio of the amount of money where the gambler goes bankrupt and the amount of money that the gambler starts with. For ten dollars and 1 cent this is a 1:1000 probability to go bankrupt, when using the Kelly criterion.
Simulations
The simulations below show different simulated trajectories for different gambling strategies. The red trajectories are ones that ended up bankrupt (hit the line $Y_t=-2$).
Distribution of profits after time $t$
To further illustrate the possible outcomes of gambling with the money tree, you can model the distribution of $Y_t$ as a one dimensional diffusion process in a homogeneous force field and with an absorbing boundary (where the gambler get's bankrupt). The solution for this situation has been given by Smoluchowski
Smoluchowski, Marian V. "Über Brownsche Molekularbewegung unter Einwirkung äußerer Kräfte und deren Zusammenhang mit der verallgemeinerten Diffusionsgleichung." Annalen der Physik 353.24 (1916): 1103-1112. (online available via: https://www.physik.uni-augsburg.de/theo1/hanggi/History/BM-History.html)
Equation 8:
$$ W(x_0,x,t) = \frac{e^{-\frac{c(x-x_0)}{2D} - \frac{c^2 t}{4D}}}{2 \sqrt{\pi D t}} \left[ e^{-\frac{(x-x_0)^2}{4Dt}} - e^{-\frac{(x+x_0)^2}{4Dt}} \right]$$
This diffusion equation relates to the tree problem when we set the speed $c$ equal to the expected increase $E[Y_t]$, we set $D$ equal to the variance of the change in a single steps $\text{Var}(X_t)$, $x_0$ is the initial amount of money, and $t$ is the number of steps.
The image and code below demonstrate the equation:
The histogram shows the result from a simulation.
The dotted line shows a model when we use a naive normal distribution to approximate the distribution (this corresponds to the absence of the absorbing 'bankruptcy' barrier). This is wrong because some of the results above the bankruptcy level involve trajectories that have passed the bankruptcy level at an earlier time.
The continuous line is the approximation using the formula by Smoluchowski.
Codes
#
## Simulations of random walks and bankruptcy:
#
# functions to compute c
cx = function(c,x) {
c^log(1-x,10)+c^log(1+2*x,10) - 2
}
findc = function(x) {
r <- uniroot(cx, c(0,1-0.1^10),x=x,tol=10^-130)
r$root
}
# settings
set.seed(1)
n <- 100000
n2 <- 1000
q <- 0.45
# repeating different betting strategies
for (q in c(0.35,0.4,0.45)) {
# plot empty canvas
plot(1,-1000,
xlim=c(0,n2),ylim=c(-2,50),
type="l",
xlab = "time step", ylab = expression(log[10](M[t])) )
# steps in the logarithm of the money
steps <- c(log(1+2*q,10),log(1-q,10))
# counter for number of bankrupts
bank <- 0
# computing 1000 times
for (i in 1:1000) {
# sampling wins or looses
X_t <- sample(steps, n, replace = TRUE)
# compute log of money
Y_t <- 1+cumsum(X_t)
# compute money
M_t <- 10^Y_t
# optional stopping (bankruptcy)
tau <- min(c(n,which(-2 > Y_t)))
if (tau<n) {
bank <- bank+1
}
# plot only 100 to prevent clutter
if (i<=100) {
col=rgb(tau<n,0,0,0.5)
lines(1:tau,Y_t[1:tau],col=col)
}
}
text(0,45,paste0(bank, " bankruptcies out of 1000 \n", "theoretic bankruptcy rate is ", round(findc(q)^3,4)),cex=1,pos=4)
title(paste0("betting a fraction ", round(q,2)))
}
#
## Simulation of histogram of profits/results
#
# settings
set.seed(1)
rep <- 10000 # repetitions for histogram
n <- 5000 # time steps
q <- 0.45 # betting fraction
b <- 2 # betting ratio loss/profit
x0 <- 3 # starting money
# steps in the logarithm of the money
steps <- c(log(1+b*q,10),log(1-q,10))
# to prevent Moiré pattern in
# set binsize to discrete differences in results
binsize <- 2*(steps[1]-steps[2])
for (n in c(200,500,1000)) {
# computing several trials
pays <- rep(0,rep)
for (i in 1:rep) {
# sampling wins or looses
X_t <- sample(steps, n, replace = TRUE)
# you could also make steps according to a normal distribution
# this will give a smoother histogram
# to do this uncomment the line below
# X_t <- rnorm(n,mean(steps),sqrt(0.25*(steps[1]-steps[2])^2))
# compute log of money
Y_t <- x0+cumsum(X_t)
# compute money
M_t <- 10^Y_t
# optional stopping (bankruptcy)
tau <- min(c(n,which(Y_t < 0)))
if (tau<n) {
Y_t[n] <- 0
M_t[n] <- 0
}
pays[i] <- Y_t[n]
}
# histogram
h <- hist(pays[pays>0],
breaks = seq(0,round(2+max(pays)),binsize),
col=rgb(0,0,0,0.5),
ylim=c(0,1200),
xlab = "log(result)", ylab = "counts",
main = "")
title(paste0("after ", n ," steps"),line = 0)
# regular diffusion in a force field (shifted normal distribution)
x <- h$mids
mu <- x0+n*mean(steps)
sig <- sqrt(n*0.25*(steps[1]-steps[2])^2)
lines(x,rep*binsize*(dnorm(x,mu,sig)), lty=2)
# diffusion using the solution by Smoluchowski
# which accounts for absorption
lines(x,rep*binsize*Smoluchowski(x,x0,0.25*(steps[1]-steps[2])^2,mean(steps),n))
}
|
The magic money tree problem
|
Problem statement
$\mathbf{M_t}$: the amount of money $M_t$ the gambler has at time $t$
$\mathbf{Y_t}$: Let $Y_t = \log_{10}(M_t)$ be the logarithm of $M_t$.
$\mathbf{Y_0}$: Let $Y_0 = 1$ be the amo
|
The magic money tree problem
Problem statement
$\mathbf{M_t}$: the amount of money $M_t$ the gambler has at time $t$
$\mathbf{Y_t}$: Let $Y_t = \log_{10}(M_t)$ be the logarithm of $M_t$.
$\mathbf{Y_0}$: Let $Y_0 = 1$ be the amount of money that the gambler starts with (ten dollars).
$\mathbf{Y_L}$: Let $Y_L=-2$ be the amount of money where the gambler goes bankrupt (below 1 cent).
$\mathbf{Y_W}$: For simplicity we add a rule that the gambler stops gambling when he has passed some amount of money $Y_W$ (we can later lift this rule by taking the limit $Y_W \to \infty$).
$\mathbf{q}$: Let $q$ be the fraction of money that the gambler is betting.
$\mathbf{b}$: Let $b$ be the ratio of payout for a win and a loss. In this case, a win is twice the gamble $q$ and a loss is once the gamble $q$, so $b = 2$.
$\mathbf{X_i}$: The change of the logarithm of the amount of money in the $i$-th gamble. $X_i = Y_t-Y_{t-1}$
$\mathbf{a_w}$: $X$ for a win.
$\mathbf{a_l}$: $X$ for a loss.
Random walk
You can see the growth and decline of the money as an asymmetric random walk. That is you can describe $Y_t$ as:
$$Y_t = Y_0 + \sum_{i=1}^t X_i$$
where
$$\mathbb{P}[X_i= a_w =\log(1+2q)] = \mathbb{P}[X_i= a_l =\log(1-q)] = \frac{1}{2}$$
Probability of bankruptcy
Martingale
The expression
$$Z_t = c^{Y_t}$$
is a martingale when we choose $c$ such that.
$$c^{a_w}+ c^{a_l} = 2$$ (where $c<1$ if $q<0.5$). Since in that case
$$E[Z_{t+1}] = E[Z_t] \frac{1}{2} c^{a_w} + E[Z_t] \frac{1}{2} c^{a_l} = E[Z_t]$$
Probability to end up bankrupt
The stopping time (losing/bankruptcy $Y_t < Y_L$ or winning $Y_t>Y_W$) is almost surely finite since it requires in the worst case a winning streak (or losing streak) of a certain finite length, $\frac{Y_W-Y_L}{a_w}$, which is almost surely gonna happen.
Then, we can use the optional stopping theorem to say $E[Z_\tau]$ at the stopping time $\tau$ equals the expected value $E[Z_0]$ at time zero.
Thus
$$c^{Y_0} = E[Z_0] = E[Z_\tau] \approx \mathbb{P}[Y_\tau<L] c^{Y_L} + (1-\mathbb{P}[Y_\tau<L]) c^{Y_W}$$
and
$$ \mathbb{P}[Y_\tau<Y_L] \approx \frac{c^{Y_0}-c^{Y_W}}{c^{Y_L}-c^{Y_W}}$$
and the limit $Y_W \to \infty$
$$ \mathbb{P}[Y_\tau<Y_L] \approx c^{Y_0-Y_L}$$
Conclusions
Is there an optimal percentage of your cash you can offer without losing it all?
Whichever is the optimal percentage will depend on how you value different profits. However, we can say something about the probability to lose it all.
Only when the gambler is betting zero fraction of his money then he will certainly not go bankrupt.
With increasing $q$ the probability to go bankrupt will increase up to some point where the gambler will almost surely go bankrupt within a finite time (the gambler's ruin mentioned by Robert Long in the comments). This point, $q_{\text{gambler's ruin}}$, is at $$q_{\text{gambler's ruin}} = 1-1/b$$ This is the point where there is no solution for $c$ below one. This is also the point where the increasing steps $a_w$ are smaller than the decreasing steps $a_l$.
Thus, for $b=2$, as long as the gambler bets less than half the money then the gambler will not certainly go bankrupt.
do the odds of losing all your money decrease or increase over time?
The probability to go bankrupt is dependent on the distance from the amount of money where the gambler goes bankrupt. When $q<q_{\text{gambler's ruin}}$ the gambler's money will, on average increase, and the probability to go bankrupt will, on average, decrease.
Bankruptcy probability when using the Kelly criterion.
When you use the Kelly criterion mentioned in Dave Harris answer, $q = 0.5(1-1/b)$, for $b$ being the ratio between loss and profit in a single bet, then independent from $b$ the value of $c$ will be equal to $0.1$ and the probability to go bankrupt will be $0.1^{Y_0-Y_L}$....
Derivation: if $c=0.1$, with $a_w = \log_{10}(1+bq)$ and $a_l = \log_{10}(1-q)$, then $$c^{a_w}+c^{a_l} = 0.1^{\log(1+bq)}+0.1^{\log(1-q)} = \frac{1}{1+bq} + \frac{1}{1-q} $$ which equals 2 when we fill in $q=0.5\frac{b-1}{b}$.
...That is, independent from the assymetry parameter $b$ of the magic tree, the probability to go bankrupt, when using the Kelly criterion, is equal to the ratio of the amount of money where the gambler goes bankrupt and the amount of money that the gambler starts with. For ten dollars and 1 cent this is a 1:1000 probability to go bankrupt, when using the Kelly criterion.
Simulations
The simulations below show different simulated trajectories for different gambling strategies. The red trajectories are ones that ended up bankrupt (hit the line $Y_t=-2$).
Distribution of profits after time $t$
To further illustrate the possible outcomes of gambling with the money tree, you can model the distribution of $Y_t$ as a one dimensional diffusion process in a homogeneous force field and with an absorbing boundary (where the gambler get's bankrupt). The solution for this situation has been given by Smoluchowski
Smoluchowski, Marian V. "Über Brownsche Molekularbewegung unter Einwirkung äußerer Kräfte und deren Zusammenhang mit der verallgemeinerten Diffusionsgleichung." Annalen der Physik 353.24 (1916): 1103-1112. (online available via: https://www.physik.uni-augsburg.de/theo1/hanggi/History/BM-History.html)
Equation 8:
$$ W(x_0,x,t) = \frac{e^{-\frac{c(x-x_0)}{2D} - \frac{c^2 t}{4D}}}{2 \sqrt{\pi D t}} \left[ e^{-\frac{(x-x_0)^2}{4Dt}} - e^{-\frac{(x+x_0)^2}{4Dt}} \right]$$
This diffusion equation relates to the tree problem when we set the speed $c$ equal to the expected increase $E[Y_t]$, we set $D$ equal to the variance of the change in a single steps $\text{Var}(X_t)$, $x_0$ is the initial amount of money, and $t$ is the number of steps.
The image and code below demonstrate the equation:
The histogram shows the result from a simulation.
The dotted line shows a model when we use a naive normal distribution to approximate the distribution (this corresponds to the absence of the absorbing 'bankruptcy' barrier). This is wrong because some of the results above the bankruptcy level involve trajectories that have passed the bankruptcy level at an earlier time.
The continuous line is the approximation using the formula by Smoluchowski.
Codes
#
## Simulations of random walks and bankruptcy:
#
# functions to compute c
cx = function(c,x) {
c^log(1-x,10)+c^log(1+2*x,10) - 2
}
findc = function(x) {
r <- uniroot(cx, c(0,1-0.1^10),x=x,tol=10^-130)
r$root
}
# settings
set.seed(1)
n <- 100000
n2 <- 1000
q <- 0.45
# repeating different betting strategies
for (q in c(0.35,0.4,0.45)) {
# plot empty canvas
plot(1,-1000,
xlim=c(0,n2),ylim=c(-2,50),
type="l",
xlab = "time step", ylab = expression(log[10](M[t])) )
# steps in the logarithm of the money
steps <- c(log(1+2*q,10),log(1-q,10))
# counter for number of bankrupts
bank <- 0
# computing 1000 times
for (i in 1:1000) {
# sampling wins or looses
X_t <- sample(steps, n, replace = TRUE)
# compute log of money
Y_t <- 1+cumsum(X_t)
# compute money
M_t <- 10^Y_t
# optional stopping (bankruptcy)
tau <- min(c(n,which(-2 > Y_t)))
if (tau<n) {
bank <- bank+1
}
# plot only 100 to prevent clutter
if (i<=100) {
col=rgb(tau<n,0,0,0.5)
lines(1:tau,Y_t[1:tau],col=col)
}
}
text(0,45,paste0(bank, " bankruptcies out of 1000 \n", "theoretic bankruptcy rate is ", round(findc(q)^3,4)),cex=1,pos=4)
title(paste0("betting a fraction ", round(q,2)))
}
#
## Simulation of histogram of profits/results
#
# settings
set.seed(1)
rep <- 10000 # repetitions for histogram
n <- 5000 # time steps
q <- 0.45 # betting fraction
b <- 2 # betting ratio loss/profit
x0 <- 3 # starting money
# steps in the logarithm of the money
steps <- c(log(1+b*q,10),log(1-q,10))
# to prevent Moiré pattern in
# set binsize to discrete differences in results
binsize <- 2*(steps[1]-steps[2])
for (n in c(200,500,1000)) {
# computing several trials
pays <- rep(0,rep)
for (i in 1:rep) {
# sampling wins or looses
X_t <- sample(steps, n, replace = TRUE)
# you could also make steps according to a normal distribution
# this will give a smoother histogram
# to do this uncomment the line below
# X_t <- rnorm(n,mean(steps),sqrt(0.25*(steps[1]-steps[2])^2))
# compute log of money
Y_t <- x0+cumsum(X_t)
# compute money
M_t <- 10^Y_t
# optional stopping (bankruptcy)
tau <- min(c(n,which(Y_t < 0)))
if (tau<n) {
Y_t[n] <- 0
M_t[n] <- 0
}
pays[i] <- Y_t[n]
}
# histogram
h <- hist(pays[pays>0],
breaks = seq(0,round(2+max(pays)),binsize),
col=rgb(0,0,0,0.5),
ylim=c(0,1200),
xlab = "log(result)", ylab = "counts",
main = "")
title(paste0("after ", n ," steps"),line = 0)
# regular diffusion in a force field (shifted normal distribution)
x <- h$mids
mu <- x0+n*mean(steps)
sig <- sqrt(n*0.25*(steps[1]-steps[2])^2)
lines(x,rep*binsize*(dnorm(x,mu,sig)), lty=2)
# diffusion using the solution by Smoluchowski
# which accounts for absorption
lines(x,rep*binsize*Smoluchowski(x,x0,0.25*(steps[1]-steps[2])^2,mean(steps),n))
}
|
The magic money tree problem
Problem statement
$\mathbf{M_t}$: the amount of money $M_t$ the gambler has at time $t$
$\mathbf{Y_t}$: Let $Y_t = \log_{10}(M_t)$ be the logarithm of $M_t$.
$\mathbf{Y_0}$: Let $Y_0 = 1$ be the amo
|
11,507
|
How to split r-squared between predictor variables in multiple regression?
|
You can just get the two separate correlations and square them or run two separate models and get the R^2. They will only sum up if the predictors are orthogonal.
|
How to split r-squared between predictor variables in multiple regression?
|
You can just get the two separate correlations and square them or run two separate models and get the R^2. They will only sum up if the predictors are orthogonal.
|
How to split r-squared between predictor variables in multiple regression?
You can just get the two separate correlations and square them or run two separate models and get the R^2. They will only sum up if the predictors are orthogonal.
|
How to split r-squared between predictor variables in multiple regression?
You can just get the two separate correlations and square them or run two separate models and get the R^2. They will only sum up if the predictors are orthogonal.
|
11,508
|
How to split r-squared between predictor variables in multiple regression?
|
In addition to John's answer, you may wish to obtain the squared semi-partial correlations for each predictor.
Uncorrelated predictors: If the predictors are orthogonal (i.e., uncorrelated), then the squared semi-partial correlations will be the same as the squared zero-order correlations.
Correlated predictors: If the predictors are correlated, then the squared semi-partial correlation will represent the unique variance explained by a given predictor. In this case, the sum of squared semi-partial correlations will be less than $R^2$. This remaining explained variance will represent variance explained by more than one variable.
If you are looking for an R function there is spcor() in the ppcor package.
You might also want to consider the broader topic of evaluating variable importance in multiple regression (e.g., see this page about the relaimpo package).
|
How to split r-squared between predictor variables in multiple regression?
|
In addition to John's answer, you may wish to obtain the squared semi-partial correlations for each predictor.
Uncorrelated predictors: If the predictors are orthogonal (i.e., uncorrelated), then th
|
How to split r-squared between predictor variables in multiple regression?
In addition to John's answer, you may wish to obtain the squared semi-partial correlations for each predictor.
Uncorrelated predictors: If the predictors are orthogonal (i.e., uncorrelated), then the squared semi-partial correlations will be the same as the squared zero-order correlations.
Correlated predictors: If the predictors are correlated, then the squared semi-partial correlation will represent the unique variance explained by a given predictor. In this case, the sum of squared semi-partial correlations will be less than $R^2$. This remaining explained variance will represent variance explained by more than one variable.
If you are looking for an R function there is spcor() in the ppcor package.
You might also want to consider the broader topic of evaluating variable importance in multiple regression (e.g., see this page about the relaimpo package).
|
How to split r-squared between predictor variables in multiple regression?
In addition to John's answer, you may wish to obtain the squared semi-partial correlations for each predictor.
Uncorrelated predictors: If the predictors are orthogonal (i.e., uncorrelated), then th
|
11,509
|
How to split r-squared between predictor variables in multiple regression?
|
I added the variance-decomposition tag to your question. Here is part of its tag wiki:
One common method is to add regressors to the model one by one and record the increase in $R^2$ as each regressor is added. Since this value depends on the regressors already in the model, one needs to do this for every possible order in which regressors can enter the model, and then average over orders. This is feasible for small models but becomes computationally prohibitive for large models, since the number of possible orders is $p!$ for $p$ predictors.
Grömping (2007, The American Statistician) gives an overview and pointers to literature in the context of assessing variable importance.
|
How to split r-squared between predictor variables in multiple regression?
|
I added the variance-decomposition tag to your question. Here is part of its tag wiki:
One common method is to add regressors to the model one by one and record the increase in $R^2$ as each regresso
|
How to split r-squared between predictor variables in multiple regression?
I added the variance-decomposition tag to your question. Here is part of its tag wiki:
One common method is to add regressors to the model one by one and record the increase in $R^2$ as each regressor is added. Since this value depends on the regressors already in the model, one needs to do this for every possible order in which regressors can enter the model, and then average over orders. This is feasible for small models but becomes computationally prohibitive for large models, since the number of possible orders is $p!$ for $p$ predictors.
Grömping (2007, The American Statistician) gives an overview and pointers to literature in the context of assessing variable importance.
|
How to split r-squared between predictor variables in multiple regression?
I added the variance-decomposition tag to your question. Here is part of its tag wiki:
One common method is to add regressors to the model one by one and record the increase in $R^2$ as each regresso
|
11,510
|
How to calculate a confidence interval for Spearman's rank correlation?
|
In a nutshell, a 95% confidence interval is given by
$$\tanh(\operatorname{atanh}r\pm1.96/\sqrt{n-3}),$$
where $r$ is the estimate of the correlation and $n$ is the sample size.
Explanation: The Fisher transformation is atanh. On the transformed scale, the sampling distribution of the estimate is approximately normal, so a 95% CI is found by taking the transformed estimate and adding and subtracting 1.96 times its standard error. The standard error is (approximately) $1/\sqrt{n-3}$.
EDIT: The example above in Python:
import math
r = 0.684848
num = 10
stderr = 1.0 / math.sqrt(num - 3)
delta = 1.96 * stderr
lower = math.tanh(math.atanh(r) - delta)
upper = math.tanh(math.atanh(r) + delta)
print "lower %.6f upper %.6f" % (lower, upper)
gives
lower 0.097071 upper 0.918445
which agrees with your example to 4 decimal places.
|
How to calculate a confidence interval for Spearman's rank correlation?
|
In a nutshell, a 95% confidence interval is given by
$$\tanh(\operatorname{atanh}r\pm1.96/\sqrt{n-3}),$$
where $r$ is the estimate of the correlation and $n$ is the sample size.
Explanation: The Fishe
|
How to calculate a confidence interval for Spearman's rank correlation?
In a nutshell, a 95% confidence interval is given by
$$\tanh(\operatorname{atanh}r\pm1.96/\sqrt{n-3}),$$
where $r$ is the estimate of the correlation and $n$ is the sample size.
Explanation: The Fisher transformation is atanh. On the transformed scale, the sampling distribution of the estimate is approximately normal, so a 95% CI is found by taking the transformed estimate and adding and subtracting 1.96 times its standard error. The standard error is (approximately) $1/\sqrt{n-3}$.
EDIT: The example above in Python:
import math
r = 0.684848
num = 10
stderr = 1.0 / math.sqrt(num - 3)
delta = 1.96 * stderr
lower = math.tanh(math.atanh(r) - delta)
upper = math.tanh(math.atanh(r) + delta)
print "lower %.6f upper %.6f" % (lower, upper)
gives
lower 0.097071 upper 0.918445
which agrees with your example to 4 decimal places.
|
How to calculate a confidence interval for Spearman's rank correlation?
In a nutshell, a 95% confidence interval is given by
$$\tanh(\operatorname{atanh}r\pm1.96/\sqrt{n-3}),$$
where $r$ is the estimate of the correlation and $n$ is the sample size.
Explanation: The Fishe
|
11,511
|
How to calculate a confidence interval for Spearman's rank correlation?
|
Maybe some additional remarks about the comment of @chl
The Spearman correlation can be seen as a Pearson correlation of the ranks. Ranks clearly do not follow a normal distribution, with the consequence that the variance of the Fisher transformation ($\zeta$) is not well approximated by $(n-3)^{-1}$ especially at large absolute values of $\rho_s$ and low number of observations. Various empirically motivated adjustments of the variance have been suggested in literature. They are compared in Bonnett and Wright (2000), including the one with the 1.06 factor also mentioned in Wikipedia. Bonnett and Wright (2000) finally recommended the following variance estimator
$$
\sigma^2_\zeta = \frac{1 + r_s^2/2}{n-3}
$$
where $r^2_s$ is the sample Spearman correlation and $n$ is the number of observations. This leads to the following $(1-\alpha)$-CI
$$
\tanh\left(\text{atanh}(r_s) \pm \sqrt{\frac{1 + r_s^2/2}{n-3}} z_{\frac{\alpha}{2}}\right).
$$
where $z_{\frac{\alpha}{2}}$ is the $\frac{\alpha}{2}$-quantile of the standard normal distribution. In R, this function would calculate the CI
spearman_CI <- function(x, y, alpha = 0.05){
rs <- cor(x, y, method = "spearman", use = "complete.obs")
n <- sum(complete.cases(x, y))
sort(tanh(atanh(rs) + c(-1,1)*sqrt((1+rs^2/2)/(n-3))*qnorm(p = alpha/2)))
}
Ruscio (2008) further suggests to replace the normal quantile $z_{\frac{\alpha}{2}}$ by a $t$-quantile with $n-2$ degrees of freedom in order to get better coverage.
Still, the CI is approximate. Especially in situations where
$|\rho_s| > 0.95$ (where $\rho_s$ is the true population Spearman correlation)
$n < 25$
ordinal data
a bootstrap CI has clearly better properties (Ruscio 2008, Bishara and Hittner 2017).
Source
Bishara, Anthony J., and James B. Hittner. “Confidence Intervals for Correlations When Data Are Not Normal.” Behavior Research Methods 49, no. 1 (February 1, 2017): 294–309. https://doi.org/10.3758/s13428-016-0702-8.
Bonett, Douglas G., and Thomas A. Wright. “Sample Size Requirements for Estimating Pearson, Kendall and Spearman Correlations.” Psychometrika 65, no. 1 (March 1, 2000): 23–28. https://doi.org/10.1007/BF02294183.
Ruscio, John. “Constructing Confidence Intervals for Spearman’s Rank Correlation with Ordinal Data: A Simulation Study Comparing Analytic and Bootstrap Methods.” Journal of Modern Applied Statistical Methods 7, no. 2 (November 1, 2008). https://doi.org/10.22237/jmasm/1225512360.
|
How to calculate a confidence interval for Spearman's rank correlation?
|
Maybe some additional remarks about the comment of @chl
The Spearman correlation can be seen as a Pearson correlation of the ranks. Ranks clearly do not follow a normal distribution, with the conseque
|
How to calculate a confidence interval for Spearman's rank correlation?
Maybe some additional remarks about the comment of @chl
The Spearman correlation can be seen as a Pearson correlation of the ranks. Ranks clearly do not follow a normal distribution, with the consequence that the variance of the Fisher transformation ($\zeta$) is not well approximated by $(n-3)^{-1}$ especially at large absolute values of $\rho_s$ and low number of observations. Various empirically motivated adjustments of the variance have been suggested in literature. They are compared in Bonnett and Wright (2000), including the one with the 1.06 factor also mentioned in Wikipedia. Bonnett and Wright (2000) finally recommended the following variance estimator
$$
\sigma^2_\zeta = \frac{1 + r_s^2/2}{n-3}
$$
where $r^2_s$ is the sample Spearman correlation and $n$ is the number of observations. This leads to the following $(1-\alpha)$-CI
$$
\tanh\left(\text{atanh}(r_s) \pm \sqrt{\frac{1 + r_s^2/2}{n-3}} z_{\frac{\alpha}{2}}\right).
$$
where $z_{\frac{\alpha}{2}}$ is the $\frac{\alpha}{2}$-quantile of the standard normal distribution. In R, this function would calculate the CI
spearman_CI <- function(x, y, alpha = 0.05){
rs <- cor(x, y, method = "spearman", use = "complete.obs")
n <- sum(complete.cases(x, y))
sort(tanh(atanh(rs) + c(-1,1)*sqrt((1+rs^2/2)/(n-3))*qnorm(p = alpha/2)))
}
Ruscio (2008) further suggests to replace the normal quantile $z_{\frac{\alpha}{2}}$ by a $t$-quantile with $n-2$ degrees of freedom in order to get better coverage.
Still, the CI is approximate. Especially in situations where
$|\rho_s| > 0.95$ (where $\rho_s$ is the true population Spearman correlation)
$n < 25$
ordinal data
a bootstrap CI has clearly better properties (Ruscio 2008, Bishara and Hittner 2017).
Source
Bishara, Anthony J., and James B. Hittner. “Confidence Intervals for Correlations When Data Are Not Normal.” Behavior Research Methods 49, no. 1 (February 1, 2017): 294–309. https://doi.org/10.3758/s13428-016-0702-8.
Bonett, Douglas G., and Thomas A. Wright. “Sample Size Requirements for Estimating Pearson, Kendall and Spearman Correlations.” Psychometrika 65, no. 1 (March 1, 2000): 23–28. https://doi.org/10.1007/BF02294183.
Ruscio, John. “Constructing Confidence Intervals for Spearman’s Rank Correlation with Ordinal Data: A Simulation Study Comparing Analytic and Bootstrap Methods.” Journal of Modern Applied Statistical Methods 7, no. 2 (November 1, 2008). https://doi.org/10.22237/jmasm/1225512360.
|
How to calculate a confidence interval for Spearman's rank correlation?
Maybe some additional remarks about the comment of @chl
The Spearman correlation can be seen as a Pearson correlation of the ranks. Ranks clearly do not follow a normal distribution, with the conseque
|
11,512
|
Probability of defeating a dragon in one turn rolling a 20 sided die
|
Your suggestion to solve a general version of the problem is spot on. Let's set this up.
The die has two special outcomes: "death," which terminates the process, and 0, which has no effect. We might as well remove the 0, creating a "truncated die" of 19 sides. Let the probability that the die shows up a numeric value $\omega$ be $p(\omega)$ and let $p_{*}$ be the probability of death. $\Omega$ is the set of all these possible numeric values (not including "death," which is non-numeric).
You aim to reach a total of $T$ before observing "death." When $T\le 0,$ you have achieved this threshold, so the chance of winning is $1.$ Otherwise, when $T \gt 0,$ partition the event "eventually I win" into the separate numbered outcomes occurring within $\Omega.$ It is an axiom of probability that the chance of this event is the sum of the chances of its (non-overlapping) components.
$$\Pr(\text{Reach } T) = \sum_{\omega\in\Omega}p(\omega) \Pr(\text{Reach } T-\omega).$$
This recursion can be carried out with a simple form of a dynamic program. Unless the values and probabilities are very special, you can't hope to write a nice closed formula for the solution. You just have to carry out the calculation by computing the values for $T=1,$ $T=2,$ etc., in order. (This is called "eliminating tail recursion" in computer science.)
The number of calculations performed by this algorithm is proportional to $T$ times the number of unique values on the truncated die. That makes it effective for moderately large $T$ and realistic dice.
By means of such a program (using double precision floating point) I find the chance of reaching $T=250$ is $0.269880432506\ldots.$
As a reality check, you expect to deal about 9.5 damage points per roll, suggesting it will take about $250/9.5 \approx 27$ rolls to win. But on each roll there is a $1-1/20$ chance of surviving, so your chance of surviving by then is $$(1-1/20)^{27} = \left[(1-1/20)^{20}\right]^{27/20} \approx \exp(-27/20) = 0.25924\ldots.$$
That's pretty close to the answer I obtained.
As another reality check, that's also close to your simulation results. Indeed, I obtain comparable simulation results: they do not differ significantly from the exact answer.
I leave it to you to write the program. It will require a data structure that can store all the values of $\Pr(\text{Reach } T-\omega)$ given on the right hand side of the formula. Consider using an array for this, indexed by the values $0,1,2,\ldots, T.$
BTW, there are other solution methods. This problem describes a Markov Chain whose states are the total values that have been reached (from $0$ through $T,$ since anything larger than $T$ might as well be combined with $T$), along with a special (absorbing) "death" state. This chain can be analyzed in terms of a large matrix (having $250+2$ dimensions). As a practical matter this formulation isn't worth much, but the theory of Markov Chains provides insight into the process. You can mine that theory for information on your chances of winning and on how many rolls it is likely to take you to win if you do.
Yet another approach was suggested in a comment to the question: exploit a geometric distribution. This refers to analyzing the process according to how many rolls you will have before dying. To deal hit points, imagine rolling the die, with its "death" face removed parallel with flipping a (biased) coin, whose function is to determine whether you die. (Thus, in the situation of the question, each of the 19 remaining sides of the die--including the $0,$ which must be left in--has a $1/19$ chance; more generally, the side with value $\omega$ has a chance $p(\omega)/(1-p_{*}).$) The two sides of the coin are "death" (with probability $p_{*}$) and "continue" (with probability $1-p_{*}$). At each turn you separately roll the truncated die and flip the coin, accumulating hit points until you reach the threshold $T$ or the coin turns up "death."
A simplification is available, because it's easy to work out the chance of never flipping "death" in the first $n=0,1,2,\ldots$ turns: it equals $(1-p_{*})^n$ because all the flips are independent. Formally, this describes a random variable $N$ whose value equals $n$ with probability $p_{*}(1-p_{*})^{n}.$ (This is a geometric distribution).
To model the rolls of the truncated die, let $X_1$ be its value in the first roll, $X_2$ its value in the second roll, and so on. The sum after $n$ rolls therefore is $S_n = X_1 + X_2 + \cdots + X_n.$ (This is a random walk.) The chance of reaching the threshold can be computed by decomposing this event into the countable infinity of possibilities corresponding to the number of rolls needed. The basic rules of conditional probability tell us
$$\Pr(\text{Reach }T) = \sum_{n=0}^\infty \Pr(S_N\ge T\mid N=n)\Pr(N=n).\tag{*}$$
The right hand side requires us to find these chances of each $S_n$ reaching the threshold. Although this isn't much of a simplification for a general die ($S_n$ can have a very complicated distribution) , it leads to a good approximation when the process is likely to take many rolls before dying or reaching the threshold. That's because the sum of a large number of the $X_i$ approximately has a Normal distribution (according to the Central Limit Theorem). When the expectation of the truncated die is $\mu$ (equal to $9.45/(1-0.05)$ in the question) and its variance is $\sigma^2,$ the distribution of $S_n$ has an expectation of $n\mu$ and variance of $n\sigma^2$ (according to basic laws of expectation and variance as applied to the independent variables $X_1,X_2,\ldots, X_n$). Writing $\Phi(x;n\mu,n\sigma^2$ for the Normal distribution function with expectation $n\mu$ and variance $n\sigma^2,$ we obtain
$$\Pr(S_N\ge T\mid N=n) \approx 1 - \Phi\left(T-\frac{1}{2}; n\mu, n\sigma^2\right).$$
Plugging this into $(*)$ along with the geometric distribution law yields
$$\Pr(\text{Reach }T) \approx \sum_{n=1}^\infty \left(1 - \Phi\left(T-\frac{1}{2}; n\mu, n\sigma^2\right)\right)p_{*}(1-p_{*})^n.$$
As a practical matter, we may terminate the sum by the time $\sum_{i=n}^\infty p_{*}(1-p_{*})^i$ is less than a tolerable error $\epsilon\gt 0,$ because the $\Phi$ factor never exceeds $1.$ This upper limit equals $\log(p_{*}\epsilon)/\log(1-p_{*}).$ (For the situation in the question, that upper limit is around 418.) We can also work out a reasonable value for beginning the sum (by skipping over really tiny initial values). That leads to the relatively short and simple code shown below (written in R). Its output, obtained through the command dragon.Normal(), is $0.269879\ldots,$ agreeing with the exact answer to five significant figures.
# Use `NA` to specify the "death" sides of the die; otherwise, specify the
# values on its faces. `p` gives the associated probabilities.
dragon.Normal <- function(threshold=250, die=c(NA, 2:19, 0), p=rep(1/20,20), eps=1e-6) {
#
# Find and remove the "death" face(s) to create the truncated die.
#
i.death <- which(is.na(die))
p.death <- sum(p[i.death])
if (p.death <= 0) return(1)
die <- die[-i.death]
p <- p[-i.death]
p <- p / sum(p)
#
# Compute the expectation and variance of the truncated die.
#
mu <- sum(die * p)
sigma2 <- sum((die-mu)^2 * p)
#
# Establish limits for the sum.
#
N <- ceiling(log(eps * p.death) / log(1 - p.death))
if (N > 1e8) stop("Problem is too large.")
Z <- qnorm(eps)
n <- min(N, max(1,
floor((Z * (1 - sqrt(1 + 4*threshold*mu/(Z^2*sigma2)))/(2*mu))^2 * sigma2)))
#
# Compute the sum.
#
n <- n:N
sum(p.death * (1-p.death)^n *
pnorm(threshold - 1/2, mu*n, sqrt(sigma2*n), lower.tail=FALSE))
}
|
Probability of defeating a dragon in one turn rolling a 20 sided die
|
Your suggestion to solve a general version of the problem is spot on. Let's set this up.
The die has two special outcomes: "death," which terminates the process, and 0, which has no effect. We might
|
Probability of defeating a dragon in one turn rolling a 20 sided die
Your suggestion to solve a general version of the problem is spot on. Let's set this up.
The die has two special outcomes: "death," which terminates the process, and 0, which has no effect. We might as well remove the 0, creating a "truncated die" of 19 sides. Let the probability that the die shows up a numeric value $\omega$ be $p(\omega)$ and let $p_{*}$ be the probability of death. $\Omega$ is the set of all these possible numeric values (not including "death," which is non-numeric).
You aim to reach a total of $T$ before observing "death." When $T\le 0,$ you have achieved this threshold, so the chance of winning is $1.$ Otherwise, when $T \gt 0,$ partition the event "eventually I win" into the separate numbered outcomes occurring within $\Omega.$ It is an axiom of probability that the chance of this event is the sum of the chances of its (non-overlapping) components.
$$\Pr(\text{Reach } T) = \sum_{\omega\in\Omega}p(\omega) \Pr(\text{Reach } T-\omega).$$
This recursion can be carried out with a simple form of a dynamic program. Unless the values and probabilities are very special, you can't hope to write a nice closed formula for the solution. You just have to carry out the calculation by computing the values for $T=1,$ $T=2,$ etc., in order. (This is called "eliminating tail recursion" in computer science.)
The number of calculations performed by this algorithm is proportional to $T$ times the number of unique values on the truncated die. That makes it effective for moderately large $T$ and realistic dice.
By means of such a program (using double precision floating point) I find the chance of reaching $T=250$ is $0.269880432506\ldots.$
As a reality check, you expect to deal about 9.5 damage points per roll, suggesting it will take about $250/9.5 \approx 27$ rolls to win. But on each roll there is a $1-1/20$ chance of surviving, so your chance of surviving by then is $$(1-1/20)^{27} = \left[(1-1/20)^{20}\right]^{27/20} \approx \exp(-27/20) = 0.25924\ldots.$$
That's pretty close to the answer I obtained.
As another reality check, that's also close to your simulation results. Indeed, I obtain comparable simulation results: they do not differ significantly from the exact answer.
I leave it to you to write the program. It will require a data structure that can store all the values of $\Pr(\text{Reach } T-\omega)$ given on the right hand side of the formula. Consider using an array for this, indexed by the values $0,1,2,\ldots, T.$
BTW, there are other solution methods. This problem describes a Markov Chain whose states are the total values that have been reached (from $0$ through $T,$ since anything larger than $T$ might as well be combined with $T$), along with a special (absorbing) "death" state. This chain can be analyzed in terms of a large matrix (having $250+2$ dimensions). As a practical matter this formulation isn't worth much, but the theory of Markov Chains provides insight into the process. You can mine that theory for information on your chances of winning and on how many rolls it is likely to take you to win if you do.
Yet another approach was suggested in a comment to the question: exploit a geometric distribution. This refers to analyzing the process according to how many rolls you will have before dying. To deal hit points, imagine rolling the die, with its "death" face removed parallel with flipping a (biased) coin, whose function is to determine whether you die. (Thus, in the situation of the question, each of the 19 remaining sides of the die--including the $0,$ which must be left in--has a $1/19$ chance; more generally, the side with value $\omega$ has a chance $p(\omega)/(1-p_{*}).$) The two sides of the coin are "death" (with probability $p_{*}$) and "continue" (with probability $1-p_{*}$). At each turn you separately roll the truncated die and flip the coin, accumulating hit points until you reach the threshold $T$ or the coin turns up "death."
A simplification is available, because it's easy to work out the chance of never flipping "death" in the first $n=0,1,2,\ldots$ turns: it equals $(1-p_{*})^n$ because all the flips are independent. Formally, this describes a random variable $N$ whose value equals $n$ with probability $p_{*}(1-p_{*})^{n}.$ (This is a geometric distribution).
To model the rolls of the truncated die, let $X_1$ be its value in the first roll, $X_2$ its value in the second roll, and so on. The sum after $n$ rolls therefore is $S_n = X_1 + X_2 + \cdots + X_n.$ (This is a random walk.) The chance of reaching the threshold can be computed by decomposing this event into the countable infinity of possibilities corresponding to the number of rolls needed. The basic rules of conditional probability tell us
$$\Pr(\text{Reach }T) = \sum_{n=0}^\infty \Pr(S_N\ge T\mid N=n)\Pr(N=n).\tag{*}$$
The right hand side requires us to find these chances of each $S_n$ reaching the threshold. Although this isn't much of a simplification for a general die ($S_n$ can have a very complicated distribution) , it leads to a good approximation when the process is likely to take many rolls before dying or reaching the threshold. That's because the sum of a large number of the $X_i$ approximately has a Normal distribution (according to the Central Limit Theorem). When the expectation of the truncated die is $\mu$ (equal to $9.45/(1-0.05)$ in the question) and its variance is $\sigma^2,$ the distribution of $S_n$ has an expectation of $n\mu$ and variance of $n\sigma^2$ (according to basic laws of expectation and variance as applied to the independent variables $X_1,X_2,\ldots, X_n$). Writing $\Phi(x;n\mu,n\sigma^2$ for the Normal distribution function with expectation $n\mu$ and variance $n\sigma^2,$ we obtain
$$\Pr(S_N\ge T\mid N=n) \approx 1 - \Phi\left(T-\frac{1}{2}; n\mu, n\sigma^2\right).$$
Plugging this into $(*)$ along with the geometric distribution law yields
$$\Pr(\text{Reach }T) \approx \sum_{n=1}^\infty \left(1 - \Phi\left(T-\frac{1}{2}; n\mu, n\sigma^2\right)\right)p_{*}(1-p_{*})^n.$$
As a practical matter, we may terminate the sum by the time $\sum_{i=n}^\infty p_{*}(1-p_{*})^i$ is less than a tolerable error $\epsilon\gt 0,$ because the $\Phi$ factor never exceeds $1.$ This upper limit equals $\log(p_{*}\epsilon)/\log(1-p_{*}).$ (For the situation in the question, that upper limit is around 418.) We can also work out a reasonable value for beginning the sum (by skipping over really tiny initial values). That leads to the relatively short and simple code shown below (written in R). Its output, obtained through the command dragon.Normal(), is $0.269879\ldots,$ agreeing with the exact answer to five significant figures.
# Use `NA` to specify the "death" sides of the die; otherwise, specify the
# values on its faces. `p` gives the associated probabilities.
dragon.Normal <- function(threshold=250, die=c(NA, 2:19, 0), p=rep(1/20,20), eps=1e-6) {
#
# Find and remove the "death" face(s) to create the truncated die.
#
i.death <- which(is.na(die))
p.death <- sum(p[i.death])
if (p.death <= 0) return(1)
die <- die[-i.death]
p <- p[-i.death]
p <- p / sum(p)
#
# Compute the expectation and variance of the truncated die.
#
mu <- sum(die * p)
sigma2 <- sum((die-mu)^2 * p)
#
# Establish limits for the sum.
#
N <- ceiling(log(eps * p.death) / log(1 - p.death))
if (N > 1e8) stop("Problem is too large.")
Z <- qnorm(eps)
n <- min(N, max(1,
floor((Z * (1 - sqrt(1 + 4*threshold*mu/(Z^2*sigma2)))/(2*mu))^2 * sigma2)))
#
# Compute the sum.
#
n <- n:N
sum(p.death * (1-p.death)^n *
pnorm(threshold - 1/2, mu*n, sqrt(sigma2*n), lower.tail=FALSE))
}
|
Probability of defeating a dragon in one turn rolling a 20 sided die
Your suggestion to solve a general version of the problem is spot on. Let's set this up.
The die has two special outcomes: "death," which terminates the process, and 0, which has no effect. We might
|
11,513
|
Probability of defeating a dragon in one turn rolling a 20 sided die
|
I think the most understandable method to compute probabilities like these is to define a Markov chain that represents all of the possible states that the game can be in, with absorbing states that represent the death of either the player or the dragon.
A Markov chain is a set of states together with an associated probability transition matrix, where the transition probabilities depend only on the current state. Storing all of the transition probabilities in a matrix is a convenient organizational tool for computing compound conditional probabilities like those you find in your game.
In this example, you can define a separate state for every possible value of damage that could have been dealt to the dragon (from 0 to 249). Additionally, you need two absorbing states to represent when either the player or the dragon dies. In an absorbing state, there is no escape. You have a 100% chance of remaining in that state for eternity.
Next, you define the probability transitions for each state. For example, if you have dealt 100 damage to the dragon, you have a 1/20 chance to go to the 102 damage state, 1/20 chance to go to the 103 damage state, etc up to 119. You also have a 1/20 chance to go to the 'player death' state, and a 1/20 chance to stay on state 100 (if you roll a 20). For another example, if you have dealt 249 damage, then you have a 1/20 chance of dying, a 1/20 chance of remaining at 249, and an 18/20 chance of defeating the dragon. These probabilities are all stored in a transition matrix $P$, such that $P_{ij} = $ the probability of moving from state $i$ to state $j$.
Finally, you define your initial state probability distribution vector (in this case we have a 100% chance of starting in the 0 damage state), and left-multiply this vector by your transition matrix raised the power of the number of times you repeat your attacks. This will output the exact probabilities that you will be in each state. In this game, there is a theoretical chance for the fight to last arbitrarily long if you continue rolling critical hits. One way to get around this possibility is to redefine the game to work on a 19 sided die and remove the critical strike option, since it is overall irrelevant to the final probabilities. Another option is to simply attack a huge number of times such that the chance the fight hasn't ended is essentially zero.
Since you mentioned Python, I've written up some functions for you that create the Markov transition matrix and compute the state probabilities.
import numpy as np
def markov_matrix(hp,num_sides):
#P is the transition matrix.
# Need one state for each hp of the dragon, plus a 'player dies' state and a 'dragon dies' state
# States 0-hp are damage done states, state -2 is 'player dies', state -1 is 'dragon dies'
P = []
for damage_done in range(hp):
P_row = np.zeros(hp+2)
#For each state, the probability for the player to die is 1/num_sides.
P_row[-2] = 1/num_sides
#Otherwise, there is an equal probability to deal 2 or more damage.
for hit_damage in range(2,num_sides):
new_state_index = damage_done+hit_damage
#If the total damage would be enough to kill the dragon, that probability is added to the 'dragon dies' state.
if new_state_index >= hp:
P_row[-1] = P_row[-1] + 1/num_sides
else:
P_row[new_state_index] = 1/num_sides
#If a crit is rolled, the dragon is immune.
P_row[damage_done] = 1/num_sides
P.append(P_row)
#The 'player dies' and 'dragon dies' states are absorbing.
player_dies_row = np.zeros(hp+2)
player_dies_row[-2] = 1
P.append(player_dies_row)
dragon_dies_row = np.zeros(hp+2)
dragon_dies_row[-1] = 1
P.append(dragon_dies_row)
P = np.stack(P)
return P
def probability_of_dragon_death(hp,num_sides,max_num_attacks):
P = markov_matrix(hp,num_sides)
initial_state_probabilities = np.zeros(hp+2)
#Initially we are in the 0 damage done state with 100% probability.
initial_state_probabilities[0] = 1
final_state_probabilities = initial_state_probabilities@(np.linalg.matrix_power(P,max_num_attacks))
return final_state_probabilities[-1]
Running the function probability_of_dragon_death(hp=250,num_sides=20,max_num_attacks=10000) returns a probability of $\approx 0.269880$.
For fun, I've also attached a figure showing your probability to defeat the dragon when given its HP.
|
Probability of defeating a dragon in one turn rolling a 20 sided die
|
I think the most understandable method to compute probabilities like these is to define a Markov chain that represents all of the possible states that the game can be in, with absorbing states that re
|
Probability of defeating a dragon in one turn rolling a 20 sided die
I think the most understandable method to compute probabilities like these is to define a Markov chain that represents all of the possible states that the game can be in, with absorbing states that represent the death of either the player or the dragon.
A Markov chain is a set of states together with an associated probability transition matrix, where the transition probabilities depend only on the current state. Storing all of the transition probabilities in a matrix is a convenient organizational tool for computing compound conditional probabilities like those you find in your game.
In this example, you can define a separate state for every possible value of damage that could have been dealt to the dragon (from 0 to 249). Additionally, you need two absorbing states to represent when either the player or the dragon dies. In an absorbing state, there is no escape. You have a 100% chance of remaining in that state for eternity.
Next, you define the probability transitions for each state. For example, if you have dealt 100 damage to the dragon, you have a 1/20 chance to go to the 102 damage state, 1/20 chance to go to the 103 damage state, etc up to 119. You also have a 1/20 chance to go to the 'player death' state, and a 1/20 chance to stay on state 100 (if you roll a 20). For another example, if you have dealt 249 damage, then you have a 1/20 chance of dying, a 1/20 chance of remaining at 249, and an 18/20 chance of defeating the dragon. These probabilities are all stored in a transition matrix $P$, such that $P_{ij} = $ the probability of moving from state $i$ to state $j$.
Finally, you define your initial state probability distribution vector (in this case we have a 100% chance of starting in the 0 damage state), and left-multiply this vector by your transition matrix raised the power of the number of times you repeat your attacks. This will output the exact probabilities that you will be in each state. In this game, there is a theoretical chance for the fight to last arbitrarily long if you continue rolling critical hits. One way to get around this possibility is to redefine the game to work on a 19 sided die and remove the critical strike option, since it is overall irrelevant to the final probabilities. Another option is to simply attack a huge number of times such that the chance the fight hasn't ended is essentially zero.
Since you mentioned Python, I've written up some functions for you that create the Markov transition matrix and compute the state probabilities.
import numpy as np
def markov_matrix(hp,num_sides):
#P is the transition matrix.
# Need one state for each hp of the dragon, plus a 'player dies' state and a 'dragon dies' state
# States 0-hp are damage done states, state -2 is 'player dies', state -1 is 'dragon dies'
P = []
for damage_done in range(hp):
P_row = np.zeros(hp+2)
#For each state, the probability for the player to die is 1/num_sides.
P_row[-2] = 1/num_sides
#Otherwise, there is an equal probability to deal 2 or more damage.
for hit_damage in range(2,num_sides):
new_state_index = damage_done+hit_damage
#If the total damage would be enough to kill the dragon, that probability is added to the 'dragon dies' state.
if new_state_index >= hp:
P_row[-1] = P_row[-1] + 1/num_sides
else:
P_row[new_state_index] = 1/num_sides
#If a crit is rolled, the dragon is immune.
P_row[damage_done] = 1/num_sides
P.append(P_row)
#The 'player dies' and 'dragon dies' states are absorbing.
player_dies_row = np.zeros(hp+2)
player_dies_row[-2] = 1
P.append(player_dies_row)
dragon_dies_row = np.zeros(hp+2)
dragon_dies_row[-1] = 1
P.append(dragon_dies_row)
P = np.stack(P)
return P
def probability_of_dragon_death(hp,num_sides,max_num_attacks):
P = markov_matrix(hp,num_sides)
initial_state_probabilities = np.zeros(hp+2)
#Initially we are in the 0 damage done state with 100% probability.
initial_state_probabilities[0] = 1
final_state_probabilities = initial_state_probabilities@(np.linalg.matrix_power(P,max_num_attacks))
return final_state_probabilities[-1]
Running the function probability_of_dragon_death(hp=250,num_sides=20,max_num_attacks=10000) returns a probability of $\approx 0.269880$.
For fun, I've also attached a figure showing your probability to defeat the dragon when given its HP.
|
Probability of defeating a dragon in one turn rolling a 20 sided die
I think the most understandable method to compute probabilities like these is to define a Markov chain that represents all of the possible states that the game can be in, with absorbing states that re
|
11,514
|
Probability of defeating a dragon in one turn rolling a 20 sided die
|
Here's an approach that uses ideas from Markov chains & generating functions.
Plan: We'll construct the recursion relation for the probabilities in question, and then apply techniques from linear algebra to solve it. (The nice feature of this approach is that its computational complexity is independent of how many health points the dragon has... so no matter if the dragon has 250 or 250 million points we do the same amount of computation. This is not the case for the other approaches here.)
We could jump right to the recursion formula, but let's warm up and motivate it by setting up the Markov chain it follows from.
Our Markov chain lives on the state space spanned by two types of sates
$ | 0 \rangle , | 1 \rangle , | 2 \rangle , \cdots$ denoting that the dragon has $n$ health points and we're still alive
$ | \ast \rangle $ denoting that we're dead.
The Markov transition matrix is defined via
$$ T | n \rangle = \frac{1}{m}| \ast \rangle + \frac{1}{m} \sum_{i=2}^{m-1} | n - i\rangle + \frac{1}{m} | n \rangle $$
$$ T | 0 \rangle = | 0 \rangle$$
where we $m$ is the number of faces, i.e. $m=20$.
We win, and the chain terminates, once we've taken all the dragon's life points, i.e. once the Markov chain reaches any state $ |n \rangle $ with $ n \leq 0$.
Let's call the probability of defeating a dragon with $n$ health points $p(n)$.
Now, after one roll of the die, we might either
be dead, and our combo is over, so our chance of winning is 0
still be alive, and now we're in a similar situation as before, just that we're facing a dragon with $n-i$ health points if we health $i$ damage. In this case, from here on our chance of winning is $p(n-i)$
We can translate this into the equation
$$ p(n) = \frac{1}{m} \cdot 0 + \frac{1}{m} \sum_{i=2}^{m-1} p( n - i ) + \frac{1}{m} p( n ) $$
with the initial conditions $p(n) = 1$ for $n \leq 0$. Notice the structural similarity to the transition matrix equation... this is of course no coincidence.
Re-arranging that equation a bit we arrive at
$$ p(n) = \frac{1}{m-1} \sum_{i=2}^{m-1} p( n - i ) $$
If we could solve this recursion relation, then our answer would be $p(250)$.
There a many ways to solve this equation, for example explicitly unrolling the recursion, but that would take $O(n)$ steps of computation.
Since this equation is linear, we can do better.
All solutions of linear recursion equations are linear combinations of exponentials. (Note that all Markov chains give rise to linear recursion equations... this is ultimately why Markov chains are powerful.)
We can find a basis of solutions by making the Ansatz $p(n) = x^{-n}$, where $x$ is TBD. Plugging that into the recursion equation and simplifying a bit we find
$$m-1 = \sum_{i=2}^{m-1} x^i$$
This is sometimes called the characteristic equation of the chain.
It is a polynomial equation of degree $m-1$ so it has $m-1$ solutions.
Unfortunately there's no closed form expression for these solutions, but we can very easily compute them numerically. Let's call the solutions $x_\alpha$, where $\alpha = 1, 2, \cdots, m-1$. Then the general solution to the recursion equation is
$$ p(n) = \sum_{\alpha=1}^{m-1} w_\alpha x_\alpha ^{-n} $$
with any coefficients $w_\alpha$.
We're almost there now... all we need is to determine the $w_\alpha$.
To do that, we compute the first $m-1$ values of the sequence $p(n)$ "manually", and then solve the linear system of equations
$$ p(n) = \sum_{\alpha=1}^{m-1} w_\alpha x_\alpha ^{-n} \quad \text{for } n = 1, \cdots , m-1$$ .
This amounts to a matrix inversion, and again can be done numerically.
Finally, having determined the $x_\alpha$ from the chain dynamics and the $w_\alpha$ from the initial conditions, we can compute the desired number as
$$ p(250) = \sum_{\alpha=1}^{m-1} w_\alpha x_\alpha ^{-250} $$.
Here's how this would look like in python
>>> import numpy as np
>>> import pandas as pd
>>> m = 20
>>> characteristic_polynomial = np.polynomial.Polynomial((1 - m, 0) + (1, ) * (m - 2))
>>> characteristic_roots = characteristic_polynomial.roots()
>>> starting_values = np.ones(2 * m - 1)
>>> for i in range(m + 1, 2 * m - 1):
>>> starting_values[i] = starting_values[i-m+1:i-1].sum() / (m - 1)
>>> starting_values = starting_values[m:]
>>> basis_matrix = characteristic_roots[:, None] ** (-np.arange(m-1))
>>> coefficients = starting_values @ np.linalg.inv(basis_matrix)
>>> np.real_if_close(coefficients @ (characteristic_roots ** (-250)))
0.26988043
We can just as easily generate the values for a range of $n$
>>> result = coefficients @ (characteristic_roots[:, None] ** (-np.arange(300)))
>>> pd.Series(np.real_if_close(result)).plot()
|
Probability of defeating a dragon in one turn rolling a 20 sided die
|
Here's an approach that uses ideas from Markov chains & generating functions.
Plan: We'll construct the recursion relation for the probabilities in question, and then apply techniques from linear alge
|
Probability of defeating a dragon in one turn rolling a 20 sided die
Here's an approach that uses ideas from Markov chains & generating functions.
Plan: We'll construct the recursion relation for the probabilities in question, and then apply techniques from linear algebra to solve it. (The nice feature of this approach is that its computational complexity is independent of how many health points the dragon has... so no matter if the dragon has 250 or 250 million points we do the same amount of computation. This is not the case for the other approaches here.)
We could jump right to the recursion formula, but let's warm up and motivate it by setting up the Markov chain it follows from.
Our Markov chain lives on the state space spanned by two types of sates
$ | 0 \rangle , | 1 \rangle , | 2 \rangle , \cdots$ denoting that the dragon has $n$ health points and we're still alive
$ | \ast \rangle $ denoting that we're dead.
The Markov transition matrix is defined via
$$ T | n \rangle = \frac{1}{m}| \ast \rangle + \frac{1}{m} \sum_{i=2}^{m-1} | n - i\rangle + \frac{1}{m} | n \rangle $$
$$ T | 0 \rangle = | 0 \rangle$$
where we $m$ is the number of faces, i.e. $m=20$.
We win, and the chain terminates, once we've taken all the dragon's life points, i.e. once the Markov chain reaches any state $ |n \rangle $ with $ n \leq 0$.
Let's call the probability of defeating a dragon with $n$ health points $p(n)$.
Now, after one roll of the die, we might either
be dead, and our combo is over, so our chance of winning is 0
still be alive, and now we're in a similar situation as before, just that we're facing a dragon with $n-i$ health points if we health $i$ damage. In this case, from here on our chance of winning is $p(n-i)$
We can translate this into the equation
$$ p(n) = \frac{1}{m} \cdot 0 + \frac{1}{m} \sum_{i=2}^{m-1} p( n - i ) + \frac{1}{m} p( n ) $$
with the initial conditions $p(n) = 1$ for $n \leq 0$. Notice the structural similarity to the transition matrix equation... this is of course no coincidence.
Re-arranging that equation a bit we arrive at
$$ p(n) = \frac{1}{m-1} \sum_{i=2}^{m-1} p( n - i ) $$
If we could solve this recursion relation, then our answer would be $p(250)$.
There a many ways to solve this equation, for example explicitly unrolling the recursion, but that would take $O(n)$ steps of computation.
Since this equation is linear, we can do better.
All solutions of linear recursion equations are linear combinations of exponentials. (Note that all Markov chains give rise to linear recursion equations... this is ultimately why Markov chains are powerful.)
We can find a basis of solutions by making the Ansatz $p(n) = x^{-n}$, where $x$ is TBD. Plugging that into the recursion equation and simplifying a bit we find
$$m-1 = \sum_{i=2}^{m-1} x^i$$
This is sometimes called the characteristic equation of the chain.
It is a polynomial equation of degree $m-1$ so it has $m-1$ solutions.
Unfortunately there's no closed form expression for these solutions, but we can very easily compute them numerically. Let's call the solutions $x_\alpha$, where $\alpha = 1, 2, \cdots, m-1$. Then the general solution to the recursion equation is
$$ p(n) = \sum_{\alpha=1}^{m-1} w_\alpha x_\alpha ^{-n} $$
with any coefficients $w_\alpha$.
We're almost there now... all we need is to determine the $w_\alpha$.
To do that, we compute the first $m-1$ values of the sequence $p(n)$ "manually", and then solve the linear system of equations
$$ p(n) = \sum_{\alpha=1}^{m-1} w_\alpha x_\alpha ^{-n} \quad \text{for } n = 1, \cdots , m-1$$ .
This amounts to a matrix inversion, and again can be done numerically.
Finally, having determined the $x_\alpha$ from the chain dynamics and the $w_\alpha$ from the initial conditions, we can compute the desired number as
$$ p(250) = \sum_{\alpha=1}^{m-1} w_\alpha x_\alpha ^{-250} $$.
Here's how this would look like in python
>>> import numpy as np
>>> import pandas as pd
>>> m = 20
>>> characteristic_polynomial = np.polynomial.Polynomial((1 - m, 0) + (1, ) * (m - 2))
>>> characteristic_roots = characteristic_polynomial.roots()
>>> starting_values = np.ones(2 * m - 1)
>>> for i in range(m + 1, 2 * m - 1):
>>> starting_values[i] = starting_values[i-m+1:i-1].sum() / (m - 1)
>>> starting_values = starting_values[m:]
>>> basis_matrix = characteristic_roots[:, None] ** (-np.arange(m-1))
>>> coefficients = starting_values @ np.linalg.inv(basis_matrix)
>>> np.real_if_close(coefficients @ (characteristic_roots ** (-250)))
0.26988043
We can just as easily generate the values for a range of $n$
>>> result = coefficients @ (characteristic_roots[:, None] ** (-np.arange(300)))
>>> pd.Series(np.real_if_close(result)).plot()
|
Probability of defeating a dragon in one turn rolling a 20 sided die
Here's an approach that uses ideas from Markov chains & generating functions.
Plan: We'll construct the recursion relation for the probabilities in question, and then apply techniques from linear alge
|
11,515
|
What's the formula for the Benjamini-Hochberg adjusted p-value?
|
The famous seminal Benjamini & Hochberg (1995) paper described the procedure for accepting/rejecting hypotheses based on adjusting the alpha levels. This procedure has a straightforward equivalent reformulation in terms of adjusted $p$-values, but it was not discussed in the original paper. According to Gordon Smyth, he introduced adjusted $p$-values in 2002 when implementing p.adjust in R. Unfortunately, there is no corresponding citation, so it has always been unclear to me what one should cite if one uses BH-adjusted $p$-values.
Turns out, the procedure is described in the Benjamini, Heller, Yekutieli (2009):
An alternative way of presenting the results of this procedure is by presenting the adjusted $p$-values. The BH-adjusted $p$-values are defined as $$p^\mathrm{BH}_{(i)} = \min\Big\{\min_{j\ge i}\big\{\frac{mp_{(j)}}{j}\big\},1\Big\}.$$
This formula looks more complicated than it really is. It says:
First, order all $p$-values from small to large. Then multiply each $p$-value by the total number of tests $m$ and divide by its rank order.
Second, make sure that the resulting sequence is non-decreasing: if it ever starts decreasing, make the preceding $p$-value equal to the subsequent (repeatedly, until the whole sequence becomes non-decreasing).
If any $p$-value ends up larger than 1, make it equal to 1.
This is a straightforward reformulation of the original BH procedure from 1995. There might exist an earlier paper that explicitly introduced the concept of BH-adjusted $p$-values, but I am not aware of any.
Update. @Zenit found that Yekutieli & Benjamini (1999) described the same thing already back in 1999:
|
What's the formula for the Benjamini-Hochberg adjusted p-value?
|
The famous seminal Benjamini & Hochberg (1995) paper described the procedure for accepting/rejecting hypotheses based on adjusting the alpha levels. This procedure has a straightforward equivalent ref
|
What's the formula for the Benjamini-Hochberg adjusted p-value?
The famous seminal Benjamini & Hochberg (1995) paper described the procedure for accepting/rejecting hypotheses based on adjusting the alpha levels. This procedure has a straightforward equivalent reformulation in terms of adjusted $p$-values, but it was not discussed in the original paper. According to Gordon Smyth, he introduced adjusted $p$-values in 2002 when implementing p.adjust in R. Unfortunately, there is no corresponding citation, so it has always been unclear to me what one should cite if one uses BH-adjusted $p$-values.
Turns out, the procedure is described in the Benjamini, Heller, Yekutieli (2009):
An alternative way of presenting the results of this procedure is by presenting the adjusted $p$-values. The BH-adjusted $p$-values are defined as $$p^\mathrm{BH}_{(i)} = \min\Big\{\min_{j\ge i}\big\{\frac{mp_{(j)}}{j}\big\},1\Big\}.$$
This formula looks more complicated than it really is. It says:
First, order all $p$-values from small to large. Then multiply each $p$-value by the total number of tests $m$ and divide by its rank order.
Second, make sure that the resulting sequence is non-decreasing: if it ever starts decreasing, make the preceding $p$-value equal to the subsequent (repeatedly, until the whole sequence becomes non-decreasing).
If any $p$-value ends up larger than 1, make it equal to 1.
This is a straightforward reformulation of the original BH procedure from 1995. There might exist an earlier paper that explicitly introduced the concept of BH-adjusted $p$-values, but I am not aware of any.
Update. @Zenit found that Yekutieli & Benjamini (1999) described the same thing already back in 1999:
|
What's the formula for the Benjamini-Hochberg adjusted p-value?
The famous seminal Benjamini & Hochberg (1995) paper described the procedure for accepting/rejecting hypotheses based on adjusting the alpha levels. This procedure has a straightforward equivalent ref
|
11,516
|
What's the formula for the Benjamini-Hochberg adjusted p-value?
|
First a to the point answer. Consider that $p_0$ is the (single test) $p$ value associated with value $z_0$ of the test statistic. The Benjamini-Hochberg FDR is computed in two steps ($N_0$ = # pvalues $\le$ $p_0$, $N$ = # pvalues):
$\text{FDR }(p_0) = \frac{\quad p_0 \quad }{\frac{N_0}{N}}$
$\text{FDR }(p_i) = \min (\text{FDR}(p_i), \text{FDR}(p_{i+1}))$
Now let's understand this.
The (Bayesian) underlying idea is that observations come from a mixture of two distributions:
$\pi_0 \: N$ observations from the null density $f_0(z)$
$(1-\pi_0) \: N$ observations from alternative density $f_1(z)$.
What is observed is the mixture of those two:
$f(z) = \pi_0 \cdot f_0(z) + (1-\pi_0) \cdot f_1(z)$
The (Bayesian) definitions are:
$\text{Fdr} = \frac{\pi_0 \: (1-F_0(z_0))}{(1-F(z))}$ (a fraction of the tail areas)
$\text{fdr} = \frac{\pi_0 \: f_0(z_0)}{f(z)}$ (a fraction of the tail densities)
As shown below, Fdr is equivalent to the Benjamini hocherg FDR when $\pi_0 \approx 1$ (which is the case in most bioinformatics studies)
(Based on Efron & Tibshirani's Computer Age Statistical Inference)
|
What's the formula for the Benjamini-Hochberg adjusted p-value?
|
First a to the point answer. Consider that $p_0$ is the (single test) $p$ value associated with value $z_0$ of the test statistic. The Benjamini-Hochberg FDR is computed in two steps ($N_0$ = # pvalue
|
What's the formula for the Benjamini-Hochberg adjusted p-value?
First a to the point answer. Consider that $p_0$ is the (single test) $p$ value associated with value $z_0$ of the test statistic. The Benjamini-Hochberg FDR is computed in two steps ($N_0$ = # pvalues $\le$ $p_0$, $N$ = # pvalues):
$\text{FDR }(p_0) = \frac{\quad p_0 \quad }{\frac{N_0}{N}}$
$\text{FDR }(p_i) = \min (\text{FDR}(p_i), \text{FDR}(p_{i+1}))$
Now let's understand this.
The (Bayesian) underlying idea is that observations come from a mixture of two distributions:
$\pi_0 \: N$ observations from the null density $f_0(z)$
$(1-\pi_0) \: N$ observations from alternative density $f_1(z)$.
What is observed is the mixture of those two:
$f(z) = \pi_0 \cdot f_0(z) + (1-\pi_0) \cdot f_1(z)$
The (Bayesian) definitions are:
$\text{Fdr} = \frac{\pi_0 \: (1-F_0(z_0))}{(1-F(z))}$ (a fraction of the tail areas)
$\text{fdr} = \frac{\pi_0 \: f_0(z_0)}{f(z)}$ (a fraction of the tail densities)
As shown below, Fdr is equivalent to the Benjamini hocherg FDR when $\pi_0 \approx 1$ (which is the case in most bioinformatics studies)
(Based on Efron & Tibshirani's Computer Age Statistical Inference)
|
What's the formula for the Benjamini-Hochberg adjusted p-value?
First a to the point answer. Consider that $p_0$ is the (single test) $p$ value associated with value $z_0$ of the test statistic. The Benjamini-Hochberg FDR is computed in two steps ($N_0$ = # pvalue
|
11,517
|
Jackknife vs. LOOCV
|
In cross-validation you compute a statistic on the left-out sample(s). Most often, you predict the left-out sample(s) by a model built on the kept samples. In jackknifing, you compute a statistic from the kept samples only.
|
Jackknife vs. LOOCV
|
In cross-validation you compute a statistic on the left-out sample(s). Most often, you predict the left-out sample(s) by a model built on the kept samples. In jackknifing, you compute a statistic from
|
Jackknife vs. LOOCV
In cross-validation you compute a statistic on the left-out sample(s). Most often, you predict the left-out sample(s) by a model built on the kept samples. In jackknifing, you compute a statistic from the kept samples only.
|
Jackknife vs. LOOCV
In cross-validation you compute a statistic on the left-out sample(s). Most often, you predict the left-out sample(s) by a model built on the kept samples. In jackknifing, you compute a statistic from
|
11,518
|
Jackknife vs. LOOCV
|
Jackknife often refers to 2 related but different processes, both of which rely on a leave-one-out approach -- leading to this very confusion.
In one context, jackknife can be used to estimate population parameters and their standards errors. For example, to use a jackknife approach to estimate the slope and intercept of a simple regression model one would:
Estimate the slope and intercept using all available data.
Leave out 1 observation and estimate the slope and intercept (also known as the "partial estimate" of the coefficients).
Calculate the difference between the "partial estimate" and the "all data" estimate of the slope and the intercept (also know as the "pseudo value" of the coefficients).
Repeat steps 2 & 3 for the entire data set.
Compute the mean of the pseudo values for each coefficient -- these are the jackknife estimates of the slope and intercept
The pseudo values and the jackknife estimates of the coefficients can also be used to determine the standard errors and thus confidence intervals. Typically this approach gives wider confidence intervals for the coefficients because it's a better, more conservative, measure of uncertainty. Also, this approach can be used to get a jackknife estimate of bias for the coefficients too.
In the other context, jackknife is used to evaluate model performance. In this case jackknife = leave-one-out cross validation. Both refer to leaving one observation out of the calibration data set, recalibrating the model, and predicting the observation that was left out. Essentially, each observation is being predicted using its "partial estimates" of the predictors.
Here's a nice little write-up about jackknife I found online:
https://www.utdallas.edu/~herve/abdi-Jackknife2010-pretty.pdf
|
Jackknife vs. LOOCV
|
Jackknife often refers to 2 related but different processes, both of which rely on a leave-one-out approach -- leading to this very confusion.
In one context, jackknife can be used to estimate populat
|
Jackknife vs. LOOCV
Jackknife often refers to 2 related but different processes, both of which rely on a leave-one-out approach -- leading to this very confusion.
In one context, jackknife can be used to estimate population parameters and their standards errors. For example, to use a jackknife approach to estimate the slope and intercept of a simple regression model one would:
Estimate the slope and intercept using all available data.
Leave out 1 observation and estimate the slope and intercept (also known as the "partial estimate" of the coefficients).
Calculate the difference between the "partial estimate" and the "all data" estimate of the slope and the intercept (also know as the "pseudo value" of the coefficients).
Repeat steps 2 & 3 for the entire data set.
Compute the mean of the pseudo values for each coefficient -- these are the jackknife estimates of the slope and intercept
The pseudo values and the jackknife estimates of the coefficients can also be used to determine the standard errors and thus confidence intervals. Typically this approach gives wider confidence intervals for the coefficients because it's a better, more conservative, measure of uncertainty. Also, this approach can be used to get a jackknife estimate of bias for the coefficients too.
In the other context, jackknife is used to evaluate model performance. In this case jackknife = leave-one-out cross validation. Both refer to leaving one observation out of the calibration data set, recalibrating the model, and predicting the observation that was left out. Essentially, each observation is being predicted using its "partial estimates" of the predictors.
Here's a nice little write-up about jackknife I found online:
https://www.utdallas.edu/~herve/abdi-Jackknife2010-pretty.pdf
|
Jackknife vs. LOOCV
Jackknife often refers to 2 related but different processes, both of which rely on a leave-one-out approach -- leading to this very confusion.
In one context, jackknife can be used to estimate populat
|
11,519
|
How does neural network recognise images?
|
A major insight into how a neural network can learn to classify something as complex as image data given just examples and correct answers came to me while studying the work of Professor Kunihiko Fukushima on the neocognitrion in the 1980's. Instead of just showing his network a bunch of images, and using back-propagation to let it figure things on it's own, he took a different approach and trained his network layer by layer, and even node by node. He analyzed the performance and operation of each individual node of the network and intentionally modified those parts to make them respond in intended ways.
For instance, he knew he wanted the network to be able to recognize lines, so he trained specific layers and nodes to recognize three pixel horizontal lines, 3 pixel vertical lines and specific variations of diagonal lines at all angles. By doing this, he knew exactly which parts of the network could be counted on to fire when the desired patterns existed. Then, since each layer is highly connected, the entire neocognitron as a whole could identify each of the composite parts present in the image no matter where they physically existed. So when a specific line segment existed somewhere in the image, there would always be a specific node that would fire.
Keeping this picture ever present, consider linear regression which is simply finding a formula ( or a line) via sum of squared error, that passes most closely through your data, that's easy enough to understand. To find curved "lines" we can do the same sum of products calculation, except now we add a few parameters of x^2 or x^3 or even higher order polynomials. Now you have a logistic regression classifier. This classifier can find relationships that are not linear in nature. In fact logistic regression can express relationships that are arbitrarily complex, but you still need to manually choose the correct number of power features to do a good job at predicting the data.
One way to think of the neural network is to consider the last layer as a logistic regression classifier, and then the hidden layers can be thought of as automatic "feature selectors". This eliminates the work of manually choosing the correct number of, and power of, the input features. Thus, the NN becomes an automatic power feature selector and can find any linear or non-linear relationship or serve as a classifier of arbitrarily complex sets** (this, assumes only, that there are enough hidden layers and connections to represent the complexity of the model it needs to learn). In the end, a well functioning NN is expected to learn not just "the relationship" between the input and outputs, but instead we strive for an abstraction or a model that generalizes well.
As a rule of thumb, the neural network can not learn anything a reasonably intelligent human could not theoretically learn given enough time from the same data, however,
it may be able to learn somethings no one has figured out yet
for large problems a bank of computers processing neural networks can find really good solutions much faster than a team of people (at a much lower cost)
once trained NNs will produce consitsent results with the inputs they've been trained on and should generalize well if tweaked properly
NN's never get bored or distracted
|
How does neural network recognise images?
|
A major insight into how a neural network can learn to classify something as complex as image data given just examples and correct answers came to me while studying the work of Professor Kunihiko Fuku
|
How does neural network recognise images?
A major insight into how a neural network can learn to classify something as complex as image data given just examples and correct answers came to me while studying the work of Professor Kunihiko Fukushima on the neocognitrion in the 1980's. Instead of just showing his network a bunch of images, and using back-propagation to let it figure things on it's own, he took a different approach and trained his network layer by layer, and even node by node. He analyzed the performance and operation of each individual node of the network and intentionally modified those parts to make them respond in intended ways.
For instance, he knew he wanted the network to be able to recognize lines, so he trained specific layers and nodes to recognize three pixel horizontal lines, 3 pixel vertical lines and specific variations of diagonal lines at all angles. By doing this, he knew exactly which parts of the network could be counted on to fire when the desired patterns existed. Then, since each layer is highly connected, the entire neocognitron as a whole could identify each of the composite parts present in the image no matter where they physically existed. So when a specific line segment existed somewhere in the image, there would always be a specific node that would fire.
Keeping this picture ever present, consider linear regression which is simply finding a formula ( or a line) via sum of squared error, that passes most closely through your data, that's easy enough to understand. To find curved "lines" we can do the same sum of products calculation, except now we add a few parameters of x^2 or x^3 or even higher order polynomials. Now you have a logistic regression classifier. This classifier can find relationships that are not linear in nature. In fact logistic regression can express relationships that are arbitrarily complex, but you still need to manually choose the correct number of power features to do a good job at predicting the data.
One way to think of the neural network is to consider the last layer as a logistic regression classifier, and then the hidden layers can be thought of as automatic "feature selectors". This eliminates the work of manually choosing the correct number of, and power of, the input features. Thus, the NN becomes an automatic power feature selector and can find any linear or non-linear relationship or serve as a classifier of arbitrarily complex sets** (this, assumes only, that there are enough hidden layers and connections to represent the complexity of the model it needs to learn). In the end, a well functioning NN is expected to learn not just "the relationship" between the input and outputs, but instead we strive for an abstraction or a model that generalizes well.
As a rule of thumb, the neural network can not learn anything a reasonably intelligent human could not theoretically learn given enough time from the same data, however,
it may be able to learn somethings no one has figured out yet
for large problems a bank of computers processing neural networks can find really good solutions much faster than a team of people (at a much lower cost)
once trained NNs will produce consitsent results with the inputs they've been trained on and should generalize well if tweaked properly
NN's never get bored or distracted
|
How does neural network recognise images?
A major insight into how a neural network can learn to classify something as complex as image data given just examples and correct answers came to me while studying the work of Professor Kunihiko Fuku
|
11,520
|
How does neural network recognise images?
|
You may have heard it said that neural networks are "universal function approximators". In essence, the Cybenko theorem says that for any function mapping reals to reals, you can approximate it with a neural network with sigmoid activation functions. In fact, it turns out that neural networks allow you to compute any function which is computable by a Turing machine (ie anything you can write an algorithm to compute). Unfortunately, these proofs only say that for some finite configuration of neurons and weights, you can approximate any function.
The theory is all nice and dandy, but your question seems to be more along the lines of how to actually encode the computation of some function into a set of neurons and weights. To illustrate, consider a simple example - the exclusive-or. The XOR takes two inputs, passes those inputs. When one and only one of the inputs are activated, then the output node is activated. With both or none of the inputs are activated, then the output node is not activated.
Notice that the three hidden nodes do different things. The left most and right most nodes simply pass through the respect input nodes activations. The middle neuron takes the two inputs and somehow negates them if they are both on. This clever combining and recombining of inputs is essentially how work in a neural network is done.
Obviously for more complex functions the combining and recombining must be done in more clever and complicated ways, but this is in essence what happens at a low level. The crazy thing is that this is really all you need to compute any computable function! Then again, turing machines also turn out to be deceptively simple...
The problem is that we don't really have a way to magically generate the neural network which computes some arbitrary function. The proofs only tell us that there is some network out there that could do it. When we train our neural networks, we are simply trying to find a network which is pretty close.
In the context of image recognition, you could imagine encoding patterns into the network. For example, to recognize the number '1', you could imagine a hidden nodes which expect a column of pixels to be mostly or all activated, with neighboring pixels to be off. This hidden node could be fairly good at recognizing a straight line in that particular column. Put enough of these together and pretty soon you've got a bunch of nodes that do it in enough places of your image that if I show the network a one, enough straight line hidden nodes will be activated, indicating a '1'. The problem of course become generalizing the network so it can recognize a varied set of inputs.
Hopefully this helps you understand more or less the concepts of how a neural network can perform computations. However, you've hit upon a point which is rather important about neural networks: in general it is difficult at best to understand why the network spit out a particular output, especially when you consider that for something like image recognition, the networks are generally big enough that humans have a tough time comprehending each of the moving parts of the machine. Further complicating the matter is that in general most neural networks do not actually have a single hidden node for each little feature the network could learn about the data. Instead, detecting something like a straight line to classify the number '1' would take place in a non-centralized manner over many hidden nodes. Other algorithms, such as decision trees, are much nicer in this respect.
If you are looking for more reading, I highly recommend reading through this tutorial over at ai junkie. It walks you through the basics of how a neural network works, and even gives a simple code example getting neural networks to drive a tank towards a goal. The tutorial does not however cover backpropagation, which is by far the most common way of training neural networks, and instead uses a simple genetic algorithm. Once he starts talking genetics, I guess you can stop reading...
|
How does neural network recognise images?
|
You may have heard it said that neural networks are "universal function approximators". In essence, the Cybenko theorem says that for any function mapping reals to reals, you can approximate it with a
|
How does neural network recognise images?
You may have heard it said that neural networks are "universal function approximators". In essence, the Cybenko theorem says that for any function mapping reals to reals, you can approximate it with a neural network with sigmoid activation functions. In fact, it turns out that neural networks allow you to compute any function which is computable by a Turing machine (ie anything you can write an algorithm to compute). Unfortunately, these proofs only say that for some finite configuration of neurons and weights, you can approximate any function.
The theory is all nice and dandy, but your question seems to be more along the lines of how to actually encode the computation of some function into a set of neurons and weights. To illustrate, consider a simple example - the exclusive-or. The XOR takes two inputs, passes those inputs. When one and only one of the inputs are activated, then the output node is activated. With both or none of the inputs are activated, then the output node is not activated.
Notice that the three hidden nodes do different things. The left most and right most nodes simply pass through the respect input nodes activations. The middle neuron takes the two inputs and somehow negates them if they are both on. This clever combining and recombining of inputs is essentially how work in a neural network is done.
Obviously for more complex functions the combining and recombining must be done in more clever and complicated ways, but this is in essence what happens at a low level. The crazy thing is that this is really all you need to compute any computable function! Then again, turing machines also turn out to be deceptively simple...
The problem is that we don't really have a way to magically generate the neural network which computes some arbitrary function. The proofs only tell us that there is some network out there that could do it. When we train our neural networks, we are simply trying to find a network which is pretty close.
In the context of image recognition, you could imagine encoding patterns into the network. For example, to recognize the number '1', you could imagine a hidden nodes which expect a column of pixels to be mostly or all activated, with neighboring pixels to be off. This hidden node could be fairly good at recognizing a straight line in that particular column. Put enough of these together and pretty soon you've got a bunch of nodes that do it in enough places of your image that if I show the network a one, enough straight line hidden nodes will be activated, indicating a '1'. The problem of course become generalizing the network so it can recognize a varied set of inputs.
Hopefully this helps you understand more or less the concepts of how a neural network can perform computations. However, you've hit upon a point which is rather important about neural networks: in general it is difficult at best to understand why the network spit out a particular output, especially when you consider that for something like image recognition, the networks are generally big enough that humans have a tough time comprehending each of the moving parts of the machine. Further complicating the matter is that in general most neural networks do not actually have a single hidden node for each little feature the network could learn about the data. Instead, detecting something like a straight line to classify the number '1' would take place in a non-centralized manner over many hidden nodes. Other algorithms, such as decision trees, are much nicer in this respect.
If you are looking for more reading, I highly recommend reading through this tutorial over at ai junkie. It walks you through the basics of how a neural network works, and even gives a simple code example getting neural networks to drive a tank towards a goal. The tutorial does not however cover backpropagation, which is by far the most common way of training neural networks, and instead uses a simple genetic algorithm. Once he starts talking genetics, I guess you can stop reading...
|
How does neural network recognise images?
You may have heard it said that neural networks are "universal function approximators". In essence, the Cybenko theorem says that for any function mapping reals to reals, you can approximate it with a
|
11,521
|
How does neural network recognise images?
|
That what confused you is
how it learns about what's in an image.
What is in an image is digitally represented by the values in the image's pixels. If you take an example of color in the image. The pixel may have three values, each for the three main colors - Red, Green and Blue (RGB). A pixel with (10,50,100) means it has 'less' blue color elements than a pixel with (40,50,100). Thus, in the image the first pixel represent a region with less color blue. This is the information the neural network learns, from one location/region of the image to the other and ends up 'knowing' what is in the image. The same principle is applied for other image features (besides color) that may be used as input to neural network. See this,and this for basic image concepts and then move to this to learn how neural network work.
|
How does neural network recognise images?
|
That what confused you is
how it learns about what's in an image.
What is in an image is digitally represented by the values in the image's pixels. If you take an example of color in the image. The
|
How does neural network recognise images?
That what confused you is
how it learns about what's in an image.
What is in an image is digitally represented by the values in the image's pixels. If you take an example of color in the image. The pixel may have three values, each for the three main colors - Red, Green and Blue (RGB). A pixel with (10,50,100) means it has 'less' blue color elements than a pixel with (40,50,100). Thus, in the image the first pixel represent a region with less color blue. This is the information the neural network learns, from one location/region of the image to the other and ends up 'knowing' what is in the image. The same principle is applied for other image features (besides color) that may be used as input to neural network. See this,and this for basic image concepts and then move to this to learn how neural network work.
|
How does neural network recognise images?
That what confused you is
how it learns about what's in an image.
What is in an image is digitally represented by the values in the image's pixels. If you take an example of color in the image. The
|
11,522
|
How does neural network recognise images?
|
All the machine learning problems are same. You have some train data, learn a model that represent this data and have ability to generalize this knowledge in that way you cluster,classify, learn with different algorithms.
In Image recognition you have again a set of images you want to to learn about.
These images firstly processed and some features are extracted from images (lots of possible image feature schemes like SIFT, Bag of WORDS) like you use pixels and their values.
Give these images with corresponding feature vectors to your ML algorithm (Neural Net, SVM or others).
Learn a model
Use this model to recognize objects that are seen sufficiently on training data.
If you want to recognize more than one thing, use multiple classifier for each.
|
How does neural network recognise images?
|
All the machine learning problems are same. You have some train data, learn a model that represent this data and have ability to generalize this knowledge in that way you cluster,classify, learn with
|
How does neural network recognise images?
All the machine learning problems are same. You have some train data, learn a model that represent this data and have ability to generalize this knowledge in that way you cluster,classify, learn with different algorithms.
In Image recognition you have again a set of images you want to to learn about.
These images firstly processed and some features are extracted from images (lots of possible image feature schemes like SIFT, Bag of WORDS) like you use pixels and their values.
Give these images with corresponding feature vectors to your ML algorithm (Neural Net, SVM or others).
Learn a model
Use this model to recognize objects that are seen sufficiently on training data.
If you want to recognize more than one thing, use multiple classifier for each.
|
How does neural network recognise images?
All the machine learning problems are same. You have some train data, learn a model that represent this data and have ability to generalize this knowledge in that way you cluster,classify, learn with
|
11,523
|
How does neural network recognise images?
|
I would also like to mention very popular for image recognition convolutional neural networks.
Here is a link to simplified explanation of a CNN.
Briefly, in CNN image is first split into features, like edges, shapes, collections of shapes. Then these features are 'fed' into a 'regular' fully-connected multi-layer neural network (multi-layer perceptron).
In more details, a set of filters are applied to extract features in a form of a feature map. A filter is just a matrix (random in the beginning) that is applied to the original image so that dot product of the original image matrix and filter matrix is calculated and the result is summed up. Filter moves along the original image one pixel (the step) at a time and the matrix of feature map is being filled. A feature map is created for each filter. Then non-linearity introduced with RELU(Rectified Linear Unit) for each pixel in each feature map. Pooling, through application of either max(), sum() or average(), is done after convolution. Finally, features extracted this way look like 'magnified' pieces of the original image. These features are input into a fully connected (all units are connected) neural network and the probabilities for each image (lets say we trained our network on images of cars, trees and boats) are calculated after each feedforward pass through the network. The network is trained, which means that the parameters(weights) and filter matrices are optimized through backpropagation (minimization of misclassification error). When a new image is input into the trained network only feedforward is needed to identify the image (provided that the network is accurate enough, i.e. we trained it with enough examples etc.)
|
How does neural network recognise images?
|
I would also like to mention very popular for image recognition convolutional neural networks.
Here is a link to simplified explanation of a CNN.
Briefly, in CNN image is first split into features, li
|
How does neural network recognise images?
I would also like to mention very popular for image recognition convolutional neural networks.
Here is a link to simplified explanation of a CNN.
Briefly, in CNN image is first split into features, like edges, shapes, collections of shapes. Then these features are 'fed' into a 'regular' fully-connected multi-layer neural network (multi-layer perceptron).
In more details, a set of filters are applied to extract features in a form of a feature map. A filter is just a matrix (random in the beginning) that is applied to the original image so that dot product of the original image matrix and filter matrix is calculated and the result is summed up. Filter moves along the original image one pixel (the step) at a time and the matrix of feature map is being filled. A feature map is created for each filter. Then non-linearity introduced with RELU(Rectified Linear Unit) for each pixel in each feature map. Pooling, through application of either max(), sum() or average(), is done after convolution. Finally, features extracted this way look like 'magnified' pieces of the original image. These features are input into a fully connected (all units are connected) neural network and the probabilities for each image (lets say we trained our network on images of cars, trees and boats) are calculated after each feedforward pass through the network. The network is trained, which means that the parameters(weights) and filter matrices are optimized through backpropagation (minimization of misclassification error). When a new image is input into the trained network only feedforward is needed to identify the image (provided that the network is accurate enough, i.e. we trained it with enough examples etc.)
|
How does neural network recognise images?
I would also like to mention very popular for image recognition convolutional neural networks.
Here is a link to simplified explanation of a CNN.
Briefly, in CNN image is first split into features, li
|
11,524
|
How does neural network recognise images?
|
It's good to know ANN can create any function f(x) or f(x,y,z,..) or any multifunction for that matter. But it's also important to know that functions have limits in how they can classify data...there are more complex relations subsets of powersets of objects, which are important in classification and these are not described by such functions in an elegant or natural way, but are important in language and classifying objects. ANN can accomplish this however as well.
|
How does neural network recognise images?
|
It's good to know ANN can create any function f(x) or f(x,y,z,..) or any multifunction for that matter. But it's also important to know that functions have limits in how they can classify data...ther
|
How does neural network recognise images?
It's good to know ANN can create any function f(x) or f(x,y,z,..) or any multifunction for that matter. But it's also important to know that functions have limits in how they can classify data...there are more complex relations subsets of powersets of objects, which are important in classification and these are not described by such functions in an elegant or natural way, but are important in language and classifying objects. ANN can accomplish this however as well.
|
How does neural network recognise images?
It's good to know ANN can create any function f(x) or f(x,y,z,..) or any multifunction for that matter. But it's also important to know that functions have limits in how they can classify data...ther
|
11,525
|
How can I estimate coefficient standard errors when using ridge regression?
|
I think boostrap would the best option to obtain robust SEs. This was done in some applied work using shrinkage methods, e.g. Analysis of North American Rheumatoid Arthritis Consortium data using a penalized logistic regression approach (BMC Proceedings 2009).
There is also a nice paper from Casella on SE computation with penalized model, Penalized Regression, Standard Errors, and Bayesian Lassos (Bayesian Analysis 2010 5(2)). But they are more concerned with lasso and elasticnet penalization.
I always thought of ridge regression as a way to get better predictions than standard OLS, where the model is generally not parcimonious. For variable selection, the lasso or elasticnet criteria are more appropriate, but then it is difficult to apply a bootstrap procedure (since selected variables would change from one sample to the other, and even in the inner $k$-fold loop used to optimize the $\ell_1$/$\ell_2$ parameters); this is not the case with ridge regression, since you always consider all variables.
I have no idea about R packages that would give this information. It doesn't seem to be available in the glmnet package (see Friedman's paper in JSS, Regularization Paths for Generalized Linear Models via Coordinate Descent).
However, Jelle Goeman who authored the penalized package discuss this point too. Cannot find the original PDF on the web, so I simply quote his words:
It is a very natural question to ask
for standard errors of regression
coefficients or other estimated
quantities. In principle such standard
errors can easily be calculated, e.g.
using the bootstrap.
Still, this
package deliberately does not provide
them. The reason for this is that
standard errors are not very
meaningful for strongly biased
estimates such as arise from penalized
estimation methods. Penalized
estimation is a procedure that reduces
the variance of estimators by
introducing substantial bias. The bias
of each estimator is therefore a major
component of its mean squared error,
whereas its variance may contribute
only a small part.
Unfortunately, in
most applications of penalized
regression it is impossible to obtain
a sufficiently precise estimate of the
bias. Any bootstrap-based cal-
culations can only give an assessment
of the variance of the estimates.
Reliable estimates of the bias are
only available if reliable unbiased
estimates are available, which is
typically not the case in situations
in which penalized estimates are used.
Reporting a standard error of a
penalized estimate therefore tells
only part of the story. It can give a
mistaken impression of great
precision, completely ignoring the
inaccuracy caused by the bias. It is
certainly a mistake to make confidence
statements that are only based on an
assessment of the variance of the
estimates, such as bootstrap-based
confidence intervals do.
|
How can I estimate coefficient standard errors when using ridge regression?
|
I think boostrap would the best option to obtain robust SEs. This was done in some applied work using shrinkage methods, e.g. Analysis of North American Rheumatoid Arthritis Consortium data using a pe
|
How can I estimate coefficient standard errors when using ridge regression?
I think boostrap would the best option to obtain robust SEs. This was done in some applied work using shrinkage methods, e.g. Analysis of North American Rheumatoid Arthritis Consortium data using a penalized logistic regression approach (BMC Proceedings 2009).
There is also a nice paper from Casella on SE computation with penalized model, Penalized Regression, Standard Errors, and Bayesian Lassos (Bayesian Analysis 2010 5(2)). But they are more concerned with lasso and elasticnet penalization.
I always thought of ridge regression as a way to get better predictions than standard OLS, where the model is generally not parcimonious. For variable selection, the lasso or elasticnet criteria are more appropriate, but then it is difficult to apply a bootstrap procedure (since selected variables would change from one sample to the other, and even in the inner $k$-fold loop used to optimize the $\ell_1$/$\ell_2$ parameters); this is not the case with ridge regression, since you always consider all variables.
I have no idea about R packages that would give this information. It doesn't seem to be available in the glmnet package (see Friedman's paper in JSS, Regularization Paths for Generalized Linear Models via Coordinate Descent).
However, Jelle Goeman who authored the penalized package discuss this point too. Cannot find the original PDF on the web, so I simply quote his words:
It is a very natural question to ask
for standard errors of regression
coefficients or other estimated
quantities. In principle such standard
errors can easily be calculated, e.g.
using the bootstrap.
Still, this
package deliberately does not provide
them. The reason for this is that
standard errors are not very
meaningful for strongly biased
estimates such as arise from penalized
estimation methods. Penalized
estimation is a procedure that reduces
the variance of estimators by
introducing substantial bias. The bias
of each estimator is therefore a major
component of its mean squared error,
whereas its variance may contribute
only a small part.
Unfortunately, in
most applications of penalized
regression it is impossible to obtain
a sufficiently precise estimate of the
bias. Any bootstrap-based cal-
culations can only give an assessment
of the variance of the estimates.
Reliable estimates of the bias are
only available if reliable unbiased
estimates are available, which is
typically not the case in situations
in which penalized estimates are used.
Reporting a standard error of a
penalized estimate therefore tells
only part of the story. It can give a
mistaken impression of great
precision, completely ignoring the
inaccuracy caused by the bias. It is
certainly a mistake to make confidence
statements that are only based on an
assessment of the variance of the
estimates, such as bootstrap-based
confidence intervals do.
|
How can I estimate coefficient standard errors when using ridge regression?
I think boostrap would the best option to obtain robust SEs. This was done in some applied work using shrinkage methods, e.g. Analysis of North American Rheumatoid Arthritis Consortium data using a pe
|
11,526
|
How can I estimate coefficient standard errors when using ridge regression?
|
Assuming that the data generating process follows the standard assumptions behind OLS the standard errors for ridge regression is given by:
$ \sigma^2 (A^T A + \Gamma^T \Gamma)^{-1} A^T A (A^T A + \Gamma^T \Gamma)^{-1}$
The notation above follows the wiki notation for ridge regression. Specifically,
$A$ is the covraiate matrix,
$\sigma^2$ is the error variance.
$\Gamma$ is the Tikhonov matrix chosen suitably in ridge regression.
|
How can I estimate coefficient standard errors when using ridge regression?
|
Assuming that the data generating process follows the standard assumptions behind OLS the standard errors for ridge regression is given by:
$ \sigma^2 (A^T A + \Gamma^T \Gamma)^{-1} A^T A (A^T A + \Ga
|
How can I estimate coefficient standard errors when using ridge regression?
Assuming that the data generating process follows the standard assumptions behind OLS the standard errors for ridge regression is given by:
$ \sigma^2 (A^T A + \Gamma^T \Gamma)^{-1} A^T A (A^T A + \Gamma^T \Gamma)^{-1}$
The notation above follows the wiki notation for ridge regression. Specifically,
$A$ is the covraiate matrix,
$\sigma^2$ is the error variance.
$\Gamma$ is the Tikhonov matrix chosen suitably in ridge regression.
|
How can I estimate coefficient standard errors when using ridge regression?
Assuming that the data generating process follows the standard assumptions behind OLS the standard errors for ridge regression is given by:
$ \sigma^2 (A^T A + \Gamma^T \Gamma)^{-1} A^T A (A^T A + \Ga
|
11,527
|
How can I estimate coefficient standard errors when using ridge regression?
|
Ridge regression is a subset of Tikhonov regularization (Tk) that normalizes the smoothing factors. The more general regularizing term $\Gamma ^T\Gamma$ is replaced in ridge regression by $\text{$\lambda $I}$, where $\text{I}$ is the identity matrix, and $\lambda $ is a Lagrange (i.e., constraint) multiplier, also commonly called the smoothing, shrinkage, Tikhonov or damping factor. Both Tk and ridge regression are used to solve ill-posed integrals and other inverse problems. "An inverse problem in science is the process of calculating from a set of observations the causal factors that produced them: for example, calculating an image in computer tomography, source reconstructing in acoustics, or calculating the density of the Earth from measurements of its gravity field. here" SPSS contains supplementary code that gives the standard deviation of all the parameters and additional parameters can be derived using error propagation as in the appendix to this paper.
What is generally misunderstood about Tikhonov regularization is that the amount of smoothing has very little to do with fitting the curve, the smoothing factor should be used to minimize the error of the parameters of interest. You would have to explain a lot more about the specific problem you are trying to solve to use ridge regression properly in some valid inverse problem context, and many of the papers on selection of smoothing factors, and many of the published uses of Tikhonov regularization are a bit heuristic.
Moreover Tikhonov regularization is only one inverse problem treatment among many. Follow the link to the journal Inverse Problems.
|
How can I estimate coefficient standard errors when using ridge regression?
|
Ridge regression is a subset of Tikhonov regularization (Tk) that normalizes the smoothing factors. The more general regularizing term $\Gamma ^T\Gamma$ is replaced in ridge regression by $\text{$\lam
|
How can I estimate coefficient standard errors when using ridge regression?
Ridge regression is a subset of Tikhonov regularization (Tk) that normalizes the smoothing factors. The more general regularizing term $\Gamma ^T\Gamma$ is replaced in ridge regression by $\text{$\lambda $I}$, where $\text{I}$ is the identity matrix, and $\lambda $ is a Lagrange (i.e., constraint) multiplier, also commonly called the smoothing, shrinkage, Tikhonov or damping factor. Both Tk and ridge regression are used to solve ill-posed integrals and other inverse problems. "An inverse problem in science is the process of calculating from a set of observations the causal factors that produced them: for example, calculating an image in computer tomography, source reconstructing in acoustics, or calculating the density of the Earth from measurements of its gravity field. here" SPSS contains supplementary code that gives the standard deviation of all the parameters and additional parameters can be derived using error propagation as in the appendix to this paper.
What is generally misunderstood about Tikhonov regularization is that the amount of smoothing has very little to do with fitting the curve, the smoothing factor should be used to minimize the error of the parameters of interest. You would have to explain a lot more about the specific problem you are trying to solve to use ridge regression properly in some valid inverse problem context, and many of the papers on selection of smoothing factors, and many of the published uses of Tikhonov regularization are a bit heuristic.
Moreover Tikhonov regularization is only one inverse problem treatment among many. Follow the link to the journal Inverse Problems.
|
How can I estimate coefficient standard errors when using ridge regression?
Ridge regression is a subset of Tikhonov regularization (Tk) that normalizes the smoothing factors. The more general regularizing term $\Gamma ^T\Gamma$ is replaced in ridge regression by $\text{$\lam
|
11,528
|
Should feature selection be performed only on training data (or all data)?
|
The procedure you are using will result in optimistically biased performance estimates, because you use the data from the test set used in steps 2 and 3 to decide which features used in step 1. Repeating the exercise reduces the variance of the performance estimate, not the bias, so the bias will not average out. To get an unbiased performance estimate, the test data must not be used in any way to make choices about the model, including feature selection.
A better approach is to use nested cross-validation, so that the outer cross-validation provides an estimate of the performance obtainable using a method of constructing the model (including feature selection) and the inner cross-validation is used to select the features independently in each fold of the outer cross-validation. Then build your final predictive model using all the data.
As you have more features than cases, you are very likely to over-fit the data simply by feature selection. It is a bit of a myth that feature selection should be expected to improve predictive performance, so if that is what you are interested in (rather than identifying the relevant features as an end in itself) then you are probably better off using ridge regression and not performing any feature selection. This will probably give better predictive performance than feature selection, provided the ridge parameter is selected carefully (I use minimisation of Allen's PRESS statistic - i.e. the leave-one-out estimate of the mean-squared error).
For further details, see Ambroise and McLachlan, and my answer to this question.
|
Should feature selection be performed only on training data (or all data)?
|
The procedure you are using will result in optimistically biased performance estimates, because you use the data from the test set used in steps 2 and 3 to decide which features used in step 1. Repea
|
Should feature selection be performed only on training data (or all data)?
The procedure you are using will result in optimistically biased performance estimates, because you use the data from the test set used in steps 2 and 3 to decide which features used in step 1. Repeating the exercise reduces the variance of the performance estimate, not the bias, so the bias will not average out. To get an unbiased performance estimate, the test data must not be used in any way to make choices about the model, including feature selection.
A better approach is to use nested cross-validation, so that the outer cross-validation provides an estimate of the performance obtainable using a method of constructing the model (including feature selection) and the inner cross-validation is used to select the features independently in each fold of the outer cross-validation. Then build your final predictive model using all the data.
As you have more features than cases, you are very likely to over-fit the data simply by feature selection. It is a bit of a myth that feature selection should be expected to improve predictive performance, so if that is what you are interested in (rather than identifying the relevant features as an end in itself) then you are probably better off using ridge regression and not performing any feature selection. This will probably give better predictive performance than feature selection, provided the ridge parameter is selected carefully (I use minimisation of Allen's PRESS statistic - i.e. the leave-one-out estimate of the mean-squared error).
For further details, see Ambroise and McLachlan, and my answer to this question.
|
Should feature selection be performed only on training data (or all data)?
The procedure you are using will result in optimistically biased performance estimates, because you use the data from the test set used in steps 2 and 3 to decide which features used in step 1. Repea
|
11,529
|
Should feature selection be performed only on training data (or all data)?
|
Just as an addendum to the answers here, I've got two links that really helped me understand why this isn't a good procedure:
http://nbviewer.jupyter.org/github/cs109/content/blob/master/lec_10_cross_val.ipynb
https://www.youtube.com/watch?v=S06JpVoNaA0
Edit: as requested, a brief explanation of the contents of the links:
Suppose I'm training a classifier, and I have a dataset of 1000 samples, with 1 million features each. I cannot process them all, so I need less features (say, I can compute 300 features). I also have a held-out test set of 100 samples to accurately estimate my out-of-sample, real-world accuracy.
If I filter my 1 million features down to 300, by selecting those features with a highest correlation to the targets of my whole dataset, I am making a mistake (because I'm introducing overfitting which cannot be detected by Cross Validation later on). My held-out set will show this by spitting back a bad accuracy value.
According to the above links, the correct way to do it is to divide my dataset into a training set and Cross-Validation set, and then tune my model (filtering out features, etc) based on this training set and it's associated CV score. If I'm using K-folds, I must tune from scratch each time I make a split/fold, and then average the results.
Programatically, you do the following:
Keep aside a part of your dataset as a hold-out set.
Split the remainder of your dataset (henceforth called T1) into K-folds.
In a for-loop from i=1 to K, do the following:
select the i'th fold as your CV set, and the remaining samples as your training set (henceforth called Ti).
Do whatever feature engineering and feature selection you want: filter features, combine them etc.
Convert both your CV set (the current fold, called CVi) and your current training set Ti to one with the appropriate features.
Train your model on the training set Ti
Get the score from the current fold, CVi. Append this score to a list holding all the scores.
Now, your list has the score of each fold, so you average it, getting the K-folds score.
It's really important that you perform the feature engineering inside the loop, on the sub-training set, Ti, rather than on the full training set, T1.
The reason for this is that when you fit/feature engineer for Ti, you test on CVi, which is unseen for that model. Whereas, if you fit/feature engineer on T1, any CV you choose has to be a subset T1, and so you will be optimistically biased, i.e. you will overfit, because you're training and testing on the same data samples.
A really good StackExchange answer is this one, which really explains it more in depth and with an example of the code. Also see this as an addendum.
|
Should feature selection be performed only on training data (or all data)?
|
Just as an addendum to the answers here, I've got two links that really helped me understand why this isn't a good procedure:
http://nbviewer.jupyter.org/github/cs109/content/blob/master/lec_10_cross
|
Should feature selection be performed only on training data (or all data)?
Just as an addendum to the answers here, I've got two links that really helped me understand why this isn't a good procedure:
http://nbviewer.jupyter.org/github/cs109/content/blob/master/lec_10_cross_val.ipynb
https://www.youtube.com/watch?v=S06JpVoNaA0
Edit: as requested, a brief explanation of the contents of the links:
Suppose I'm training a classifier, and I have a dataset of 1000 samples, with 1 million features each. I cannot process them all, so I need less features (say, I can compute 300 features). I also have a held-out test set of 100 samples to accurately estimate my out-of-sample, real-world accuracy.
If I filter my 1 million features down to 300, by selecting those features with a highest correlation to the targets of my whole dataset, I am making a mistake (because I'm introducing overfitting which cannot be detected by Cross Validation later on). My held-out set will show this by spitting back a bad accuracy value.
According to the above links, the correct way to do it is to divide my dataset into a training set and Cross-Validation set, and then tune my model (filtering out features, etc) based on this training set and it's associated CV score. If I'm using K-folds, I must tune from scratch each time I make a split/fold, and then average the results.
Programatically, you do the following:
Keep aside a part of your dataset as a hold-out set.
Split the remainder of your dataset (henceforth called T1) into K-folds.
In a for-loop from i=1 to K, do the following:
select the i'th fold as your CV set, and the remaining samples as your training set (henceforth called Ti).
Do whatever feature engineering and feature selection you want: filter features, combine them etc.
Convert both your CV set (the current fold, called CVi) and your current training set Ti to one with the appropriate features.
Train your model on the training set Ti
Get the score from the current fold, CVi. Append this score to a list holding all the scores.
Now, your list has the score of each fold, so you average it, getting the K-folds score.
It's really important that you perform the feature engineering inside the loop, on the sub-training set, Ti, rather than on the full training set, T1.
The reason for this is that when you fit/feature engineer for Ti, you test on CVi, which is unseen for that model. Whereas, if you fit/feature engineer on T1, any CV you choose has to be a subset T1, and so you will be optimistically biased, i.e. you will overfit, because you're training and testing on the same data samples.
A really good StackExchange answer is this one, which really explains it more in depth and with an example of the code. Also see this as an addendum.
|
Should feature selection be performed only on training data (or all data)?
Just as an addendum to the answers here, I've got two links that really helped me understand why this isn't a good procedure:
http://nbviewer.jupyter.org/github/cs109/content/blob/master/lec_10_cross
|
11,530
|
Should feature selection be performed only on training data (or all data)?
|
The Efron-Gong "optimism" bootstrap is very good for this. The idea is to use all available data for developing the predictive model, and using all data for estimating the likely future performance of that same model. And your sample size is too small by a factor of 100 for any split-sample approaches to work.
To use the bootstrap correctly you have to program all steps that used $Y$ and have them repeated afresh at each resample. Except for feature selection, here's a good example: Interpreting a logistic regression model with multiple predictors
|
Should feature selection be performed only on training data (or all data)?
|
The Efron-Gong "optimism" bootstrap is very good for this. The idea is to use all available data for developing the predictive model, and using all data for estimating the likely future performance o
|
Should feature selection be performed only on training data (or all data)?
The Efron-Gong "optimism" bootstrap is very good for this. The idea is to use all available data for developing the predictive model, and using all data for estimating the likely future performance of that same model. And your sample size is too small by a factor of 100 for any split-sample approaches to work.
To use the bootstrap correctly you have to program all steps that used $Y$ and have them repeated afresh at each resample. Except for feature selection, here's a good example: Interpreting a logistic regression model with multiple predictors
|
Should feature selection be performed only on training data (or all data)?
The Efron-Gong "optimism" bootstrap is very good for this. The idea is to use all available data for developing the predictive model, and using all data for estimating the likely future performance o
|
11,531
|
How to get started with applying item response theory and what software to use?
|
As a good starter to IRT, I always recommend reading A visual guide to item response theory.
A survey of available software can be found on www.rasch.org.
From my experience, I found the Raschtest (and associated) Stata command(s) very handy in most cases where one is interested in fitting one-parameter model. For more complex design, one can resort on GLLAMM; there's a nice working example based on De Boeck and Wilson's book, Explanatory Item and Response Models (Springer, 2004).
About R specifically, there are plenty of packages that have become available in the past five years, see for instance the related CRAN Task View. Most of them are discussed in a special issue of the Journal of Statistical Software (vol. 20, 2007). As discussed in another response, the ltm and eRm allow to fit a wide range of IRT models. As they rely on different method of estimation---ltm used the marginal approach while eRm use the conditional approach---choosing one or the other is mainly a matter of the model you want to fit (eRm won't fit 2- or 3-parameter models) and the measurement objective you follow: conditional estimation of person parameters has some nice psychometric properties while a marginal approach let you easily switch to mixed-effects model, as discussed in the following two papers:
Doran, H., Bates, D., Bliese, P. and Dowling, M. (2007). Estimating the Multilevel Rasch Model: With the lme4 Package. Journal of Statistical Software, 20(2). See also Doug Bates's slides on R-forge
De Boeck, P., Bakker, M., Zwitser, R., Nivard, M., Hofman, A., Tuerlinckx, F., and Partchev, I. (2011). The Estimation of Item Response Models with the lmer Function from the lme4 Package in R. Journal of Statistical Software, 39(12). See also the aforementioned De Boeck's handbook and this handout
There are also some possibilities to fit Rasch models using MCMC methods, see e.g. the MCMCpack package (or WinBUGS/JAGS, but see BUGS Code for Item Response Theory, JSS (2010) 36).
I have no experience with SAS for IRT modeling, so I'll let that to someone who is more versed into SAS programming.
Other dedicated software (mostly used in educational assessment) include: RUMM, Conquest, Winsteps, BILOG/MULTILOG, Mplus (not citing the list already available on wikipedia). None are free to use, but time-limited demonstration version are proposed for some of them. I found jMetrik very limited when I tried it (one year ago), and all functionalities are already available in R. Likewise, ConstructMap can be safely replaced by lme4, as illustrated in the handout linked above.
I should also mention mdltm (Multidimensional Discrete Latent Trait Models) for mixture Rasch models, by von Davier and coll., which is supposed to accompagny the book Multivariate and Mixture Distribution Rasch Models (Springer, 2007).
|
How to get started with applying item response theory and what software to use?
|
As a good starter to IRT, I always recommend reading A visual guide to item response theory.
A survey of available software can be found on www.rasch.org.
From my experience, I found the Raschtest (an
|
How to get started with applying item response theory and what software to use?
As a good starter to IRT, I always recommend reading A visual guide to item response theory.
A survey of available software can be found on www.rasch.org.
From my experience, I found the Raschtest (and associated) Stata command(s) very handy in most cases where one is interested in fitting one-parameter model. For more complex design, one can resort on GLLAMM; there's a nice working example based on De Boeck and Wilson's book, Explanatory Item and Response Models (Springer, 2004).
About R specifically, there are plenty of packages that have become available in the past five years, see for instance the related CRAN Task View. Most of them are discussed in a special issue of the Journal of Statistical Software (vol. 20, 2007). As discussed in another response, the ltm and eRm allow to fit a wide range of IRT models. As they rely on different method of estimation---ltm used the marginal approach while eRm use the conditional approach---choosing one or the other is mainly a matter of the model you want to fit (eRm won't fit 2- or 3-parameter models) and the measurement objective you follow: conditional estimation of person parameters has some nice psychometric properties while a marginal approach let you easily switch to mixed-effects model, as discussed in the following two papers:
Doran, H., Bates, D., Bliese, P. and Dowling, M. (2007). Estimating the Multilevel Rasch Model: With the lme4 Package. Journal of Statistical Software, 20(2). See also Doug Bates's slides on R-forge
De Boeck, P., Bakker, M., Zwitser, R., Nivard, M., Hofman, A., Tuerlinckx, F., and Partchev, I. (2011). The Estimation of Item Response Models with the lmer Function from the lme4 Package in R. Journal of Statistical Software, 39(12). See also the aforementioned De Boeck's handbook and this handout
There are also some possibilities to fit Rasch models using MCMC methods, see e.g. the MCMCpack package (or WinBUGS/JAGS, but see BUGS Code for Item Response Theory, JSS (2010) 36).
I have no experience with SAS for IRT modeling, so I'll let that to someone who is more versed into SAS programming.
Other dedicated software (mostly used in educational assessment) include: RUMM, Conquest, Winsteps, BILOG/MULTILOG, Mplus (not citing the list already available on wikipedia). None are free to use, but time-limited demonstration version are proposed for some of them. I found jMetrik very limited when I tried it (one year ago), and all functionalities are already available in R. Likewise, ConstructMap can be safely replaced by lme4, as illustrated in the handout linked above.
I should also mention mdltm (Multidimensional Discrete Latent Trait Models) for mixture Rasch models, by von Davier and coll., which is supposed to accompagny the book Multivariate and Mixture Distribution Rasch Models (Springer, 2007).
|
How to get started with applying item response theory and what software to use?
As a good starter to IRT, I always recommend reading A visual guide to item response theory.
A survey of available software can be found on www.rasch.org.
From my experience, I found the Raschtest (an
|
11,532
|
How to get started with applying item response theory and what software to use?
|
To the first question, I don't have any information about jMetrick.
In applying IRT, (as with any other statistical procedure) the first step is to use it with as many different kinds of data as possible. There is a learning curve, but I believe that it is worth it.
One important feature of IRT is the differentiation between Rasch models and IRT models. They were developed by different people for different purposes. That being said, IRT models are a superset of Rasch models.
Rasch models are one parameter models - they assume that all items on a questionnaire are equally predictive of the latent trait.
IRT models, however are two parameter models which allow the questions to differ in their ability to provide information about the ability of participants.
In addition, there are three parameter models which are like the IRT models, except that they allow for a guessing parameter to account for participants ability to get the right answer by chance (this is more of a concern in ability rather than personality tests).
In addition, there is multidimensional IRT which estimates multiple latent abilities at once. I don't know much about this, but its an area which I intend to learn more.
There is also a distinction between dichotomous and polytomous IRT methods. Dichotomous IRT models are those used in ability tests, which have a right and wrong answer. Polytomous IRT models are used in personality tests, where there are multiple answers, which are equally right (in the sense that there is no correct answer).
I personally use R for item response theory. There are two main packages that I have used, eRm which fits Rasch models only, and ltm which fits item response theory models (two and three parameter models). Both have similiar functionality, and both provide more routines for dichotomous IRT models. I don't know if R is the "best" for IRT, it does not have all of the multitude of IRT models available, but it is certainly the most extensible, in that one can program these models relatively easily.
I use IRT almost exclusively for polytomous models, in R. I typically start with non parametric IRT methods (provided in the package mokken) to test the assumptions, and then proceed with a rasch model, adding more complexity as required to get good fit.
For multidimensional IRT, there is the package `mirt', which provides this functionality. I have not used it so I cannot really comment.
If you do install these packages into R, and call the 'vignette("packagename")' function then you should get some useful vignettes (definitely for eRm and mokken, possibly for the others) which may prove useful for you (depending on your level of mathematical sophistication).
Finally, there are a number of good books available for rasch and irt models. Item response theory for psychologists is often used (though I didn't like the style), and further up the technical sophistication chain, there are two extremely comprehensive and useful textbooks - the Handbook of Modern Item Response Theory and Rasch Models:Foundations, Recent Developments and Applications.
I hope this helps.
|
How to get started with applying item response theory and what software to use?
|
To the first question, I don't have any information about jMetrick.
In applying IRT, (as with any other statistical procedure) the first step is to use it with as many different kinds of data as possi
|
How to get started with applying item response theory and what software to use?
To the first question, I don't have any information about jMetrick.
In applying IRT, (as with any other statistical procedure) the first step is to use it with as many different kinds of data as possible. There is a learning curve, but I believe that it is worth it.
One important feature of IRT is the differentiation between Rasch models and IRT models. They were developed by different people for different purposes. That being said, IRT models are a superset of Rasch models.
Rasch models are one parameter models - they assume that all items on a questionnaire are equally predictive of the latent trait.
IRT models, however are two parameter models which allow the questions to differ in their ability to provide information about the ability of participants.
In addition, there are three parameter models which are like the IRT models, except that they allow for a guessing parameter to account for participants ability to get the right answer by chance (this is more of a concern in ability rather than personality tests).
In addition, there is multidimensional IRT which estimates multiple latent abilities at once. I don't know much about this, but its an area which I intend to learn more.
There is also a distinction between dichotomous and polytomous IRT methods. Dichotomous IRT models are those used in ability tests, which have a right and wrong answer. Polytomous IRT models are used in personality tests, where there are multiple answers, which are equally right (in the sense that there is no correct answer).
I personally use R for item response theory. There are two main packages that I have used, eRm which fits Rasch models only, and ltm which fits item response theory models (two and three parameter models). Both have similiar functionality, and both provide more routines for dichotomous IRT models. I don't know if R is the "best" for IRT, it does not have all of the multitude of IRT models available, but it is certainly the most extensible, in that one can program these models relatively easily.
I use IRT almost exclusively for polytomous models, in R. I typically start with non parametric IRT methods (provided in the package mokken) to test the assumptions, and then proceed with a rasch model, adding more complexity as required to get good fit.
For multidimensional IRT, there is the package `mirt', which provides this functionality. I have not used it so I cannot really comment.
If you do install these packages into R, and call the 'vignette("packagename")' function then you should get some useful vignettes (definitely for eRm and mokken, possibly for the others) which may prove useful for you (depending on your level of mathematical sophistication).
Finally, there are a number of good books available for rasch and irt models. Item response theory for psychologists is often used (though I didn't like the style), and further up the technical sophistication chain, there are two extremely comprehensive and useful textbooks - the Handbook of Modern Item Response Theory and Rasch Models:Foundations, Recent Developments and Applications.
I hope this helps.
|
How to get started with applying item response theory and what software to use?
To the first question, I don't have any information about jMetrick.
In applying IRT, (as with any other statistical procedure) the first step is to use it with as many different kinds of data as possi
|
11,533
|
How to get started with applying item response theory and what software to use?
|
jMetrik is more powerful than you may think. It is designed for operational work where researchers need multiple procedures in a single unified framework. Currently you can estimate IRT parameters for the Rasch, partial credit and rating scale models. It also allows for IRT scale linking via the Stocking-Lord, Haebara and other methods. Because it includes an integrated database, the output from the IRT estimation can be used in scale linking without the need to reshape data files. Moreover, all output can be stored in the database for use with other methods in jMetrik or external programs like R.
You can also run it with scripts instead of the GUI. For example, the follwing code will (a) import data into the database, (b) score items with an answer key, (c) estimate Rasch model parameters, and (d) export data as a CSV file. You can use the final output file as input into R for further analysis, or you can use R to connect directly to the jMetrik database and work with the results.
#import data into database
import{
delimiter(comma);
header(included);
options(display);
description();
file(C:/exam1-raw-data.txt);
data(db = testdb1, table = EXAM1);
}
#conduct item scoring with the answer key
scoring{
data(db = mydb, table = exam1);
keys(4);
key1(options=(A,B,C,D), scores=(1,0,0,0), variables= (item1,item9,item12,item15,item19,item21,item22,item28,item29,item30,item34,item38,item42,item52,item55));
key2(options=(A,B,C,D), scores=(0,1,0,0), variables=(item4,item6,item16,item18,item24,item26,item32,item33,item35,item43,item44,item47,item50,item54));
key3(options=(A,B,C,D), scores=(0,0,1,0), variables=(item3,item5,item7,item11,item14,item20,item23,item25,item31,item40,item45,item48,item49,item53));
key4(options=(A,B,C,D), scores=(0,0,0,1), variables=(item2,item8,item10,item13,item17,item27,item36,item37,item39,item41,item46,item51,item56));
}
#Run a Rasch models analysis.
#Item parameters saved as database table named exam1_rasch_output
#Residuals saved as a databse table named exam1_rasch_resid
#Person estimates saved to original data table. Person estimate in variable called "theta"
rasch{
center(items);
missing(ignore);
person(rsave, pfit, psave);
item(isave);
adjust(0.3);
itemout(EXAM1_RASCH_OUTPUT);
residout(EXAM1_RASCH_RESID);
variables(item1, item2, item3, item4, item5, item6, item7, item8, item9, item10, item11, item12, item13, item14, item15, item16, item17, item18, item19, item20, item21, item22, item23, item24, item25, item26, item27, item28, item29, item30, item31, item32, item33, item34, item35, item36, item37, item38, item39, item40, item41, item42, item43, item44, item45, item46, item47, item48, item49, item50, item51, item52, item53, item54, item55, item56);
transform(scale = 1.0, precision = 4, intercept = 0.0);
gupdate(maxiter = 150, converge = 0.005);
data(db = testdb1, table = EXAM1);
}
#Export output table for use in another program like R
export{
delimiter(comma);
header(included);
options();
file(C:/EXAM1_RASCH_OUTPUT.txt);
data(db = testdb1, table = EXAM1_RASCH_OUTPUT);
}
The software is still in its early stages of development. I am currently adding exploratory factor analysis and more advanced item response models. Unlike many other IRT programs, jMetrik is open source. all of the measurement procedures use the psychometrics library which is currently available on GitHub, https://github.com/meyerjp3/psychometrics. Anyone interested in contributing is welcomed.
|
How to get started with applying item response theory and what software to use?
|
jMetrik is more powerful than you may think. It is designed for operational work where researchers need multiple procedures in a single unified framework. Currently you can estimate IRT parameters for
|
How to get started with applying item response theory and what software to use?
jMetrik is more powerful than you may think. It is designed for operational work where researchers need multiple procedures in a single unified framework. Currently you can estimate IRT parameters for the Rasch, partial credit and rating scale models. It also allows for IRT scale linking via the Stocking-Lord, Haebara and other methods. Because it includes an integrated database, the output from the IRT estimation can be used in scale linking without the need to reshape data files. Moreover, all output can be stored in the database for use with other methods in jMetrik or external programs like R.
You can also run it with scripts instead of the GUI. For example, the follwing code will (a) import data into the database, (b) score items with an answer key, (c) estimate Rasch model parameters, and (d) export data as a CSV file. You can use the final output file as input into R for further analysis, or you can use R to connect directly to the jMetrik database and work with the results.
#import data into database
import{
delimiter(comma);
header(included);
options(display);
description();
file(C:/exam1-raw-data.txt);
data(db = testdb1, table = EXAM1);
}
#conduct item scoring with the answer key
scoring{
data(db = mydb, table = exam1);
keys(4);
key1(options=(A,B,C,D), scores=(1,0,0,0), variables= (item1,item9,item12,item15,item19,item21,item22,item28,item29,item30,item34,item38,item42,item52,item55));
key2(options=(A,B,C,D), scores=(0,1,0,0), variables=(item4,item6,item16,item18,item24,item26,item32,item33,item35,item43,item44,item47,item50,item54));
key3(options=(A,B,C,D), scores=(0,0,1,0), variables=(item3,item5,item7,item11,item14,item20,item23,item25,item31,item40,item45,item48,item49,item53));
key4(options=(A,B,C,D), scores=(0,0,0,1), variables=(item2,item8,item10,item13,item17,item27,item36,item37,item39,item41,item46,item51,item56));
}
#Run a Rasch models analysis.
#Item parameters saved as database table named exam1_rasch_output
#Residuals saved as a databse table named exam1_rasch_resid
#Person estimates saved to original data table. Person estimate in variable called "theta"
rasch{
center(items);
missing(ignore);
person(rsave, pfit, psave);
item(isave);
adjust(0.3);
itemout(EXAM1_RASCH_OUTPUT);
residout(EXAM1_RASCH_RESID);
variables(item1, item2, item3, item4, item5, item6, item7, item8, item9, item10, item11, item12, item13, item14, item15, item16, item17, item18, item19, item20, item21, item22, item23, item24, item25, item26, item27, item28, item29, item30, item31, item32, item33, item34, item35, item36, item37, item38, item39, item40, item41, item42, item43, item44, item45, item46, item47, item48, item49, item50, item51, item52, item53, item54, item55, item56);
transform(scale = 1.0, precision = 4, intercept = 0.0);
gupdate(maxiter = 150, converge = 0.005);
data(db = testdb1, table = EXAM1);
}
#Export output table for use in another program like R
export{
delimiter(comma);
header(included);
options();
file(C:/EXAM1_RASCH_OUTPUT.txt);
data(db = testdb1, table = EXAM1_RASCH_OUTPUT);
}
The software is still in its early stages of development. I am currently adding exploratory factor analysis and more advanced item response models. Unlike many other IRT programs, jMetrik is open source. all of the measurement procedures use the psychometrics library which is currently available on GitHub, https://github.com/meyerjp3/psychometrics. Anyone interested in contributing is welcomed.
|
How to get started with applying item response theory and what software to use?
jMetrik is more powerful than you may think. It is designed for operational work where researchers need multiple procedures in a single unified framework. Currently you can estimate IRT parameters for
|
11,534
|
How to get started with applying item response theory and what software to use?
|
You have quite a broad list of questions here, but quite relevant for many researchers!
I highly recommend you go forward in IRT, but only if your situation meets the requirements. For example, it fits well with the types of tests you use, and probably most importantly that you have the necessary sample sizes. For dichotomous multiple-choice data, I recommend the 3PL model (the Rasch argument of "objective measurement" is strikingly uncompelling), and 500-1000 is generally the minimum sample size. Dichotomous data without guessing, like psychological surveys that have Y/N responses to statements, work well with the 2PL. If you have rating scale or partial credit data, there are polytomous models designed specifically for those situations.
IMHO, the best program for applying IRT is Xcalibre. It is relatively user-friendly (simple GUI as well as some command-line batch-type if you want it for some reason) and produces highly readable output (MS Word reports with extensive tables and figures). I recommend against using R for the opposite reasons. The drawback, of course, is that it is not free, but you tend to get what you pay for as they say. Full description, example output, and a free trial are available at www.assess.com.
|
How to get started with applying item response theory and what software to use?
|
You have quite a broad list of questions here, but quite relevant for many researchers!
I highly recommend you go forward in IRT, but only if your situation meets the requirements. For example, it fi
|
How to get started with applying item response theory and what software to use?
You have quite a broad list of questions here, but quite relevant for many researchers!
I highly recommend you go forward in IRT, but only if your situation meets the requirements. For example, it fits well with the types of tests you use, and probably most importantly that you have the necessary sample sizes. For dichotomous multiple-choice data, I recommend the 3PL model (the Rasch argument of "objective measurement" is strikingly uncompelling), and 500-1000 is generally the minimum sample size. Dichotomous data without guessing, like psychological surveys that have Y/N responses to statements, work well with the 2PL. If you have rating scale or partial credit data, there are polytomous models designed specifically for those situations.
IMHO, the best program for applying IRT is Xcalibre. It is relatively user-friendly (simple GUI as well as some command-line batch-type if you want it for some reason) and produces highly readable output (MS Word reports with extensive tables and figures). I recommend against using R for the opposite reasons. The drawback, of course, is that it is not free, but you tend to get what you pay for as they say. Full description, example output, and a free trial are available at www.assess.com.
|
How to get started with applying item response theory and what software to use?
You have quite a broad list of questions here, but quite relevant for many researchers!
I highly recommend you go forward in IRT, but only if your situation meets the requirements. For example, it fi
|
11,535
|
How to get started with applying item response theory and what software to use?
|
In the mean time there has published a new book by Frank Baker, Baker Frank B. , Seock-Ho Kim. The Basics of Item Response Theory Using R. Springer International Publishing (2017). It does not make use of R packages but offers snippets.
A (crowded) list of R packages for IRT with succinct description is available on CRAN.
|
How to get started with applying item response theory and what software to use?
|
In the mean time there has published a new book by Frank Baker, Baker Frank B. , Seock-Ho Kim. The Basics of Item Response Theory Using R. Springer International Publishing (2017). It does not make us
|
How to get started with applying item response theory and what software to use?
In the mean time there has published a new book by Frank Baker, Baker Frank B. , Seock-Ho Kim. The Basics of Item Response Theory Using R. Springer International Publishing (2017). It does not make use of R packages but offers snippets.
A (crowded) list of R packages for IRT with succinct description is available on CRAN.
|
How to get started with applying item response theory and what software to use?
In the mean time there has published a new book by Frank Baker, Baker Frank B. , Seock-Ho Kim. The Basics of Item Response Theory Using R. Springer International Publishing (2017). It does not make us
|
11,536
|
What could be the reason for using square root transformation on data?
|
In general, parametric regression / GLM assume that the relationship between the $Y$ variable and each $X$ variable is linear, that the residuals once you've fitted the model follow a normal distribution and that the size of the residuals stays about the same all the way along your fitted line(s). When your data don't conform to these assumptions, transformations can help.
It should be intuitive that if $Y$ is proportional to $X^2$ then square-rooting $Y$ linearises this relationship, leading to a model that better fits the assumptions and that explains more variance (has higher $R^2$). Square rooting $Y$ also helps when you have the problem that the size of your residuals progressively increases as your values of $X$ increase (i.e. the scatter of data points around the fitted line gets more marked as you move along it). Think of the shape of a square root function: it increases steeply at first but then saturates. So applying a square root transform inflates smaller numbers but stabilises bigger ones. So you can think of it as pushing small residuals at low $X$ values away from the fitted line and squishing large residuals at high $X$ values towards the line. (This is mental shorthand not proper maths!)
As Dmitrij and ocram say, this is just one possible transformation which will help in certain circumstances, and tools like the Box-Cox formula can help you to pick the most useful one. I would advise getting into the habit of always looking at a plots of residuals against fitted values (and also a normal probability plot or histogram of residuals) when you fit a model. You'll find you'll often end up being able to see from these what sort of transformation will help.
|
What could be the reason for using square root transformation on data?
|
In general, parametric regression / GLM assume that the relationship between the $Y$ variable and each $X$ variable is linear, that the residuals once you've fitted the model follow a normal distribut
|
What could be the reason for using square root transformation on data?
In general, parametric regression / GLM assume that the relationship between the $Y$ variable and each $X$ variable is linear, that the residuals once you've fitted the model follow a normal distribution and that the size of the residuals stays about the same all the way along your fitted line(s). When your data don't conform to these assumptions, transformations can help.
It should be intuitive that if $Y$ is proportional to $X^2$ then square-rooting $Y$ linearises this relationship, leading to a model that better fits the assumptions and that explains more variance (has higher $R^2$). Square rooting $Y$ also helps when you have the problem that the size of your residuals progressively increases as your values of $X$ increase (i.e. the scatter of data points around the fitted line gets more marked as you move along it). Think of the shape of a square root function: it increases steeply at first but then saturates. So applying a square root transform inflates smaller numbers but stabilises bigger ones. So you can think of it as pushing small residuals at low $X$ values away from the fitted line and squishing large residuals at high $X$ values towards the line. (This is mental shorthand not proper maths!)
As Dmitrij and ocram say, this is just one possible transformation which will help in certain circumstances, and tools like the Box-Cox formula can help you to pick the most useful one. I would advise getting into the habit of always looking at a plots of residuals against fitted values (and also a normal probability plot or histogram of residuals) when you fit a model. You'll find you'll often end up being able to see from these what sort of transformation will help.
|
What could be the reason for using square root transformation on data?
In general, parametric regression / GLM assume that the relationship between the $Y$ variable and each $X$ variable is linear, that the residuals once you've fitted the model follow a normal distribut
|
11,537
|
What could be the reason for using square root transformation on data?
|
The square-root transformation is just a special case of Box-Cox power transformation (a nice overview by Pengfi Li, could be useful reading and is found here), with $\lambda = 0.5$ and omitting some centering.
The aim of the Box-Cox transformations is to ensure the usual
assumptions for Linear Model hold. That is, $y\sim N(X\beta, \sigma^2 I_n)$.
However this a priori fixed value could be (and probably is) not optimal. In R you may consider a function from car library powerTransform that helps to estimate an optimal value for Box-Cox transformations for each of the variables participated in linear regression or any data you work with (see the example(powerTransform) for further details).
|
What could be the reason for using square root transformation on data?
|
The square-root transformation is just a special case of Box-Cox power transformation (a nice overview by Pengfi Li, could be useful reading and is found here), with $\lambda = 0.5$ and omitting some
|
What could be the reason for using square root transformation on data?
The square-root transformation is just a special case of Box-Cox power transformation (a nice overview by Pengfi Li, could be useful reading and is found here), with $\lambda = 0.5$ and omitting some centering.
The aim of the Box-Cox transformations is to ensure the usual
assumptions for Linear Model hold. That is, $y\sim N(X\beta, \sigma^2 I_n)$.
However this a priori fixed value could be (and probably is) not optimal. In R you may consider a function from car library powerTransform that helps to estimate an optimal value for Box-Cox transformations for each of the variables participated in linear regression or any data you work with (see the example(powerTransform) for further details).
|
What could be the reason for using square root transformation on data?
The square-root transformation is just a special case of Box-Cox power transformation (a nice overview by Pengfi Li, could be useful reading and is found here), with $\lambda = 0.5$ and omitting some
|
11,538
|
What could be the reason for using square root transformation on data?
|
When the variable follows a Poisson distribution, the results of the square root transform will be much closer to Gaussian.
|
What could be the reason for using square root transformation on data?
|
When the variable follows a Poisson distribution, the results of the square root transform will be much closer to Gaussian.
|
What could be the reason for using square root transformation on data?
When the variable follows a Poisson distribution, the results of the square root transform will be much closer to Gaussian.
|
What could be the reason for using square root transformation on data?
When the variable follows a Poisson distribution, the results of the square root transform will be much closer to Gaussian.
|
11,539
|
What could be the reason for using square root transformation on data?
|
Taking the square root is sometimes advocated to make a non-normal variable appear like a normal variable in regression problems. The logarithm is another common possible transformation.
|
What could be the reason for using square root transformation on data?
|
Taking the square root is sometimes advocated to make a non-normal variable appear like a normal variable in regression problems. The logarithm is another common possible transformation.
|
What could be the reason for using square root transformation on data?
Taking the square root is sometimes advocated to make a non-normal variable appear like a normal variable in regression problems. The logarithm is another common possible transformation.
|
What could be the reason for using square root transformation on data?
Taking the square root is sometimes advocated to make a non-normal variable appear like a normal variable in regression problems. The logarithm is another common possible transformation.
|
11,540
|
What could be the reason for using square root transformation on data?
|
Distance matrix calculated with Bray-Curtis are usually not metric for some data, giving rise to negative eigenvalues. One of the solutions to overcome this problem is to transform (logarithmic, Square root or double Square root) it.
|
What could be the reason for using square root transformation on data?
|
Distance matrix calculated with Bray-Curtis are usually not metric for some data, giving rise to negative eigenvalues. One of the solutions to overcome this problem is to transform (logarithmic, Squar
|
What could be the reason for using square root transformation on data?
Distance matrix calculated with Bray-Curtis are usually not metric for some data, giving rise to negative eigenvalues. One of the solutions to overcome this problem is to transform (logarithmic, Square root or double Square root) it.
|
What could be the reason for using square root transformation on data?
Distance matrix calculated with Bray-Curtis are usually not metric for some data, giving rise to negative eigenvalues. One of the solutions to overcome this problem is to transform (logarithmic, Squar
|
11,541
|
difference between conditional probability and bayes rule
|
OK, now that you have updated your question to include the two formulas:
$$P(A\mid B) = \frac{P(A\cap B)}{P(B)} ~~ \text{provided that }
P(B) > 0, \tag{1}$$
is the definition of the conditional probability of $A$ given that
$B$ occurred. Similarly,
$$P(B\mid A) = \frac{P(B\cap A)}{P(A)} = \frac{P(A\cap B)}{P(A)} ~~ \text{provided that }
P(A) > 0, \tag{2}$$
is the definition of the conditional probability of $B$ given that
$A$ occurred. Now, it is true that it is a trivial matter to
substitute the value of $P(A\cap B)$ from $(2)$ into $(1)$ to
arrive at
$$P(A\mid B) = \frac{P(B\mid A)P(A)}{P(B)} ~~ \text{provided that }
P(A), P(B) > 0, \tag{3}$$
which is Bayes' formula but notice that Bayes's formula actually connects two different conditional probabilities $P(A\mid B)$
and $P(B\mid A)$, and is essentially a formula for "turning the
conditioning around". The Reverend Thomas Bayes referred to this
in terms of "inverse probability" and even today, there is
vigorous debate as to whether statistical inference should be
based on $P(B\mid A)$ or the inverse probability (called
the a posteriori or posterior probability).
It is undoubtedly as galling to you as it was to me when I first
discovered that Bayes' formula was just a trivial substitution of
$(2)$ into $(1)$. Perhaps if you have been born 250 years ago,
you (Note: the OP masqueraded under username AlphaBetaGamma when I wrote this answer but has since changed his username) could have made the substitution and then
people today would be talking about the AlphaBetaGamma formula and the
AlphaBetaGammian heresy and the Naive AlphaBetaGamma method$^*$ instead
of invoking Bayes' name everywhere. So
let me console you on your loss of fame by pointing out a different
version of Bayes' formula. The Law of Total Probability says
that
$$P(B) = P(B\mid A)P(A) + P(B\mid A^c)P(A^c) \tag{4}$$
and using this, we can write $(3)$ as
$$P(A\mid B) = \frac{P(B\mid A)P(A)}{P(B\mid A)P(A) + P(B\mid A^c)P(A^c)}, \tag{5}$$
or more generally as
$$P(A_i\mid B) = \frac{P(B\mid A_i)P(A_i)}{P(B\mid A_1)P(A_1) + P(B\mid A_2)P(A_2) + \cdots + P(B\mid A_n)P(A_n)}, \tag{6}$$
where the posterior probability of a possible "cause" $A_i$ of a
"datum" $B$ is related to $P(B\mid A_i)$, the likelihood of the
observation $B$ when $A_i$ is the true hypothesis and $P(A_i)$, the prior probability
(horrors!) of the hypothesis $A_i$.
$^*$ There is a famous paper R. Alpher, H. Bethe, and
G. Gamow, "The Origin of Chemical Elements", Physical Review, April 1, 1948, that is commonly referred to as
the $\alpha\beta\gamma$ paper.
|
difference between conditional probability and bayes rule
|
OK, now that you have updated your question to include the two formulas:
$$P(A\mid B) = \frac{P(A\cap B)}{P(B)} ~~ \text{provided that }
P(B) > 0, \tag{1}$$
is the definition of the conditional proba
|
difference between conditional probability and bayes rule
OK, now that you have updated your question to include the two formulas:
$$P(A\mid B) = \frac{P(A\cap B)}{P(B)} ~~ \text{provided that }
P(B) > 0, \tag{1}$$
is the definition of the conditional probability of $A$ given that
$B$ occurred. Similarly,
$$P(B\mid A) = \frac{P(B\cap A)}{P(A)} = \frac{P(A\cap B)}{P(A)} ~~ \text{provided that }
P(A) > 0, \tag{2}$$
is the definition of the conditional probability of $B$ given that
$A$ occurred. Now, it is true that it is a trivial matter to
substitute the value of $P(A\cap B)$ from $(2)$ into $(1)$ to
arrive at
$$P(A\mid B) = \frac{P(B\mid A)P(A)}{P(B)} ~~ \text{provided that }
P(A), P(B) > 0, \tag{3}$$
which is Bayes' formula but notice that Bayes's formula actually connects two different conditional probabilities $P(A\mid B)$
and $P(B\mid A)$, and is essentially a formula for "turning the
conditioning around". The Reverend Thomas Bayes referred to this
in terms of "inverse probability" and even today, there is
vigorous debate as to whether statistical inference should be
based on $P(B\mid A)$ or the inverse probability (called
the a posteriori or posterior probability).
It is undoubtedly as galling to you as it was to me when I first
discovered that Bayes' formula was just a trivial substitution of
$(2)$ into $(1)$. Perhaps if you have been born 250 years ago,
you (Note: the OP masqueraded under username AlphaBetaGamma when I wrote this answer but has since changed his username) could have made the substitution and then
people today would be talking about the AlphaBetaGamma formula and the
AlphaBetaGammian heresy and the Naive AlphaBetaGamma method$^*$ instead
of invoking Bayes' name everywhere. So
let me console you on your loss of fame by pointing out a different
version of Bayes' formula. The Law of Total Probability says
that
$$P(B) = P(B\mid A)P(A) + P(B\mid A^c)P(A^c) \tag{4}$$
and using this, we can write $(3)$ as
$$P(A\mid B) = \frac{P(B\mid A)P(A)}{P(B\mid A)P(A) + P(B\mid A^c)P(A^c)}, \tag{5}$$
or more generally as
$$P(A_i\mid B) = \frac{P(B\mid A_i)P(A_i)}{P(B\mid A_1)P(A_1) + P(B\mid A_2)P(A_2) + \cdots + P(B\mid A_n)P(A_n)}, \tag{6}$$
where the posterior probability of a possible "cause" $A_i$ of a
"datum" $B$ is related to $P(B\mid A_i)$, the likelihood of the
observation $B$ when $A_i$ is the true hypothesis and $P(A_i)$, the prior probability
(horrors!) of the hypothesis $A_i$.
$^*$ There is a famous paper R. Alpher, H. Bethe, and
G. Gamow, "The Origin of Chemical Elements", Physical Review, April 1, 1948, that is commonly referred to as
the $\alpha\beta\gamma$ paper.
|
difference between conditional probability and bayes rule
OK, now that you have updated your question to include the two formulas:
$$P(A\mid B) = \frac{P(A\cap B)}{P(B)} ~~ \text{provided that }
P(B) > 0, \tag{1}$$
is the definition of the conditional proba
|
11,542
|
difference between conditional probability and bayes rule
|
One way to intuitively think of Bayes' theorem is that when any one of these is easy to calculate
$$P(A∣B) ~~ \text{or } P(B∣A)$$
we can calculate the other one even though the other one seems to be bit hard at first
Consider an example,
Here $$P(A∣B)$$ is say I have a curtain and I told you there is an animal behind the curtain and given it is a four legged animal what is the probability of that animal being dog ?
It is hard to find a probability for that.
But you can find the answer for $$P(B∣A)$$
What is the probability of a four legged animal behind the curtain and given that it is a dog, now it is easy to calculate
it could be nearly 1 and you plug in those values in the bayes theorem and you ll find the answer for $$P(A∣B)$$ that is the probability of the animal being a dog which at first was hard.
Now this is just an over simplified version where you can intuitively think why rearranging the formula could help us.
I hope this helps.
|
difference between conditional probability and bayes rule
|
One way to intuitively think of Bayes' theorem is that when any one of these is easy to calculate
$$P(A∣B) ~~ \text{or } P(B∣A)$$
we can calculate the other one even though the other one seems to be b
|
difference between conditional probability and bayes rule
One way to intuitively think of Bayes' theorem is that when any one of these is easy to calculate
$$P(A∣B) ~~ \text{or } P(B∣A)$$
we can calculate the other one even though the other one seems to be bit hard at first
Consider an example,
Here $$P(A∣B)$$ is say I have a curtain and I told you there is an animal behind the curtain and given it is a four legged animal what is the probability of that animal being dog ?
It is hard to find a probability for that.
But you can find the answer for $$P(B∣A)$$
What is the probability of a four legged animal behind the curtain and given that it is a dog, now it is easy to calculate
it could be nearly 1 and you plug in those values in the bayes theorem and you ll find the answer for $$P(A∣B)$$ that is the probability of the animal being a dog which at first was hard.
Now this is just an over simplified version where you can intuitively think why rearranging the formula could help us.
I hope this helps.
|
difference between conditional probability and bayes rule
One way to intuitively think of Bayes' theorem is that when any one of these is easy to calculate
$$P(A∣B) ~~ \text{or } P(B∣A)$$
we can calculate the other one even though the other one seems to be b
|
11,543
|
difference between conditional probability and bayes rule
|
While converting P(A|B) to P(B|A) might be helpful in probability problems, we should take care not to imply causality. A large number of people with umbrellas (A) might indicate a high probability of rain (B), and rain (B) may equally indicate a high probability of umbrellas (A). We might be able to argue that the rain causes the umbrellas (A -> B), but we cannot argue that the umbrellas cause he rain (B -> A).
|
difference between conditional probability and bayes rule
|
While converting P(A|B) to P(B|A) might be helpful in probability problems, we should take care not to imply causality. A large number of people with umbrellas (A) might indicate a high probability of
|
difference between conditional probability and bayes rule
While converting P(A|B) to P(B|A) might be helpful in probability problems, we should take care not to imply causality. A large number of people with umbrellas (A) might indicate a high probability of rain (B), and rain (B) may equally indicate a high probability of umbrellas (A). We might be able to argue that the rain causes the umbrellas (A -> B), but we cannot argue that the umbrellas cause he rain (B -> A).
|
difference between conditional probability and bayes rule
While converting P(A|B) to P(B|A) might be helpful in probability problems, we should take care not to imply causality. A large number of people with umbrellas (A) might indicate a high probability of
|
11,544
|
How does `predict.randomForest` estimate class probabilities?
|
It's just the proportion of votes of the trees in the ensemble.
library(randomForest)
rf = randomForest(Species~., data = iris, norm.votes = TRUE, proximity = TRUE)
p1 = predict(rf, iris, type = "prob")
p2 = predict(rf, iris, type = "vote", norm.votes = TRUE)
identical(p1,p2)
#[1] TRUE
Alternatively, if you multiply your probabilities by ntree, you get the same result, but now in counts instead of proportions.
p1 = predict(rf, iris, type = "prob")
p2 = predict(rf, iris, type = "vote", norm.votes = FALSE)
identical(500*p1,p2)
#[1] TRUE
|
How does `predict.randomForest` estimate class probabilities?
|
It's just the proportion of votes of the trees in the ensemble.
library(randomForest)
rf = randomForest(Species~., data = iris, norm.votes = TRUE, proximity = TRUE)
p1 = predict(rf, iris, type = "pro
|
How does `predict.randomForest` estimate class probabilities?
It's just the proportion of votes of the trees in the ensemble.
library(randomForest)
rf = randomForest(Species~., data = iris, norm.votes = TRUE, proximity = TRUE)
p1 = predict(rf, iris, type = "prob")
p2 = predict(rf, iris, type = "vote", norm.votes = TRUE)
identical(p1,p2)
#[1] TRUE
Alternatively, if you multiply your probabilities by ntree, you get the same result, but now in counts instead of proportions.
p1 = predict(rf, iris, type = "prob")
p2 = predict(rf, iris, type = "vote", norm.votes = FALSE)
identical(500*p1,p2)
#[1] TRUE
|
How does `predict.randomForest` estimate class probabilities?
It's just the proportion of votes of the trees in the ensemble.
library(randomForest)
rf = randomForest(Species~., data = iris, norm.votes = TRUE, proximity = TRUE)
p1 = predict(rf, iris, type = "pro
|
11,545
|
How does `predict.randomForest` estimate class probabilities?
|
The Malley (2012) is available here: http://dx.doi.org/10.3414%2FME00-01-0052. A full reference is in the references part in the ranger documentation.
In short, each tree predicts class probabilities and these probabilities are averaged for the forest prediction. For two classes, this is equivalent to a regression forest on a 0-1 coded response.
In contrast, in randomForest with type="prob" each tree predicts a class and probabilities are calculated from these classes.
In the example here I tried to use the uniform distribution instead of the normal distribution to generate the probabilities, and here the other approach seems to perform better. I wonder if these probabilities are really the truth?
By the way, the same results as in the randomForest example above can be achieved with ranger by using classification and manual probability computation (use predict.all=TRUE in prediction).
|
How does `predict.randomForest` estimate class probabilities?
|
The Malley (2012) is available here: http://dx.doi.org/10.3414%2FME00-01-0052. A full reference is in the references part in the ranger documentation.
In short, each tree predicts class probabilities
|
How does `predict.randomForest` estimate class probabilities?
The Malley (2012) is available here: http://dx.doi.org/10.3414%2FME00-01-0052. A full reference is in the references part in the ranger documentation.
In short, each tree predicts class probabilities and these probabilities are averaged for the forest prediction. For two classes, this is equivalent to a regression forest on a 0-1 coded response.
In contrast, in randomForest with type="prob" each tree predicts a class and probabilities are calculated from these classes.
In the example here I tried to use the uniform distribution instead of the normal distribution to generate the probabilities, and here the other approach seems to perform better. I wonder if these probabilities are really the truth?
By the way, the same results as in the randomForest example above can be achieved with ranger by using classification and manual probability computation (use predict.all=TRUE in prediction).
|
How does `predict.randomForest` estimate class probabilities?
The Malley (2012) is available here: http://dx.doi.org/10.3414%2FME00-01-0052. A full reference is in the references part in the ranger documentation.
In short, each tree predicts class probabilities
|
11,546
|
How does `predict.randomForest` estimate class probabilities?
|
If you want Out-Of-Bag probability estimates, you only can do it in randomForest package in R using model$votes. The other probability estimates are not OOB.
|
How does `predict.randomForest` estimate class probabilities?
|
If you want Out-Of-Bag probability estimates, you only can do it in randomForest package in R using model$votes. The other probability estimates are not OOB.
|
How does `predict.randomForest` estimate class probabilities?
If you want Out-Of-Bag probability estimates, you only can do it in randomForest package in R using model$votes. The other probability estimates are not OOB.
|
How does `predict.randomForest` estimate class probabilities?
If you want Out-Of-Bag probability estimates, you only can do it in randomForest package in R using model$votes. The other probability estimates are not OOB.
|
11,547
|
Why is the rank of covariance matrix at most $n-1$?
|
The unbiased estimator of the sample covariance matrix given $n$ data points $\newcommand{\x}{\mathbf x}\x_i \in \mathbb R^d$ is $$\mathbf C = \frac{1}{n-1}\sum_{i=1}^n (\x_i - \bar \x)(\x_i - \bar \x)^\top,$$ where $\bar \x = \sum \x_i /n$ is the average over all points. Let us denote $(\x_i-\bar \x)$ as $\newcommand{\z}{\mathbf z}\z_i$. The $\frac{1}{n-1}$ factor does not change the rank, and each term in the sum has (by definition) rank $1$, so the core of the question is as follows:
Why does $\sum \z_i\z_i^\top$ have rank $n-1$ and not rank $n$, as it would seem because we are summing $n$ rank-$1$ matrices?
The answer is that it happens because $\z_i$ are not independent. By construction, $\sum\z_i = 0$. So if you know $n-1$ of $\z_i$, then the last remaining $\z_n$ is completely determined; we are not summing $n$ independent rank-$1$ matrices, we are summing only $n-1$ independent rank-$1$ matrices and then adding one more rank-$1$ matrix that is fully linearly determined by the rest. This last addition does not change the overall rank.
We can see this directly if we rewrite $\sum\z_i = 0$ as $$\z_n = -\sum_{i=1}^{n-1}\z_i,$$ and now plug it into the above expression: $$\sum_{i=1}^n \z_i\z_i^\top = \sum_{i=1}^{n-1} \z_i\z_i^\top + \Big(-\sum_{i=1}^{n-1}\z_i\Big)\z_n^\top=\sum_{i=1}^{n-1} \z_i(\z_i-\z_n)^\top.$$ Now there is only $n-1$ terms left in the sum and it becomes clear that the whole sum can have at most rank $n-1$.
This result, by the way, hints to why the factor in the unbiased estimator of covariance is $\frac{1}{n-1}$ and not $\frac{1}{n}$.
The geometric intuition that I alluded to in the comments above is that one can always fit a 1D line to any two points in 2D and one can always fit a 2D plane to any three points in 3D, i.e. the dimensionality of the subspace is always $n-1$; this only works because we assume that this line (and plane) can be "moved around" in order to fit our points. "Positioning" this line (or plane) such that it passes through $\bar \x$ is equivalent of centering in the algebraic argument above.
|
Why is the rank of covariance matrix at most $n-1$?
|
The unbiased estimator of the sample covariance matrix given $n$ data points $\newcommand{\x}{\mathbf x}\x_i \in \mathbb R^d$ is $$\mathbf C = \frac{1}{n-1}\sum_{i=1}^n (\x_i - \bar \x)(\x_i - \bar \x
|
Why is the rank of covariance matrix at most $n-1$?
The unbiased estimator of the sample covariance matrix given $n$ data points $\newcommand{\x}{\mathbf x}\x_i \in \mathbb R^d$ is $$\mathbf C = \frac{1}{n-1}\sum_{i=1}^n (\x_i - \bar \x)(\x_i - \bar \x)^\top,$$ where $\bar \x = \sum \x_i /n$ is the average over all points. Let us denote $(\x_i-\bar \x)$ as $\newcommand{\z}{\mathbf z}\z_i$. The $\frac{1}{n-1}$ factor does not change the rank, and each term in the sum has (by definition) rank $1$, so the core of the question is as follows:
Why does $\sum \z_i\z_i^\top$ have rank $n-1$ and not rank $n$, as it would seem because we are summing $n$ rank-$1$ matrices?
The answer is that it happens because $\z_i$ are not independent. By construction, $\sum\z_i = 0$. So if you know $n-1$ of $\z_i$, then the last remaining $\z_n$ is completely determined; we are not summing $n$ independent rank-$1$ matrices, we are summing only $n-1$ independent rank-$1$ matrices and then adding one more rank-$1$ matrix that is fully linearly determined by the rest. This last addition does not change the overall rank.
We can see this directly if we rewrite $\sum\z_i = 0$ as $$\z_n = -\sum_{i=1}^{n-1}\z_i,$$ and now plug it into the above expression: $$\sum_{i=1}^n \z_i\z_i^\top = \sum_{i=1}^{n-1} \z_i\z_i^\top + \Big(-\sum_{i=1}^{n-1}\z_i\Big)\z_n^\top=\sum_{i=1}^{n-1} \z_i(\z_i-\z_n)^\top.$$ Now there is only $n-1$ terms left in the sum and it becomes clear that the whole sum can have at most rank $n-1$.
This result, by the way, hints to why the factor in the unbiased estimator of covariance is $\frac{1}{n-1}$ and not $\frac{1}{n}$.
The geometric intuition that I alluded to in the comments above is that one can always fit a 1D line to any two points in 2D and one can always fit a 2D plane to any three points in 3D, i.e. the dimensionality of the subspace is always $n-1$; this only works because we assume that this line (and plane) can be "moved around" in order to fit our points. "Positioning" this line (or plane) such that it passes through $\bar \x$ is equivalent of centering in the algebraic argument above.
|
Why is the rank of covariance matrix at most $n-1$?
The unbiased estimator of the sample covariance matrix given $n$ data points $\newcommand{\x}{\mathbf x}\x_i \in \mathbb R^d$ is $$\mathbf C = \frac{1}{n-1}\sum_{i=1}^n (\x_i - \bar \x)(\x_i - \bar \x
|
11,548
|
Why is the rank of covariance matrix at most $n-1$?
|
A bit shorter, I believe, explanation goes like this:
Let us define matrix $n$ x $m$ matrix $x$ of sample data points where
$n$ is a number of variables and $m$ is a number of samples for each variable. Let us assume that none of the variables are linearly dependent.
The rank of $x$ is $\min(n,m)$.
Let us define matrix $n$ x $m$ matrix $z$ of row-wise centered variables:
$z = x - E[x]$.
The rank of centered data becomes $\min(n,m-1)$, because each data row is now subjected to constraint:
$ \sum_{i=1}^{m}z_{*i} =0$.
It basically means we can recreate the entire $z$ matrix even if one of columns is removed.
The equation for sample covariance of $x$ becomes:
$ cov(x,x) = \frac{1}{m-1}zz^T $
Clearly, the rank of covariance matrix is the $rank(zz^T)$.
By rank-nullity theorem:
$rank(zz^T) = rank(z) = \min(n,m-1)$.
|
Why is the rank of covariance matrix at most $n-1$?
|
A bit shorter, I believe, explanation goes like this:
Let us define matrix $n$ x $m$ matrix $x$ of sample data points where
$n$ is a number of variables and $m$ is a number of samples for each variabl
|
Why is the rank of covariance matrix at most $n-1$?
A bit shorter, I believe, explanation goes like this:
Let us define matrix $n$ x $m$ matrix $x$ of sample data points where
$n$ is a number of variables and $m$ is a number of samples for each variable. Let us assume that none of the variables are linearly dependent.
The rank of $x$ is $\min(n,m)$.
Let us define matrix $n$ x $m$ matrix $z$ of row-wise centered variables:
$z = x - E[x]$.
The rank of centered data becomes $\min(n,m-1)$, because each data row is now subjected to constraint:
$ \sum_{i=1}^{m}z_{*i} =0$.
It basically means we can recreate the entire $z$ matrix even if one of columns is removed.
The equation for sample covariance of $x$ becomes:
$ cov(x,x) = \frac{1}{m-1}zz^T $
Clearly, the rank of covariance matrix is the $rank(zz^T)$.
By rank-nullity theorem:
$rank(zz^T) = rank(z) = \min(n,m-1)$.
|
Why is the rank of covariance matrix at most $n-1$?
A bit shorter, I believe, explanation goes like this:
Let us define matrix $n$ x $m$ matrix $x$ of sample data points where
$n$ is a number of variables and $m$ is a number of samples for each variabl
|
11,549
|
Why is the rank of covariance matrix at most $n-1$?
|
For the same reason that you need at least two observations to estimate the variance of a single random variable.
|
Why is the rank of covariance matrix at most $n-1$?
|
For the same reason that you need at least two observations to estimate the variance of a single random variable.
|
Why is the rank of covariance matrix at most $n-1$?
For the same reason that you need at least two observations to estimate the variance of a single random variable.
|
Why is the rank of covariance matrix at most $n-1$?
For the same reason that you need at least two observations to estimate the variance of a single random variable.
|
11,550
|
How to apply binomial GLMM (glmer) to percentages rather than yes-no counts?
|
In order to use a vector of proportions as the response variable with glmer(., family = binomial), you need to set the number of trials that led to each proportion using the weights argument. For example, using the cbpp data from the lme4 package:
glmer(incidence / size ~ period + (1 | herd), weights = size,
family = binomial, data = cbpp)
If you do not know the total number of trials, then a binomial model is not appropriate, as is indicated in the error message.
|
How to apply binomial GLMM (glmer) to percentages rather than yes-no counts?
|
In order to use a vector of proportions as the response variable with glmer(., family = binomial), you need to set the number of trials that led to each proportion using the weights argument. For exa
|
How to apply binomial GLMM (glmer) to percentages rather than yes-no counts?
In order to use a vector of proportions as the response variable with glmer(., family = binomial), you need to set the number of trials that led to each proportion using the weights argument. For example, using the cbpp data from the lme4 package:
glmer(incidence / size ~ period + (1 | herd), weights = size,
family = binomial, data = cbpp)
If you do not know the total number of trials, then a binomial model is not appropriate, as is indicated in the error message.
|
How to apply binomial GLMM (glmer) to percentages rather than yes-no counts?
In order to use a vector of proportions as the response variable with glmer(., family = binomial), you need to set the number of trials that led to each proportion using the weights argument. For exa
|
11,551
|
How to apply binomial GLMM (glmer) to percentages rather than yes-no counts?
|
If your response is a proportion, percentage or anything similiar that can only take values in $(0,1)$ you would typically use beta regression, not the binomial one.
|
How to apply binomial GLMM (glmer) to percentages rather than yes-no counts?
|
If your response is a proportion, percentage or anything similiar that can only take values in $(0,1)$ you would typically use beta regression, not the binomial one.
|
How to apply binomial GLMM (glmer) to percentages rather than yes-no counts?
If your response is a proportion, percentage or anything similiar that can only take values in $(0,1)$ you would typically use beta regression, not the binomial one.
|
How to apply binomial GLMM (glmer) to percentages rather than yes-no counts?
If your response is a proportion, percentage or anything similiar that can only take values in $(0,1)$ you would typically use beta regression, not the binomial one.
|
11,552
|
What is the difference between policy-based, on-policy, value-based, off-policy, model-free and model-based?
|
Here is a quick summary on the Reinforcement Learning taxonomy:
On-policy vs. Off-Policy
This division is based on whether you update your $Q$ values based on actions undertaken according to your current policy or not. Let's say your current policy is a completely random policy. You're in state $s$ and make an action $a$ that leads you to state $s'$. Will you update your $Q(s, a)$ based on the best possible action you can take in $s'$ or based on an action according to your current policy (random action)? The first choice method is called off-policy and the latter - on-policy. E.g. Q-learning does the first and SARSA does the latter.
Policy-based vs. Value-based
In Policy-based methods we explicitly build a representation of a policy (mapping $\pi: s \to a$) and keep it in memory during learning.
In Value-based we don't store any explicit policy, only a value function. The policy is here implicit and can be derived directly from the value function (pick the action with the best value).
Actor-critic is a mix of the two.
Model-based vs. Model-free
The problem we're often dealing with in RL is that whenever you are in state $s$ and make an action $a$ you might not necessarily know the next state $s'$ that you'll end up in (the environment influences the agent).
In Model-based approach you either have an access to the model (environment) so you know the probability distribution over states that you end up in, or you first try to build a model (often - approximation) yourself. This might be useful because it allows you to do planning (you can "think" about making moves ahead without actually performing any actions).
In Model-free you're not given a model and you're not trying to explicitly figure out how it works. You just collect some experience and then derive (hopefully) optimal policy.
|
What is the difference between policy-based, on-policy, value-based, off-policy, model-free and mode
|
Here is a quick summary on the Reinforcement Learning taxonomy:
On-policy vs. Off-Policy
This division is based on whether you update your $Q$ values based on actions undertaken according to your curr
|
What is the difference between policy-based, on-policy, value-based, off-policy, model-free and model-based?
Here is a quick summary on the Reinforcement Learning taxonomy:
On-policy vs. Off-Policy
This division is based on whether you update your $Q$ values based on actions undertaken according to your current policy or not. Let's say your current policy is a completely random policy. You're in state $s$ and make an action $a$ that leads you to state $s'$. Will you update your $Q(s, a)$ based on the best possible action you can take in $s'$ or based on an action according to your current policy (random action)? The first choice method is called off-policy and the latter - on-policy. E.g. Q-learning does the first and SARSA does the latter.
Policy-based vs. Value-based
In Policy-based methods we explicitly build a representation of a policy (mapping $\pi: s \to a$) and keep it in memory during learning.
In Value-based we don't store any explicit policy, only a value function. The policy is here implicit and can be derived directly from the value function (pick the action with the best value).
Actor-critic is a mix of the two.
Model-based vs. Model-free
The problem we're often dealing with in RL is that whenever you are in state $s$ and make an action $a$ you might not necessarily know the next state $s'$ that you'll end up in (the environment influences the agent).
In Model-based approach you either have an access to the model (environment) so you know the probability distribution over states that you end up in, or you first try to build a model (often - approximation) yourself. This might be useful because it allows you to do planning (you can "think" about making moves ahead without actually performing any actions).
In Model-free you're not given a model and you're not trying to explicitly figure out how it works. You just collect some experience and then derive (hopefully) optimal policy.
|
What is the difference between policy-based, on-policy, value-based, off-policy, model-free and mode
Here is a quick summary on the Reinforcement Learning taxonomy:
On-policy vs. Off-Policy
This division is based on whether you update your $Q$ values based on actions undertaken according to your curr
|
11,553
|
What is the difference between policy-based, on-policy, value-based, off-policy, model-free and model-based?
|
You can have an on-policy RL algorithm that is value-based. An example of such algorithm is SARSA, so not all value-based algorithms are off-policy. A value-based algorithm is just an algorithm that estimates the policy by first estimating the associated value function.
To understand the difference between on-policy and off-policy, you need to understand that there are two phases of an RL algorithm: the learning (or training) phase and the inference (or behaviour) phase (after the training phase). The distinction between on-policy and off-policy algorithms only concerns the training phase.
During the learning phase, the RL agent needs to learn an estimate of the optimal value (or policy) function. Given that the agent still does not know the optimal policy, it often behaves sub-optimally. During training, the agent faces a dilemma: the exploration or exploitation dilemma. In the context of RL, exploration and exploitation are different concepts: exploration is the selection and execution (in the environment) of an action that is likely not optimal (according to the knowledge of the agent) and exploitation is the selection and execution of an action that is optimal according to the agent's knowledge (that is, according to the agent's current best estimate of the optimal policy). During the training phase, the agent needs to explore and exploit: the exploration is required to discover more about the optimal strategy, but the exploitation is also required to know even more about the already visited and partially known states of the environment. During the learning phase, the agent thus can't just exploit the already visited states, but it also needs to explore possibly unvisited states. To explore possibly unvisited states, the agent often needs to perform a sub-optimal action.
An off-policy algorithm is an algorithm that, during training, uses a behaviour policy (that is, the policy it uses to select actions) that is different than the optimal policy it tries to estimate (the optimal policy). For example, $Q$-learning often uses an $\epsilon$-greedy policy ($\epsilon$ percentage of the time it chooses a random or explorative action and $1-\epsilon$ percentage of the time it chooses the action that is optimal, according to its current best estimate of the optimal policy) to behave (that is, to exploit and explore the environment), while, in its update rule, because of the $\max$ operator, it assumes that the greedy action (that is, the current optimal action in a given state) is chosen.
An on-policy algorithm is an algorithm that, during training, chooses actions using a policy that is derived from the current estimate of the optimal policy, while the updates are also based on the current estimate of the optimal policy. For example, SARSA is an on-policy algorithm because it doesn't use the $\max$ operator in its update rule.
The difference between $Q$-learning (off-policy) and SARSA (on-policy) is respectively the use or not of the $\max$ operator in their update rule.
In the case of policy-based or policy search algorithm (e.g. REINFORCE), the distinction between on-policy and off-policy is often not made because, in this context, there isn't usually a clear separation between a behaviour policy (the policy to behave during training) and a target policy (the policy to be estimated).
You can think of actor-critic algorithms as value and policy-based because they use both a value and policy functions.
The usual examples of model-based algorithms are value and policy iterations, which are algorithms that use the transition and reward functions (of the given Markov decision process) to estimate the value function. However, it might be the case that you also have on-policy, off-policy, value-based or policy-based algorithms that are model-based, in some way, that is, they might use a model of the environment in some way.
|
What is the difference between policy-based, on-policy, value-based, off-policy, model-free and mode
|
You can have an on-policy RL algorithm that is value-based. An example of such algorithm is SARSA, so not all value-based algorithms are off-policy. A value-based algorithm is just an algorithm that e
|
What is the difference between policy-based, on-policy, value-based, off-policy, model-free and model-based?
You can have an on-policy RL algorithm that is value-based. An example of such algorithm is SARSA, so not all value-based algorithms are off-policy. A value-based algorithm is just an algorithm that estimates the policy by first estimating the associated value function.
To understand the difference between on-policy and off-policy, you need to understand that there are two phases of an RL algorithm: the learning (or training) phase and the inference (or behaviour) phase (after the training phase). The distinction between on-policy and off-policy algorithms only concerns the training phase.
During the learning phase, the RL agent needs to learn an estimate of the optimal value (or policy) function. Given that the agent still does not know the optimal policy, it often behaves sub-optimally. During training, the agent faces a dilemma: the exploration or exploitation dilemma. In the context of RL, exploration and exploitation are different concepts: exploration is the selection and execution (in the environment) of an action that is likely not optimal (according to the knowledge of the agent) and exploitation is the selection and execution of an action that is optimal according to the agent's knowledge (that is, according to the agent's current best estimate of the optimal policy). During the training phase, the agent needs to explore and exploit: the exploration is required to discover more about the optimal strategy, but the exploitation is also required to know even more about the already visited and partially known states of the environment. During the learning phase, the agent thus can't just exploit the already visited states, but it also needs to explore possibly unvisited states. To explore possibly unvisited states, the agent often needs to perform a sub-optimal action.
An off-policy algorithm is an algorithm that, during training, uses a behaviour policy (that is, the policy it uses to select actions) that is different than the optimal policy it tries to estimate (the optimal policy). For example, $Q$-learning often uses an $\epsilon$-greedy policy ($\epsilon$ percentage of the time it chooses a random or explorative action and $1-\epsilon$ percentage of the time it chooses the action that is optimal, according to its current best estimate of the optimal policy) to behave (that is, to exploit and explore the environment), while, in its update rule, because of the $\max$ operator, it assumes that the greedy action (that is, the current optimal action in a given state) is chosen.
An on-policy algorithm is an algorithm that, during training, chooses actions using a policy that is derived from the current estimate of the optimal policy, while the updates are also based on the current estimate of the optimal policy. For example, SARSA is an on-policy algorithm because it doesn't use the $\max$ operator in its update rule.
The difference between $Q$-learning (off-policy) and SARSA (on-policy) is respectively the use or not of the $\max$ operator in their update rule.
In the case of policy-based or policy search algorithm (e.g. REINFORCE), the distinction between on-policy and off-policy is often not made because, in this context, there isn't usually a clear separation between a behaviour policy (the policy to behave during training) and a target policy (the policy to be estimated).
You can think of actor-critic algorithms as value and policy-based because they use both a value and policy functions.
The usual examples of model-based algorithms are value and policy iterations, which are algorithms that use the transition and reward functions (of the given Markov decision process) to estimate the value function. However, it might be the case that you also have on-policy, off-policy, value-based or policy-based algorithms that are model-based, in some way, that is, they might use a model of the environment in some way.
|
What is the difference between policy-based, on-policy, value-based, off-policy, model-free and mode
You can have an on-policy RL algorithm that is value-based. An example of such algorithm is SARSA, so not all value-based algorithms are off-policy. A value-based algorithm is just an algorithm that e
|
11,554
|
What does a bottleneck layer mean in neural networks?
|
A bottleneck layer is a layer that contains few nodes compared to the previous layers. It can be used to obtain a representation of the input with reduced dimensionality. An example of this is the use of autoencoders with bottleneck layers for nonlinear dimensionality reduction.
My understanding of the quote is that previous approaches use a deep network to classify faces. They then take the first several layers of this network, from the input up to some intermediate layer (say, the $k$th layer, containing $n_k$ nodes). This subnetwork implements a mapping from the input space to an $n_k$-dimensional vector space. The $k$th layer is a bottleneck layer, so the vector of activations of nodes in the $k$th layer gives a lower dimensional representation of the input. The original network can't be used to classify new identities, on which it wasn't trained. But, the $k$th layer may provide a good representation of faces in general. So, to learn new identities, new classifier layers can be stacked on top of the $k$th layer and trained. Or, the new training data can be fed through the subnetwork to obtain representations from the $k$th layer, and these representations can be fed to some other classifier.
|
What does a bottleneck layer mean in neural networks?
|
A bottleneck layer is a layer that contains few nodes compared to the previous layers. It can be used to obtain a representation of the input with reduced dimensionality. An example of this is the use
|
What does a bottleneck layer mean in neural networks?
A bottleneck layer is a layer that contains few nodes compared to the previous layers. It can be used to obtain a representation of the input with reduced dimensionality. An example of this is the use of autoencoders with bottleneck layers for nonlinear dimensionality reduction.
My understanding of the quote is that previous approaches use a deep network to classify faces. They then take the first several layers of this network, from the input up to some intermediate layer (say, the $k$th layer, containing $n_k$ nodes). This subnetwork implements a mapping from the input space to an $n_k$-dimensional vector space. The $k$th layer is a bottleneck layer, so the vector of activations of nodes in the $k$th layer gives a lower dimensional representation of the input. The original network can't be used to classify new identities, on which it wasn't trained. But, the $k$th layer may provide a good representation of faces in general. So, to learn new identities, new classifier layers can be stacked on top of the $k$th layer and trained. Or, the new training data can be fed through the subnetwork to obtain representations from the $k$th layer, and these representations can be fed to some other classifier.
|
What does a bottleneck layer mean in neural networks?
A bottleneck layer is a layer that contains few nodes compared to the previous layers. It can be used to obtain a representation of the input with reduced dimensionality. An example of this is the use
|
11,555
|
What does a bottleneck layer mean in neural networks?
|
Adding to the previous answer:
Bottlenecks can also be understood as a design pattern, consisting of three convolution layers, introduced by the ResNet paper.
Deeper Bottleneck Architectures. Next, we describe our deeper nets for ImageNet. Because of concerns on the training time that we can afford, we modify the building block as a bottleneck. For each residual function F , we use a stack of 3 layers instead of 2 (Fig. 5). The three layers are 1×1, 3×3, and 1×1 convolutions, where the 1×1 layers are responsible for reducing and then increasing (restoring) dimensions, leaving the 3x3 layer a bottleneck with smaller input/output dimensions. Fig 5. shows an example, where both designs have similar time complexity.
|
What does a bottleneck layer mean in neural networks?
|
Adding to the previous answer:
Bottlenecks can also be understood as a design pattern, consisting of three convolution layers, introduced by the ResNet paper.
Deeper Bottleneck Architectures. Next, w
|
What does a bottleneck layer mean in neural networks?
Adding to the previous answer:
Bottlenecks can also be understood as a design pattern, consisting of three convolution layers, introduced by the ResNet paper.
Deeper Bottleneck Architectures. Next, we describe our deeper nets for ImageNet. Because of concerns on the training time that we can afford, we modify the building block as a bottleneck. For each residual function F , we use a stack of 3 layers instead of 2 (Fig. 5). The three layers are 1×1, 3×3, and 1×1 convolutions, where the 1×1 layers are responsible for reducing and then increasing (restoring) dimensions, leaving the 3x3 layer a bottleneck with smaller input/output dimensions. Fig 5. shows an example, where both designs have similar time complexity.
|
What does a bottleneck layer mean in neural networks?
Adding to the previous answer:
Bottlenecks can also be understood as a design pattern, consisting of three convolution layers, introduced by the ResNet paper.
Deeper Bottleneck Architectures. Next, w
|
11,556
|
Such thing as a weighted correlation?
|
Formula for weighted Pearson correlation can be easily found on the web, StackOverflow, and Wikipedia and is implemented in several R packages e.g. psych, or weights and in Python's statsmodels package. It is calculated like regular correlation but with using weighted means,
$$ m_X = \frac{\sum_i w_i x_i}{\sum_i w_i}, ~~~~ m_Y = \frac{\sum_i w_i y_i}{\sum_i w_i} $$
weighted variances,
$$ s_X = \frac{\sum_i w_i (x_i - m_X)^2}{ \sum_i w_i}, ~~~~
s_Y = \frac{\sum_i w_i (y_i - m_Y)^2}{ \sum_i w_i} $$
and weighted covariance
$$ s_{XY} = \frac{\sum_i w_i (x_i - m_X)(y_i - m_Y)}{ \sum_i w_i} $$
having all this you can easily compute the weighted correlation
$$ \rho_{XY} = \frac{s_{XY}}{\sqrt{s_X s_Y}} $$
As for your second question, as I understand it, you would have data about correlations between political orientation and preference for the twenty artists and users binary answers about his/her preference and you want to get some kind of aggregate measure of it.
Let's start with averaging correlations. There are multiple methods for averaging probabilities, but there don't seem to be so many approaches to averaging correlations. One thing that could be done is to use Fisher's $z$-transformation as described on MathOverflow, i.e.
$$ \bar\rho = \tanh \left(\frac{\sum_{j=1}^K \tanh^{-1}(\rho_j)}{K} \right) $$
It reduces the skewness of the distribution and makes it closer to normal. This procedure was also described by Bushman and Wang (1995) and Corey, Dunlap, and Burke (1998).
Next, you have to notice that if $r = \mathrm{cor}(X,Y)$, then $-r = \mathrm{cor}(-X,Y) = \mathrm{cor}(X,-Y)$, so positive correlation of musical preference with some political orientation is the same as negative correlation of musical dislike to such political orientation, and the other way around.
Now, let's define $r_j$ as correlation of musical preference of $j$-th artist to some political orientation, and $x_{ij}$ as $i$-th users preference for $j$-th artist, where $x_{ij} = 1$ for preference and $x_{ij} = -1$ for dislike. You can define your final estimate as
$$ \bar r_i = \tanh \left(\frac{\sum_{j=1}^K \tanh^{-1}(r_j x_{ij})}{K} \right) $$
i.e. compute average correlation that inverts the signs for correlations accordingly for preferred and disliked artists. By applying such a procedure you end up with the average "correlation" of users' preference and political orientation, that as regular correlation ranges from $-1$ to $1$.
But...
Don't you think that all of this is overkill for something that is basically a multiple regression problem? Instead of all the weighting and averaging you could simply use weighted multiple regression (linear or logistic depending if you predict binary preference or degree off preference in either direction) where weights are based on sizes of subsamples. You would use musical preference for each artist as a predictor. In the end, you'll use the user's preference to make predictions. This approach is simpler and more statistically elegant. It also applies relative weights to the artists while averaging the correlations doesn't correct for their relative "impact" on the final score. Moreover, regression takes into consideration the base rate (or default political orientation), while averaging correlations does not. Imagine that the vast majority of the population prefers party $A$, this should make you less eager to predict $B$'s, and regression accounts for that by including the intercept. The only problem is multicollinearity but when averaging correlations you ignore it rather than dealing with it.
Bushman, B.J., & Wang, M.C. (1995). A procedure for combining sample correlation coefficients and vote counts to obtain an estimate and a confidence interval for the population correlation coefficient. Psychological Bulletin, 117(3), 530.
Corey, D.M., Dunlap, W.P., and Burke, M.J. (1998). Averaging Correlations: Expected Values and Bias in Combined Pearson rs and
Fisher's z Transformations, The Journal of General Psychology, 125(3), 245-261.
|
Such thing as a weighted correlation?
|
Formula for weighted Pearson correlation can be easily found on the web, StackOverflow, and Wikipedia and is implemented in several R packages e.g. psych, or weights and in Python's statsmodels packag
|
Such thing as a weighted correlation?
Formula for weighted Pearson correlation can be easily found on the web, StackOverflow, and Wikipedia and is implemented in several R packages e.g. psych, or weights and in Python's statsmodels package. It is calculated like regular correlation but with using weighted means,
$$ m_X = \frac{\sum_i w_i x_i}{\sum_i w_i}, ~~~~ m_Y = \frac{\sum_i w_i y_i}{\sum_i w_i} $$
weighted variances,
$$ s_X = \frac{\sum_i w_i (x_i - m_X)^2}{ \sum_i w_i}, ~~~~
s_Y = \frac{\sum_i w_i (y_i - m_Y)^2}{ \sum_i w_i} $$
and weighted covariance
$$ s_{XY} = \frac{\sum_i w_i (x_i - m_X)(y_i - m_Y)}{ \sum_i w_i} $$
having all this you can easily compute the weighted correlation
$$ \rho_{XY} = \frac{s_{XY}}{\sqrt{s_X s_Y}} $$
As for your second question, as I understand it, you would have data about correlations between political orientation and preference for the twenty artists and users binary answers about his/her preference and you want to get some kind of aggregate measure of it.
Let's start with averaging correlations. There are multiple methods for averaging probabilities, but there don't seem to be so many approaches to averaging correlations. One thing that could be done is to use Fisher's $z$-transformation as described on MathOverflow, i.e.
$$ \bar\rho = \tanh \left(\frac{\sum_{j=1}^K \tanh^{-1}(\rho_j)}{K} \right) $$
It reduces the skewness of the distribution and makes it closer to normal. This procedure was also described by Bushman and Wang (1995) and Corey, Dunlap, and Burke (1998).
Next, you have to notice that if $r = \mathrm{cor}(X,Y)$, then $-r = \mathrm{cor}(-X,Y) = \mathrm{cor}(X,-Y)$, so positive correlation of musical preference with some political orientation is the same as negative correlation of musical dislike to such political orientation, and the other way around.
Now, let's define $r_j$ as correlation of musical preference of $j$-th artist to some political orientation, and $x_{ij}$ as $i$-th users preference for $j$-th artist, where $x_{ij} = 1$ for preference and $x_{ij} = -1$ for dislike. You can define your final estimate as
$$ \bar r_i = \tanh \left(\frac{\sum_{j=1}^K \tanh^{-1}(r_j x_{ij})}{K} \right) $$
i.e. compute average correlation that inverts the signs for correlations accordingly for preferred and disliked artists. By applying such a procedure you end up with the average "correlation" of users' preference and political orientation, that as regular correlation ranges from $-1$ to $1$.
But...
Don't you think that all of this is overkill for something that is basically a multiple regression problem? Instead of all the weighting and averaging you could simply use weighted multiple regression (linear or logistic depending if you predict binary preference or degree off preference in either direction) where weights are based on sizes of subsamples. You would use musical preference for each artist as a predictor. In the end, you'll use the user's preference to make predictions. This approach is simpler and more statistically elegant. It also applies relative weights to the artists while averaging the correlations doesn't correct for their relative "impact" on the final score. Moreover, regression takes into consideration the base rate (or default political orientation), while averaging correlations does not. Imagine that the vast majority of the population prefers party $A$, this should make you less eager to predict $B$'s, and regression accounts for that by including the intercept. The only problem is multicollinearity but when averaging correlations you ignore it rather than dealing with it.
Bushman, B.J., & Wang, M.C. (1995). A procedure for combining sample correlation coefficients and vote counts to obtain an estimate and a confidence interval for the population correlation coefficient. Psychological Bulletin, 117(3), 530.
Corey, D.M., Dunlap, W.P., and Burke, M.J. (1998). Averaging Correlations: Expected Values and Bias in Combined Pearson rs and
Fisher's z Transformations, The Journal of General Psychology, 125(3), 245-261.
|
Such thing as a weighted correlation?
Formula for weighted Pearson correlation can be easily found on the web, StackOverflow, and Wikipedia and is implemented in several R packages e.g. psych, or weights and in Python's statsmodels packag
|
11,557
|
How can I prove that the cumulative distribution function is right continuous?
|
To prove the right continuity of the distribution function you have to use the continuity from above of $P$, which you probably proved in one of your probability courses.
Lemma. If a sequence of events $\{A_n\}_{n\geq 1}$ is decreasing, in the sense that $A_n\supset A_{n+1}$ for every $n\geq 1$, then $P(A_n)\downarrow P(A)$, in which $A=\cap_{n=1}^\infty A_n$.
Let's use the Lemma. The distribution function $F$ is right continuous at some point $a$ if and only if for every decreasing sequence of real numbers $\{x_n\}_{n\geq 1}$ such that $x_n\downarrow a$ we have $F(x_n)\downarrow F(a)$.
Define the events $A_n=\{\omega : X(\omega)\leq x_n\}$, for $n\geq 1$. We will prove that $$\bigcap_{n=1}^\infty A_n=\{\omega:X(\omega)\leq a\}\, .$$
In one direction, if $X(\omega)\leq x_n$ for every $n\geq 1$, since $x_n\downarrow a$, we have $X(\omega)\leq a$.
In the other direction, if $X(\omega)\leq a$, since $a\leq x_n$ for each $n\geq 1$, we have $X(\omega)\leq x_n$, for every $n\geq 1$.
Using the Lemma, the result follows:
$$
F(x_n) = P\{X\leq x_n\} = P(A_n) \downarrow P\left( \cap_{n=1}^\infty A_n \right) = P\{X\leq a\} = F(a) \, .
$$
|
How can I prove that the cumulative distribution function is right continuous?
|
To prove the right continuity of the distribution function you have to use the continuity from above of $P$, which you probably proved in one of your probability courses.
Lemma. If a sequence of event
|
How can I prove that the cumulative distribution function is right continuous?
To prove the right continuity of the distribution function you have to use the continuity from above of $P$, which you probably proved in one of your probability courses.
Lemma. If a sequence of events $\{A_n\}_{n\geq 1}$ is decreasing, in the sense that $A_n\supset A_{n+1}$ for every $n\geq 1$, then $P(A_n)\downarrow P(A)$, in which $A=\cap_{n=1}^\infty A_n$.
Let's use the Lemma. The distribution function $F$ is right continuous at some point $a$ if and only if for every decreasing sequence of real numbers $\{x_n\}_{n\geq 1}$ such that $x_n\downarrow a$ we have $F(x_n)\downarrow F(a)$.
Define the events $A_n=\{\omega : X(\omega)\leq x_n\}$, for $n\geq 1$. We will prove that $$\bigcap_{n=1}^\infty A_n=\{\omega:X(\omega)\leq a\}\, .$$
In one direction, if $X(\omega)\leq x_n$ for every $n\geq 1$, since $x_n\downarrow a$, we have $X(\omega)\leq a$.
In the other direction, if $X(\omega)\leq a$, since $a\leq x_n$ for each $n\geq 1$, we have $X(\omega)\leq x_n$, for every $n\geq 1$.
Using the Lemma, the result follows:
$$
F(x_n) = P\{X\leq x_n\} = P(A_n) \downarrow P\left( \cap_{n=1}^\infty A_n \right) = P\{X\leq a\} = F(a) \, .
$$
|
How can I prove that the cumulative distribution function is right continuous?
To prove the right continuity of the distribution function you have to use the continuity from above of $P$, which you probably proved in one of your probability courses.
Lemma. If a sequence of event
|
11,558
|
How does boosting work?
|
In plain English: If your classifier misclassifies some data, train another copy of it mainly on this misclassified part with hope that it will discover something subtle. And then, as usual, iterate. On the way there are some voting schemes that allow to combine all those classifiers' predictions in sensible way.
Because sometimes it is impossible (the noise is just hiding some of the information, or it is not even present in the data); on the other hand, boosting too much may lead to overfitting.
|
How does boosting work?
|
In plain English: If your classifier misclassifies some data, train another copy of it mainly on this misclassified part with hope that it will discover something subtle. And then, as usual, iterate.
|
How does boosting work?
In plain English: If your classifier misclassifies some data, train another copy of it mainly on this misclassified part with hope that it will discover something subtle. And then, as usual, iterate. On the way there are some voting schemes that allow to combine all those classifiers' predictions in sensible way.
Because sometimes it is impossible (the noise is just hiding some of the information, or it is not even present in the data); on the other hand, boosting too much may lead to overfitting.
|
How does boosting work?
In plain English: If your classifier misclassifies some data, train another copy of it mainly on this misclassified part with hope that it will discover something subtle. And then, as usual, iterate.
|
11,559
|
How does boosting work?
|
Boosting employs shrinkage through the learning rate parameter, which, coupled with k-fold cross validation, "out-of-bag" (OOB) predictions or independent test set, determine the number of trees one should keep in the ensemble.
We want a model that learns slowly, hence there is a trade-off in terms of the complexity of each individual model and the number of models to include. The guidance I have seen suggests you should set the learning rate as low as is feasibly possible (given compute time and storage space requirements), whilst the complexity of each tree should be selected on basis of whether interactions are allowed, and to what degree, the more complex the tree, the more complex the interactions that can be represented.
The learning rate is chosen in the range $[0,1]$. Smaller values ($<0.01$) preferred. This is a weighting applied to each tree to down weight the contribution of each model to the fitted values.
k-fold CV (or OOB predictions or independent test set) is used to decide when the boosted model has started to overfit. Essentially it is this that stops us boosting to the perfect model, but it is better to learn slowly so we have a large ensemble of models contributing to the fitted model.
|
How does boosting work?
|
Boosting employs shrinkage through the learning rate parameter, which, coupled with k-fold cross validation, "out-of-bag" (OOB) predictions or independent test set, determine the number of trees one s
|
How does boosting work?
Boosting employs shrinkage through the learning rate parameter, which, coupled with k-fold cross validation, "out-of-bag" (OOB) predictions or independent test set, determine the number of trees one should keep in the ensemble.
We want a model that learns slowly, hence there is a trade-off in terms of the complexity of each individual model and the number of models to include. The guidance I have seen suggests you should set the learning rate as low as is feasibly possible (given compute time and storage space requirements), whilst the complexity of each tree should be selected on basis of whether interactions are allowed, and to what degree, the more complex the tree, the more complex the interactions that can be represented.
The learning rate is chosen in the range $[0,1]$. Smaller values ($<0.01$) preferred. This is a weighting applied to each tree to down weight the contribution of each model to the fitted values.
k-fold CV (or OOB predictions or independent test set) is used to decide when the boosted model has started to overfit. Essentially it is this that stops us boosting to the perfect model, but it is better to learn slowly so we have a large ensemble of models contributing to the fitted model.
|
How does boosting work?
Boosting employs shrinkage through the learning rate parameter, which, coupled with k-fold cross validation, "out-of-bag" (OOB) predictions or independent test set, determine the number of trees one s
|
11,560
|
What is a distribution over functions?
|
The concept is a bit more abstract than a usual distribution. The problem is that we are used to the concept of a distribution over $\mathbb{R}$, typically shown as a line, and then expand it to a surface $\mathbb{R}^2$, and so on to distributions over $\mathbb{R}^n$. But the space of functions cannot be represented as a square or a line or a vector. It's not a crime to think of it that way, like you do, but theory that works in $\mathbb{R}^n$, having to do with distance, neighborhoods and such (this is known as the topology of the space), are not the same in the space of functions. So drawing it as a square can give you wrong intuitions about that space.
You can simply think of the space of functions as a big collection of functions, perhaps a bag of things if you will. The distribution here then gives you the probabilities of drawing a subset of those things. The distribution will say: the probability that your next draw (of a function) is in this subset, is, for example, 10%. In the case of a Gaussian process on functions in two dimensions, you might ask, given an x-coordinate and an interval of y-values, this is a small vertical line segment, what is the probability that a (random) function will pass through this small line? That's going to be a positive probability. So the Gaussian process specifies a distribution (of probability) over a space of functions. In this example, the subset of the space of functions is the subset that passes through the line segment.
Another confusing naming conventention here is that a distribution is commonly specified by a density function, such as the bell shape with the normal distribution. There, the area under the distribution function tells you how probable an interval is. This doesn't work for all distributions however, and in particular, in the case of functions (not $\mathbb{R}$ as with the normal distributions), this doesn't work at all. That means you won't be able to write this distribution (as specified by the Gaussian process) as a density function.
|
What is a distribution over functions?
|
The concept is a bit more abstract than a usual distribution. The problem is that we are used to the concept of a distribution over $\mathbb{R}$, typically shown as a line, and then expand it to a sur
|
What is a distribution over functions?
The concept is a bit more abstract than a usual distribution. The problem is that we are used to the concept of a distribution over $\mathbb{R}$, typically shown as a line, and then expand it to a surface $\mathbb{R}^2$, and so on to distributions over $\mathbb{R}^n$. But the space of functions cannot be represented as a square or a line or a vector. It's not a crime to think of it that way, like you do, but theory that works in $\mathbb{R}^n$, having to do with distance, neighborhoods and such (this is known as the topology of the space), are not the same in the space of functions. So drawing it as a square can give you wrong intuitions about that space.
You can simply think of the space of functions as a big collection of functions, perhaps a bag of things if you will. The distribution here then gives you the probabilities of drawing a subset of those things. The distribution will say: the probability that your next draw (of a function) is in this subset, is, for example, 10%. In the case of a Gaussian process on functions in two dimensions, you might ask, given an x-coordinate and an interval of y-values, this is a small vertical line segment, what is the probability that a (random) function will pass through this small line? That's going to be a positive probability. So the Gaussian process specifies a distribution (of probability) over a space of functions. In this example, the subset of the space of functions is the subset that passes through the line segment.
Another confusing naming conventention here is that a distribution is commonly specified by a density function, such as the bell shape with the normal distribution. There, the area under the distribution function tells you how probable an interval is. This doesn't work for all distributions however, and in particular, in the case of functions (not $\mathbb{R}$ as with the normal distributions), this doesn't work at all. That means you won't be able to write this distribution (as specified by the Gaussian process) as a density function.
|
What is a distribution over functions?
The concept is a bit more abstract than a usual distribution. The problem is that we are used to the concept of a distribution over $\mathbb{R}$, typically shown as a line, and then expand it to a sur
|
11,561
|
What is a distribution over functions?
|
Your question has already been asked, and beautifully answered, on the Mathematics SE site:
https://math.stackexchange.com/questions/2297424/extending-a-distribution-over-samples-to-a-distribution-over-functions
It sounds like you're not familiar with the concepts of Gaussian measures on infinite-dimensional spaces, linear functionals, pushforward measures, etc. thus I'll try to keep it as simple as possible.
You already know how to define probabilities over real numbers (random variables) and over vectors (again, random variables, even if we usually call them random vectors). Now we want to introduce a probability measure over an infinite-dimensional vector-space: for example, the space $L^2([0,1])$ of square-integrable functions over $I=[0,1]$. Things get complicated now, because when we defined probability on $\mathbb{R}$ or $\mathbb{R}^n$, we were helped by the fact that the Lebesgue measure is defined on both spaces. However, there exists no Lebesgue measure over $L^2$(or any infinite-dimensional Banach space, for that matter). There are various solutions to this conundrum, most of which need a good familiarity with Functional Analysis.
However, there's also a simple "trick" based on the Kolmogorov extension theorem, which is basically the way stochastic processes are introduced in most of the probability courses which are not heavily measure-theoretic. Now I'm going to be very hand-wavy and non-rigorous, and limit myself to the case of Gaussian processes. If you want a more general definition, you can read the above answer or look up the Wikipedia link. The Kolmogorov extension theorem, applied to your specific use case, states more or less the following:
suppose that, for each finite set of points $S_n=\{ t_1, \dots ,t_n\} \subset I$, $\mathbf{x}_n=(x(t_1),\dots,x(t_n))$ has the multivariate Gaussian distribution
suppose now that for all possible $S_n, S_m, \enspace S_n\subset S_m $, the corresponding probability distribution functions $f_{S_n}(x_1,\dots,x_n)$ and $f_{S_m}(x_1,\dots,x_{n},x_{n+1},\dots,x_m)$ are consistent, i.e., if I integrate $f_{S_m}$ with respect to the variables which are in $S_m$ but not in $S_n$, then the resulting pdf is $f_{S_n}$:
$$ \int_{\mathbb{R}^{n-m+1}}f_{S_m}(x_1,\dots,x_{n},x_{n+1},\dots,x_m)\text{d}x_{n+1}\dots \text{d}x_m=f_{S_n}(x_1,\dots,x_n) $$
then there exist a stochastic process $X$, i.e., a random variable on the space of functions $L^2$, such that, for each finite set $S_n$, the probability distribution of those $n$ points is multivariate Gaussian.
The actual theorem is widely more general, but I guess this is what you were looking for.
|
What is a distribution over functions?
|
Your question has already been asked, and beautifully answered, on the Mathematics SE site:
https://math.stackexchange.com/questions/2297424/extending-a-distribution-over-samples-to-a-distribution-ove
|
What is a distribution over functions?
Your question has already been asked, and beautifully answered, on the Mathematics SE site:
https://math.stackexchange.com/questions/2297424/extending-a-distribution-over-samples-to-a-distribution-over-functions
It sounds like you're not familiar with the concepts of Gaussian measures on infinite-dimensional spaces, linear functionals, pushforward measures, etc. thus I'll try to keep it as simple as possible.
You already know how to define probabilities over real numbers (random variables) and over vectors (again, random variables, even if we usually call them random vectors). Now we want to introduce a probability measure over an infinite-dimensional vector-space: for example, the space $L^2([0,1])$ of square-integrable functions over $I=[0,1]$. Things get complicated now, because when we defined probability on $\mathbb{R}$ or $\mathbb{R}^n$, we were helped by the fact that the Lebesgue measure is defined on both spaces. However, there exists no Lebesgue measure over $L^2$(or any infinite-dimensional Banach space, for that matter). There are various solutions to this conundrum, most of which need a good familiarity with Functional Analysis.
However, there's also a simple "trick" based on the Kolmogorov extension theorem, which is basically the way stochastic processes are introduced in most of the probability courses which are not heavily measure-theoretic. Now I'm going to be very hand-wavy and non-rigorous, and limit myself to the case of Gaussian processes. If you want a more general definition, you can read the above answer or look up the Wikipedia link. The Kolmogorov extension theorem, applied to your specific use case, states more or less the following:
suppose that, for each finite set of points $S_n=\{ t_1, \dots ,t_n\} \subset I$, $\mathbf{x}_n=(x(t_1),\dots,x(t_n))$ has the multivariate Gaussian distribution
suppose now that for all possible $S_n, S_m, \enspace S_n\subset S_m $, the corresponding probability distribution functions $f_{S_n}(x_1,\dots,x_n)$ and $f_{S_m}(x_1,\dots,x_{n},x_{n+1},\dots,x_m)$ are consistent, i.e., if I integrate $f_{S_m}$ with respect to the variables which are in $S_m$ but not in $S_n$, then the resulting pdf is $f_{S_n}$:
$$ \int_{\mathbb{R}^{n-m+1}}f_{S_m}(x_1,\dots,x_{n},x_{n+1},\dots,x_m)\text{d}x_{n+1}\dots \text{d}x_m=f_{S_n}(x_1,\dots,x_n) $$
then there exist a stochastic process $X$, i.e., a random variable on the space of functions $L^2$, such that, for each finite set $S_n$, the probability distribution of those $n$ points is multivariate Gaussian.
The actual theorem is widely more general, but I guess this is what you were looking for.
|
What is a distribution over functions?
Your question has already been asked, and beautifully answered, on the Mathematics SE site:
https://math.stackexchange.com/questions/2297424/extending-a-distribution-over-samples-to-a-distribution-ove
|
11,562
|
How do ABC and MCMC differ in their applications?
|
Some additional comments on top of Björn's answer:
ABC was first introduced by Rubin (1984) as an explanation of the nature of Bayesian inference, rather than for computational purposes. In this paper he explained how the sampling distribution and the prior distribution interact to produce the posterior distribution.
ABC is however primarily exploited for computational reasons. Population geneticists came up with the method on tree-based models where the likelihood of the observed sample was intractable. The MCMC (Data Augmentation) schemes that were available in such settings were awfully inefficient and so was importance sampling, even with a parameter of a single dimension... At its core, ABC is a substitute to Monte Carlo methods like MCMC or PMC when those are not available for all practical purposes. When they are available, ABC appears as a proxy that may be used to calibrate them if it runs faster.
In a more modern perspective, I personally consider ABC as an approximate inference method rather than a computational technique. By building an approximate model, one can draw inference on the parameter of interest without necessarily relying on a precise model. While some degree of validation is necessary in this setting, it is not less valid than doing model averaging or non-parametrics. In fact, ABC can be seen as a special type of non-parametric Bayesian statistics.
It can also be shown that (noisy) ABC is a perfectly well-defined Bayesian approach if one replaces the original model and data with a noisy one. As such it allows for all Bayesian inferences one can think of. Including testing. Our input to the debate about ABC and hypothesis testing is that the approximate model underlying ABC may end up as poorly equipped to assess the relevance of an hypothesis given the data, but not necessarily, which is just as well since most applications of ABC in population genetics are concerned with model choice.
In an even more recent perspective, we can see ABC as a Bayesian version of indirect inference where the parameters of a statistical model are related with the moments of a pre-determined statistic. If this statistic is enough (or sufficient in the vernacular sense) to identify these parameters, ABC can be shown to converge to the true value of the parameters with the number of observations.
|
How do ABC and MCMC differ in their applications?
|
Some additional comments on top of Björn's answer:
ABC was first introduced by Rubin (1984) as an explanation of the nature of Bayesian inference, rather than for computational purposes. In this pape
|
How do ABC and MCMC differ in their applications?
Some additional comments on top of Björn's answer:
ABC was first introduced by Rubin (1984) as an explanation of the nature of Bayesian inference, rather than for computational purposes. In this paper he explained how the sampling distribution and the prior distribution interact to produce the posterior distribution.
ABC is however primarily exploited for computational reasons. Population geneticists came up with the method on tree-based models where the likelihood of the observed sample was intractable. The MCMC (Data Augmentation) schemes that were available in such settings were awfully inefficient and so was importance sampling, even with a parameter of a single dimension... At its core, ABC is a substitute to Monte Carlo methods like MCMC or PMC when those are not available for all practical purposes. When they are available, ABC appears as a proxy that may be used to calibrate them if it runs faster.
In a more modern perspective, I personally consider ABC as an approximate inference method rather than a computational technique. By building an approximate model, one can draw inference on the parameter of interest without necessarily relying on a precise model. While some degree of validation is necessary in this setting, it is not less valid than doing model averaging or non-parametrics. In fact, ABC can be seen as a special type of non-parametric Bayesian statistics.
It can also be shown that (noisy) ABC is a perfectly well-defined Bayesian approach if one replaces the original model and data with a noisy one. As such it allows for all Bayesian inferences one can think of. Including testing. Our input to the debate about ABC and hypothesis testing is that the approximate model underlying ABC may end up as poorly equipped to assess the relevance of an hypothesis given the data, but not necessarily, which is just as well since most applications of ABC in population genetics are concerned with model choice.
In an even more recent perspective, we can see ABC as a Bayesian version of indirect inference where the parameters of a statistical model are related with the moments of a pre-determined statistic. If this statistic is enough (or sufficient in the vernacular sense) to identify these parameters, ABC can be shown to converge to the true value of the parameters with the number of observations.
|
How do ABC and MCMC differ in their applications?
Some additional comments on top of Björn's answer:
ABC was first introduced by Rubin (1984) as an explanation of the nature of Bayesian inference, rather than for computational purposes. In this pape
|
11,563
|
How do ABC and MCMC differ in their applications?
|
The difference is that with ABC you do not need an analytic expression for $P(x|\theta)$ and instead approximate it by simulating data and seeing for which values of $\theta$ simulated data most often (approximately) matches the observed data (with proposed values e.g. drawn randomly from the prior). For simple cases, such as a single binomial random variable with a not too large sample size you can even require an exact match and in those cases, there really is absolutely nothing you could not do with these posterior samples that you could not also do with standard MCMC samples. For more complex situations with continuous (even for multivariate discrete outcomes) and potentially multivariate outcomes requiring an exact match is no longer feasible.
There are in fact MCMC versions of ABC, which addresses the issue that if you have a prior that does not closely resemble the posterior (e.g. because the prior is very uninformative) sampling by drawing from the prior is extremly inefficient, because you very rarely will get a close match between the observed and the simulated data.
When $P(x|\theta)$ is analytically available, I assume it will nearly always be preferrable to use a standard MCMC. I suppose it is conceivable that somehow the evaluation of $P(x|\theta)$ is so incredibly computationally expensive that ABC performs better. Perhaps someone knows an example of this. In contrast I would consider ABC or MCMC-ABC (or one of the many other ABC variants) primarily when a standard MCMC approach is not an option, because $P(x|\theta)$ is not analytically available. Of course there may be some other possible options in such cases (e.g. INLA, quadratic approximations to likelihoods etc.) that may be more efficient/successful for particular problems. In a way, any limitations in what you can do with posterior samples from ABC come from only requiring an aproximate match between the actual and the simulated data (if you could require an exact match, there would be no issues, at all). There are several good introductory papers e.g. this paper by Marin et al. (2012). At least one of the co-authors (@Xi'an) is an active contributor here and I'd love to here his thoughts, too - I believe he may be able to say a lot more on the testing topic.
|
How do ABC and MCMC differ in their applications?
|
The difference is that with ABC you do not need an analytic expression for $P(x|\theta)$ and instead approximate it by simulating data and seeing for which values of $\theta$ simulated data most often
|
How do ABC and MCMC differ in their applications?
The difference is that with ABC you do not need an analytic expression for $P(x|\theta)$ and instead approximate it by simulating data and seeing for which values of $\theta$ simulated data most often (approximately) matches the observed data (with proposed values e.g. drawn randomly from the prior). For simple cases, such as a single binomial random variable with a not too large sample size you can even require an exact match and in those cases, there really is absolutely nothing you could not do with these posterior samples that you could not also do with standard MCMC samples. For more complex situations with continuous (even for multivariate discrete outcomes) and potentially multivariate outcomes requiring an exact match is no longer feasible.
There are in fact MCMC versions of ABC, which addresses the issue that if you have a prior that does not closely resemble the posterior (e.g. because the prior is very uninformative) sampling by drawing from the prior is extremly inefficient, because you very rarely will get a close match between the observed and the simulated data.
When $P(x|\theta)$ is analytically available, I assume it will nearly always be preferrable to use a standard MCMC. I suppose it is conceivable that somehow the evaluation of $P(x|\theta)$ is so incredibly computationally expensive that ABC performs better. Perhaps someone knows an example of this. In contrast I would consider ABC or MCMC-ABC (or one of the many other ABC variants) primarily when a standard MCMC approach is not an option, because $P(x|\theta)$ is not analytically available. Of course there may be some other possible options in such cases (e.g. INLA, quadratic approximations to likelihoods etc.) that may be more efficient/successful for particular problems. In a way, any limitations in what you can do with posterior samples from ABC come from only requiring an aproximate match between the actual and the simulated data (if you could require an exact match, there would be no issues, at all). There are several good introductory papers e.g. this paper by Marin et al. (2012). At least one of the co-authors (@Xi'an) is an active contributor here and I'd love to here his thoughts, too - I believe he may be able to say a lot more on the testing topic.
|
How do ABC and MCMC differ in their applications?
The difference is that with ABC you do not need an analytic expression for $P(x|\theta)$ and instead approximate it by simulating data and seeing for which values of $\theta$ simulated data most often
|
11,564
|
Methods to compute factor scores, and what is the "score coefficient" matrix in PCA or factor analysis?
|
Methods of computation of factor/component scores
After a series of comments I decided finally to issue an answer (based on the comments and more). It is about computing component scores in PCA and factor scores in factor analysis.
Factor/component scores are given by $\bf \hat{F}=XB$, where $\bf X$ are the analyzed variables (centered if the PCA/factor analysis was based on covariances or z-standardized if it was based on correlations). $\bf B$ is the factor/component score coefficient (or weight) matrix. How can these weights be estimated?
Notation
$\bf R$ - p x p matrix of variable (item) correlations or covariances, whichever was factor/PCA analyzed.
$\bf P$ - p x m matrix of factor/component loadings. These might be loadings after extraction (often also denoted $\bf A$) whereupon the latents are orthogonal or practically so, or loadings after rotation, orthogonal or oblique. If the rotation was oblique, it must be pattern loadings.
$\bf C$ - m x m matrix of correlations between the factors/components after their (the loadings) oblique rotation. If no rotation or orthogonal rotation was performed, this is identity matrix.
$\bf \hat R$ - p x p reduced matrix of reproduced correlations/covariances, $\bf = PCP'$ ($\bf = PP'$ for orthogonal solutions), it contains communalities on its diagonal.
$\bf U_2$ - p x p diagonal matrix of uniquenesses (uniqueness + communality = diagonal element of $\bf R$). I'm using "2" as subscript here instead of superscript ($\bf U^2$) for readability convenience in formulas.
$\bf R^*$ - p x p full matrix of reproduced correlations/covariances, $\bf = \hat R + U_2$.
$\bf M^+$ - pseudoinverse of some matrix $\bf M$; if $\bf M$ is full-rank, $\bf M^+ = (M'M)^{-1}M'$.
$\bf M^{power}$ - for some square symmetric matrix $\bf M$ its raising to $power$ amounts to eigendecomposing $\bf HKH'=M$, raising the eigenvalues to the power and composing back: $\bf M^{power}=HK^{power}H'$.
Coarse method of computing factor/component scores
This popular/traditional approach, sometimes called Cattell's, is simply averaging (or summing up) values of items which are loaded by the same factor. Mathematically, it amounts to setting weights $\bf B=P$ in computation of scores $\bf \hat{F}=XB$. There is three main versions of the approach: 1) Use loadings as they are; 2) Dichotomize them (1 = loaded, 0 = not loaded); 3) Use loadings as they are but zero-off loadings smaller than some threshold.
Often with this approach when items are on the same scale unit, values $\bf X$ are used just raw; though not to break the logic of factoring one would better use the $\bf X$ as it entered the factoring - standardized (= analysis of correlations) or centered (= analysis of covariances).
The principal disadvantage of the coarse method of reckoning factor/component scores in my view is that it does not account for correlations between the loaded items. If items loaded by a factor tightly correlate and one is loaded stronger then the other, the latter can be reasonably considered a younger duplicate and its weight could be lessened. Refined methods do it, but coarse method cannot.
Coarse scores are of course easy to compute because no matrix inversion is needed. Advantage of the coarse method (explaining why it is still widely used in spite of computers availability) is that it gives scores which are more stable from sample to sample when sampling is not ideal (in the sense of representativeness and size) or the items for analysis were not well selected. To cite one paper, "The sum score method may be most desirable when the scales used to collect the original data are untested and exploratory, with little or no evidence of reliability or validity". Also, it does not require to understand "factor" necessarily as univariate latent essense, as factor analysis model requires it (see, see). You could, for example, conceptuilize a factor as a collection of phenomena - then to sum the item values is reasonable.
Refined methods of computing factor/component scores
These methods are what factor analytic packages do. They estimate $\bf B$ by various methods. While loadings $\bf A$ or $\bf P$ are the coefficients of linear combinations to predict variables by factors/components, $\bf B$ are the coefficients to compute factor/component scores out of variables.
The scores computed via $\bf B$ are scaled: they have variances equal to or close to 1 (standardized or near standardized) - not the true factor variances (which equal the sum of squared structure loadings, see Footnote 3 here). So, when you need to supply factor scores with the true factor's variance, multiply the scores (having standardized them to st.dev. 1) by the sq. root of that variance.
You may preserve $\bf B$ from the analysis done, to be able to compute scores for new coming observations of $\bf X$. Also, $\bf B$ may be used to weight items constituting a scale of a questionnaire when the scale is developed from or validated by factor analysis. (Squared) coefficients of $\bf B$ can be interpreted as contributions of items to factors. Coefficints can be standardized like regression coefficient is standardized $\beta=b \frac{\sigma_{item}}{\sigma_{factor}}$ (where $\sigma_{factor}=1$) to compare contributions of items with different variances.
See an example showing computations done in PCA and in FA, including computation of scores out of the score coefficient matrix.
Geometric explanation of loadings $a$'s (as perpendicular coordinates) and score coefficients $b$'s (skew coordinates) in PCA settings is presented on the first two pictures here.
Now to the refined methods.
The methods
Computation of $\bf B$ in PCA
When component loadings are extracted but not rotated, $\bf B= AL^{-1}$, where $\bf L$ is the diagonal matrix comprised of m eigenvalues; this formula amounts to simply dividing each column of $\bf A$ by the respective eigenvalue - the component's variance.
Equivalently, $\bf B= (P^+)'$. This formula holds also for components (loadings) rotated, orthogonally (such as varimax), or obliquely.
Some of methods used in factor analysis (see below), if applied within PCA return the same result.
Component scores computed have variances 1 and they are true standardized values of components.
What in statistical data analysis is called principal component coefficient matrix $\bf B$, and if it is computed from complete p x p and not anyhow rotated loading matrix, that in machine learning literature is often labelled the (PCA-based) whitening matrix, and the standardized principal components are recognized as "whitened" data.
Computation of $\bf B$ in common Factor analysis
Unlike component scores, factor scores are never exact; they are only approximations to the unknown true values $\bf F$ of the factors. This is because we don't know values of communalities or uniquenesses on case level, - since factors, unlike components, are external variables separate from the manifest ones, and having their own, unknown to us distribution. Which is the cause of that factor score indeterminacy. Note that the indeterminacy problem is logically independent on the quality of the factor solution: how much a factor is true (corresponds to the latent what generates data in population) is another issue than how much respondents' scores of a factor are true (accurate estimates of the extracted factor).
Since factor scores are approximations, alternative methods to compute them exist and compete.
Regression or Thurstone's or Thompson's method of estimating factor scores is given by $\bf B=R^{-1} PC = R^{-1} S$, where $\bf S=PC$ is the matrix of structure loadings (for orthogonal factor solutions, we know $\bf A=P=S$). The foundation of regression method is in footnote $^1$.
Note. This formula for $\bf B$ is usable also with PCA: it will give, in PCA, the same result as the formulas cited in the previous section.
In FA (not PCA), regressionally computed factor scores will appear not quite "standardized" - will have variances not 1, but equal to the $\frac {SS_{regr}}{(n-1)}$ of regressing these scores by the variables. This value can be interpreted as the degree of determination of a factor (its true unknown values) by variables - the R-square of the prediction of the real factor by them, and the regression method maximizes it, - the "validity" of computed scores. Picture $^2$ shows the geometry. (Please note that $\frac {SS_{regr}}{(n-1)}$ will equal the scores' variance for any refined method, yet only for regression method that quantity will equal the proportion of determination of true f. values by f. scores.)
As a variant of regression method, one may use $\bf R^*$ in place of $\bf R$ in the formula. It is warranted on the grounds that in a good factor analysis $\bf R$ and $\bf R^*$ are very similar. However, when they are not, especially when the number of factors m is less than the true population number, the method produces strong bias in scores. And you should not use this "reproduced R regression" method with PCA.
PCA's method, also known as Horst's (Mulaik) or ideal(ized) variable approach (Harman). This is regression method with $\bf \hat R$ in place of $\bf R$ in its formula. It can be easily shown that the formula then reduces to $\bf B= (P^+)'$ (and so yes, we actually don't need to know $\bf C$ with it). Factor scores are computed as if they were component scores.
[Label "idealized variable" comes from the fact that since according to factor or component model the predicted portion of variables is $\bf \hat X = FP'$, it follows $\bf F= (P^+)' \hat X$, but we substitute $\bf X$ for the unknown (ideal) $\bf \hat X$, to estimate $\bf F$ as scores $\bf \hat F$; we therefore "idealize" $\bf X$.]
Please note that this method is not passing off PCA component scores for factor scores, because loadings used are not PCA's loadings but factor analysis'; only that the computation approach for scores mirrors that in PCA.
Bartlett's method. Here, $\bf B'=(P'U_2^{-1}P)^{-1} P' U_2^{-1}$. This method seeks to minimize, for every respondent, varince across p unique ("error") factors. Variances of the resultant common factor scores will not be equal and may exceed 1.
Anderson-Rubin method was developed as a modification of the previous. $\bf B'=(P'U_2^{-1}RU_2^{-1}P)^{-1/2} P'U_2^{-1}$. Variances of the scores will be exactly 1. This method, however, is for orthogonal factor solutions only (for oblique solutions it will yield still orthogonal scores).
McDonald-Anderson-Rubin method. McDonald extended Anderson-Rubin over to the oblique factors solutions as well. So this one is more general. With orthogonal factors, it actually reduces to Anderson-Rubin. Some packages probably may use McDonald's method while calling it "Anderson-Rubin". The formula is: $\bf B= R^{-1/2} GH' C^{1/2}$, where $\bf G$ and $\bf H$ are obtained in $\text{svd} \bf (R^{1/2}U_2^{-1}PC^{1/2}) = G \Delta H'$. (Use only first m columns in $\bf G$, of course.)
Green's method. Uses the same formula as McDonald-Anderson-Rubin, but $\bf G$ and $\bf H$ are computed as: $\text{svd} \bf (R^{-1/2}PC^{3/2}) = G \Delta H'$. (Use only first m columns in $\bf G$, of course.) Green's method doesn't use commulalities (or uniquenesses) information. It approaches and converges to McDonald-Anderson-Rubin method as variables' actual communalities become more and more equal. And if applied to loadings of PCA, Green returns component scores, like native PCA's method.
Krijnen et al method. This method is a generalization which accommodates both previous two by a single formula. It probably doesn't add any new or important new features, so I'm not considering it.
Comparison between the refined methods.
Regression method maximizes correlation between factor scores and
unknown true values of that factor (i.e. maximizes the statistical validity), but the scores are somewhat biased and they somewhat incorrectly correlate
between factors (e.g., they correlate even when factors in a solution are orthogonal). These are least-squares estimates.
PCA's method is also least squares, but with less statistical validity. They are faster to compute; they are not often used in factor analysis nowadays, due to computers. (In PCA, this method is native and optimal.)
Bartlett's scores are unbiased estimates of true factor values. The
scores are computed to correlate accurately with true, unknown values of other
factors (e.g. not to correlate with them in orthogonal solution, for example). However, they still may correlate inaccurately with factor scores
computed for other factors. These are maximum-likelihood (under multivariate normality of $\bf X$ assumption) estimates.
Anderson-Rubin / McDonald-Anderson-Rubin and Green's scores are called correlation preserving because are computed to correlate accurately with factor scores of other factors. Correlations between factor scores equal the correlations between the factors in the solution (so in orthogonal solution, for instance, the scores will be perfectly uncorrelated). But the scores are somewhat biased and their validity may be modest.
Check this table, too:
[A note for SPSS users: If you are doing PCA ("principal components" extraction method) but request factor scores other than "Regression" method, the program will disregard the request and will compute you "Regression" scores instead (which are exact component scores).]
References
Grice, James W. Computing and Evaluating Factor Scores //
Psychological Methods 2001, Vol. 6, No. 4, 430-450.
DiStefano, Christine et al. Understanding and Using Factor Scores // Practical Assessment, Research & Evaluation, Vol 14, No 20
ten Berge, Jos M.F.et al. Some new results on correlation-preserving factor scores prediction methods // Linear Algebra and its Applications 289 (1999)
311-318.
Mulaik, Stanley A. Foundations of Factor Analysis, 2nd Edition, 2009
Harman, Harry H. Modern Factor Analysis, 3rd Edition, 1976
Neudecker, Heinz. On best affine unbiased covariance-preserving prediction of factor scores // SORT 28(1) January-June 2004, 27-36
$^1$ It can be observed in multiple linear regression with centered data that if
$F=b_1X_1+b_2X_2$, then covariances $s_1$ and $s_2$ between $F$ and the predictors are:
$s_1=b_1r_{11}+b_2r_{12}$,
$s_2=b_1r_{12}+b_2r_{22}$,
with $r$s being the covariances between the $X$s. In vector notation: $\bf s=Rb$. In regression method of computing factor scores $F$ we estimate $b$s from true known $r$s and $s$s.
$^2$ The following picture is both pictures of here combined in one. It shows the difference between common factor and principal component. Component (thin red vector) lies in the space spanned by the variables (two blue vectors), white "plane X". Factor (fat red vector) overruns that space. Factor's orthogonal projection on the plane (thin grey vector) is the regressionally estimated factor scores. By the definition of linear regression, factor scores is the best, in terms of least squares, approximation of factor available by the variables.
|
Methods to compute factor scores, and what is the "score coefficient" matrix in PCA or factor analys
|
Methods of computation of factor/component scores
After a series of comments I decided finally to issue an answer (based on the comments and more). It is about computing component scores in PCA and fa
|
Methods to compute factor scores, and what is the "score coefficient" matrix in PCA or factor analysis?
Methods of computation of factor/component scores
After a series of comments I decided finally to issue an answer (based on the comments and more). It is about computing component scores in PCA and factor scores in factor analysis.
Factor/component scores are given by $\bf \hat{F}=XB$, where $\bf X$ are the analyzed variables (centered if the PCA/factor analysis was based on covariances or z-standardized if it was based on correlations). $\bf B$ is the factor/component score coefficient (or weight) matrix. How can these weights be estimated?
Notation
$\bf R$ - p x p matrix of variable (item) correlations or covariances, whichever was factor/PCA analyzed.
$\bf P$ - p x m matrix of factor/component loadings. These might be loadings after extraction (often also denoted $\bf A$) whereupon the latents are orthogonal or practically so, or loadings after rotation, orthogonal or oblique. If the rotation was oblique, it must be pattern loadings.
$\bf C$ - m x m matrix of correlations between the factors/components after their (the loadings) oblique rotation. If no rotation or orthogonal rotation was performed, this is identity matrix.
$\bf \hat R$ - p x p reduced matrix of reproduced correlations/covariances, $\bf = PCP'$ ($\bf = PP'$ for orthogonal solutions), it contains communalities on its diagonal.
$\bf U_2$ - p x p diagonal matrix of uniquenesses (uniqueness + communality = diagonal element of $\bf R$). I'm using "2" as subscript here instead of superscript ($\bf U^2$) for readability convenience in formulas.
$\bf R^*$ - p x p full matrix of reproduced correlations/covariances, $\bf = \hat R + U_2$.
$\bf M^+$ - pseudoinverse of some matrix $\bf M$; if $\bf M$ is full-rank, $\bf M^+ = (M'M)^{-1}M'$.
$\bf M^{power}$ - for some square symmetric matrix $\bf M$ its raising to $power$ amounts to eigendecomposing $\bf HKH'=M$, raising the eigenvalues to the power and composing back: $\bf M^{power}=HK^{power}H'$.
Coarse method of computing factor/component scores
This popular/traditional approach, sometimes called Cattell's, is simply averaging (or summing up) values of items which are loaded by the same factor. Mathematically, it amounts to setting weights $\bf B=P$ in computation of scores $\bf \hat{F}=XB$. There is three main versions of the approach: 1) Use loadings as they are; 2) Dichotomize them (1 = loaded, 0 = not loaded); 3) Use loadings as they are but zero-off loadings smaller than some threshold.
Often with this approach when items are on the same scale unit, values $\bf X$ are used just raw; though not to break the logic of factoring one would better use the $\bf X$ as it entered the factoring - standardized (= analysis of correlations) or centered (= analysis of covariances).
The principal disadvantage of the coarse method of reckoning factor/component scores in my view is that it does not account for correlations between the loaded items. If items loaded by a factor tightly correlate and one is loaded stronger then the other, the latter can be reasonably considered a younger duplicate and its weight could be lessened. Refined methods do it, but coarse method cannot.
Coarse scores are of course easy to compute because no matrix inversion is needed. Advantage of the coarse method (explaining why it is still widely used in spite of computers availability) is that it gives scores which are more stable from sample to sample when sampling is not ideal (in the sense of representativeness and size) or the items for analysis were not well selected. To cite one paper, "The sum score method may be most desirable when the scales used to collect the original data are untested and exploratory, with little or no evidence of reliability or validity". Also, it does not require to understand "factor" necessarily as univariate latent essense, as factor analysis model requires it (see, see). You could, for example, conceptuilize a factor as a collection of phenomena - then to sum the item values is reasonable.
Refined methods of computing factor/component scores
These methods are what factor analytic packages do. They estimate $\bf B$ by various methods. While loadings $\bf A$ or $\bf P$ are the coefficients of linear combinations to predict variables by factors/components, $\bf B$ are the coefficients to compute factor/component scores out of variables.
The scores computed via $\bf B$ are scaled: they have variances equal to or close to 1 (standardized or near standardized) - not the true factor variances (which equal the sum of squared structure loadings, see Footnote 3 here). So, when you need to supply factor scores with the true factor's variance, multiply the scores (having standardized them to st.dev. 1) by the sq. root of that variance.
You may preserve $\bf B$ from the analysis done, to be able to compute scores for new coming observations of $\bf X$. Also, $\bf B$ may be used to weight items constituting a scale of a questionnaire when the scale is developed from or validated by factor analysis. (Squared) coefficients of $\bf B$ can be interpreted as contributions of items to factors. Coefficints can be standardized like regression coefficient is standardized $\beta=b \frac{\sigma_{item}}{\sigma_{factor}}$ (where $\sigma_{factor}=1$) to compare contributions of items with different variances.
See an example showing computations done in PCA and in FA, including computation of scores out of the score coefficient matrix.
Geometric explanation of loadings $a$'s (as perpendicular coordinates) and score coefficients $b$'s (skew coordinates) in PCA settings is presented on the first two pictures here.
Now to the refined methods.
The methods
Computation of $\bf B$ in PCA
When component loadings are extracted but not rotated, $\bf B= AL^{-1}$, where $\bf L$ is the diagonal matrix comprised of m eigenvalues; this formula amounts to simply dividing each column of $\bf A$ by the respective eigenvalue - the component's variance.
Equivalently, $\bf B= (P^+)'$. This formula holds also for components (loadings) rotated, orthogonally (such as varimax), or obliquely.
Some of methods used in factor analysis (see below), if applied within PCA return the same result.
Component scores computed have variances 1 and they are true standardized values of components.
What in statistical data analysis is called principal component coefficient matrix $\bf B$, and if it is computed from complete p x p and not anyhow rotated loading matrix, that in machine learning literature is often labelled the (PCA-based) whitening matrix, and the standardized principal components are recognized as "whitened" data.
Computation of $\bf B$ in common Factor analysis
Unlike component scores, factor scores are never exact; they are only approximations to the unknown true values $\bf F$ of the factors. This is because we don't know values of communalities or uniquenesses on case level, - since factors, unlike components, are external variables separate from the manifest ones, and having their own, unknown to us distribution. Which is the cause of that factor score indeterminacy. Note that the indeterminacy problem is logically independent on the quality of the factor solution: how much a factor is true (corresponds to the latent what generates data in population) is another issue than how much respondents' scores of a factor are true (accurate estimates of the extracted factor).
Since factor scores are approximations, alternative methods to compute them exist and compete.
Regression or Thurstone's or Thompson's method of estimating factor scores is given by $\bf B=R^{-1} PC = R^{-1} S$, where $\bf S=PC$ is the matrix of structure loadings (for orthogonal factor solutions, we know $\bf A=P=S$). The foundation of regression method is in footnote $^1$.
Note. This formula for $\bf B$ is usable also with PCA: it will give, in PCA, the same result as the formulas cited in the previous section.
In FA (not PCA), regressionally computed factor scores will appear not quite "standardized" - will have variances not 1, but equal to the $\frac {SS_{regr}}{(n-1)}$ of regressing these scores by the variables. This value can be interpreted as the degree of determination of a factor (its true unknown values) by variables - the R-square of the prediction of the real factor by them, and the regression method maximizes it, - the "validity" of computed scores. Picture $^2$ shows the geometry. (Please note that $\frac {SS_{regr}}{(n-1)}$ will equal the scores' variance for any refined method, yet only for regression method that quantity will equal the proportion of determination of true f. values by f. scores.)
As a variant of regression method, one may use $\bf R^*$ in place of $\bf R$ in the formula. It is warranted on the grounds that in a good factor analysis $\bf R$ and $\bf R^*$ are very similar. However, when they are not, especially when the number of factors m is less than the true population number, the method produces strong bias in scores. And you should not use this "reproduced R regression" method with PCA.
PCA's method, also known as Horst's (Mulaik) or ideal(ized) variable approach (Harman). This is regression method with $\bf \hat R$ in place of $\bf R$ in its formula. It can be easily shown that the formula then reduces to $\bf B= (P^+)'$ (and so yes, we actually don't need to know $\bf C$ with it). Factor scores are computed as if they were component scores.
[Label "idealized variable" comes from the fact that since according to factor or component model the predicted portion of variables is $\bf \hat X = FP'$, it follows $\bf F= (P^+)' \hat X$, but we substitute $\bf X$ for the unknown (ideal) $\bf \hat X$, to estimate $\bf F$ as scores $\bf \hat F$; we therefore "idealize" $\bf X$.]
Please note that this method is not passing off PCA component scores for factor scores, because loadings used are not PCA's loadings but factor analysis'; only that the computation approach for scores mirrors that in PCA.
Bartlett's method. Here, $\bf B'=(P'U_2^{-1}P)^{-1} P' U_2^{-1}$. This method seeks to minimize, for every respondent, varince across p unique ("error") factors. Variances of the resultant common factor scores will not be equal and may exceed 1.
Anderson-Rubin method was developed as a modification of the previous. $\bf B'=(P'U_2^{-1}RU_2^{-1}P)^{-1/2} P'U_2^{-1}$. Variances of the scores will be exactly 1. This method, however, is for orthogonal factor solutions only (for oblique solutions it will yield still orthogonal scores).
McDonald-Anderson-Rubin method. McDonald extended Anderson-Rubin over to the oblique factors solutions as well. So this one is more general. With orthogonal factors, it actually reduces to Anderson-Rubin. Some packages probably may use McDonald's method while calling it "Anderson-Rubin". The formula is: $\bf B= R^{-1/2} GH' C^{1/2}$, where $\bf G$ and $\bf H$ are obtained in $\text{svd} \bf (R^{1/2}U_2^{-1}PC^{1/2}) = G \Delta H'$. (Use only first m columns in $\bf G$, of course.)
Green's method. Uses the same formula as McDonald-Anderson-Rubin, but $\bf G$ and $\bf H$ are computed as: $\text{svd} \bf (R^{-1/2}PC^{3/2}) = G \Delta H'$. (Use only first m columns in $\bf G$, of course.) Green's method doesn't use commulalities (or uniquenesses) information. It approaches and converges to McDonald-Anderson-Rubin method as variables' actual communalities become more and more equal. And if applied to loadings of PCA, Green returns component scores, like native PCA's method.
Krijnen et al method. This method is a generalization which accommodates both previous two by a single formula. It probably doesn't add any new or important new features, so I'm not considering it.
Comparison between the refined methods.
Regression method maximizes correlation between factor scores and
unknown true values of that factor (i.e. maximizes the statistical validity), but the scores are somewhat biased and they somewhat incorrectly correlate
between factors (e.g., they correlate even when factors in a solution are orthogonal). These are least-squares estimates.
PCA's method is also least squares, but with less statistical validity. They are faster to compute; they are not often used in factor analysis nowadays, due to computers. (In PCA, this method is native and optimal.)
Bartlett's scores are unbiased estimates of true factor values. The
scores are computed to correlate accurately with true, unknown values of other
factors (e.g. not to correlate with them in orthogonal solution, for example). However, they still may correlate inaccurately with factor scores
computed for other factors. These are maximum-likelihood (under multivariate normality of $\bf X$ assumption) estimates.
Anderson-Rubin / McDonald-Anderson-Rubin and Green's scores are called correlation preserving because are computed to correlate accurately with factor scores of other factors. Correlations between factor scores equal the correlations between the factors in the solution (so in orthogonal solution, for instance, the scores will be perfectly uncorrelated). But the scores are somewhat biased and their validity may be modest.
Check this table, too:
[A note for SPSS users: If you are doing PCA ("principal components" extraction method) but request factor scores other than "Regression" method, the program will disregard the request and will compute you "Regression" scores instead (which are exact component scores).]
References
Grice, James W. Computing and Evaluating Factor Scores //
Psychological Methods 2001, Vol. 6, No. 4, 430-450.
DiStefano, Christine et al. Understanding and Using Factor Scores // Practical Assessment, Research & Evaluation, Vol 14, No 20
ten Berge, Jos M.F.et al. Some new results on correlation-preserving factor scores prediction methods // Linear Algebra and its Applications 289 (1999)
311-318.
Mulaik, Stanley A. Foundations of Factor Analysis, 2nd Edition, 2009
Harman, Harry H. Modern Factor Analysis, 3rd Edition, 1976
Neudecker, Heinz. On best affine unbiased covariance-preserving prediction of factor scores // SORT 28(1) January-June 2004, 27-36
$^1$ It can be observed in multiple linear regression with centered data that if
$F=b_1X_1+b_2X_2$, then covariances $s_1$ and $s_2$ between $F$ and the predictors are:
$s_1=b_1r_{11}+b_2r_{12}$,
$s_2=b_1r_{12}+b_2r_{22}$,
with $r$s being the covariances between the $X$s. In vector notation: $\bf s=Rb$. In regression method of computing factor scores $F$ we estimate $b$s from true known $r$s and $s$s.
$^2$ The following picture is both pictures of here combined in one. It shows the difference between common factor and principal component. Component (thin red vector) lies in the space spanned by the variables (two blue vectors), white "plane X". Factor (fat red vector) overruns that space. Factor's orthogonal projection on the plane (thin grey vector) is the regressionally estimated factor scores. By the definition of linear regression, factor scores is the best, in terms of least squares, approximation of factor available by the variables.
|
Methods to compute factor scores, and what is the "score coefficient" matrix in PCA or factor analys
Methods of computation of factor/component scores
After a series of comments I decided finally to issue an answer (based on the comments and more). It is about computing component scores in PCA and fa
|
11,565
|
Stouffer's Z-score method: what if we sum $z^2$ instead of $z$?
|
One flaw that jumps out is Stouffer's method can detect systematic shifts in the $z_i$, which is what one would usually expect to happen when one alternative is consistently true, whereas the chi-squared method would appear to have less power to do so. A quick simulation shows this to be the case; the chi-squared method is less powerful to detect a one-sided alternative. Here are histograms of the p-values by both methods (red=Stouffer, blue=chi-squared) for $10^5$ independent iterations with $N=10$ and various one-sided standardized effects $\mu$ ranging from none ($\mu=0$) through $0.6$ SD ($\mu=0.6$).
The better procedure will have more area close to zero. For all positive values of $\mu$ shown, that procedure is the Stouffer procedure.
R code
This includes Fisher's method (commented out) for comparison.
n <- 10
n.iter <- 10^5
z <- matrix(rnorm(n*n.iter), ncol=n)
sim <- function(mu) {
stouffer.sim <- apply(z + mu, 1,
function(y) {q <- pnorm(sum(y)/sqrt(length(y))); 2*min(q, 1-q)})
chisq.sim <- apply(z + mu, 1,
function(y) 1 - pchisq(sum(y^2), length(y)))
#fisher.sim <- apply(z + mu, 1,
# function(y) {q <- pnorm(y);
# 1 - pchisq(-2 * sum(log(2*pmin(q, 1-q))), 2*length(y))})
return(list(stouffer=stouffer.sim, chisq=chisq.sim, fisher=fisher.sim))
}
par(mfrow=c(2, 3))
breaks=seq(0, 1, .05)
tmp <- sapply(c(0, .1, .2, .3, .4, .6),
function(mu) {
x <- sim(mu);
hist(x[[1]], breaks=breaks, xlab="p", col="#ff606060",
main=paste("Mu =", mu));
hist(x[[2]], breaks=breaks, xlab="p", col="#6060ff60", add=TRUE)
#hist(x[[3]], breaks=breaks, xlab="p", col="#60ff6060", add=TRUE)
})
|
Stouffer's Z-score method: what if we sum $z^2$ instead of $z$?
|
One flaw that jumps out is Stouffer's method can detect systematic shifts in the $z_i$, which is what one would usually expect to happen when one alternative is consistently true, whereas the chi-squa
|
Stouffer's Z-score method: what if we sum $z^2$ instead of $z$?
One flaw that jumps out is Stouffer's method can detect systematic shifts in the $z_i$, which is what one would usually expect to happen when one alternative is consistently true, whereas the chi-squared method would appear to have less power to do so. A quick simulation shows this to be the case; the chi-squared method is less powerful to detect a one-sided alternative. Here are histograms of the p-values by both methods (red=Stouffer, blue=chi-squared) for $10^5$ independent iterations with $N=10$ and various one-sided standardized effects $\mu$ ranging from none ($\mu=0$) through $0.6$ SD ($\mu=0.6$).
The better procedure will have more area close to zero. For all positive values of $\mu$ shown, that procedure is the Stouffer procedure.
R code
This includes Fisher's method (commented out) for comparison.
n <- 10
n.iter <- 10^5
z <- matrix(rnorm(n*n.iter), ncol=n)
sim <- function(mu) {
stouffer.sim <- apply(z + mu, 1,
function(y) {q <- pnorm(sum(y)/sqrt(length(y))); 2*min(q, 1-q)})
chisq.sim <- apply(z + mu, 1,
function(y) 1 - pchisq(sum(y^2), length(y)))
#fisher.sim <- apply(z + mu, 1,
# function(y) {q <- pnorm(y);
# 1 - pchisq(-2 * sum(log(2*pmin(q, 1-q))), 2*length(y))})
return(list(stouffer=stouffer.sim, chisq=chisq.sim, fisher=fisher.sim))
}
par(mfrow=c(2, 3))
breaks=seq(0, 1, .05)
tmp <- sapply(c(0, .1, .2, .3, .4, .6),
function(mu) {
x <- sim(mu);
hist(x[[1]], breaks=breaks, xlab="p", col="#ff606060",
main=paste("Mu =", mu));
hist(x[[2]], breaks=breaks, xlab="p", col="#6060ff60", add=TRUE)
#hist(x[[3]], breaks=breaks, xlab="p", col="#60ff6060", add=TRUE)
})
|
Stouffer's Z-score method: what if we sum $z^2$ instead of $z$?
One flaw that jumps out is Stouffer's method can detect systematic shifts in the $z_i$, which is what one would usually expect to happen when one alternative is consistently true, whereas the chi-squa
|
11,566
|
Stouffer's Z-score method: what if we sum $z^2$ instead of $z$?
|
One general way to gain insight into test statistics is to
derive the (usually implicit) underlying assumptions that would lead
that test statistic to be most powerful. For this particular case a student and I
have recently done this:
http://arxiv.org/abs/1111.1210v2
(a revised version is to appear in Annals of Applied Statistics).
To very briefly summarize (and consistent with the simulation results in another answer) Stouffer's method will be most powerful when the "true"
underlying effects are all equal; the sum of Z^2 will be most powerful when
the underlying effects are normally distributed about 0.
This is a slight simplification
that omits details: see section 2.5 in the arxiv preprint linked above
for more details.
|
Stouffer's Z-score method: what if we sum $z^2$ instead of $z$?
|
One general way to gain insight into test statistics is to
derive the (usually implicit) underlying assumptions that would lead
that test statistic to be most powerful. For this particular case a stud
|
Stouffer's Z-score method: what if we sum $z^2$ instead of $z$?
One general way to gain insight into test statistics is to
derive the (usually implicit) underlying assumptions that would lead
that test statistic to be most powerful. For this particular case a student and I
have recently done this:
http://arxiv.org/abs/1111.1210v2
(a revised version is to appear in Annals of Applied Statistics).
To very briefly summarize (and consistent with the simulation results in another answer) Stouffer's method will be most powerful when the "true"
underlying effects are all equal; the sum of Z^2 will be most powerful when
the underlying effects are normally distributed about 0.
This is a slight simplification
that omits details: see section 2.5 in the arxiv preprint linked above
for more details.
|
Stouffer's Z-score method: what if we sum $z^2$ instead of $z$?
One general way to gain insight into test statistics is to
derive the (usually implicit) underlying assumptions that would lead
that test statistic to be most powerful. For this particular case a stud
|
11,567
|
Stouffer's Z-score method: what if we sum $z^2$ instead of $z$?
|
Slightly o/t: one of the issues with both these approaches is the loss of power due to the degrees of freedom (N for stouffer's; 2N for Fisher's). There have been better meta-analytical approaches developed for this, which you may want to consider (inverse-variance weighted meta-analysis, for example).
If you're looking for evidence of some alternative tests within a group, you may want to look at Donoho and Jin's higher criticism statistic: https://projecteuclid.org/euclid.aos/1085408492
|
Stouffer's Z-score method: what if we sum $z^2$ instead of $z$?
|
Slightly o/t: one of the issues with both these approaches is the loss of power due to the degrees of freedom (N for stouffer's; 2N for Fisher's). There have been better meta-analytical approaches dev
|
Stouffer's Z-score method: what if we sum $z^2$ instead of $z$?
Slightly o/t: one of the issues with both these approaches is the loss of power due to the degrees of freedom (N for stouffer's; 2N for Fisher's). There have been better meta-analytical approaches developed for this, which you may want to consider (inverse-variance weighted meta-analysis, for example).
If you're looking for evidence of some alternative tests within a group, you may want to look at Donoho and Jin's higher criticism statistic: https://projecteuclid.org/euclid.aos/1085408492
|
Stouffer's Z-score method: what if we sum $z^2$ instead of $z$?
Slightly o/t: one of the issues with both these approaches is the loss of power due to the degrees of freedom (N for stouffer's; 2N for Fisher's). There have been better meta-analytical approaches dev
|
11,568
|
Stouffer's Z-score method: what if we sum $z^2$ instead of $z$?
|
To answer the question and for any further readers: is it ever used?, there is an exhaustive paper by Cousins (2008) on arXiv, which listed and reviewed a couple of alternative approaches. The proposed one does not seem to appear.
|
Stouffer's Z-score method: what if we sum $z^2$ instead of $z$?
|
To answer the question and for any further readers: is it ever used?, there is an exhaustive paper by Cousins (2008) on arXiv, which listed and reviewed a couple of alternative approaches. The propose
|
Stouffer's Z-score method: what if we sum $z^2$ instead of $z$?
To answer the question and for any further readers: is it ever used?, there is an exhaustive paper by Cousins (2008) on arXiv, which listed and reviewed a couple of alternative approaches. The proposed one does not seem to appear.
|
Stouffer's Z-score method: what if we sum $z^2$ instead of $z$?
To answer the question and for any further readers: is it ever used?, there is an exhaustive paper by Cousins (2008) on arXiv, which listed and reviewed a couple of alternative approaches. The propose
|
11,569
|
K successes in Bernoulli trials, or George Lucas movie experiment
|
Here is some R code to simulate the George Lucas experiment:
B<-20000
steps<-2*rbinom(B,1,0.5)-1
rw<-cumsum(steps)
ts.plot(rw,xlab="Number of customers",ylab="Difference")
Running it, we get pictures like these:
where the difference in sold tickets between A and B is on the y-axis.
Next, we run $10,000$ such simulated George Lucas experiments. For each experiment, we compute the proportion of time spent $\geq 0$, i.e. the proportion of the lined-up viewers for which the number of tickets sold to A is greater or equal to the number of tickets sold to B. Intuitively, you'd say that this proportion should be roughly $1/2$. Here is a histogram of the results:
The proportion is $1/2$ on average in the sense that the expected value is $1/2$, but $1/2$ is an unlikely value compared to values close to $0$ or $1$. For most experiments, the differences are either positive or negative most of the time!
The red curve is the density function of the arcsine distribution, also known as the $\mbox{Beta}(1/2,1/2)$ distribution. What is illustrated in the above picture is a theorem known as the first arscine law for random walks, which says that as the number of steps of the simple symmetric random walk approaches infinity, the distribution of the proportion of time spent above $0$ tends to the arcsine distribution. A standard reference for this result is Section III.4 of An introduction to probability theory and its applications , Vol 1 by William Feller.
The R code for the simulation study is
prop<-vector(length=10000)
for(i in 1:10000)
{
steps<-2*rbinom(B,1,0.5)-1
rw<-cumsum(steps)
prop[i]<-sum(rw>=0)/B
}
hist(prop,freq=FALSE,xlab="Proportion of time spent above 0",main="George Lucas experiment")
curve(dbeta(x,1/2,1/2),0,1,col=2,add=TRUE)
|
K successes in Bernoulli trials, or George Lucas movie experiment
|
Here is some R code to simulate the George Lucas experiment:
B<-20000
steps<-2*rbinom(B,1,0.5)-1
rw<-cumsum(steps)
ts.plot(rw,xlab="Number of customers",ylab="Difference")
Running it, we get pictures
|
K successes in Bernoulli trials, or George Lucas movie experiment
Here is some R code to simulate the George Lucas experiment:
B<-20000
steps<-2*rbinom(B,1,0.5)-1
rw<-cumsum(steps)
ts.plot(rw,xlab="Number of customers",ylab="Difference")
Running it, we get pictures like these:
where the difference in sold tickets between A and B is on the y-axis.
Next, we run $10,000$ such simulated George Lucas experiments. For each experiment, we compute the proportion of time spent $\geq 0$, i.e. the proportion of the lined-up viewers for which the number of tickets sold to A is greater or equal to the number of tickets sold to B. Intuitively, you'd say that this proportion should be roughly $1/2$. Here is a histogram of the results:
The proportion is $1/2$ on average in the sense that the expected value is $1/2$, but $1/2$ is an unlikely value compared to values close to $0$ or $1$. For most experiments, the differences are either positive or negative most of the time!
The red curve is the density function of the arcsine distribution, also known as the $\mbox{Beta}(1/2,1/2)$ distribution. What is illustrated in the above picture is a theorem known as the first arscine law for random walks, which says that as the number of steps of the simple symmetric random walk approaches infinity, the distribution of the proportion of time spent above $0$ tends to the arcsine distribution. A standard reference for this result is Section III.4 of An introduction to probability theory and its applications , Vol 1 by William Feller.
The R code for the simulation study is
prop<-vector(length=10000)
for(i in 1:10000)
{
steps<-2*rbinom(B,1,0.5)-1
rw<-cumsum(steps)
prop[i]<-sum(rw>=0)/B
}
hist(prop,freq=FALSE,xlab="Proportion of time spent above 0",main="George Lucas experiment")
curve(dbeta(x,1/2,1/2),0,1,col=2,add=TRUE)
|
K successes in Bernoulli trials, or George Lucas movie experiment
Here is some R code to simulate the George Lucas experiment:
B<-20000
steps<-2*rbinom(B,1,0.5)-1
rw<-cumsum(steps)
ts.plot(rw,xlab="Number of customers",ylab="Difference")
Running it, we get pictures
|
11,570
|
K successes in Bernoulli trials, or George Lucas movie experiment
|
Both A and B have a $1/2$ chance to be ahead after any odd number of trials $t$ (odd to avoid ties). However, these events are related. Whichever is ahead after $t=1$ has a $3/4$ chance to be ahead after $t=3$, and this gets more dramatic as $t$ increases.
The average number of lead changes does grow to infinity as the total number of trials increases, but slowly. A random walk without drift in $1$ dimension is recurrent, so however far you may be in the lead, the chance you will be tied at some point in the future (with an infinite number of trials) is $1$. However, even if you lead by only one, the expected time until you are even again is infinite. There is a significant chance that it will take an extremely long time to get back to even.
That said, the mode is being used to exaggerate the effect. It actually would be a surprise to see no lead changes at all in $20,000$ trials.
If you would like to compute some of the probabilities, you have to count something akin to lattice walks which don't cross the diagonal. There is a great combinatorial method which applies to random walks (and to Brownian motion) which don't cross such a line, called the reflection principle or reflection method. This is one method to determine the Catalan numbers. Here are two other applications:
The number of sequences so that $A$ ends up ahead $10,200-9,800$ is $20,000 \choose 9,800$. In each sequence ending up at $(10,200, 9,800)$, either $B$ is never in the lead, or there is some point at which $B$ is first in the lead. If $B$ gains the lead, then if you reverse the later trials, you get a sequence ending up at $(9,799, 10,201)$, and this is a bijection. So, the number of sequences which end up at $(10,200, 9,800)$ so that $B$ was never in the lead is ${20,000 \choose 9,800} - {20,000 \choose 10,201} = {20,000 \choose 9,800} - {20,000 \choose 9,799} = {20,000 \choose 9,800} \frac{401}{10,201}.$ So, you can see that the chance $B$ was ahead at some point, given that you end up at $(10,200, 9,800),$ is about $96\%$.
The total number of sequences with any endpoint so that $A$ is never behind is ${20,000 \choose 10,000} \approx 2^{20,000}/\sqrt{10,000 \pi}.$ So, the probability that $A$ is never behind is about $\frac{1}{100 \sqrt{\pi}}$. The chance that the lead never changes is about $\frac{1}{50 \sqrt{\pi}} \approx 1/89.$ The average number of lead changes is about $56$.
|
K successes in Bernoulli trials, or George Lucas movie experiment
|
Both A and B have a $1/2$ chance to be ahead after any odd number of trials $t$ (odd to avoid ties). However, these events are related. Whichever is ahead after $t=1$ has a $3/4$ chance to be ahead af
|
K successes in Bernoulli trials, or George Lucas movie experiment
Both A and B have a $1/2$ chance to be ahead after any odd number of trials $t$ (odd to avoid ties). However, these events are related. Whichever is ahead after $t=1$ has a $3/4$ chance to be ahead after $t=3$, and this gets more dramatic as $t$ increases.
The average number of lead changes does grow to infinity as the total number of trials increases, but slowly. A random walk without drift in $1$ dimension is recurrent, so however far you may be in the lead, the chance you will be tied at some point in the future (with an infinite number of trials) is $1$. However, even if you lead by only one, the expected time until you are even again is infinite. There is a significant chance that it will take an extremely long time to get back to even.
That said, the mode is being used to exaggerate the effect. It actually would be a surprise to see no lead changes at all in $20,000$ trials.
If you would like to compute some of the probabilities, you have to count something akin to lattice walks which don't cross the diagonal. There is a great combinatorial method which applies to random walks (and to Brownian motion) which don't cross such a line, called the reflection principle or reflection method. This is one method to determine the Catalan numbers. Here are two other applications:
The number of sequences so that $A$ ends up ahead $10,200-9,800$ is $20,000 \choose 9,800$. In each sequence ending up at $(10,200, 9,800)$, either $B$ is never in the lead, or there is some point at which $B$ is first in the lead. If $B$ gains the lead, then if you reverse the later trials, you get a sequence ending up at $(9,799, 10,201)$, and this is a bijection. So, the number of sequences which end up at $(10,200, 9,800)$ so that $B$ was never in the lead is ${20,000 \choose 9,800} - {20,000 \choose 10,201} = {20,000 \choose 9,800} - {20,000 \choose 9,799} = {20,000 \choose 9,800} \frac{401}{10,201}.$ So, you can see that the chance $B$ was ahead at some point, given that you end up at $(10,200, 9,800),$ is about $96\%$.
The total number of sequences with any endpoint so that $A$ is never behind is ${20,000 \choose 10,000} \approx 2^{20,000}/\sqrt{10,000 \pi}.$ So, the probability that $A$ is never behind is about $\frac{1}{100 \sqrt{\pi}}$. The chance that the lead never changes is about $\frac{1}{50 \sqrt{\pi}} \approx 1/89.$ The average number of lead changes is about $56$.
|
K successes in Bernoulli trials, or George Lucas movie experiment
Both A and B have a $1/2$ chance to be ahead after any odd number of trials $t$ (odd to avoid ties). However, these events are related. Whichever is ahead after $t=1$ has a $3/4$ chance to be ahead af
|
11,571
|
K successes in Bernoulli trials, or George Lucas movie experiment
|
"it is 88 times more probable that one of the two films will lead through all 20,000 customers than it is that, say, the lead continuously seesaws"
In plain English: one of the movies gets an early lead. It has to, as the first customer has to go to A or B. That movie is then just as likely to keep its lead as lose it.
88 times more likely sounds, well, unlikely, until you remember that perfect seesawing is very improbable. The chart in MansT's answer, showing this graphically, is fascinating isn't it.
ASIDE: Personally, I think it'll be more than 88 times - due to <buzzword-alert> viral marketing </buzzword-alert>. Each person will ask other people what they saw, and are more likely to visit the same movie. They'll even do this subconsciously: people are more likely to join a long queue to go an see something. I.e. as soon as randomness amongst the first few customers has created a leader, human psychology will keep it as a leader :-).
|
K successes in Bernoulli trials, or George Lucas movie experiment
|
"it is 88 times more probable that one of the two films will lead through all 20,000 customers than it is that, say, the lead continuously seesaws"
In plain English: one of the movies gets an early le
|
K successes in Bernoulli trials, or George Lucas movie experiment
"it is 88 times more probable that one of the two films will lead through all 20,000 customers than it is that, say, the lead continuously seesaws"
In plain English: one of the movies gets an early lead. It has to, as the first customer has to go to A or B. That movie is then just as likely to keep its lead as lose it.
88 times more likely sounds, well, unlikely, until you remember that perfect seesawing is very improbable. The chart in MansT's answer, showing this graphically, is fascinating isn't it.
ASIDE: Personally, I think it'll be more than 88 times - due to <buzzword-alert> viral marketing </buzzword-alert>. Each person will ask other people what they saw, and are more likely to visit the same movie. They'll even do this subconsciously: people are more likely to join a long queue to go an see something. I.e. as soon as randomness amongst the first few customers has created a leader, human psychology will keep it as a leader :-).
|
K successes in Bernoulli trials, or George Lucas movie experiment
"it is 88 times more probable that one of the two films will lead through all 20,000 customers than it is that, say, the lead continuously seesaws"
In plain English: one of the movies gets an early le
|
11,572
|
Why are optimization algorithms defined in terms of other optimization problems?
|
You are looking at top level algorithm flow charts. Some of the individual steps in the flow chart may merit their own detailed flow charts. However, in published papers having an emphasis on brevity, many details are often omitted. Details for standard inner optimization problems, which are considered to be "old hat" may not be provided at all.
The general idea is that optimization algorithms may require the solution of a series of generally easier optimization problems. It's not uncommon to have 3 or even 4 levels of optimization algorithms within a top level algorithm, although some of them are internal to standard optimizers.
Even deciding when to terminate an algorithm (at one of the hierarchial levels) may require solving a side optimization problem. For instance, a non-negatively constrained linear least squares problem might be solved to determine the Lagrange multipliers used to evaluate the KKT optimality score used to decide when to declare optimality.
If the optimization problem is stochastic or dynamic, there may be yet additional hierarchial levels of optimization.
Here's an example. Sequential Quadratic Programming (SQP). An initial optimization problem is treated by iteratively solving the Karush-Kuhn-Tucker optimality conditions, starting from an initial point with an objective which is a quadratic approximation of the Lagrangian of the problem, and a linearization of the constraints. The resulting Quadratic Program (QP) is solved. The QP which was solved either has trust region constraints, or a line search is conducted from the current iterate to the solution of the QP, which is itself an optimization problem, in order to find the next iterate. If a Quasi-Newton method is being used, an optimization problem has to be solved to determine the Quasi-Newton update to the Hessian of the Lagrangian - usually this is a closed form optimization using closed form formulas such as BFGS or SR1, but it could be a numerical optimization. Then the new QP is solved, etc. If the QP is ever infeasible, including to start, an optimization problem is solved to find a feasible point. Meanwhile, there may be one or two levels of internal optimization problems being called inside the QP solver. At the end of each iteration, a non-negative linear least squares problem might be solved to determine the optimality score. Etc.
If this is a mixed integer problem, then this whole shebang might be performed at each branching node, as part of a higher level algorithm. Similarly for a global optimizer - a local optimization problem is used to produce an upper bound on the globally optimal solution, then a relaxation of some constraints is done to produce a lower bound optimization problem. Thousands or even millions of "easy" optimization problems from branch and bound might be solved in order to solve one mixed integer or global optimization problem.
This should start to give you an idea.
Edit: In response to the chicken and egg question which was added to the question after my answer:
If there's a chicken and egg problem, then it's not a well-defined practical algorithm. In the examples I gave, there is no chicken and egg. Higher level algorithm steps invoke optimization solvers, which are either defined or already exist. SQP iteratively invokes a QP solver to solve sub-problems, but the QP solver solves an easier problem, QP, than the original problem. If there is an even higher level global optimization algorithm, it may invoke an SQP solver to solve local nonlinear optimization subproblems, and the SQP solver in turn calls a QP solver to solve QP subproblems. No chiicken and egg.
Note: Optimization opportunities are "everywhere". Optimization experts, such as those developing optimization algorithms, are more likely to see these optimization opportunities, and view them as such, than the average Joe or Jane. And being algorithmically inclined, quite naturally they see opportunities for building up optimization algorithms out of lower-level optimization algorithms. Formulation and solution of optimization problems serve as building blocks for other (higher level) optimization algorithms.
Edit 2: In response to bounty request which was just added by the OP.
The paper describing the SQP nonlinear optimizer SNOPT https://web.stanford.edu/group/SOL/reports/snopt.pdf specifically mentions the QP solver SQOPT, which is separately documented, as being used to solve QP subproblems in SNOPT.
|
Why are optimization algorithms defined in terms of other optimization problems?
|
You are looking at top level algorithm flow charts. Some of the individual steps in the flow chart may merit their own detailed flow charts. However, in published papers having an emphasis on brevit
|
Why are optimization algorithms defined in terms of other optimization problems?
You are looking at top level algorithm flow charts. Some of the individual steps in the flow chart may merit their own detailed flow charts. However, in published papers having an emphasis on brevity, many details are often omitted. Details for standard inner optimization problems, which are considered to be "old hat" may not be provided at all.
The general idea is that optimization algorithms may require the solution of a series of generally easier optimization problems. It's not uncommon to have 3 or even 4 levels of optimization algorithms within a top level algorithm, although some of them are internal to standard optimizers.
Even deciding when to terminate an algorithm (at one of the hierarchial levels) may require solving a side optimization problem. For instance, a non-negatively constrained linear least squares problem might be solved to determine the Lagrange multipliers used to evaluate the KKT optimality score used to decide when to declare optimality.
If the optimization problem is stochastic or dynamic, there may be yet additional hierarchial levels of optimization.
Here's an example. Sequential Quadratic Programming (SQP). An initial optimization problem is treated by iteratively solving the Karush-Kuhn-Tucker optimality conditions, starting from an initial point with an objective which is a quadratic approximation of the Lagrangian of the problem, and a linearization of the constraints. The resulting Quadratic Program (QP) is solved. The QP which was solved either has trust region constraints, or a line search is conducted from the current iterate to the solution of the QP, which is itself an optimization problem, in order to find the next iterate. If a Quasi-Newton method is being used, an optimization problem has to be solved to determine the Quasi-Newton update to the Hessian of the Lagrangian - usually this is a closed form optimization using closed form formulas such as BFGS or SR1, but it could be a numerical optimization. Then the new QP is solved, etc. If the QP is ever infeasible, including to start, an optimization problem is solved to find a feasible point. Meanwhile, there may be one or two levels of internal optimization problems being called inside the QP solver. At the end of each iteration, a non-negative linear least squares problem might be solved to determine the optimality score. Etc.
If this is a mixed integer problem, then this whole shebang might be performed at each branching node, as part of a higher level algorithm. Similarly for a global optimizer - a local optimization problem is used to produce an upper bound on the globally optimal solution, then a relaxation of some constraints is done to produce a lower bound optimization problem. Thousands or even millions of "easy" optimization problems from branch and bound might be solved in order to solve one mixed integer or global optimization problem.
This should start to give you an idea.
Edit: In response to the chicken and egg question which was added to the question after my answer:
If there's a chicken and egg problem, then it's not a well-defined practical algorithm. In the examples I gave, there is no chicken and egg. Higher level algorithm steps invoke optimization solvers, which are either defined or already exist. SQP iteratively invokes a QP solver to solve sub-problems, but the QP solver solves an easier problem, QP, than the original problem. If there is an even higher level global optimization algorithm, it may invoke an SQP solver to solve local nonlinear optimization subproblems, and the SQP solver in turn calls a QP solver to solve QP subproblems. No chiicken and egg.
Note: Optimization opportunities are "everywhere". Optimization experts, such as those developing optimization algorithms, are more likely to see these optimization opportunities, and view them as such, than the average Joe or Jane. And being algorithmically inclined, quite naturally they see opportunities for building up optimization algorithms out of lower-level optimization algorithms. Formulation and solution of optimization problems serve as building blocks for other (higher level) optimization algorithms.
Edit 2: In response to bounty request which was just added by the OP.
The paper describing the SQP nonlinear optimizer SNOPT https://web.stanford.edu/group/SOL/reports/snopt.pdf specifically mentions the QP solver SQOPT, which is separately documented, as being used to solve QP subproblems in SNOPT.
|
Why are optimization algorithms defined in terms of other optimization problems?
You are looking at top level algorithm flow charts. Some of the individual steps in the flow chart may merit their own detailed flow charts. However, in published papers having an emphasis on brevit
|
11,573
|
Why are optimization algorithms defined in terms of other optimization problems?
|
I like Mark's answer, but I though I would mention "Simulated Annealing", which basically can run on top of any optimization algorithm. At a high level it works like this:
It has a "temperature" parameter which starts hot. While hot it steps frequently away and (and further away) from the where the subordinate optimization algorithm points. As it cools it follows the advice of the subordinate algorithm more closely, and at zero it follows it to whatever local optimum it has then ended up at.
The intuition is that it will search the space widely at the beginning, looking for "better places" to look for optimums.
We know there is no real general solution to the local/global optimum problem.
Every algorithm will have its blind spots, but hybrids like this seem to give better results in a lot of cases.
|
Why are optimization algorithms defined in terms of other optimization problems?
|
I like Mark's answer, but I though I would mention "Simulated Annealing", which basically can run on top of any optimization algorithm. At a high level it works like this:
It has a "temperature" para
|
Why are optimization algorithms defined in terms of other optimization problems?
I like Mark's answer, but I though I would mention "Simulated Annealing", which basically can run on top of any optimization algorithm. At a high level it works like this:
It has a "temperature" parameter which starts hot. While hot it steps frequently away and (and further away) from the where the subordinate optimization algorithm points. As it cools it follows the advice of the subordinate algorithm more closely, and at zero it follows it to whatever local optimum it has then ended up at.
The intuition is that it will search the space widely at the beginning, looking for "better places" to look for optimums.
We know there is no real general solution to the local/global optimum problem.
Every algorithm will have its blind spots, but hybrids like this seem to give better results in a lot of cases.
|
Why are optimization algorithms defined in terms of other optimization problems?
I like Mark's answer, but I though I would mention "Simulated Annealing", which basically can run on top of any optimization algorithm. At a high level it works like this:
It has a "temperature" para
|
11,574
|
Why are optimization algorithms defined in terms of other optimization problems?
|
I think a reference that my satisfy your desire is here. Go to section 4 - Optimisation in Modern Bayesian Computation.
TL;DR -they discuss proximal methods. One of the advantages of such methods is splitting - you can find a solution by optimizing easier subproblems. A lot of times (or, at least, sometimes) you may find in the literature a specialized algorithm to evaluate a specific proximal function. In their example, they do image denoising. One of the steps is a very successful and highly cited algorithm by Chambolle.
|
Why are optimization algorithms defined in terms of other optimization problems?
|
I think a reference that my satisfy your desire is here. Go to section 4 - Optimisation in Modern Bayesian Computation.
TL;DR -they discuss proximal methods. One of the advantages of such methods is
|
Why are optimization algorithms defined in terms of other optimization problems?
I think a reference that my satisfy your desire is here. Go to section 4 - Optimisation in Modern Bayesian Computation.
TL;DR -they discuss proximal methods. One of the advantages of such methods is splitting - you can find a solution by optimizing easier subproblems. A lot of times (or, at least, sometimes) you may find in the literature a specialized algorithm to evaluate a specific proximal function. In their example, they do image denoising. One of the steps is a very successful and highly cited algorithm by Chambolle.
|
Why are optimization algorithms defined in terms of other optimization problems?
I think a reference that my satisfy your desire is here. Go to section 4 - Optimisation in Modern Bayesian Computation.
TL;DR -they discuss proximal methods. One of the advantages of such methods is
|
11,575
|
Why are optimization algorithms defined in terms of other optimization problems?
|
This is quite common in many optimization papers and it has to do with generality. The authors usually write the algorithms in this manner to show that they technically work for any function f. However, in practice, they are only useful for very specific functions where these sub-problems can be efficiently solved.
For example, and now I'm talking about the second algorithm only, whenever you see a proximal operator (which as you noted its another optimization problem that can be indeed very hard to solve) is usually implicit that it has a closed form solution in order for the algorithm to be efficient. This is so for many functions of interest in machine learning such as the l1-norm, group norms, and so on. In those cases you would replace the sub-problems for the explicit formula of the proximal operator, and there is no need for an algorithm to solve that problem.
As to why they are writen in this manner just note that if you were to come up with another function and wanted to apply that algorithm you would check, first, if the proximal has a closed form solution or can be computed efficiently. In that case you just plug in the formula into the algorithm and you are good to go. As mentioned before, this guarantees that the algorithm is general enough that can be applied to future function that may come up after the algorithm is first published, together with their proximal expressions of efficient algorithms to compute them.
Finally, as an example, take the classic FISTA algorithm original paper. They derive the algorithm for two very specific functions, the squared loss and the l1-norm. However, they note that it can be applied no any functions as long as they meet some pre-requisites, one of them being that the proximal of the regularized can be computed efficiently. This is not a theoretical requirement but a practical one.
This compartimentalization not only makes the algorithm general but also easier to analyze: as long as there exists algorithms for the sub-problems that have this properties, then the proposed algorithm will have this convergence rate or whatever.
|
Why are optimization algorithms defined in terms of other optimization problems?
|
This is quite common in many optimization papers and it has to do with generality. The authors usually write the algorithms in this manner to show that they technically work for any function f. Howeve
|
Why are optimization algorithms defined in terms of other optimization problems?
This is quite common in many optimization papers and it has to do with generality. The authors usually write the algorithms in this manner to show that they technically work for any function f. However, in practice, they are only useful for very specific functions where these sub-problems can be efficiently solved.
For example, and now I'm talking about the second algorithm only, whenever you see a proximal operator (which as you noted its another optimization problem that can be indeed very hard to solve) is usually implicit that it has a closed form solution in order for the algorithm to be efficient. This is so for many functions of interest in machine learning such as the l1-norm, group norms, and so on. In those cases you would replace the sub-problems for the explicit formula of the proximal operator, and there is no need for an algorithm to solve that problem.
As to why they are writen in this manner just note that if you were to come up with another function and wanted to apply that algorithm you would check, first, if the proximal has a closed form solution or can be computed efficiently. In that case you just plug in the formula into the algorithm and you are good to go. As mentioned before, this guarantees that the algorithm is general enough that can be applied to future function that may come up after the algorithm is first published, together with their proximal expressions of efficient algorithms to compute them.
Finally, as an example, take the classic FISTA algorithm original paper. They derive the algorithm for two very specific functions, the squared loss and the l1-norm. However, they note that it can be applied no any functions as long as they meet some pre-requisites, one of them being that the proximal of the regularized can be computed efficiently. This is not a theoretical requirement but a practical one.
This compartimentalization not only makes the algorithm general but also easier to analyze: as long as there exists algorithms for the sub-problems that have this properties, then the proposed algorithm will have this convergence rate or whatever.
|
Why are optimization algorithms defined in terms of other optimization problems?
This is quite common in many optimization papers and it has to do with generality. The authors usually write the algorithms in this manner to show that they technically work for any function f. Howeve
|
11,576
|
Sum or average of gradients in (mini) batch gradient decent? [duplicate]
|
Average.
Examples: Notes to Andrew Ng's Machine Learning Course on Coursera compiled by Alex Holehouse.
Summing the gradients due to individual samples you get a much smoother gradient. The larger the batch the smoother the resulting gradient used in updating the weight.
Dividing the sum by the batch size and taking the average gradient has the effect of:
The magnitude of the weight does not grow out of proportion. Adding L2 regularization to the weight update penalizes large weight values. This often leads to improved generalization performance. Taking the average, especially if the gradients happen to point in the same direction, keep the weights from getting too large.
The magnitude of the gradient is independent of the batch size. This allows comparison of weights from other experiments using different batch sizes.
Countering the effect of the batch size with the learning rate can be numerically equivalent but you end up with a learning rate that is implementation specific. It makes it difficult to communicate your results and experimental setup if people cannot relate to the scale of parameters you're using and they'll have trouble reproducing your experiment.
Averaging enables clearer comparability and keeping gradient magnitudes independent of batch size. Choosing a batch size is sometimes constrained by the computational resources you have and you want to mitigate the effect of this when evaluating your model.
|
Sum or average of gradients in (mini) batch gradient decent? [duplicate]
|
Average.
Examples: Notes to Andrew Ng's Machine Learning Course on Coursera compiled by Alex Holehouse.
Summing the gradients due to individual samples you get a much smoother gradient. The larger the
|
Sum or average of gradients in (mini) batch gradient decent? [duplicate]
Average.
Examples: Notes to Andrew Ng's Machine Learning Course on Coursera compiled by Alex Holehouse.
Summing the gradients due to individual samples you get a much smoother gradient. The larger the batch the smoother the resulting gradient used in updating the weight.
Dividing the sum by the batch size and taking the average gradient has the effect of:
The magnitude of the weight does not grow out of proportion. Adding L2 regularization to the weight update penalizes large weight values. This often leads to improved generalization performance. Taking the average, especially if the gradients happen to point in the same direction, keep the weights from getting too large.
The magnitude of the gradient is independent of the batch size. This allows comparison of weights from other experiments using different batch sizes.
Countering the effect of the batch size with the learning rate can be numerically equivalent but you end up with a learning rate that is implementation specific. It makes it difficult to communicate your results and experimental setup if people cannot relate to the scale of parameters you're using and they'll have trouble reproducing your experiment.
Averaging enables clearer comparability and keeping gradient magnitudes independent of batch size. Choosing a batch size is sometimes constrained by the computational resources you have and you want to mitigate the effect of this when evaluating your model.
|
Sum or average of gradients in (mini) batch gradient decent? [duplicate]
Average.
Examples: Notes to Andrew Ng's Machine Learning Course on Coursera compiled by Alex Holehouse.
Summing the gradients due to individual samples you get a much smoother gradient. The larger the
|
11,577
|
Regression with only categorical variables [duplicate]
|
We need to be clear on our terms here, but in general, yes:
If your dependent variable is continuous (and the residuals are normally distributed—see here), but all of your independent variables are categorical, this is just an ANOVA.
If your dependent variable is categorical and your independent variables are continuous, this would be logistic regression (possibly binary, ordinal, or multinomial, depending).
If both your dependent variable and your independent variables are categorical variables, you can still use logistic regression—it's kind of the ANOVA-ish version of LR.
Note that both logistic regression and ordinary least squares (linear) regression are special cases of the Generalized Linear Model.
|
Regression with only categorical variables [duplicate]
|
We need to be clear on our terms here, but in general, yes:
If your dependent variable is continuous (and the residuals are normally distributed—see here), but all of your independent variables are
|
Regression with only categorical variables [duplicate]
We need to be clear on our terms here, but in general, yes:
If your dependent variable is continuous (and the residuals are normally distributed—see here), but all of your independent variables are categorical, this is just an ANOVA.
If your dependent variable is categorical and your independent variables are continuous, this would be logistic regression (possibly binary, ordinal, or multinomial, depending).
If both your dependent variable and your independent variables are categorical variables, you can still use logistic regression—it's kind of the ANOVA-ish version of LR.
Note that both logistic regression and ordinary least squares (linear) regression are special cases of the Generalized Linear Model.
|
Regression with only categorical variables [duplicate]
We need to be clear on our terms here, but in general, yes:
If your dependent variable is continuous (and the residuals are normally distributed—see here), but all of your independent variables are
|
11,578
|
Linear regression prediction interval
|
@whuber has pointed you to three good answers, but perhaps I can still write something of value. Your explicit question, as I understand it, is:
Given my fitted model, $\hat y_i=\hat mx_i + \hat b$ (notice I added 'hats'), and assuming my residuals are normally distributed, $\mathcal N(0, \hat\sigma^2_e)$, can I predict that an as yet unobserved response, $y_{new}$, with a known predictor value, $x_{new}$, will fall within the interval $(\hat y -\sigma_e, \hat y +\sigma_e)$, with probability 68%?
Intuitively, the answer seems like it should be 'yes', but the true answer is maybe. This will be the case when the parameters (i.e., $m, b,$ & $\sigma$) are known and without error. Since you estimated these parameters, we need to take their uncertainty into account.
Let's first think about the standard deviation of your residuals. Because this is estimated from your data, there can be some error in the estimate. As a result, the distribution you should use to form your prediction interval should be $t_\text{df error}$, not the normal. However, since the $t$ converges rapidly to the normal, this is less likely to be a problem in practice.
So, can we just use $\hat y_\text{new}\pm t_{(1-\alpha/2,\ \text{df error})}s$, instead of $\hat y_\text{new}\pm z_{(1-\alpha/2)}s$, and go about our merry way? Unfortunately, no. The bigger issue is that there is uncertainty about your estimate of the conditional mean of the response at that location due to the uncertainty in your estimates $\hat m$ & $\hat b$. Thus, the standard deviation of your predictions needs to incorporate more than just $s_\text{error}$. Because variances add, the estimated variance of the predictions will be:
$$
s^2_\text{predictions(new)}=s^2_\text{error}+\text{Var}(\hat mx_\text{new}+\hat b)
$$
Notice that the "$x$" is subscripted to represent the specific value for the new observation, and that the "$s^2$" is correspondingly subscripted. That is, your prediction interval is contingent on the location of the new observation along the $x$ axis. The standard deviation of your predictions can be more conveniently estimated with the following formula:
$$
s_\text{predictions(new)}=\sqrt{s^2_\text{error}\left(1+\frac{1}{N}+\frac{(x_\text{new}-\bar x)^2}{\sum(x_i-\bar x)^2}\right)}
$$
As an interesting side note, we can infer a few facts about prediction intervals from this equation. First, prediction intervals will be narrower the more data we had when we built the prediction model (this is because there's less uncertainty in $\hat m$ & $\hat b$). Second, predictions will be most precise if they are made at the mean of the $x$ values you used to develop your model, as the numerator for the third term will be $0$. The reason is that under normal circumstances, there is no uncertainty about the estimated slope at the mean of $x$, only some uncertainty about the true vertical position of the regression line. Thus, some lessons to be learned for building prediction models are: that more data is helpful, not with finding 'significance', but with improving the precision of future predictions; and that you should center your data collection efforts on the interval where you will need to be making predictions in the future (to minimize that numerator), but spread the observations as widely from that center as you can (to maximize that denominator).
Having calculated the correct value in this manner, we can then use it with the appropriate $t$ distribution as noted above.
|
Linear regression prediction interval
|
@whuber has pointed you to three good answers, but perhaps I can still write something of value. Your explicit question, as I understand it, is:
Given my fitted model, $\hat y_i=\hat mx_i + \hat b$
|
Linear regression prediction interval
@whuber has pointed you to three good answers, but perhaps I can still write something of value. Your explicit question, as I understand it, is:
Given my fitted model, $\hat y_i=\hat mx_i + \hat b$ (notice I added 'hats'), and assuming my residuals are normally distributed, $\mathcal N(0, \hat\sigma^2_e)$, can I predict that an as yet unobserved response, $y_{new}$, with a known predictor value, $x_{new}$, will fall within the interval $(\hat y -\sigma_e, \hat y +\sigma_e)$, with probability 68%?
Intuitively, the answer seems like it should be 'yes', but the true answer is maybe. This will be the case when the parameters (i.e., $m, b,$ & $\sigma$) are known and without error. Since you estimated these parameters, we need to take their uncertainty into account.
Let's first think about the standard deviation of your residuals. Because this is estimated from your data, there can be some error in the estimate. As a result, the distribution you should use to form your prediction interval should be $t_\text{df error}$, not the normal. However, since the $t$ converges rapidly to the normal, this is less likely to be a problem in practice.
So, can we just use $\hat y_\text{new}\pm t_{(1-\alpha/2,\ \text{df error})}s$, instead of $\hat y_\text{new}\pm z_{(1-\alpha/2)}s$, and go about our merry way? Unfortunately, no. The bigger issue is that there is uncertainty about your estimate of the conditional mean of the response at that location due to the uncertainty in your estimates $\hat m$ & $\hat b$. Thus, the standard deviation of your predictions needs to incorporate more than just $s_\text{error}$. Because variances add, the estimated variance of the predictions will be:
$$
s^2_\text{predictions(new)}=s^2_\text{error}+\text{Var}(\hat mx_\text{new}+\hat b)
$$
Notice that the "$x$" is subscripted to represent the specific value for the new observation, and that the "$s^2$" is correspondingly subscripted. That is, your prediction interval is contingent on the location of the new observation along the $x$ axis. The standard deviation of your predictions can be more conveniently estimated with the following formula:
$$
s_\text{predictions(new)}=\sqrt{s^2_\text{error}\left(1+\frac{1}{N}+\frac{(x_\text{new}-\bar x)^2}{\sum(x_i-\bar x)^2}\right)}
$$
As an interesting side note, we can infer a few facts about prediction intervals from this equation. First, prediction intervals will be narrower the more data we had when we built the prediction model (this is because there's less uncertainty in $\hat m$ & $\hat b$). Second, predictions will be most precise if they are made at the mean of the $x$ values you used to develop your model, as the numerator for the third term will be $0$. The reason is that under normal circumstances, there is no uncertainty about the estimated slope at the mean of $x$, only some uncertainty about the true vertical position of the regression line. Thus, some lessons to be learned for building prediction models are: that more data is helpful, not with finding 'significance', but with improving the precision of future predictions; and that you should center your data collection efforts on the interval where you will need to be making predictions in the future (to minimize that numerator), but spread the observations as widely from that center as you can (to maximize that denominator).
Having calculated the correct value in this manner, we can then use it with the appropriate $t$ distribution as noted above.
|
Linear regression prediction interval
@whuber has pointed you to three good answers, but perhaps I can still write something of value. Your explicit question, as I understand it, is:
Given my fitted model, $\hat y_i=\hat mx_i + \hat b$
|
11,579
|
Is it possible to understand pareto/nbd model conceptually?
|
Imagine you're the newly appointed manager of a flower shop. You've got a record of last year's customers – the frequency with which they shop and how long since their last visit. You want to know how much business the listed customers are likely to bring in this year. There are a few things to consider:
[assumption (ii)] Customers have different shopping habits.
Some people like having fresh flowers all the time, while others only by them on special occasions. It makes more sense to have a distribution for the transaction rate $\lambda$, rather than assuming that a single $\lambda$ explains everyone’s behaviour.
The distribution needs to have few parameters (you don’t necessarily have a lot of data), to be fairly flexible (you’re presumably not a mind-reading entrepreneurial guru and don’t know all about shopping habits), and to take values in the positive real numbers. The Gamma distribution ticks all of those boxes, and is well-studied and relatively easy to work with. It’s often used as a prior for positive parameters in different settings.
[assumption (iii)] You might have already lost some of the customers on the list.
If Andrea has bought flowers about once a month every month in the last year, it’s a fairly safe bet she’ll be returning this year. If Ben used to buy flowers weekly, but he hasn’t been around for months, then maybe he’s found a different flower shop. In making future business plans, you might want to count on Andrea but not on Ben.
Customers won’t tell you when they’ve moved on, which is where the “unobserved lifetime” assumption kicks in for both models. Imagine a third customer, Cary. The Pareto/NBD and BG/NBD models give you two different ways to think about Cary dropping out of the shop for good.
For the Pareto/NBD case, imagine that at any point in time, there is a small chance that Cary might come across a better shop than yours. This constant infinitesimal risk gives you the exponential lifetime – and the longer it’s been since Cary’s last visit, the longer he’s been exposed to other (potentially better) flower shops.
The BG/NBD case is a little more contrived. Every time Cary arrives in your shop, he’s committed to buying some flowers. While browsing, he’ll consider the changes in price, quality and variety since his last visit, and that will ultimately make him decide whether to come back again next time, or look for another shop. So rather than being constantly at risk, Cary has some probability p of just deciding to leave after each purchase.
[assumption (iv)] Not all customers are equally committed to your shop.
Some customers are regulars, and only death – or a sharp price increase – will force them to leave. Others might like to explore, and would happily leave you for the sake of the new hipster flower shop across the street. Rather than a single drop-out rate for all customers, it makes more sense to have a distribution of drop-out rates (or probabilities in the BG/NBD case).
This works very much in the same vein as the shopping habits. We’re after a flexible, well-established distribution with few parameters. In the Pareto/NBD case we use a Gamma, since the rate $\mu$ is in the positive real numbers. In the BG/NBD case we use a Beta, which is the standard prior for parameters in $(0; 1)$.
I hope this helps. Have a look at the original paper (Schmittlein et al., 1987) if you haven't already -- they go through some of the intuition there.
|
Is it possible to understand pareto/nbd model conceptually?
|
Imagine you're the newly appointed manager of a flower shop. You've got a record of last year's customers – the frequency with which they shop and how long since their last visit. You want to know how
|
Is it possible to understand pareto/nbd model conceptually?
Imagine you're the newly appointed manager of a flower shop. You've got a record of last year's customers – the frequency with which they shop and how long since their last visit. You want to know how much business the listed customers are likely to bring in this year. There are a few things to consider:
[assumption (ii)] Customers have different shopping habits.
Some people like having fresh flowers all the time, while others only by them on special occasions. It makes more sense to have a distribution for the transaction rate $\lambda$, rather than assuming that a single $\lambda$ explains everyone’s behaviour.
The distribution needs to have few parameters (you don’t necessarily have a lot of data), to be fairly flexible (you’re presumably not a mind-reading entrepreneurial guru and don’t know all about shopping habits), and to take values in the positive real numbers. The Gamma distribution ticks all of those boxes, and is well-studied and relatively easy to work with. It’s often used as a prior for positive parameters in different settings.
[assumption (iii)] You might have already lost some of the customers on the list.
If Andrea has bought flowers about once a month every month in the last year, it’s a fairly safe bet she’ll be returning this year. If Ben used to buy flowers weekly, but he hasn’t been around for months, then maybe he’s found a different flower shop. In making future business plans, you might want to count on Andrea but not on Ben.
Customers won’t tell you when they’ve moved on, which is where the “unobserved lifetime” assumption kicks in for both models. Imagine a third customer, Cary. The Pareto/NBD and BG/NBD models give you two different ways to think about Cary dropping out of the shop for good.
For the Pareto/NBD case, imagine that at any point in time, there is a small chance that Cary might come across a better shop than yours. This constant infinitesimal risk gives you the exponential lifetime – and the longer it’s been since Cary’s last visit, the longer he’s been exposed to other (potentially better) flower shops.
The BG/NBD case is a little more contrived. Every time Cary arrives in your shop, he’s committed to buying some flowers. While browsing, he’ll consider the changes in price, quality and variety since his last visit, and that will ultimately make him decide whether to come back again next time, or look for another shop. So rather than being constantly at risk, Cary has some probability p of just deciding to leave after each purchase.
[assumption (iv)] Not all customers are equally committed to your shop.
Some customers are regulars, and only death – or a sharp price increase – will force them to leave. Others might like to explore, and would happily leave you for the sake of the new hipster flower shop across the street. Rather than a single drop-out rate for all customers, it makes more sense to have a distribution of drop-out rates (or probabilities in the BG/NBD case).
This works very much in the same vein as the shopping habits. We’re after a flexible, well-established distribution with few parameters. In the Pareto/NBD case we use a Gamma, since the rate $\mu$ is in the positive real numbers. In the BG/NBD case we use a Beta, which is the standard prior for parameters in $(0; 1)$.
I hope this helps. Have a look at the original paper (Schmittlein et al., 1987) if you haven't already -- they go through some of the intuition there.
|
Is it possible to understand pareto/nbd model conceptually?
Imagine you're the newly appointed manager of a flower shop. You've got a record of last year's customers – the frequency with which they shop and how long since their last visit. You want to know how
|
11,580
|
In neural nets, why use gradient methods rather than other metaheuristics?
|
Extending @Dikran Marsupial's answer....
Anna Choromanska and her colleagues in Yan LeCunn's group at NYU, address this in their 2014 AISTATS paper "The Loss Surface of Multilayer Nets". Using random matrix theory, along with some experiments, they argue that:
For large-size networks, most local minima are equivalent and yield similar performance on a test set.
The probability of finding a "bad" (high value) local minimum is non-zero for small-size networks and decreases quickly with networks size.
Struggling to find the global minimum on the training set (as opposed to one of the many good local ones) is not useful in practice and may lead to overfitting.
[From page 2 of the paper]
In this view, there's not a great reason to deploy heavy-weight approaches for finding the global minimum. That time would be better spent trying out new network topologies, features, data sets, etc.
That said, lots of people have thought about augmenting or replacing SGD. For fairly small networks (by contemporary standards), these improved metahuristics do seem to do something Mavrovouniotis and Yang (2016) show that ant colony optimization + backprop beats unmodified backprop on several benchmark data sets (albeit not by much). Rere el al. (2015) use simulated annealing to train a CNN and find it initially performs better on the validation set. After 10 epochs, however, only a a very small (and not-tested-for-significance) difference in performance remains. The faster convergence-per-epoch advantage is also offset by a dramatically larger amount of computation time per epoch, so this is not a obvious win for simulated annealing.
It is possible that these heuristics do a better job of initializing the network and once it has been pointed down the right path, any optimizer will do. Sutskever et al. (2013) from Geoff Hinton's group argue something like this in their 2013 ICML paper.
|
In neural nets, why use gradient methods rather than other metaheuristics?
|
Extending @Dikran Marsupial's answer....
Anna Choromanska and her colleagues in Yan LeCunn's group at NYU, address this in their 2014 AISTATS paper "The Loss Surface of Multilayer Nets". Using random
|
In neural nets, why use gradient methods rather than other metaheuristics?
Extending @Dikran Marsupial's answer....
Anna Choromanska and her colleagues in Yan LeCunn's group at NYU, address this in their 2014 AISTATS paper "The Loss Surface of Multilayer Nets". Using random matrix theory, along with some experiments, they argue that:
For large-size networks, most local minima are equivalent and yield similar performance on a test set.
The probability of finding a "bad" (high value) local minimum is non-zero for small-size networks and decreases quickly with networks size.
Struggling to find the global minimum on the training set (as opposed to one of the many good local ones) is not useful in practice and may lead to overfitting.
[From page 2 of the paper]
In this view, there's not a great reason to deploy heavy-weight approaches for finding the global minimum. That time would be better spent trying out new network topologies, features, data sets, etc.
That said, lots of people have thought about augmenting or replacing SGD. For fairly small networks (by contemporary standards), these improved metahuristics do seem to do something Mavrovouniotis and Yang (2016) show that ant colony optimization + backprop beats unmodified backprop on several benchmark data sets (albeit not by much). Rere el al. (2015) use simulated annealing to train a CNN and find it initially performs better on the validation set. After 10 epochs, however, only a a very small (and not-tested-for-significance) difference in performance remains. The faster convergence-per-epoch advantage is also offset by a dramatically larger amount of computation time per epoch, so this is not a obvious win for simulated annealing.
It is possible that these heuristics do a better job of initializing the network and once it has been pointed down the right path, any optimizer will do. Sutskever et al. (2013) from Geoff Hinton's group argue something like this in their 2013 ICML paper.
|
In neural nets, why use gradient methods rather than other metaheuristics?
Extending @Dikran Marsupial's answer....
Anna Choromanska and her colleagues in Yan LeCunn's group at NYU, address this in their 2014 AISTATS paper "The Loss Surface of Multilayer Nets". Using random
|
11,581
|
In neural nets, why use gradient methods rather than other metaheuristics?
|
Local minima are not really as great a problem with neural nets as is often suggested. Some of the local minima are due to the symmetry of the network (i.e. you can permute the hidden neurons and leave the function of the network unchanged. All that is necessary is to find a good local minima, rather than the global minima. As it happens aggressively optimising a very flexible model, such as a neural network, is likely to be a recipe for overfitting the data, so using e.g. simulated annealing to find the global minima of the training criterion is likely to give a neural network with worse generalisation performance than one trained by gradient descent that ends up in a local minima. If these heuristic optimisation methods are used, then I would advise including a regularisation term to limit the complexity of the model.
... or alternatively use e.g. a kernel method or a radial basis function model, which is likely to be less trouble.
|
In neural nets, why use gradient methods rather than other metaheuristics?
|
Local minima are not really as great a problem with neural nets as is often suggested. Some of the local minima are due to the symmetry of the network (i.e. you can permute the hidden neurons and lea
|
In neural nets, why use gradient methods rather than other metaheuristics?
Local minima are not really as great a problem with neural nets as is often suggested. Some of the local minima are due to the symmetry of the network (i.e. you can permute the hidden neurons and leave the function of the network unchanged. All that is necessary is to find a good local minima, rather than the global minima. As it happens aggressively optimising a very flexible model, such as a neural network, is likely to be a recipe for overfitting the data, so using e.g. simulated annealing to find the global minima of the training criterion is likely to give a neural network with worse generalisation performance than one trained by gradient descent that ends up in a local minima. If these heuristic optimisation methods are used, then I would advise including a regularisation term to limit the complexity of the model.
... or alternatively use e.g. a kernel method or a radial basis function model, which is likely to be less trouble.
|
In neural nets, why use gradient methods rather than other metaheuristics?
Local minima are not really as great a problem with neural nets as is often suggested. Some of the local minima are due to the symmetry of the network (i.e. you can permute the hidden neurons and lea
|
11,582
|
What does the name "Logistic Regression" mean?
|
As it has been already pointed out, ''logistic'' comes from logistic curve/function/distribution (which is underlying logistic regression). So the question is: where is logistic coming in their names?
The reference to Verhulst (i.e. Wikipedia's statement) seems a bit false. While it is clearly true that it is most widely attributed to Verhulst, the first actual use seems to come from Edward Wright. See Thompson: On Growth and Form (1945), page 145. (Found via the well-known Earliest Known Uses of Some of the Words of Mathematics page.)
Thompson hints that Verhulst used it in connection with its S-shape, but gives no clue about Wright.
However, given that one of the most important parts of Wright's work was pertaining to logarithms, it seems logical that he used it as a reference to logarithm. Indeed (and more precisely), the 1911 edition of Encyclopaedia Britannica refers to the old mathematical term logistic number:
The old name for what are now called ratios or fractions are logistic numbers, so that a table of log (a/x) where x is the argument and a a constant is called a table of logistic or proportional logarithms; and since log (a/x) =log a-log x it is clear that the tabular results differ from those given in an ordinary table of logarithms only by the subtraction of a constant and a change of sign.
Also note that logarithm itself comes from proportion (logos) + number (arithmos); originally coined by John Napier.
So, I believe, this is the most likely explanation: ''logistic'' is used in Wright's time in connection with what we now call ''logarithm'', which was used by Wright when he constructed that curve.
|
What does the name "Logistic Regression" mean?
|
As it has been already pointed out, ''logistic'' comes from logistic curve/function/distribution (which is underlying logistic regression). So the question is: where is logistic coming in their names?
|
What does the name "Logistic Regression" mean?
As it has been already pointed out, ''logistic'' comes from logistic curve/function/distribution (which is underlying logistic regression). So the question is: where is logistic coming in their names?
The reference to Verhulst (i.e. Wikipedia's statement) seems a bit false. While it is clearly true that it is most widely attributed to Verhulst, the first actual use seems to come from Edward Wright. See Thompson: On Growth and Form (1945), page 145. (Found via the well-known Earliest Known Uses of Some of the Words of Mathematics page.)
Thompson hints that Verhulst used it in connection with its S-shape, but gives no clue about Wright.
However, given that one of the most important parts of Wright's work was pertaining to logarithms, it seems logical that he used it as a reference to logarithm. Indeed (and more precisely), the 1911 edition of Encyclopaedia Britannica refers to the old mathematical term logistic number:
The old name for what are now called ratios or fractions are logistic numbers, so that a table of log (a/x) where x is the argument and a a constant is called a table of logistic or proportional logarithms; and since log (a/x) =log a-log x it is clear that the tabular results differ from those given in an ordinary table of logarithms only by the subtraction of a constant and a change of sign.
Also note that logarithm itself comes from proportion (logos) + number (arithmos); originally coined by John Napier.
So, I believe, this is the most likely explanation: ''logistic'' is used in Wright's time in connection with what we now call ''logarithm'', which was used by Wright when he constructed that curve.
|
What does the name "Logistic Regression" mean?
As it has been already pointed out, ''logistic'' comes from logistic curve/function/distribution (which is underlying logistic regression). So the question is: where is logistic coming in their names?
|
11,583
|
What does the name "Logistic Regression" mean?
|
Its related to the LOGISTIC distribution, which has an S-shaped curve.
|
What does the name "Logistic Regression" mean?
|
Its related to the LOGISTIC distribution, which has an S-shaped curve.
|
What does the name "Logistic Regression" mean?
Its related to the LOGISTIC distribution, which has an S-shaped curve.
|
What does the name "Logistic Regression" mean?
Its related to the LOGISTIC distribution, which has an S-shaped curve.
|
11,584
|
Is a weighted $R^2$ in robust linear model meaningful for goodness of fit analysis?
|
The following answer is based on: (1) my interpretation of Willett and Singer (1988) Another Cautionary Note about R-squared: It's use in weighted least squates regression analysis. The American Statistician. 42(3). pp236-238, and (2) the premise that robust linear regression is essentially weighted least squares regression with the weights estimated by an iterative process.
The formula I gave in the question for r2w needs a small correction to correspond to equation 4 in Willet and Singer (1988) for r2wls: the SSt calculation should also use a weighted mean:
the correction is SSt <- sum((x$w*observed-mean(x$w*observed))^2)].
What is the meaning of this (corrected) weighted r-squared? Willett and Singer interpret it as: "the coefficient of determination in the transformed [weighted] dataset. It is a measure of the proportion of the variation in weighted Y that can be accounted for by weighted X, and is the quantity that is output as R2 by the major statistical computer packages when a WLS regression is performed".
Is it meaningful as a measure of goodness of fit? This depends on how it is presented and interpreted. Willett and Singer caution that it is typically quite a bit higher than the r-squared obtained in ordinary least squares regression, and the high value encourages prominent display... but this display may be deceptive IF it is interpreted in the conventional sense of r-squared (as the proportion of unweighted variation explained by a model). Willett and Singer propose that a less 'deceptive' alternative is pseudoR2wls (their equation 7), which is equivalent to my function r2 in the original question. In general, Willett and Singer also caution that it is not good to rely on any r2 (even their pseudor2wls) as a sole measure of goodness of fit. Despite these cautions, the whole premise of robust regression is that some cases are judged 'not as good' and don't count as much in the model fitting, and it may be good to reflect this in part of the model assessment process. The weighted r-squared described, can be one good measure of goodness of fit - as long as the correct interpretation is clearly given in the presentation and it is not relied on as the sole assessment of goodness of fit.
|
Is a weighted $R^2$ in robust linear model meaningful for goodness of fit analysis?
|
The following answer is based on: (1) my interpretation of Willett and Singer (1988) Another Cautionary Note about R-squared: It's use in weighted least squates regression analysis. The American Stat
|
Is a weighted $R^2$ in robust linear model meaningful for goodness of fit analysis?
The following answer is based on: (1) my interpretation of Willett and Singer (1988) Another Cautionary Note about R-squared: It's use in weighted least squates regression analysis. The American Statistician. 42(3). pp236-238, and (2) the premise that robust linear regression is essentially weighted least squares regression with the weights estimated by an iterative process.
The formula I gave in the question for r2w needs a small correction to correspond to equation 4 in Willet and Singer (1988) for r2wls: the SSt calculation should also use a weighted mean:
the correction is SSt <- sum((x$w*observed-mean(x$w*observed))^2)].
What is the meaning of this (corrected) weighted r-squared? Willett and Singer interpret it as: "the coefficient of determination in the transformed [weighted] dataset. It is a measure of the proportion of the variation in weighted Y that can be accounted for by weighted X, and is the quantity that is output as R2 by the major statistical computer packages when a WLS regression is performed".
Is it meaningful as a measure of goodness of fit? This depends on how it is presented and interpreted. Willett and Singer caution that it is typically quite a bit higher than the r-squared obtained in ordinary least squares regression, and the high value encourages prominent display... but this display may be deceptive IF it is interpreted in the conventional sense of r-squared (as the proportion of unweighted variation explained by a model). Willett and Singer propose that a less 'deceptive' alternative is pseudoR2wls (their equation 7), which is equivalent to my function r2 in the original question. In general, Willett and Singer also caution that it is not good to rely on any r2 (even their pseudor2wls) as a sole measure of goodness of fit. Despite these cautions, the whole premise of robust regression is that some cases are judged 'not as good' and don't count as much in the model fitting, and it may be good to reflect this in part of the model assessment process. The weighted r-squared described, can be one good measure of goodness of fit - as long as the correct interpretation is clearly given in the presentation and it is not relied on as the sole assessment of goodness of fit.
|
Is a weighted $R^2$ in robust linear model meaningful for goodness of fit analysis?
The following answer is based on: (1) my interpretation of Willett and Singer (1988) Another Cautionary Note about R-squared: It's use in weighted least squates regression analysis. The American Stat
|
11,585
|
Is a weighted $R^2$ in robust linear model meaningful for goodness of fit analysis?
|
@CraigMilligan.
Shouldn't:
the weight be outside of the squared parenthesis
the weighted mean be calculated as sum(x$w*observed)/sum(x$w) for which we can also use weighted.mean(observed,x$w)
Something like this:
r2ww <- function(x){
SSe <- sum(x$w*(x$resid)^2)
observed <- x$resid+x$fitted
SSt <- sum(x$w*(observed-weighted.mean(observed,x$w))^2)
value <- 1-SSe/SSt;
return(value);
}
|
Is a weighted $R^2$ in robust linear model meaningful for goodness of fit analysis?
|
@CraigMilligan.
Shouldn't:
the weight be outside of the squared parenthesis
the weighted mean be calculated as sum(x$w*observed)/sum(x$w) for which we can also use weighted.mean(observed,x$w)
Someth
|
Is a weighted $R^2$ in robust linear model meaningful for goodness of fit analysis?
@CraigMilligan.
Shouldn't:
the weight be outside of the squared parenthesis
the weighted mean be calculated as sum(x$w*observed)/sum(x$w) for which we can also use weighted.mean(observed,x$w)
Something like this:
r2ww <- function(x){
SSe <- sum(x$w*(x$resid)^2)
observed <- x$resid+x$fitted
SSt <- sum(x$w*(observed-weighted.mean(observed,x$w))^2)
value <- 1-SSe/SSt;
return(value);
}
|
Is a weighted $R^2$ in robust linear model meaningful for goodness of fit analysis?
@CraigMilligan.
Shouldn't:
the weight be outside of the squared parenthesis
the weighted mean be calculated as sum(x$w*observed)/sum(x$w) for which we can also use weighted.mean(observed,x$w)
Someth
|
11,586
|
How to test for differences between two group means when the data is not normally distributed?
|
The idea that the t-test is only for small samples is a historical hold over. Yes it was originally developed for small samples, but there is nothing in the theory that distinguishes small from large. In the days before computers were common for doing statistics the t-tables often only went up to around 30 degrees of freedom and the normal was used beyond that as a close approximation of the t distribution. This was for convenience to keep the t-table's size reasonable. Now with computers we can do t-tests for any sample size (though for very large samples the difference between the results of a z-test and a t-test are very small). The main idea is to use a t-test when using the sample to estimate the standard deviations and the z-test if the population standard deviations are known (very rare).
The Central Limit Theorem lets us use the normal theory inference (t-tests in this case) even if the population is not normally distributed as long as the sample sizes are large enough. This does mean that your test is approximate (but with your sample sizes, the appromition should be very good).
The Wilcoxon test is not a test of means (unless you know that the populations are perfectly symmetric and other unlikely assumptions hold). If the means are the main point of interest then the t-test is probably the better one to quote.
Given that your standard deviations are so different, and the shapes are non-normal and possibly different from each other, the difference in the means may not be the most interesting thing going on here. Think about the science and what you want to do with your results. Are decisions being made at the population level or the individual level? Think of this example: you are comparing 2 drugs for a given disease, on drug A half the sample died immediatly the other half recovered in about a week; on drug B all survived and recovered, but the time to recovery was longer than a week. In this case would you really care about which mean recovery time was shorter? Or replace the half dying in A with just taking a really long time to recover (longer than anyone in the B group). When deciding which drug I would want to take I would want the full information, not just which was quicker on average.
|
How to test for differences between two group means when the data is not normally distributed?
|
The idea that the t-test is only for small samples is a historical hold over. Yes it was originally developed for small samples, but there is nothing in the theory that distinguishes small from large
|
How to test for differences between two group means when the data is not normally distributed?
The idea that the t-test is only for small samples is a historical hold over. Yes it was originally developed for small samples, but there is nothing in the theory that distinguishes small from large. In the days before computers were common for doing statistics the t-tables often only went up to around 30 degrees of freedom and the normal was used beyond that as a close approximation of the t distribution. This was for convenience to keep the t-table's size reasonable. Now with computers we can do t-tests for any sample size (though for very large samples the difference between the results of a z-test and a t-test are very small). The main idea is to use a t-test when using the sample to estimate the standard deviations and the z-test if the population standard deviations are known (very rare).
The Central Limit Theorem lets us use the normal theory inference (t-tests in this case) even if the population is not normally distributed as long as the sample sizes are large enough. This does mean that your test is approximate (but with your sample sizes, the appromition should be very good).
The Wilcoxon test is not a test of means (unless you know that the populations are perfectly symmetric and other unlikely assumptions hold). If the means are the main point of interest then the t-test is probably the better one to quote.
Given that your standard deviations are so different, and the shapes are non-normal and possibly different from each other, the difference in the means may not be the most interesting thing going on here. Think about the science and what you want to do with your results. Are decisions being made at the population level or the individual level? Think of this example: you are comparing 2 drugs for a given disease, on drug A half the sample died immediatly the other half recovered in about a week; on drug B all survived and recovered, but the time to recovery was longer than a week. In this case would you really care about which mean recovery time was shorter? Or replace the half dying in A with just taking a really long time to recover (longer than anyone in the B group). When deciding which drug I would want to take I would want the full information, not just which was quicker on average.
|
How to test for differences between two group means when the data is not normally distributed?
The idea that the t-test is only for small samples is a historical hold over. Yes it was originally developed for small samples, but there is nothing in the theory that distinguishes small from large
|
11,587
|
How to test for differences between two group means when the data is not normally distributed?
|
One addition to Greg's already very comprehensive answer.
If I understand you the right way, your point 3 states the following procedure:
Observe $n$ samples of a distribution $X$.
Then, draw $m$ of those $n$ values and compute their mean.
Repeat this 1000 times, save the corresponding means
Finally, compute the mean of those means and assume that the mean of $X$ equals the mean computed that way.
Now your assumption is, that for this mean the central limit theorem holds and the corresponding random variable will be normally distributed.
Maybe let's have a look at the math behind your computation to identify the error:
We will call your samples of $X$ $X_1,\ldots,X_n$, or, in statistical terminology, you have $X_1,\ldots, X_n\sim X$. Now, we draw samples of size $m$ and compute their mean. The $k$-th of those means looks somehow like this:
$$ Y_k=\frac{1}{m}\sum_{i=1}^m X_{\mu^k_{i}} $$
where $\mu^k_i$ denotes the value between 1 and $n$ that has been drawn at draw $i$. Computing the mean of all those means thus results in
$$ \frac{1}{1000}\sum_{k=1}^{1000} \frac{1}{m}\sum_{i=1}^m X_{\mu^k_{i}} $$
To spare you the exact mathematical terminology just take a look at this sum. What happens is that the $X_i$ are just added multiple times to the sum. All in all, you add up $1000m$ numbers and divide them by $1000m$. In fact, you are computing a weighted mean of the $X_i$ with random weights.
Now, however, the Central Limit Theorem states that the sum of a lot of independent random variables is approximately normal. (Which results in also being the mean approx. normal).
Your sum above does not produce independent samples. You perhaps have random weights, but that does not make your samples independent at all. Thus, the procedure written in 3 is not legal.
However, as Greg already stated, using a $t$-test on your original data may be approximately correct - if you are really interested at the mean.
|
How to test for differences between two group means when the data is not normally distributed?
|
One addition to Greg's already very comprehensive answer.
If I understand you the right way, your point 3 states the following procedure:
Observe $n$ samples of a distribution $X$.
Then, draw $m$ of
|
How to test for differences between two group means when the data is not normally distributed?
One addition to Greg's already very comprehensive answer.
If I understand you the right way, your point 3 states the following procedure:
Observe $n$ samples of a distribution $X$.
Then, draw $m$ of those $n$ values and compute their mean.
Repeat this 1000 times, save the corresponding means
Finally, compute the mean of those means and assume that the mean of $X$ equals the mean computed that way.
Now your assumption is, that for this mean the central limit theorem holds and the corresponding random variable will be normally distributed.
Maybe let's have a look at the math behind your computation to identify the error:
We will call your samples of $X$ $X_1,\ldots,X_n$, or, in statistical terminology, you have $X_1,\ldots, X_n\sim X$. Now, we draw samples of size $m$ and compute their mean. The $k$-th of those means looks somehow like this:
$$ Y_k=\frac{1}{m}\sum_{i=1}^m X_{\mu^k_{i}} $$
where $\mu^k_i$ denotes the value between 1 and $n$ that has been drawn at draw $i$. Computing the mean of all those means thus results in
$$ \frac{1}{1000}\sum_{k=1}^{1000} \frac{1}{m}\sum_{i=1}^m X_{\mu^k_{i}} $$
To spare you the exact mathematical terminology just take a look at this sum. What happens is that the $X_i$ are just added multiple times to the sum. All in all, you add up $1000m$ numbers and divide them by $1000m$. In fact, you are computing a weighted mean of the $X_i$ with random weights.
Now, however, the Central Limit Theorem states that the sum of a lot of independent random variables is approximately normal. (Which results in also being the mean approx. normal).
Your sum above does not produce independent samples. You perhaps have random weights, but that does not make your samples independent at all. Thus, the procedure written in 3 is not legal.
However, as Greg already stated, using a $t$-test on your original data may be approximately correct - if you are really interested at the mean.
|
How to test for differences between two group means when the data is not normally distributed?
One addition to Greg's already very comprehensive answer.
If I understand you the right way, your point 3 states the following procedure:
Observe $n$ samples of a distribution $X$.
Then, draw $m$ of
|
11,588
|
What non-Bayesian methods are there for predictive inference?
|
Non-Bayesian predictive inference (apart from the SLR case) is a relatively recent field. Under the heading of "non-Bayesian" we can subdivide the approaches into those that are "classical" frequentist vs those that are "likelihood" based.
Classical Frequentist Prediction
As you know, the "gold standard" in frequentism is to achieve the nominal coverage under repeated sampling. For example, we want a 95% Confidence Region to contain the true parameter(s) in 95% of samples from the same underlying population. Or, we expect to commit Type I and II errors in a hypothesis test on average equal to $\alpha$ and $\beta$. Finally, and most germane to this question, we expect our 95% Prediction Interval to contain the next sample point 95% of the time.
Now, I've generally had issues with how classical PI's are presented and taught in most stats courses, because the overwhelming tendency is to interpret these as Bayesian posterior predictive intervals, which they are decidedly not. Most fundamentally, they are talking about different probabilities! Bayesian's make no claim on the repeated sampling performance of their quantities (otherwise, they'd be frequentists). Second, a Bayesian PI is actually accomplishing something more similar in spirit to a Classical Tolerance Interval than to a Classical Prediction Interval.
For reference: Tolerance Intervals need to be specified by two probabilities: The confidence and the coverage. The confidence tells us how often it is correct in repeated samples. The coverage tells us the minimum probability measure of the interval under the true distribution (as opposed to the PI, which gives the expected probability measure...again under repeated sampling). This is basically what the Bayesian PI is trying to do as well, but without any repeated-sampling claims.
So, the basic logic of the Stats 101 Simple Linear Regression is to derive the repeated sampling properties of the PI under the assumption of normality. Its the frequentist+Gaussian approach that is typically thought of as "classical" and taught in intro stats classes. This is based on the simplicity of the resulting calculations (see Wikipedia for a nice overview).
Non-gaussian probability distributions are generally problematic because they can lack pivotal quantities that can be neatly inverted to get an interval. Therefore, there is no "exact" method for these distributions, often because the interval's properties depend on the true underlying parameters.
Acknowledging this inability, another class of prediction arose (and of inference and estimation) with the likelihood approach.
Likelihood-based Inference
Likelihood-based approaches, like many modern statistical concepts, can be traced back to Ronald Fisher. The basic idea of this school is that, except for special cases, our statistical inferences are on logically weaker ground than when we are dealing with inferences from a normal distribution (whose parameter estimates are orthogonal), where we can make exact probability statements. In this view of inference, one should really avoid statements about probability except in the exact case, otherwise, one should make statements about the likelihood and acknowledge that one does not know the exact probability of error (in a frequentist sense).
Therefore, we can see likelihood as akin to Bayesian probability, but without the integrability requirements or the possible confusion with frequentist probability. Its interpretation is entirely subjective...although a likelihood ratio of 0.15 is often recommended for single parameter inference.
However, one does not often see papers that explicitly give "likelihood intervals". Why? It appears that this is largely a matter of sociology, as we have all grown accustomed to probability-based confidence statements. Instead, what you often see is an author referring to an "approximate" or "asymptotic" confidence interval of such and such. These intervals are largely derived from likelihood methods, where we are relying on the asymptotic Chi-squared distribution of the likelihood ratio in much the same way we rely on the asymptotic normality of the sample mean.
With this "fix" we can now construct "approximate" 95% Confidence Regions with almost as much logical consistency as the Bayesians.
From CI to PI in the Likelihood Framework
The success and ease of the above likelihood approach led to ideas about how to extend it to prediction. A very nice survey article on this is given here (I will not reproduce its excellent coverage). It can be traced back to David Hinkley in the late 1970's (see JSTOR), who coined the term. He applied it to the perennial "Pearson's Binomial Prediction Problem". I'll summarize the basic logic.
The fundamental insight is that if we include an unobserved data point, say $y$, in our sample, and then perform traditional likelihood inference on $y$ instead of a fixed parameter, then what we get is not just a likelihood function, but a distribution (unnormalized), since the "parameter" $y$ is actually random and therefore can be logically assigned a frequentist probability. The mechanics of this for this particular problem are reviewed in the links I provided.
The basic rules for getting rid of "nuisance" parameters to get a predictive likelihood are as follows:
If a parameter is fixed (e.g., $\mu, \sigma$), then profile it out of the likelihood.
If a parameter is random (e.g., other unobserved data or "random effects"), then you integrate them out (just like in Bayesian approach).
The distinction between a fixed and random parameter is unique to likelihood inference, but has connections to mixed effects models, where it seems that the Bayesian, frequentist, and likelihood frameworks collide.
Hopefully this answered your question about the broad area of "non-Bayesian" prediction (and inference for that matter). Since hyperlinks can change, I'll also make a plug for the book "In All Likelihood: Statistical Modeling and Inference using Likelihood" which discusses the modern likelihood framework at depth, including a fair amount of the epistemological issues of likelihood vs Bayesian vs frequentist inference and prediction.
References
Prediction Intervals: Non-parametric methods. Wikipedia. Accessed 9/13/2015.
Bjornstad, Jan F. Predictive Likelihood: A Review. Statist. Sci. 5
(1990), no. 2, 242--254. doi:10.1214/ss/1177012175.
http://projecteuclid.org/euclid.ss/1177012175.
David Hinkley. Predictive Likelihood. The Annals of Statistics Vol. 7, No. 4 (Jul., 1979) , pp. 718-728 Published by: Institute of Mathematical Statistics
Stable URL: http://www.jstor.org/stable/2958920
Yudi Pawitan. In All Likelihood: Statistical Modeling and Inference Using Likelihood. Oxford University Press; 1 edition (August 30, 2001). ISBN-10: 0198507658, ISBN-13: 978-0198507659. Especially Chapters 5.5-5.9, 10, and 16.
|
What non-Bayesian methods are there for predictive inference?
|
Non-Bayesian predictive inference (apart from the SLR case) is a relatively recent field. Under the heading of "non-Bayesian" we can subdivide the approaches into those that are "classical" frequentis
|
What non-Bayesian methods are there for predictive inference?
Non-Bayesian predictive inference (apart from the SLR case) is a relatively recent field. Under the heading of "non-Bayesian" we can subdivide the approaches into those that are "classical" frequentist vs those that are "likelihood" based.
Classical Frequentist Prediction
As you know, the "gold standard" in frequentism is to achieve the nominal coverage under repeated sampling. For example, we want a 95% Confidence Region to contain the true parameter(s) in 95% of samples from the same underlying population. Or, we expect to commit Type I and II errors in a hypothesis test on average equal to $\alpha$ and $\beta$. Finally, and most germane to this question, we expect our 95% Prediction Interval to contain the next sample point 95% of the time.
Now, I've generally had issues with how classical PI's are presented and taught in most stats courses, because the overwhelming tendency is to interpret these as Bayesian posterior predictive intervals, which they are decidedly not. Most fundamentally, they are talking about different probabilities! Bayesian's make no claim on the repeated sampling performance of their quantities (otherwise, they'd be frequentists). Second, a Bayesian PI is actually accomplishing something more similar in spirit to a Classical Tolerance Interval than to a Classical Prediction Interval.
For reference: Tolerance Intervals need to be specified by two probabilities: The confidence and the coverage. The confidence tells us how often it is correct in repeated samples. The coverage tells us the minimum probability measure of the interval under the true distribution (as opposed to the PI, which gives the expected probability measure...again under repeated sampling). This is basically what the Bayesian PI is trying to do as well, but without any repeated-sampling claims.
So, the basic logic of the Stats 101 Simple Linear Regression is to derive the repeated sampling properties of the PI under the assumption of normality. Its the frequentist+Gaussian approach that is typically thought of as "classical" and taught in intro stats classes. This is based on the simplicity of the resulting calculations (see Wikipedia for a nice overview).
Non-gaussian probability distributions are generally problematic because they can lack pivotal quantities that can be neatly inverted to get an interval. Therefore, there is no "exact" method for these distributions, often because the interval's properties depend on the true underlying parameters.
Acknowledging this inability, another class of prediction arose (and of inference and estimation) with the likelihood approach.
Likelihood-based Inference
Likelihood-based approaches, like many modern statistical concepts, can be traced back to Ronald Fisher. The basic idea of this school is that, except for special cases, our statistical inferences are on logically weaker ground than when we are dealing with inferences from a normal distribution (whose parameter estimates are orthogonal), where we can make exact probability statements. In this view of inference, one should really avoid statements about probability except in the exact case, otherwise, one should make statements about the likelihood and acknowledge that one does not know the exact probability of error (in a frequentist sense).
Therefore, we can see likelihood as akin to Bayesian probability, but without the integrability requirements or the possible confusion with frequentist probability. Its interpretation is entirely subjective...although a likelihood ratio of 0.15 is often recommended for single parameter inference.
However, one does not often see papers that explicitly give "likelihood intervals". Why? It appears that this is largely a matter of sociology, as we have all grown accustomed to probability-based confidence statements. Instead, what you often see is an author referring to an "approximate" or "asymptotic" confidence interval of such and such. These intervals are largely derived from likelihood methods, where we are relying on the asymptotic Chi-squared distribution of the likelihood ratio in much the same way we rely on the asymptotic normality of the sample mean.
With this "fix" we can now construct "approximate" 95% Confidence Regions with almost as much logical consistency as the Bayesians.
From CI to PI in the Likelihood Framework
The success and ease of the above likelihood approach led to ideas about how to extend it to prediction. A very nice survey article on this is given here (I will not reproduce its excellent coverage). It can be traced back to David Hinkley in the late 1970's (see JSTOR), who coined the term. He applied it to the perennial "Pearson's Binomial Prediction Problem". I'll summarize the basic logic.
The fundamental insight is that if we include an unobserved data point, say $y$, in our sample, and then perform traditional likelihood inference on $y$ instead of a fixed parameter, then what we get is not just a likelihood function, but a distribution (unnormalized), since the "parameter" $y$ is actually random and therefore can be logically assigned a frequentist probability. The mechanics of this for this particular problem are reviewed in the links I provided.
The basic rules for getting rid of "nuisance" parameters to get a predictive likelihood are as follows:
If a parameter is fixed (e.g., $\mu, \sigma$), then profile it out of the likelihood.
If a parameter is random (e.g., other unobserved data or "random effects"), then you integrate them out (just like in Bayesian approach).
The distinction between a fixed and random parameter is unique to likelihood inference, but has connections to mixed effects models, where it seems that the Bayesian, frequentist, and likelihood frameworks collide.
Hopefully this answered your question about the broad area of "non-Bayesian" prediction (and inference for that matter). Since hyperlinks can change, I'll also make a plug for the book "In All Likelihood: Statistical Modeling and Inference using Likelihood" which discusses the modern likelihood framework at depth, including a fair amount of the epistemological issues of likelihood vs Bayesian vs frequentist inference and prediction.
References
Prediction Intervals: Non-parametric methods. Wikipedia. Accessed 9/13/2015.
Bjornstad, Jan F. Predictive Likelihood: A Review. Statist. Sci. 5
(1990), no. 2, 242--254. doi:10.1214/ss/1177012175.
http://projecteuclid.org/euclid.ss/1177012175.
David Hinkley. Predictive Likelihood. The Annals of Statistics Vol. 7, No. 4 (Jul., 1979) , pp. 718-728 Published by: Institute of Mathematical Statistics
Stable URL: http://www.jstor.org/stable/2958920
Yudi Pawitan. In All Likelihood: Statistical Modeling and Inference Using Likelihood. Oxford University Press; 1 edition (August 30, 2001). ISBN-10: 0198507658, ISBN-13: 978-0198507659. Especially Chapters 5.5-5.9, 10, and 16.
|
What non-Bayesian methods are there for predictive inference?
Non-Bayesian predictive inference (apart from the SLR case) is a relatively recent field. Under the heading of "non-Bayesian" we can subdivide the approaches into those that are "classical" frequentis
|
11,589
|
What non-Bayesian methods are there for predictive inference?
|
I'll address my answer specifically to the question, "What non-Bayesian methods for predictive inference are there that take into account uncertainty in parameter estimates?" I will organize my answer around expanding the meaning of uncertainty.
We hope statistical analyses provide support for various kinds of claims, including predictions. But we remain uncertain about our claims, and this uncertainty arises from many sources. Frequentist statistics is characteristically organized around addressing only that part of our uncertainty arising specifically from sampling. Sampling may well have been the main source of uncertainty in the agricultural field experiments that historically provided much of the stimulus to the development of frequentist statistics. But in many of the most important current applications, this is not the case. We now worry about all kinds of other uncertainties like model misspecification and various forms of bias---of which there are apparently hundreds (!) of types[1].
Sander Greenland has a wonderful discussion paper [2] that points out how important it can be to take account for these other sources of uncertainty, and prescribes multiple-bias analysis as the means to accomplish this. He develops the theory entirely in Bayesian terms, which is natural. If one wishes to carry forward a formal, coherent treatment of one's uncertainty about model parameters, one is led naturally to posit (subjective) probability distributions over parameters; at this point you are either lost to the Bayesian Devil or have entered the Bayesian Kingdom of Heaven (depending on your religion).
To your question, @Scortchi, about whether this can be done with "non-Bayesian methods," a non-Bayesian workaround is demonstrated in [3]. But to anyone who knows enough about Bayesianism to write your question, the treatment there will look rather like an attempt to implement Bayesian calculations 'on the sly' so to speak. Indeed, as the authors acknowledge (see p. 4), the closer you get to the more advanced methods toward the end of the book, the more the methods look like precisely the integration you describe in your question. They suggest that where they depart from Bayesianism ultimately is only in not positing explicit priors on their parameters before estimating them.
To tie this in explicitly to prediction, one need only appreciate the 'prediction' as a function of the estimated parameters. In [2], Greenland uses the notation $\theta(\alpha)$, where $\alpha$ is the vector of model parameters, and $\theta$ is the function of those parameters which is to be estimated. (In terms of Greenland's example application, a meaningful prediction could be the impact in terms of reduced pediatric leukemia of a policy of relocating power lines.)
Chavalarias, David, and John P A Ioannidis. “Science Mapping Analysis Characterizes 235 Biases in Biomedical Research.” Journal of Clinical Epidemiology 63, no. 11 (November 2010): 1205–15. doi:10.1016/j.jclinepi.2009.12.011.
Greenland, Sander. “Multiple-Bias Modelling for Analysis of Observational Data (with Discussion).” Journal of the Royal Statistical Society: Series A (Statistics in Society) 168, no. 2 (March 2005): 267–306. doi:10.1111/j.1467-985X.2004.00349.x.
Lash, Timothy L., Matthew P. Fox, and Aliza K. Fink. Applying Quantitative Bias Analysis to Epidemiologic Data. Statistics for Biology and Health. New York, NY: Springer New York, 2009. http://link.springer.com/10.1007/978-0-387-87959-8.
|
What non-Bayesian methods are there for predictive inference?
|
I'll address my answer specifically to the question, "What non-Bayesian methods for predictive inference are there that take into account uncertainty in parameter estimates?" I will organize my answer
|
What non-Bayesian methods are there for predictive inference?
I'll address my answer specifically to the question, "What non-Bayesian methods for predictive inference are there that take into account uncertainty in parameter estimates?" I will organize my answer around expanding the meaning of uncertainty.
We hope statistical analyses provide support for various kinds of claims, including predictions. But we remain uncertain about our claims, and this uncertainty arises from many sources. Frequentist statistics is characteristically organized around addressing only that part of our uncertainty arising specifically from sampling. Sampling may well have been the main source of uncertainty in the agricultural field experiments that historically provided much of the stimulus to the development of frequentist statistics. But in many of the most important current applications, this is not the case. We now worry about all kinds of other uncertainties like model misspecification and various forms of bias---of which there are apparently hundreds (!) of types[1].
Sander Greenland has a wonderful discussion paper [2] that points out how important it can be to take account for these other sources of uncertainty, and prescribes multiple-bias analysis as the means to accomplish this. He develops the theory entirely in Bayesian terms, which is natural. If one wishes to carry forward a formal, coherent treatment of one's uncertainty about model parameters, one is led naturally to posit (subjective) probability distributions over parameters; at this point you are either lost to the Bayesian Devil or have entered the Bayesian Kingdom of Heaven (depending on your religion).
To your question, @Scortchi, about whether this can be done with "non-Bayesian methods," a non-Bayesian workaround is demonstrated in [3]. But to anyone who knows enough about Bayesianism to write your question, the treatment there will look rather like an attempt to implement Bayesian calculations 'on the sly' so to speak. Indeed, as the authors acknowledge (see p. 4), the closer you get to the more advanced methods toward the end of the book, the more the methods look like precisely the integration you describe in your question. They suggest that where they depart from Bayesianism ultimately is only in not positing explicit priors on their parameters before estimating them.
To tie this in explicitly to prediction, one need only appreciate the 'prediction' as a function of the estimated parameters. In [2], Greenland uses the notation $\theta(\alpha)$, where $\alpha$ is the vector of model parameters, and $\theta$ is the function of those parameters which is to be estimated. (In terms of Greenland's example application, a meaningful prediction could be the impact in terms of reduced pediatric leukemia of a policy of relocating power lines.)
Chavalarias, David, and John P A Ioannidis. “Science Mapping Analysis Characterizes 235 Biases in Biomedical Research.” Journal of Clinical Epidemiology 63, no. 11 (November 2010): 1205–15. doi:10.1016/j.jclinepi.2009.12.011.
Greenland, Sander. “Multiple-Bias Modelling for Analysis of Observational Data (with Discussion).” Journal of the Royal Statistical Society: Series A (Statistics in Society) 168, no. 2 (March 2005): 267–306. doi:10.1111/j.1467-985X.2004.00349.x.
Lash, Timothy L., Matthew P. Fox, and Aliza K. Fink. Applying Quantitative Bias Analysis to Epidemiologic Data. Statistics for Biology and Health. New York, NY: Springer New York, 2009. http://link.springer.com/10.1007/978-0-387-87959-8.
|
What non-Bayesian methods are there for predictive inference?
I'll address my answer specifically to the question, "What non-Bayesian methods for predictive inference are there that take into account uncertainty in parameter estimates?" I will organize my answer
|
11,590
|
A proof for the stationarity of an AR(2)
|
My guess is that the characteristic equation you are departing from is different from mine. Let me proceed in a couple of steps to see whether we agree.
Consider the equation
$$
\lambda^2-\phi_1\lambda-\phi_2=0
$$
If $z$ is a root of the "standard" characteristic equation $1-\phi_1 z-\phi_2 z^2=0$ and setting $z^{-1}=\lambda$, the display obtains from rewriting the standard one as follows:
\begin{eqnarray*}
1-\phi_1 z-\phi_2 z^2&=&0\\
\Rightarrow z^{-2}-\phi_1 z^{-1}-\phi_2 &=&0\\
\Rightarrow \lambda^2-\phi_1\lambda -\phi_2 &=&0
\end{eqnarray*}
Hence, an alternative condition for stability of an $AR(2)$ is that all roots of the first display are inside the unit circle, $|z|>1 \Leftrightarrow |\lambda|=|z^{-1}|<1$.
We use this representation to derive the stationarity triangle of an $AR(2)$ process, that is that an $AR(2)$ is stable if the following three conditions are met:
$\phi_2<1+\phi_1$
$\phi_2<1-\phi_1$
$\phi_2>-1$
Recall that you can write the roots of the first display (if real) as
$$
\lambda_{1,2}=\frac{\phi_1\pm\sqrt{\phi_1^2+4\phi_2}}{2}
$$
to find the first two conditions.
Then, the $AR(2)$ is stationary iff $|\lambda|<1$, hence (if the $\lambda_i$ are real):
\begin{eqnarray*}
-1<\frac{\phi_1\pm\sqrt{\phi_1^2+4\phi_2}}{2}&<&1\\
\Rightarrow -2<\phi_1\pm\sqrt{\phi_1^2+4\phi_2}&<&2
\end{eqnarray*}
The larger of the two $\lambda_i$ is bounded by $\phi_1+\sqrt{\phi_1^2+4\phi_2}<2$, or:
\begin{eqnarray*}
\phi_1+\sqrt{\phi_1^2+4\phi_2}&<&2\\
\Rightarrow \sqrt{\phi_1^2+4\phi_2}&<&2 - \phi_1\\
\Rightarrow \phi_1^2+4\phi_2&<&(2 - \phi_1)^2\\
\Rightarrow \phi_1^2+4\phi_2&<&4 - 4\phi_1+\phi_1^2\\
\Rightarrow \phi_2&<&1 - \phi_1
\end{eqnarray*}
Analogously, we find that $\phi_2<1 + \phi_1$.
If $\lambda_i$ is complex, then $\phi_1^2<-4\phi_2$ and so $$\lambda_{1,2} = \phi_1/2\pm i\sqrt{-(\phi_1^2+4\phi_2)}/2.$$ The squared modulus of a complex number is the square of the real plus the square of the imaginary part. Hence,
$$
\lambda^2 = (\phi_1/2)^2 + \left(\sqrt{-(\phi_1^2+4\phi_2)}/2\right)^2 = \phi_1^2/4-(\phi_1^2+4\phi_2)/4 = -\phi_2.
$$
This is stable if $|\lambda|<1$, hence if $-\phi_2<1$ or $\phi_2>-1$, as was to be shown. (The restriction $\phi_2<1$ resulting from $\phi_2^2<1$ is redundant in view of $\phi_2<1+\phi_1$ and $\phi_2<1-\phi_1$.)
Plotting the stationarity triangle, also indicating the line that separates complex from real roots, we get
Produced in R using
phi1 <- seq(from = -2.5, to = 2.5, length = 51)
plot(phi1,1+phi1,lty="dashed",type="l",xlab="",ylab="",cex.axis=.8,ylim=c(-1.5,1.5))
abline(a = -1, b = 0, lty="dashed")
abline(a = 1, b = -1, lty="dashed")
title(ylab=expression(phi[2]),xlab=expression(phi[1]),cex.lab=.8)
polygon(x = phi1[6:46], y = 1-abs(phi1[6:46]), col="gray")
lines(phi1,-phi1^2/4)
text(0,-.5,expression(phi[2]<phi[1]^2/4),cex=.7)
text(1.2,.5,expression(phi[2]>1-phi[1]),cex=.7)
text(-1.75,.5,expression(phi[2]>1+phi[1]),cex=.7)
|
A proof for the stationarity of an AR(2)
|
My guess is that the characteristic equation you are departing from is different from mine. Let me proceed in a couple of steps to see whether we agree.
Consider the equation
$$
\lambda^2-\phi_1\lambd
|
A proof for the stationarity of an AR(2)
My guess is that the characteristic equation you are departing from is different from mine. Let me proceed in a couple of steps to see whether we agree.
Consider the equation
$$
\lambda^2-\phi_1\lambda-\phi_2=0
$$
If $z$ is a root of the "standard" characteristic equation $1-\phi_1 z-\phi_2 z^2=0$ and setting $z^{-1}=\lambda$, the display obtains from rewriting the standard one as follows:
\begin{eqnarray*}
1-\phi_1 z-\phi_2 z^2&=&0\\
\Rightarrow z^{-2}-\phi_1 z^{-1}-\phi_2 &=&0\\
\Rightarrow \lambda^2-\phi_1\lambda -\phi_2 &=&0
\end{eqnarray*}
Hence, an alternative condition for stability of an $AR(2)$ is that all roots of the first display are inside the unit circle, $|z|>1 \Leftrightarrow |\lambda|=|z^{-1}|<1$.
We use this representation to derive the stationarity triangle of an $AR(2)$ process, that is that an $AR(2)$ is stable if the following three conditions are met:
$\phi_2<1+\phi_1$
$\phi_2<1-\phi_1$
$\phi_2>-1$
Recall that you can write the roots of the first display (if real) as
$$
\lambda_{1,2}=\frac{\phi_1\pm\sqrt{\phi_1^2+4\phi_2}}{2}
$$
to find the first two conditions.
Then, the $AR(2)$ is stationary iff $|\lambda|<1$, hence (if the $\lambda_i$ are real):
\begin{eqnarray*}
-1<\frac{\phi_1\pm\sqrt{\phi_1^2+4\phi_2}}{2}&<&1\\
\Rightarrow -2<\phi_1\pm\sqrt{\phi_1^2+4\phi_2}&<&2
\end{eqnarray*}
The larger of the two $\lambda_i$ is bounded by $\phi_1+\sqrt{\phi_1^2+4\phi_2}<2$, or:
\begin{eqnarray*}
\phi_1+\sqrt{\phi_1^2+4\phi_2}&<&2\\
\Rightarrow \sqrt{\phi_1^2+4\phi_2}&<&2 - \phi_1\\
\Rightarrow \phi_1^2+4\phi_2&<&(2 - \phi_1)^2\\
\Rightarrow \phi_1^2+4\phi_2&<&4 - 4\phi_1+\phi_1^2\\
\Rightarrow \phi_2&<&1 - \phi_1
\end{eqnarray*}
Analogously, we find that $\phi_2<1 + \phi_1$.
If $\lambda_i$ is complex, then $\phi_1^2<-4\phi_2$ and so $$\lambda_{1,2} = \phi_1/2\pm i\sqrt{-(\phi_1^2+4\phi_2)}/2.$$ The squared modulus of a complex number is the square of the real plus the square of the imaginary part. Hence,
$$
\lambda^2 = (\phi_1/2)^2 + \left(\sqrt{-(\phi_1^2+4\phi_2)}/2\right)^2 = \phi_1^2/4-(\phi_1^2+4\phi_2)/4 = -\phi_2.
$$
This is stable if $|\lambda|<1$, hence if $-\phi_2<1$ or $\phi_2>-1$, as was to be shown. (The restriction $\phi_2<1$ resulting from $\phi_2^2<1$ is redundant in view of $\phi_2<1+\phi_1$ and $\phi_2<1-\phi_1$.)
Plotting the stationarity triangle, also indicating the line that separates complex from real roots, we get
Produced in R using
phi1 <- seq(from = -2.5, to = 2.5, length = 51)
plot(phi1,1+phi1,lty="dashed",type="l",xlab="",ylab="",cex.axis=.8,ylim=c(-1.5,1.5))
abline(a = -1, b = 0, lty="dashed")
abline(a = 1, b = -1, lty="dashed")
title(ylab=expression(phi[2]),xlab=expression(phi[1]),cex.lab=.8)
polygon(x = phi1[6:46], y = 1-abs(phi1[6:46]), col="gray")
lines(phi1,-phi1^2/4)
text(0,-.5,expression(phi[2]<phi[1]^2/4),cex=.7)
text(1.2,.5,expression(phi[2]>1-phi[1]),cex=.7)
text(-1.75,.5,expression(phi[2]>1+phi[1]),cex=.7)
|
A proof for the stationarity of an AR(2)
My guess is that the characteristic equation you are departing from is different from mine. Let me proceed in a couple of steps to see whether we agree.
Consider the equation
$$
\lambda^2-\phi_1\lambd
|
11,591
|
k-fold Cross validation of ensemble learning
|
Ensemble learning refers to quite a few different methods. Boosting and bagging are probably the two most common ones. It seems that you are attempting to implement an ensemble learning method called stacking. Stacking aims to improve accuracy by combining predictions from several learning algorithms. There are quite a few ways to do stacking and not a lot of rigorous theory. It's intuitive and popular though.
Consider your friend's approach. You are fitting the first layer models on four out of five folds and then fitting the second layer (voting) model using the same four folds. The problem is that the second layer will favor the model with the lowest training error. You are using the same data to fit models and to devise a procedure to aggregate those models. The second layer should combine the models using out-of-sample predictions. Your method is better, but there is a way to do even better still.
We'll continue to leave out one fold for testing purposes. Take the four folds and use 4-fold CV to get out-of-sample predictions for each of your first layer models on all four folds. That is, leave out one of four folds and fit the models on the other three and then predict on the held-out data. Repeat for all four folds so you get out-of-sample predictions on all four folds. Then fit the second layer model on these out-of-sample predictions. Then fit the first layer models again on all four folds. Now you can go to the fifth fold that you haven't touched yet. Use the first layer models fit on all four folds along with the second layer model to estimate the error on the held-out data. You can repeat this process again with the other folds held out of the first and second layer model fitting.
If you are satisfied with the performance then generate out-of-sample predictions for the first layer models on all five folds and then fit the second layer model on these. Then fit the first layer models one last time on all your data and use these with the second layer model on any new data!
Finally, some general advice. You'll get more benefit if your first layer models are fairly distinct from each other. You are on the right path here using SVM and decision trees, which are pretty different from each other. Since there is an averaging effect from the second layer model, you may want to try overfitting your first layer models incrementally, particularly if you have a lot of them. The second layer is generally something simple and constraints like non-negativity of weights and monotonicity are common. Finally, remember that stacking relies on cross-validation, which is only an estimate of the true risk. If you get very different error rates and very different model weights across folds, it indicates that your cv-based risk estimate has high variance. In that case, you may want to consider a simple blending of your first layer models. Or, you can compromise by stacking with constraints on the max/min weight placed on each first layer model.
|
k-fold Cross validation of ensemble learning
|
Ensemble learning refers to quite a few different methods. Boosting and bagging are probably the two most common ones. It seems that you are attempting to implement an ensemble learning method called
|
k-fold Cross validation of ensemble learning
Ensemble learning refers to quite a few different methods. Boosting and bagging are probably the two most common ones. It seems that you are attempting to implement an ensemble learning method called stacking. Stacking aims to improve accuracy by combining predictions from several learning algorithms. There are quite a few ways to do stacking and not a lot of rigorous theory. It's intuitive and popular though.
Consider your friend's approach. You are fitting the first layer models on four out of five folds and then fitting the second layer (voting) model using the same four folds. The problem is that the second layer will favor the model with the lowest training error. You are using the same data to fit models and to devise a procedure to aggregate those models. The second layer should combine the models using out-of-sample predictions. Your method is better, but there is a way to do even better still.
We'll continue to leave out one fold for testing purposes. Take the four folds and use 4-fold CV to get out-of-sample predictions for each of your first layer models on all four folds. That is, leave out one of four folds and fit the models on the other three and then predict on the held-out data. Repeat for all four folds so you get out-of-sample predictions on all four folds. Then fit the second layer model on these out-of-sample predictions. Then fit the first layer models again on all four folds. Now you can go to the fifth fold that you haven't touched yet. Use the first layer models fit on all four folds along with the second layer model to estimate the error on the held-out data. You can repeat this process again with the other folds held out of the first and second layer model fitting.
If you are satisfied with the performance then generate out-of-sample predictions for the first layer models on all five folds and then fit the second layer model on these. Then fit the first layer models one last time on all your data and use these with the second layer model on any new data!
Finally, some general advice. You'll get more benefit if your first layer models are fairly distinct from each other. You are on the right path here using SVM and decision trees, which are pretty different from each other. Since there is an averaging effect from the second layer model, you may want to try overfitting your first layer models incrementally, particularly if you have a lot of them. The second layer is generally something simple and constraints like non-negativity of weights and monotonicity are common. Finally, remember that stacking relies on cross-validation, which is only an estimate of the true risk. If you get very different error rates and very different model weights across folds, it indicates that your cv-based risk estimate has high variance. In that case, you may want to consider a simple blending of your first layer models. Or, you can compromise by stacking with constraints on the max/min weight placed on each first layer model.
|
k-fold Cross validation of ensemble learning
Ensemble learning refers to quite a few different methods. Boosting and bagging are probably the two most common ones. It seems that you are attempting to implement an ensemble learning method called
|
11,592
|
How many times should we repeat a K-fold CV?
|
The influencing factor is how stable your model - or, more precisely: the predictions of the surrogates are.
If the models are completely stable, all surrogate models will yield the same prediction for the same test case. In that case, iterations/repetitions are not needed, and they don't yield any improvements.
As you can measure the stability of the predictions, here's what I'd do:
Set up the whole procedure in a way that saves the results of each cross validation repetition/iteration e.g. to hard disk
Start with a large number of iterations
After a few iterations are through, fetch the preliminary results and have a look at the stability/variation in the results for each run.
Then decide how many further iterations you want to refine the results.
Of course you may decide to run, say, 5 iterations and then decide on the final number of iterations you want to do.
(Side note: I typically use > ca. 1000 surrogate models, so typical no of repetitions/iterations would be around 100 - 125).
|
How many times should we repeat a K-fold CV?
|
The influencing factor is how stable your model - or, more precisely: the predictions of the surrogates are.
If the models are completely stable, all surrogate models will yield the same prediction fo
|
How many times should we repeat a K-fold CV?
The influencing factor is how stable your model - or, more precisely: the predictions of the surrogates are.
If the models are completely stable, all surrogate models will yield the same prediction for the same test case. In that case, iterations/repetitions are not needed, and they don't yield any improvements.
As you can measure the stability of the predictions, here's what I'd do:
Set up the whole procedure in a way that saves the results of each cross validation repetition/iteration e.g. to hard disk
Start with a large number of iterations
After a few iterations are through, fetch the preliminary results and have a look at the stability/variation in the results for each run.
Then decide how many further iterations you want to refine the results.
Of course you may decide to run, say, 5 iterations and then decide on the final number of iterations you want to do.
(Side note: I typically use > ca. 1000 surrogate models, so typical no of repetitions/iterations would be around 100 - 125).
|
How many times should we repeat a K-fold CV?
The influencing factor is how stable your model - or, more precisely: the predictions of the surrogates are.
If the models are completely stable, all surrogate models will yield the same prediction fo
|
11,593
|
How many times should we repeat a K-fold CV?
|
Ask a statistician any question and their answer will be some form of "it depends".
It depends. Apart from the type of model (good point cbeleites!), the number of training set points and the number of predictors? If the model is for classification, a large class imbalance would cause me to increase the number of repetitions. Also, if I am resampling a feature selection procedure, I would bias myself towards more resamples.
For any resampling method used in this context, remember that (unlike classical bootstrapping), you only need enough iterations to get a "precise enough" estimate of the mean of the distribution. That is subjective but any answer will be.
Sticking with classification with two classes for a second, suppose you expect/hope the accuracy of the model to be about 0.80 . Since the resampling process is sampling the accuracy estimate (say p), the standard error would be sqrt[p*(1-p)]/sqrt(B) where B is the number of resamples. For B = 10, the standard error of the accuracy is about 0.13 and with B = 100 it is about 0.04. You might use that formula as a rough guide for this particular case.
Also consider that, in this example, the variance of the accuracy is maximized the closer you get to 0.50 so an accurate model should need less replications since the standard error should be lower than models that are weak learners.
HTH,
Max
|
How many times should we repeat a K-fold CV?
|
Ask a statistician any question and their answer will be some form of "it depends".
It depends. Apart from the type of model (good point cbeleites!), the number of training set points and the number o
|
How many times should we repeat a K-fold CV?
Ask a statistician any question and their answer will be some form of "it depends".
It depends. Apart from the type of model (good point cbeleites!), the number of training set points and the number of predictors? If the model is for classification, a large class imbalance would cause me to increase the number of repetitions. Also, if I am resampling a feature selection procedure, I would bias myself towards more resamples.
For any resampling method used in this context, remember that (unlike classical bootstrapping), you only need enough iterations to get a "precise enough" estimate of the mean of the distribution. That is subjective but any answer will be.
Sticking with classification with two classes for a second, suppose you expect/hope the accuracy of the model to be about 0.80 . Since the resampling process is sampling the accuracy estimate (say p), the standard error would be sqrt[p*(1-p)]/sqrt(B) where B is the number of resamples. For B = 10, the standard error of the accuracy is about 0.13 and with B = 100 it is about 0.04. You might use that formula as a rough guide for this particular case.
Also consider that, in this example, the variance of the accuracy is maximized the closer you get to 0.50 so an accurate model should need less replications since the standard error should be lower than models that are weak learners.
HTH,
Max
|
How many times should we repeat a K-fold CV?
Ask a statistician any question and their answer will be some form of "it depends".
It depends. Apart from the type of model (good point cbeleites!), the number of training set points and the number o
|
11,594
|
Why doesn't k-means give the global minimum?
|
You can see k-means as a special version of the EM algorithm, which may help a little.
Say you are estimating a multivariate normal distribution for each cluster with the covariance matrix fixed to the identity matrix for all, but variable mean $\mu_i$ where $i$ is the cluster's index. Clearly, if the parameters $\{\mu_i\}$ are known, you can assign each point $p$ its maximum likelihood cluster (ie. the $\mu_i$ for which the distance to $p$ in minimal). The EM algorithm for this problem is almost equivalent to k-means.
The other way around, if you know which points belong to which cluster, you can estimate the optimal $\mu_i$. The closed form solution to this (which finds a global optimum) basically says that to find the maximum likelihood models $\{\hat\mu_i\}$ you integrate over all possible assignments of points to clusters. Since even with just thirty points and two clusters, there are about a billion such possible assignments, this is unfeasible to calculate.
Instead, we can take some guess as to the hidden parameters (or the model parameters) and iterate the two steps (with the posibility of ending up in a local maximum). If you allow each cluster to take a partial responsibility for a point, you end up with EM, if you just assign the optimal cluster, you get k-means.
So, executive summary: in probabilistic terms, there is a global solution, but it requires you to iterate over all possible clusterings. Clearly if you have an objective function, the same is true. You could iterate over all solutions and maximize the objective function, but the number of iterations is exponential in the size of your data.
|
Why doesn't k-means give the global minimum?
|
You can see k-means as a special version of the EM algorithm, which may help a little.
Say you are estimating a multivariate normal distribution for each cluster with the covariance matrix fixed to t
|
Why doesn't k-means give the global minimum?
You can see k-means as a special version of the EM algorithm, which may help a little.
Say you are estimating a multivariate normal distribution for each cluster with the covariance matrix fixed to the identity matrix for all, but variable mean $\mu_i$ where $i$ is the cluster's index. Clearly, if the parameters $\{\mu_i\}$ are known, you can assign each point $p$ its maximum likelihood cluster (ie. the $\mu_i$ for which the distance to $p$ in minimal). The EM algorithm for this problem is almost equivalent to k-means.
The other way around, if you know which points belong to which cluster, you can estimate the optimal $\mu_i$. The closed form solution to this (which finds a global optimum) basically says that to find the maximum likelihood models $\{\hat\mu_i\}$ you integrate over all possible assignments of points to clusters. Since even with just thirty points and two clusters, there are about a billion such possible assignments, this is unfeasible to calculate.
Instead, we can take some guess as to the hidden parameters (or the model parameters) and iterate the two steps (with the posibility of ending up in a local maximum). If you allow each cluster to take a partial responsibility for a point, you end up with EM, if you just assign the optimal cluster, you get k-means.
So, executive summary: in probabilistic terms, there is a global solution, but it requires you to iterate over all possible clusterings. Clearly if you have an objective function, the same is true. You could iterate over all solutions and maximize the objective function, but the number of iterations is exponential in the size of your data.
|
Why doesn't k-means give the global minimum?
You can see k-means as a special version of the EM algorithm, which may help a little.
Say you are estimating a multivariate normal distribution for each cluster with the covariance matrix fixed to t
|
11,595
|
Why doesn't k-means give the global minimum?
|
This is the problem that you want to solve:
\begin{align}
&\min_{x} \sum_{i=1}^n \sum_{j=1}^k x_{ij} || p_i - c_j||^2\\
&\text{subject to:} \\
&\sum_{j=1}^k x_{ij} = 1 \quad \forall i\\
& c_j\textit{ is the centroid of cluster j}\\
&x_{ij} \in \{0,1\} \quad \forall i, j \\
\end{align}
The binary variable $x_{ij}$ indicates whether or not point $i$ is assigned to cluster $j$. Symbols $p_i$ and $c_j$ denote the coordinates of $i$th point and centroid of $j$th cluster, respectively. They are both located in $\mathbb{R}^d$, where $d$ is the dimensionality of data points.
The first group of constraints say that each point should be assigned to exactly one cluster. The second group of constraints (which we have not defined mathematically) say that the coordinates of centroid of cluster $j$ actually depend on values of $x_{ij}$ variables. We can for example express this constraint as follows:
\begin{equation}
c_j = \frac{\sum_{i} x_{ij} p_{ij}}{\sum_{i} x_{ij}}
\end{equation}
However, instead of dealing with these non-linear constraints, in K-Means we (approximately) solve a different problem which has the same optimal solution as our original problem:
\begin{align}
&\min_{x} \sum_{i=1}^n \sum_{j=1}^k x_{ij} || p_i - y_j||^2\\
&\text{subject to:} \\
&\sum_{j=1}^k x_{ij} = 1 \quad \forall i\\
&x_{ij} \in \{0,1\} \quad \forall i, j \\
&y_j \in \mathbb{R}^d \quad \forall j
\end{align}
Instead of minimizing the distance to centroids, we minimize the distance to just any set of points that will give a better solution. It turns out that these points are exactly the centroids.
Now to solve this problem, we iterate in steps 2-3 of this algorithm, until convergence:
Assign some values to $y_j$ variables
Fix the values for $y_{j}$ variables and find the optimal values for $x_{ij}$ variables.
Fix the values of $x_{ij}$ variables, and find the optimal values for $y_{j}$ variables.
In each step the objective function improves (or remains the same when the algorithm converges), since the solution found in the previous step is in the search space of current step. However, since we are fixing some of the variables in each step, this is a local search procedure which does not guarantee optimality.
Luckily, the optimization problems in steps 2 and 3 can be solved in closed form. If we know $x_{ij}$
(i.e. if we know to which cluster each point is assigned), the best values for $y_j$ variables are the centroids of clusters. If we know values for $y_j$, obviously best choice for $x_{ij}$ variables is to assign each point to the closest $y_j$.
|
Why doesn't k-means give the global minimum?
|
This is the problem that you want to solve:
\begin{align}
&\min_{x} \sum_{i=1}^n \sum_{j=1}^k x_{ij} || p_i - c_j||^2\\
&\text{subject to:} \\
&\sum_{j=1}^k x_{ij} = 1 \quad \forall i\\
& c_j\textit{
|
Why doesn't k-means give the global minimum?
This is the problem that you want to solve:
\begin{align}
&\min_{x} \sum_{i=1}^n \sum_{j=1}^k x_{ij} || p_i - c_j||^2\\
&\text{subject to:} \\
&\sum_{j=1}^k x_{ij} = 1 \quad \forall i\\
& c_j\textit{ is the centroid of cluster j}\\
&x_{ij} \in \{0,1\} \quad \forall i, j \\
\end{align}
The binary variable $x_{ij}$ indicates whether or not point $i$ is assigned to cluster $j$. Symbols $p_i$ and $c_j$ denote the coordinates of $i$th point and centroid of $j$th cluster, respectively. They are both located in $\mathbb{R}^d$, where $d$ is the dimensionality of data points.
The first group of constraints say that each point should be assigned to exactly one cluster. The second group of constraints (which we have not defined mathematically) say that the coordinates of centroid of cluster $j$ actually depend on values of $x_{ij}$ variables. We can for example express this constraint as follows:
\begin{equation}
c_j = \frac{\sum_{i} x_{ij} p_{ij}}{\sum_{i} x_{ij}}
\end{equation}
However, instead of dealing with these non-linear constraints, in K-Means we (approximately) solve a different problem which has the same optimal solution as our original problem:
\begin{align}
&\min_{x} \sum_{i=1}^n \sum_{j=1}^k x_{ij} || p_i - y_j||^2\\
&\text{subject to:} \\
&\sum_{j=1}^k x_{ij} = 1 \quad \forall i\\
&x_{ij} \in \{0,1\} \quad \forall i, j \\
&y_j \in \mathbb{R}^d \quad \forall j
\end{align}
Instead of minimizing the distance to centroids, we minimize the distance to just any set of points that will give a better solution. It turns out that these points are exactly the centroids.
Now to solve this problem, we iterate in steps 2-3 of this algorithm, until convergence:
Assign some values to $y_j$ variables
Fix the values for $y_{j}$ variables and find the optimal values for $x_{ij}$ variables.
Fix the values of $x_{ij}$ variables, and find the optimal values for $y_{j}$ variables.
In each step the objective function improves (or remains the same when the algorithm converges), since the solution found in the previous step is in the search space of current step. However, since we are fixing some of the variables in each step, this is a local search procedure which does not guarantee optimality.
Luckily, the optimization problems in steps 2 and 3 can be solved in closed form. If we know $x_{ij}$
(i.e. if we know to which cluster each point is assigned), the best values for $y_j$ variables are the centroids of clusters. If we know values for $y_j$, obviously best choice for $x_{ij}$ variables is to assign each point to the closest $y_j$.
|
Why doesn't k-means give the global minimum?
This is the problem that you want to solve:
\begin{align}
&\min_{x} \sum_{i=1}^n \sum_{j=1}^k x_{ij} || p_i - c_j||^2\\
&\text{subject to:} \\
&\sum_{j=1}^k x_{ij} = 1 \quad \forall i\\
& c_j\textit{
|
11,596
|
Why doesn't k-means give the global minimum?
|
A simple example might help.
Let us define the set of points to be clustered as A = {1,2,3,4}.
Say you're trying to find 2 appropriate clusters for A (2-means). There are (at least) two different settings which satisfy the stationary condition of k-means.
Setting 1:
Center1 = 1, Cluster1 = {1}
Center2 = 3, Cluster1 = {2,3,4}
Here the objective is 2.
As a matter of fact this is a saddle point (try center1 = 1 + epsilon and center1 = 1 - epsilon)
Setting 2:
Center1 = 1.5, Cluster1 = {1,2}
Center2 = 3.5, Cluster1 = {3,4}
here the objective is $$0.5^2 \times 4=1.$$
If k-means would be initialized as the first setting then it would be stuck.. and that's by no means a global minimum.
You can use a variant of previous example to create two different local minima.
For A = {1,2,3,4,5}, setting cluster1={1,2} and cluster2={3,4,5} would results in the same objective value as cluster1={1,2,3} and cluster2={4,5}
Finally, what would happen if you choose
A = {1,2,3,4,6}
center1={2.5} cluster1={1,2,3,4} and
center1={6} cluster1={6}
vs
center1={2} cluster1={1,2,3} and
center1={5} cluster1={4,6}
?
|
Why doesn't k-means give the global minimum?
|
A simple example might help.
Let us define the set of points to be clustered as A = {1,2,3,4}.
Say you're trying to find 2 appropriate clusters for A (2-means). There are (at least) two different set
|
Why doesn't k-means give the global minimum?
A simple example might help.
Let us define the set of points to be clustered as A = {1,2,3,4}.
Say you're trying to find 2 appropriate clusters for A (2-means). There are (at least) two different settings which satisfy the stationary condition of k-means.
Setting 1:
Center1 = 1, Cluster1 = {1}
Center2 = 3, Cluster1 = {2,3,4}
Here the objective is 2.
As a matter of fact this is a saddle point (try center1 = 1 + epsilon and center1 = 1 - epsilon)
Setting 2:
Center1 = 1.5, Cluster1 = {1,2}
Center2 = 3.5, Cluster1 = {3,4}
here the objective is $$0.5^2 \times 4=1.$$
If k-means would be initialized as the first setting then it would be stuck.. and that's by no means a global minimum.
You can use a variant of previous example to create two different local minima.
For A = {1,2,3,4,5}, setting cluster1={1,2} and cluster2={3,4,5} would results in the same objective value as cluster1={1,2,3} and cluster2={4,5}
Finally, what would happen if you choose
A = {1,2,3,4,6}
center1={2.5} cluster1={1,2,3,4} and
center1={6} cluster1={6}
vs
center1={2} cluster1={1,2,3} and
center1={5} cluster1={4,6}
?
|
Why doesn't k-means give the global minimum?
A simple example might help.
Let us define the set of points to be clustered as A = {1,2,3,4}.
Say you're trying to find 2 appropriate clusters for A (2-means). There are (at least) two different set
|
11,597
|
Why doesn't k-means give the global minimum?
|
[This was before @Peter answered]
After a small discussion (in the comments section), I feel I have to answer my own question.
I believe that when I partially differentiate the objective function with respect to one centroid, the points in the cluster of another centroid vanish in the derivative. So, the centroid we can get will minimize only the sum of squared distances of only the particular cluster.
@whuber adds:
That's partly it, but does not really explain the behavior. Of more import is the fact that the assignment of points to centroids is the big part of what k-means is doing. (Once the assignment is made, the centroids are easily computed and there's nothing left to do.) That assignment is discrete: it's not something that can be differentiated at all.
It would be awesome if anybody has more to add.
|
Why doesn't k-means give the global minimum?
|
[This was before @Peter answered]
After a small discussion (in the comments section), I feel I have to answer my own question.
I believe that when I partially differentiate the objective function wi
|
Why doesn't k-means give the global minimum?
[This was before @Peter answered]
After a small discussion (in the comments section), I feel I have to answer my own question.
I believe that when I partially differentiate the objective function with respect to one centroid, the points in the cluster of another centroid vanish in the derivative. So, the centroid we can get will minimize only the sum of squared distances of only the particular cluster.
@whuber adds:
That's partly it, but does not really explain the behavior. Of more import is the fact that the assignment of points to centroids is the big part of what k-means is doing. (Once the assignment is made, the centroids are easily computed and there's nothing left to do.) That assignment is discrete: it's not something that can be differentiated at all.
It would be awesome if anybody has more to add.
|
Why doesn't k-means give the global minimum?
[This was before @Peter answered]
After a small discussion (in the comments section), I feel I have to answer my own question.
I believe that when I partially differentiate the objective function wi
|
11,598
|
Why doesn't k-means give the global minimum?
|
Everybody has explained everything, but I would like to add that if a sample data is not distributed as a Gaussian distribution then it can stuck to a local minima. In the K-means algorithm we are actually trying to get that.
|
Why doesn't k-means give the global minimum?
|
Everybody has explained everything, but I would like to add that if a sample data is not distributed as a Gaussian distribution then it can stuck to a local minima. In the K-means algorithm we are act
|
Why doesn't k-means give the global minimum?
Everybody has explained everything, but I would like to add that if a sample data is not distributed as a Gaussian distribution then it can stuck to a local minima. In the K-means algorithm we are actually trying to get that.
|
Why doesn't k-means give the global minimum?
Everybody has explained everything, but I would like to add that if a sample data is not distributed as a Gaussian distribution then it can stuck to a local minima. In the K-means algorithm we are act
|
11,599
|
Why doesn't k-means give the global minimum?
|
Also, the global minimum depends on the type of error function you define to minimize.
For K-Means algorithm I found the way to get to global minima would be by brute-force.
suppose you have k = 2 and points = 6 the way you can initialize them is a max of 2^6 ways.
Solving k-means for that will give me all the local minimas for an error function
The global minimum will be the one with the least error as that will encompass all the local minimas.
|
Why doesn't k-means give the global minimum?
|
Also, the global minimum depends on the type of error function you define to minimize.
For K-Means algorithm I found the way to get to global minima would be by brute-force.
suppose you have k = 2 and
|
Why doesn't k-means give the global minimum?
Also, the global minimum depends on the type of error function you define to minimize.
For K-Means algorithm I found the way to get to global minima would be by brute-force.
suppose you have k = 2 and points = 6 the way you can initialize them is a max of 2^6 ways.
Solving k-means for that will give me all the local minimas for an error function
The global minimum will be the one with the least error as that will encompass all the local minimas.
|
Why doesn't k-means give the global minimum?
Also, the global minimum depends on the type of error function you define to minimize.
For K-Means algorithm I found the way to get to global minima would be by brute-force.
suppose you have k = 2 and
|
11,600
|
Mother milk of 6 Corona-positive (COVID-19) women does not contain the virus - can we make a confidence statement about this?
|
There is the rule of three saying
if a certain event did not occur in a sample with $n$ subjects, the interval from $0$ to $3/n$ is a 95% confidence interval for the rate of occurrences in the population.
You have $n=6$, so says $[0, 3/6=0.5]$ is a 95% confidence interval for the binomial $p$ of transmission. In non-technical language: 6 non-events is way too few for any strong conclusions. This data is interesting, suggesting something, but no more.
This rule of three is discussed at CV multiple times Is Rule of Three inappropriate in some cases?, When to use (and not use) the rule of three, Using Rule of Three to obtain confidence interval for a binomial population and certainly more ... A more principled approach is here: Confidence interval around binomial estimate of 0 or 1 and using code from an answer to that question:
binom::binom.confint(0, 6, method=c("wilson", "bayes", "agresti-coull"), type="central")
method x n mean lower upper
1 agresti-coull 0 6 0.00000000 -0.05244649 0.4427808
2 bayes 0 6 0.07142857 0.00000000 0.2641729
3 wilson 0 6 0.00000000 0.00000000 0.3903343
|
Mother milk of 6 Corona-positive (COVID-19) women does not contain the virus - can we make a confide
|
There is the rule of three saying
if a certain event did not occur in a sample with $n$ subjects, the interval from $0$ to $3/n$ is a 95% confidence interval for the rate of occurrences in the popul
|
Mother milk of 6 Corona-positive (COVID-19) women does not contain the virus - can we make a confidence statement about this?
There is the rule of three saying
if a certain event did not occur in a sample with $n$ subjects, the interval from $0$ to $3/n$ is a 95% confidence interval for the rate of occurrences in the population.
You have $n=6$, so says $[0, 3/6=0.5]$ is a 95% confidence interval for the binomial $p$ of transmission. In non-technical language: 6 non-events is way too few for any strong conclusions. This data is interesting, suggesting something, but no more.
This rule of three is discussed at CV multiple times Is Rule of Three inappropriate in some cases?, When to use (and not use) the rule of three, Using Rule of Three to obtain confidence interval for a binomial population and certainly more ... A more principled approach is here: Confidence interval around binomial estimate of 0 or 1 and using code from an answer to that question:
binom::binom.confint(0, 6, method=c("wilson", "bayes", "agresti-coull"), type="central")
method x n mean lower upper
1 agresti-coull 0 6 0.00000000 -0.05244649 0.4427808
2 bayes 0 6 0.07142857 0.00000000 0.2641729
3 wilson 0 6 0.00000000 0.00000000 0.3903343
|
Mother milk of 6 Corona-positive (COVID-19) women does not contain the virus - can we make a confide
There is the rule of three saying
if a certain event did not occur in a sample with $n$ subjects, the interval from $0$ to $3/n$ is a 95% confidence interval for the rate of occurrences in the popul
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.