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
|
|---|---|---|---|---|---|---|
10,901
|
Confused about independent probabilities. If a fair coin is flipped 5 times, P(HHHHH) = 0.03125, but P(H | HHHH) = 0.5
|
I see two explainations:
1: (Same as already posted, but specific to fair coin Heads and Tails)
Because there are only two possibilities, H and T, P(H|HHHH) is the same as P(HHHHH) / (P(HHHHH) + P(HHHHT))
P(HHHHH) = .5^5 and P(HHHHT) = .5^5, therefore P(H|HHHH) = .5^5/(.5^5+.5^5) = .5^5/(2*(.5^5)) = 1/2
2:
P(HHHHH) is the whole story, P(H|HHHH) is just the last chapter.
The probability of getting to HHHHH after 5 flips is (1/2)^5 because each flip has an unconditional probability of 1/2, as stated. The paradox of P(H|HHHH) being represented as (1/2) is related to ignoring the probability of getting into a state of HHHH after 4 flips before looking at the next flip. In conclusion, 1/2 seems surprisingly high of a probability for P(H|HHHH) without considering that the probability of achieving a state of HHHH is low ((1/2)^4) in the first place.
|
Confused about independent probabilities. If a fair coin is flipped 5 times, P(HHHHH) = 0.03125, but
|
I see two explainations:
1: (Same as already posted, but specific to fair coin Heads and Tails)
Because there are only two possibilities, H and T, P(H|HHHH) is the same as P(HHHHH) / (P(HHHHH) + P(HHH
|
Confused about independent probabilities. If a fair coin is flipped 5 times, P(HHHHH) = 0.03125, but P(H | HHHH) = 0.5
I see two explainations:
1: (Same as already posted, but specific to fair coin Heads and Tails)
Because there are only two possibilities, H and T, P(H|HHHH) is the same as P(HHHHH) / (P(HHHHH) + P(HHHHT))
P(HHHHH) = .5^5 and P(HHHHT) = .5^5, therefore P(H|HHHH) = .5^5/(.5^5+.5^5) = .5^5/(2*(.5^5)) = 1/2
2:
P(HHHHH) is the whole story, P(H|HHHH) is just the last chapter.
The probability of getting to HHHHH after 5 flips is (1/2)^5 because each flip has an unconditional probability of 1/2, as stated. The paradox of P(H|HHHH) being represented as (1/2) is related to ignoring the probability of getting into a state of HHHH after 4 flips before looking at the next flip. In conclusion, 1/2 seems surprisingly high of a probability for P(H|HHHH) without considering that the probability of achieving a state of HHHH is low ((1/2)^4) in the first place.
|
Confused about independent probabilities. If a fair coin is flipped 5 times, P(HHHHH) = 0.03125, but
I see two explainations:
1: (Same as already posted, but specific to fair coin Heads and Tails)
Because there are only two possibilities, H and T, P(H|HHHH) is the same as P(HHHHH) / (P(HHHHH) + P(HHH
|
10,902
|
Confused about independent probabilities. If a fair coin is flipped 5 times, P(HHHHH) = 0.03125, but P(H | HHHH) = 0.5
|
$P(H|\text{anything}) = P(H) = 0.5$ The probability of the toss of a fair coin being "heads" is half, unconditionally, no matter what other events have occurred previously or at the same time.
The $|$ conditional probability notation $P(A|B)$ primarily expresses the probability of $A$. The $B$ gives the condition which modifies the meaning of $P(A)$ from the perspective of situation $B$ being true.
$P(A|B)$ may be regarded as a macro operator according to this definition:
$$P(A|B) \equiv \frac{P(A\cap B)}{P(B)}$$
Therefore, if we substitute our parameters of interest:
$$P(H|HHHH) \equiv \frac{P(H\cap HHHH)}{P(HHHH)}$$
But $P(H\cap HHHH)$ just means the probability of tossing four heads, and then one more: it means exactly the same thing as $P(HHHHH)$. In fact, $P(HHH...)$ is a shorthand for $P(H\cap H\cap H ...)$. Thus:
$$P(H|HHHH) \equiv \frac{P(H\cap HHHH)}{P(HHHH)} \equiv \frac{P(HHHHH)}{P(HHHH)}$$
It is the probability of tossing five heads, divided by the probability of tossing four heads. Since coin tosses are independent and their probabilities are multiplied together, this is just:
$$\frac{(1/2)^5}{(1/2)^4} = 1/2 = P(H)$$
|
Confused about independent probabilities. If a fair coin is flipped 5 times, P(HHHHH) = 0.03125, but
|
$P(H|\text{anything}) = P(H) = 0.5$ The probability of the toss of a fair coin being "heads" is half, unconditionally, no matter what other events have occurred previously or at the same time.
The $|$
|
Confused about independent probabilities. If a fair coin is flipped 5 times, P(HHHHH) = 0.03125, but P(H | HHHH) = 0.5
$P(H|\text{anything}) = P(H) = 0.5$ The probability of the toss of a fair coin being "heads" is half, unconditionally, no matter what other events have occurred previously or at the same time.
The $|$ conditional probability notation $P(A|B)$ primarily expresses the probability of $A$. The $B$ gives the condition which modifies the meaning of $P(A)$ from the perspective of situation $B$ being true.
$P(A|B)$ may be regarded as a macro operator according to this definition:
$$P(A|B) \equiv \frac{P(A\cap B)}{P(B)}$$
Therefore, if we substitute our parameters of interest:
$$P(H|HHHH) \equiv \frac{P(H\cap HHHH)}{P(HHHH)}$$
But $P(H\cap HHHH)$ just means the probability of tossing four heads, and then one more: it means exactly the same thing as $P(HHHHH)$. In fact, $P(HHH...)$ is a shorthand for $P(H\cap H\cap H ...)$. Thus:
$$P(H|HHHH) \equiv \frac{P(H\cap HHHH)}{P(HHHH)} \equiv \frac{P(HHHHH)}{P(HHHH)}$$
It is the probability of tossing five heads, divided by the probability of tossing four heads. Since coin tosses are independent and their probabilities are multiplied together, this is just:
$$\frac{(1/2)^5}{(1/2)^4} = 1/2 = P(H)$$
|
Confused about independent probabilities. If a fair coin is flipped 5 times, P(HHHHH) = 0.03125, but
$P(H|\text{anything}) = P(H) = 0.5$ The probability of the toss of a fair coin being "heads" is half, unconditionally, no matter what other events have occurred previously or at the same time.
The $|$
|
10,903
|
Confused about independent probabilities. If a fair coin is flipped 5 times, P(HHHHH) = 0.03125, but P(H | HHHH) = 0.5
|
It may help to think of these independent events like the individual steps used in climbing a mountain. Each step takes you only one step up the mountain. Yet, although those steps are the same in distance and effort, each subsequent step also results in you being higher up.
How is it that my last step up the mountain can take me all the way to the top, when I am still only stepping one step? Still only expending a fractional amount of energy? Of course it is because all of the prior steps created a situation where one more of exactly the same steps would result in me reaching the top.
In flipping coins, each coin flip has a 50% chance of taking you one flip closer to your goal. That 50% chance, when successful, only ever buys you one more "heads" toward getting 5 in a row. One more step. And it's always a 50% chance. However, if you have already experienced a somewhat rare set of four in a row, that one more step (which is just like the rest) will complete the set of 5 in-a-row... If it comes to pass... Which it will, exactly 50% of the time.
Hope that helps.
|
Confused about independent probabilities. If a fair coin is flipped 5 times, P(HHHHH) = 0.03125, but
|
It may help to think of these independent events like the individual steps used in climbing a mountain. Each step takes you only one step up the mountain. Yet, although those steps are the same in dis
|
Confused about independent probabilities. If a fair coin is flipped 5 times, P(HHHHH) = 0.03125, but P(H | HHHH) = 0.5
It may help to think of these independent events like the individual steps used in climbing a mountain. Each step takes you only one step up the mountain. Yet, although those steps are the same in distance and effort, each subsequent step also results in you being higher up.
How is it that my last step up the mountain can take me all the way to the top, when I am still only stepping one step? Still only expending a fractional amount of energy? Of course it is because all of the prior steps created a situation where one more of exactly the same steps would result in me reaching the top.
In flipping coins, each coin flip has a 50% chance of taking you one flip closer to your goal. That 50% chance, when successful, only ever buys you one more "heads" toward getting 5 in a row. One more step. And it's always a 50% chance. However, if you have already experienced a somewhat rare set of four in a row, that one more step (which is just like the rest) will complete the set of 5 in-a-row... If it comes to pass... Which it will, exactly 50% of the time.
Hope that helps.
|
Confused about independent probabilities. If a fair coin is flipped 5 times, P(HHHHH) = 0.03125, but
It may help to think of these independent events like the individual steps used in climbing a mountain. Each step takes you only one step up the mountain. Yet, although those steps are the same in dis
|
10,904
|
Confused about independent probabilities. If a fair coin is flipped 5 times, P(HHHHH) = 0.03125, but P(H | HHHH) = 0.5
|
The observations are independent, so the previous draws don’t affect the next draw. Thus P(H) = P(T) = 0.50 if you saw THTHH beforehand or H beforehand or TTTHHH beforehand. What you actually saw last does not affect the next draw. If the previous event is yet unseen, however, you are not dealing with a conditional probability.
That is also true when looking forward. Because each draw does not impact its successor, you have to multiply the probabilities of outcomes. That’s how you get P(TH) = 0.25 but P(T|H) = 0.50.
Conditional probability is the likelihood that something happens given something has already happened — emphasis on past tense.
|
Confused about independent probabilities. If a fair coin is flipped 5 times, P(HHHHH) = 0.03125, but
|
The observations are independent, so the previous draws don’t affect the next draw. Thus P(H) = P(T) = 0.50 if you saw THTHH beforehand or H beforehand or TTTHHH beforehand. What you actually saw last
|
Confused about independent probabilities. If a fair coin is flipped 5 times, P(HHHHH) = 0.03125, but P(H | HHHH) = 0.5
The observations are independent, so the previous draws don’t affect the next draw. Thus P(H) = P(T) = 0.50 if you saw THTHH beforehand or H beforehand or TTTHHH beforehand. What you actually saw last does not affect the next draw. If the previous event is yet unseen, however, you are not dealing with a conditional probability.
That is also true when looking forward. Because each draw does not impact its successor, you have to multiply the probabilities of outcomes. That’s how you get P(TH) = 0.25 but P(T|H) = 0.50.
Conditional probability is the likelihood that something happens given something has already happened — emphasis on past tense.
|
Confused about independent probabilities. If a fair coin is flipped 5 times, P(HHHHH) = 0.03125, but
The observations are independent, so the previous draws don’t affect the next draw. Thus P(H) = P(T) = 0.50 if you saw THTHH beforehand or H beforehand or TTTHHH beforehand. What you actually saw last
|
10,905
|
Which distribution has its maximum uniformly distributed?
|
Let $F$ be the CDF of $X_i$. We know that the CDF of $Y$ is
$$G(y) = P(Y\leq y)= P(\textrm{all } X_i\leq y)= \prod_i P(X_i\leq y) = F(y)^n$$
Now, it's no loss of generality to take $a=0$, $b=1$, since we can just shift and scale the distribution of $X$ to $[0,\,1]$ and then unshift and unscale the distribution of $Y$.
So what does $F$ have to be to get $G(y) =y$?
We need $F(x)= x^{1/n}I_{[0,1]}$, so $f(x)=\frac{1}{n}x^{1/n-1}I_{[0,1]}$, which is a Beta(1/n,1) density.
Let's check
> r<-replicate(100000, max(rbeta(4,1/4,1)))
> hist(r)
|
Which distribution has its maximum uniformly distributed?
|
Let $F$ be the CDF of $X_i$. We know that the CDF of $Y$ is
$$G(y) = P(Y\leq y)= P(\textrm{all } X_i\leq y)= \prod_i P(X_i\leq y) = F(y)^n$$
Now, it's no loss of generality to take $a=0$, $b=1$, since
|
Which distribution has its maximum uniformly distributed?
Let $F$ be the CDF of $X_i$. We know that the CDF of $Y$ is
$$G(y) = P(Y\leq y)= P(\textrm{all } X_i\leq y)= \prod_i P(X_i\leq y) = F(y)^n$$
Now, it's no loss of generality to take $a=0$, $b=1$, since we can just shift and scale the distribution of $X$ to $[0,\,1]$ and then unshift and unscale the distribution of $Y$.
So what does $F$ have to be to get $G(y) =y$?
We need $F(x)= x^{1/n}I_{[0,1]}$, so $f(x)=\frac{1}{n}x^{1/n-1}I_{[0,1]}$, which is a Beta(1/n,1) density.
Let's check
> r<-replicate(100000, max(rbeta(4,1/4,1)))
> hist(r)
|
Which distribution has its maximum uniformly distributed?
Let $F$ be the CDF of $X_i$. We know that the CDF of $Y$ is
$$G(y) = P(Y\leq y)= P(\textrm{all } X_i\leq y)= \prod_i P(X_i\leq y) = F(y)^n$$
Now, it's no loss of generality to take $a=0$, $b=1$, since
|
10,906
|
Which distribution has its maximum uniformly distributed?
|
$F_{X_{(n)}}(x)=[F_X(x)]^n$, so for a standard uniform you need $F_X(x)=x^{1/n}$ for $0<x<1$ (and $0$ to the left and $1$ to the right of that interval), so $f_X(x)=\frac{1}{n}x^{\frac{1}{n}-1}$ on the unit interval and $0$ elsewhere.
It's a special case of the beta.
|
Which distribution has its maximum uniformly distributed?
|
$F_{X_{(n)}}(x)=[F_X(x)]^n$, so for a standard uniform you need $F_X(x)=x^{1/n}$ for $0<x<1$ (and $0$ to the left and $1$ to the right of that interval), so $f_X(x)=\frac{1}{n}x^{\frac{1}{n}-1}$ on t
|
Which distribution has its maximum uniformly distributed?
$F_{X_{(n)}}(x)=[F_X(x)]^n$, so for a standard uniform you need $F_X(x)=x^{1/n}$ for $0<x<1$ (and $0$ to the left and $1$ to the right of that interval), so $f_X(x)=\frac{1}{n}x^{\frac{1}{n}-1}$ on the unit interval and $0$ elsewhere.
It's a special case of the beta.
|
Which distribution has its maximum uniformly distributed?
$F_{X_{(n)}}(x)=[F_X(x)]^n$, so for a standard uniform you need $F_X(x)=x^{1/n}$ for $0<x<1$ (and $0$ to the left and $1$ to the right of that interval), so $f_X(x)=\frac{1}{n}x^{\frac{1}{n}-1}$ on t
|
10,907
|
Are differences between uniformly distributed numbers uniformly distributed?
|
No it is not uniform
You can count the $36$ equally likely possibilities for the absolute differences
second 1 2 3 4 5 6
first
1 0 1 2 3 4 5
2 1 0 1 2 3 4
3 2 1 0 1 2 3
4 3 2 1 0 1 2
5 4 3 2 1 0 1
6 5 4 3 2 1 0
which gives a probability distribution for the absolute differences of
0 6/36 1/6
1 10/36 5/18
2 8/36 2/9
3 6/36 1/6
4 4/36 1/9
5 2/36 1/18
|
Are differences between uniformly distributed numbers uniformly distributed?
|
No it is not uniform
You can count the $36$ equally likely possibilities for the absolute differences
second 1 2 3 4 5 6
first
1 0 1 2 3
|
Are differences between uniformly distributed numbers uniformly distributed?
No it is not uniform
You can count the $36$ equally likely possibilities for the absolute differences
second 1 2 3 4 5 6
first
1 0 1 2 3 4 5
2 1 0 1 2 3 4
3 2 1 0 1 2 3
4 3 2 1 0 1 2
5 4 3 2 1 0 1
6 5 4 3 2 1 0
which gives a probability distribution for the absolute differences of
0 6/36 1/6
1 10/36 5/18
2 8/36 2/9
3 6/36 1/6
4 4/36 1/9
5 2/36 1/18
|
Are differences between uniformly distributed numbers uniformly distributed?
No it is not uniform
You can count the $36$ equally likely possibilities for the absolute differences
second 1 2 3 4 5 6
first
1 0 1 2 3
|
10,908
|
Are differences between uniformly distributed numbers uniformly distributed?
|
Using only the most basic axioms about probabilities and real numbers, one can prove a much stronger statement:
The difference of any two independent, identically distributed nonconstant random values $X-Y$ never has a discrete uniform distribution.
(An analogous statement for continuous variables is proven at Uniform PDF of the difference of two r.v.)
The idea is that the chance $X-Y$ is an extreme value must be less than the chance that $X-Y$ is zero, because there is only one way to (say) maximize $X-Y$ whereas there are many ways to make the difference zero, because $X$ and $Y$ have the same distribution and therefore can equal each other. Here are the details.
First observe that the hypothetical two variables $X$ and $Y$ in question can each attain only a finite number $n$ of values with positive probability, because there will be at least $n$ distinct differences and a uniform distribution assigns them all equal probability. If $n$ is infinite, then so would be the number of possible differences having positive, equal probability, whence the sum of their chances would be infinite, which is impossible.
Next, since the number of differences is finite, there will be a largest among them. The largest difference can be achieved only when subtracting the smallest value of $Y$--let's call it $m$ and suppose it has probability $q = \Pr(Y=m)$--from the largest value of $X$--let's call that that one $M$ with $p = \Pr(X=M).$ Because $X$ and $Y$ are independent, the chance of this difference is the product of these chances,
$$\Pr(X-Y = M - m) = \Pr(X=M)\Pr(Y=m) = pq \gt 0.\tag{*}$$
Finally, because $X$ and $Y$ have the same distribution, there are many ways their differences can produce the value $0.$ Among these ways are the cases where $X=Y=m$ and $X=Y=M.$ Because this distribution is nonconstant, $m$ differs from $M.$ That shows those two cases are disjoint events and therefore they must contribute at least an amount $p^2 + q^2$ to the chance that $X-Y$ is zero; that is,
$$\Pr(X-Y=0) \ge \Pr(X=Y=m) + \Pr(X=Y=M) = p^2 + q^2.$$
Since squares of numbers are not negative, $0 \le (p-q)^2,$ whence we deduce from $(*)$ that
$$\Pr(X-Y=M-m)=pq \le pq + (p-q)^2 = p^2 + q^2 - pq \lt p^2 + q^2 \le \Pr(X-Y=0),$$
showing the distribution of $X-Y$ is not uniform, QED.
Edit in response to a comment
A similar analysis of the absolute differences $|X-Y|$ observes that because $X$ and $Y$ have the same distribution, $m=-M.$ This requires us to study $\Pr(X-Y=|M-m|) = 2pq.$ The same algebraic technique yields almost the same result, but there is the possibility that $2pq=2pq+(p-q)^2$ and $2pq+p^2+q^2=1.$ That system of equations has the unique solution $p=q=1/2$ corresponding to a fair coin (a "two-sided die"). Apart from this exception the result for the absolute differences is the same as that for the differences, and for the same underlying reasons already given: namely, the absolute differences of two iid random variables cannot be uniformly distributed whenever there are more than two distinct differences with positive probability.
(end of edit)
Let's apply this result to the question, which asks about something a little more complex.
Model each independent roll of the die (which might be an unfair die) with a random variable $X_i,$ $i=1, 2, \ldots, n.$ The differences observed in these $n$ rolls are the numbers $\Delta X_i = X_{i+1}-X_i.$ We might wonder how uniformly distributed these $n-1$ numbers are. That's really a question about the statistical expectations: what is the expected number of $\Delta X_i$ that are equal to zero, for instance? What is the expected number of $\Delta X_i$ equal to $-1$? Etc., etc.
The problematic aspect of this question is that the $\Delta X_i$ are not independent: for instance, $\Delta X_1 = X_2-X_1$ and $\Delta X_2 = X_3 - X_2$ involve the same roll $X_2.$
However, this isn't really a difficulty. Since statistical expectation is additive and all differences have the same distribution, if we pick any possible value $k$ of the differences, the expected number of times the difference equals $k$ in the entire sequence of $n$ rolls is just $n-1$ times the expected number of times the difference equals $k$ in a single step of the process. That single-step expectation is $\Pr(\Delta X_i = k)$ (for any $i$). These expectations will be the same for all $k$ (that is, uniform) if and only if they are the same for a single $\Delta X_i.$ But we have seen that no $\Delta X_i$ has a uniform distribution, even when the die might be biased. Thus, even in this weaker sense of expected frequencies, the differences of the rolls are not uniform.
|
Are differences between uniformly distributed numbers uniformly distributed?
|
Using only the most basic axioms about probabilities and real numbers, one can prove a much stronger statement:
The difference of any two independent, identically distributed nonconstant random value
|
Are differences between uniformly distributed numbers uniformly distributed?
Using only the most basic axioms about probabilities and real numbers, one can prove a much stronger statement:
The difference of any two independent, identically distributed nonconstant random values $X-Y$ never has a discrete uniform distribution.
(An analogous statement for continuous variables is proven at Uniform PDF of the difference of two r.v.)
The idea is that the chance $X-Y$ is an extreme value must be less than the chance that $X-Y$ is zero, because there is only one way to (say) maximize $X-Y$ whereas there are many ways to make the difference zero, because $X$ and $Y$ have the same distribution and therefore can equal each other. Here are the details.
First observe that the hypothetical two variables $X$ and $Y$ in question can each attain only a finite number $n$ of values with positive probability, because there will be at least $n$ distinct differences and a uniform distribution assigns them all equal probability. If $n$ is infinite, then so would be the number of possible differences having positive, equal probability, whence the sum of their chances would be infinite, which is impossible.
Next, since the number of differences is finite, there will be a largest among them. The largest difference can be achieved only when subtracting the smallest value of $Y$--let's call it $m$ and suppose it has probability $q = \Pr(Y=m)$--from the largest value of $X$--let's call that that one $M$ with $p = \Pr(X=M).$ Because $X$ and $Y$ are independent, the chance of this difference is the product of these chances,
$$\Pr(X-Y = M - m) = \Pr(X=M)\Pr(Y=m) = pq \gt 0.\tag{*}$$
Finally, because $X$ and $Y$ have the same distribution, there are many ways their differences can produce the value $0.$ Among these ways are the cases where $X=Y=m$ and $X=Y=M.$ Because this distribution is nonconstant, $m$ differs from $M.$ That shows those two cases are disjoint events and therefore they must contribute at least an amount $p^2 + q^2$ to the chance that $X-Y$ is zero; that is,
$$\Pr(X-Y=0) \ge \Pr(X=Y=m) + \Pr(X=Y=M) = p^2 + q^2.$$
Since squares of numbers are not negative, $0 \le (p-q)^2,$ whence we deduce from $(*)$ that
$$\Pr(X-Y=M-m)=pq \le pq + (p-q)^2 = p^2 + q^2 - pq \lt p^2 + q^2 \le \Pr(X-Y=0),$$
showing the distribution of $X-Y$ is not uniform, QED.
Edit in response to a comment
A similar analysis of the absolute differences $|X-Y|$ observes that because $X$ and $Y$ have the same distribution, $m=-M.$ This requires us to study $\Pr(X-Y=|M-m|) = 2pq.$ The same algebraic technique yields almost the same result, but there is the possibility that $2pq=2pq+(p-q)^2$ and $2pq+p^2+q^2=1.$ That system of equations has the unique solution $p=q=1/2$ corresponding to a fair coin (a "two-sided die"). Apart from this exception the result for the absolute differences is the same as that for the differences, and for the same underlying reasons already given: namely, the absolute differences of two iid random variables cannot be uniformly distributed whenever there are more than two distinct differences with positive probability.
(end of edit)
Let's apply this result to the question, which asks about something a little more complex.
Model each independent roll of the die (which might be an unfair die) with a random variable $X_i,$ $i=1, 2, \ldots, n.$ The differences observed in these $n$ rolls are the numbers $\Delta X_i = X_{i+1}-X_i.$ We might wonder how uniformly distributed these $n-1$ numbers are. That's really a question about the statistical expectations: what is the expected number of $\Delta X_i$ that are equal to zero, for instance? What is the expected number of $\Delta X_i$ equal to $-1$? Etc., etc.
The problematic aspect of this question is that the $\Delta X_i$ are not independent: for instance, $\Delta X_1 = X_2-X_1$ and $\Delta X_2 = X_3 - X_2$ involve the same roll $X_2.$
However, this isn't really a difficulty. Since statistical expectation is additive and all differences have the same distribution, if we pick any possible value $k$ of the differences, the expected number of times the difference equals $k$ in the entire sequence of $n$ rolls is just $n-1$ times the expected number of times the difference equals $k$ in a single step of the process. That single-step expectation is $\Pr(\Delta X_i = k)$ (for any $i$). These expectations will be the same for all $k$ (that is, uniform) if and only if they are the same for a single $\Delta X_i.$ But we have seen that no $\Delta X_i$ has a uniform distribution, even when the die might be biased. Thus, even in this weaker sense of expected frequencies, the differences of the rolls are not uniform.
|
Are differences between uniformly distributed numbers uniformly distributed?
Using only the most basic axioms about probabilities and real numbers, one can prove a much stronger statement:
The difference of any two independent, identically distributed nonconstant random value
|
10,909
|
Are differences between uniformly distributed numbers uniformly distributed?
|
On an intuitive level, a random event can only be uniformly distributed if all of its outcomes are equally likely.
Is that so for the random event in question -- absolute difference between two dice rolls?
It suffices in this case to look at the extremes -- what are the biggest and smallest values this difference could take?
Obviously 0 is the smallest (we're looking at absolute differences and the rolls can be the same), and 5 is the biggest (6 vs 1).
We can show the event is non-uniform by showing that 0 is more (or less) likely to occur than 5.
At a glance, there are only two ways for 5 to occur -- if the first dice is 6 and the second 1, or vice versa. How many ways can 0 occur?
|
Are differences between uniformly distributed numbers uniformly distributed?
|
On an intuitive level, a random event can only be uniformly distributed if all of its outcomes are equally likely.
Is that so for the random event in question -- absolute difference between two dice r
|
Are differences between uniformly distributed numbers uniformly distributed?
On an intuitive level, a random event can only be uniformly distributed if all of its outcomes are equally likely.
Is that so for the random event in question -- absolute difference between two dice rolls?
It suffices in this case to look at the extremes -- what are the biggest and smallest values this difference could take?
Obviously 0 is the smallest (we're looking at absolute differences and the rolls can be the same), and 5 is the biggest (6 vs 1).
We can show the event is non-uniform by showing that 0 is more (or less) likely to occur than 5.
At a glance, there are only two ways for 5 to occur -- if the first dice is 6 and the second 1, or vice versa. How many ways can 0 occur?
|
Are differences between uniformly distributed numbers uniformly distributed?
On an intuitive level, a random event can only be uniformly distributed if all of its outcomes are equally likely.
Is that so for the random event in question -- absolute difference between two dice r
|
10,910
|
Are differences between uniformly distributed numbers uniformly distributed?
|
As presented by Henry, differences of uniformly distributed distributions are not uniformly distributed.
To illustrate this with simulated data, we can use a very simple R script:
barplot(table(sample(x=1:6, size=10000, replace=T)))
We see that this produces indeed a uniform distribution. Let's now have a look at the distribution of the absolute differences of two random samples from this distribution.
barplot(table(abs(sample(x=1:6, size=10000, replace=T) - sample(x=1:6, size=10000, replace=T))))
|
Are differences between uniformly distributed numbers uniformly distributed?
|
As presented by Henry, differences of uniformly distributed distributions are not uniformly distributed.
To illustrate this with simulated data, we can use a very simple R script:
barplot(table(sample
|
Are differences between uniformly distributed numbers uniformly distributed?
As presented by Henry, differences of uniformly distributed distributions are not uniformly distributed.
To illustrate this with simulated data, we can use a very simple R script:
barplot(table(sample(x=1:6, size=10000, replace=T)))
We see that this produces indeed a uniform distribution. Let's now have a look at the distribution of the absolute differences of two random samples from this distribution.
barplot(table(abs(sample(x=1:6, size=10000, replace=T) - sample(x=1:6, size=10000, replace=T))))
|
Are differences between uniformly distributed numbers uniformly distributed?
As presented by Henry, differences of uniformly distributed distributions are not uniformly distributed.
To illustrate this with simulated data, we can use a very simple R script:
barplot(table(sample
|
10,911
|
Are differences between uniformly distributed numbers uniformly distributed?
|
Others have worked the calculations, I will give you an answer that seems more intuitive to me. You want to study the sum of two unifrom r.v. (Z = X + (-Y)), the overall distribution is the (discrete) convolution product :
$$ P(Z=z) = \sum^{\infty}_{k=-\infty} P(X=k) P(-Y = z-k) $$
This sum is rather intuitive : the probability to get $z$, is the sum of the probabilities to get something with X (noted $k$ here) and the complement to $z$ with -Y.
From signal processing, we know how the convolution product behave:
The convolution product of two uniform function (two rectangles) will give a triangle. This is illustrated by wikipedia for continuous functions:
You can understand what happen here : as $z$ move up (the vertical dotted line) the common domain of both rectangle move up then down, which correspond to the probability to get $z$.
More generally we know that the only functions that are stable by convolution are those of the gaussian familly. i.e. Only gaussian distribution are stable by addition (or more generally, linear combination). This is also meaning that you don't get a uniform distribution when combining uniform distributions.
As to why we get those results, the answer lies in the Fourrier decomposition of those functions. The Fourrier transformation of a convolution product being the simple product of the Fourrier transformations of each function. This give direct links between the fourrier coefficients of the rectangle and triangle functions.
|
Are differences between uniformly distributed numbers uniformly distributed?
|
Others have worked the calculations, I will give you an answer that seems more intuitive to me. You want to study the sum of two unifrom r.v. (Z = X + (-Y)), the overall distribution is the (discrete)
|
Are differences between uniformly distributed numbers uniformly distributed?
Others have worked the calculations, I will give you an answer that seems more intuitive to me. You want to study the sum of two unifrom r.v. (Z = X + (-Y)), the overall distribution is the (discrete) convolution product :
$$ P(Z=z) = \sum^{\infty}_{k=-\infty} P(X=k) P(-Y = z-k) $$
This sum is rather intuitive : the probability to get $z$, is the sum of the probabilities to get something with X (noted $k$ here) and the complement to $z$ with -Y.
From signal processing, we know how the convolution product behave:
The convolution product of two uniform function (two rectangles) will give a triangle. This is illustrated by wikipedia for continuous functions:
You can understand what happen here : as $z$ move up (the vertical dotted line) the common domain of both rectangle move up then down, which correspond to the probability to get $z$.
More generally we know that the only functions that are stable by convolution are those of the gaussian familly. i.e. Only gaussian distribution are stable by addition (or more generally, linear combination). This is also meaning that you don't get a uniform distribution when combining uniform distributions.
As to why we get those results, the answer lies in the Fourrier decomposition of those functions. The Fourrier transformation of a convolution product being the simple product of the Fourrier transformations of each function. This give direct links between the fourrier coefficients of the rectangle and triangle functions.
|
Are differences between uniformly distributed numbers uniformly distributed?
Others have worked the calculations, I will give you an answer that seems more intuitive to me. You want to study the sum of two unifrom r.v. (Z = X + (-Y)), the overall distribution is the (discrete)
|
10,912
|
Are differences between uniformly distributed numbers uniformly distributed?
|
If $x$ and $y$ are two consecutive dice rolls, you can visualize $|x-y| = k$ (for $k = 0, 1, 2, 3, 4, 5$) as follows where each color corresponds to a different value of $k$:
As you can easily see, the number of points for each color is not the same; therefore, the differences are not uniformly distributed.
|
Are differences between uniformly distributed numbers uniformly distributed?
|
If $x$ and $y$ are two consecutive dice rolls, you can visualize $|x-y| = k$ (for $k = 0, 1, 2, 3, 4, 5$) as follows where each color corresponds to a different value of $k$:
As you can easily see, t
|
Are differences between uniformly distributed numbers uniformly distributed?
If $x$ and $y$ are two consecutive dice rolls, you can visualize $|x-y| = k$ (for $k = 0, 1, 2, 3, 4, 5$) as follows where each color corresponds to a different value of $k$:
As you can easily see, the number of points for each color is not the same; therefore, the differences are not uniformly distributed.
|
Are differences between uniformly distributed numbers uniformly distributed?
If $x$ and $y$ are two consecutive dice rolls, you can visualize $|x-y| = k$ (for $k = 0, 1, 2, 3, 4, 5$) as follows where each color corresponds to a different value of $k$:
As you can easily see, t
|
10,913
|
Are differences between uniformly distributed numbers uniformly distributed?
|
Let $D_t$ denote the difference and $X$ the value of the roll, then
$P(D_t = 5) = P(X_t = 6, X_{t-1} = 1) < P((X_t, X_{t-1}) \in \{(6, 3), (5, 2)\}) < P(D_t = 3)$
So the function $P(D_t = d)$ is not constant in $d$. This means that the distribution is not uniform.
|
Are differences between uniformly distributed numbers uniformly distributed?
|
Let $D_t$ denote the difference and $X$ the value of the roll, then
$P(D_t = 5) = P(X_t = 6, X_{t-1} = 1) < P((X_t, X_{t-1}) \in \{(6, 3), (5, 2)\}) < P(D_t = 3)$
So the function $P(D_t = d)$ is not c
|
Are differences between uniformly distributed numbers uniformly distributed?
Let $D_t$ denote the difference and $X$ the value of the roll, then
$P(D_t = 5) = P(X_t = 6, X_{t-1} = 1) < P((X_t, X_{t-1}) \in \{(6, 3), (5, 2)\}) < P(D_t = 3)$
So the function $P(D_t = d)$ is not constant in $d$. This means that the distribution is not uniform.
|
Are differences between uniformly distributed numbers uniformly distributed?
Let $D_t$ denote the difference and $X$ the value of the roll, then
$P(D_t = 5) = P(X_t = 6, X_{t-1} = 1) < P((X_t, X_{t-1}) \in \{(6, 3), (5, 2)\}) < P(D_t = 3)$
So the function $P(D_t = d)$ is not c
|
10,914
|
How do I make my neural network better at predicting sine waves?
|
You're using a feed-forward network; the other answers are correct that FFNNs are not great at extrapolation beyond the range of the training data.
However, since the data has a periodic quality, the problem may be amenable to modeling with an LSTM. LSTMs are a variety of neural network cell that operate on sequences, and have a "memory" about what they have "seen" before. The abstract of this book chapter suggests an LSTM approach is a qualified success on periodic problems.
In this case, the training data would be a sequence of tuples $(x_i, \sin(x_i))$, and the task to make accurate predictions for new inputs $x_{i+1} \dots x_{i+n}$ for some $n$ and $i$ indexes some increasing sequence. The length of each input sequence, the width of the interval which they cover, and their spacing, are up to you. Intuitively, I'd expect a regular grid covering 1 period to be a good place to start, with training sequences covering a wide range of values, rather than restricted to some interval.
(Jimenez-Guarneros, Magdiel
and Gomez-Gil, Pilar
and Fonseca-Delgado, Rigoberto
and Ramirez-Cortes, Manuel
and Alarcon-Aquino, Vicente, "Long-Term Prediction of a Sine Function Using a LSTM Neural Network", in Nature-Inspired Design of Hybrid Intelligent Systems)
|
How do I make my neural network better at predicting sine waves?
|
You're using a feed-forward network; the other answers are correct that FFNNs are not great at extrapolation beyond the range of the training data.
However, since the data has a periodic quality, the
|
How do I make my neural network better at predicting sine waves?
You're using a feed-forward network; the other answers are correct that FFNNs are not great at extrapolation beyond the range of the training data.
However, since the data has a periodic quality, the problem may be amenable to modeling with an LSTM. LSTMs are a variety of neural network cell that operate on sequences, and have a "memory" about what they have "seen" before. The abstract of this book chapter suggests an LSTM approach is a qualified success on periodic problems.
In this case, the training data would be a sequence of tuples $(x_i, \sin(x_i))$, and the task to make accurate predictions for new inputs $x_{i+1} \dots x_{i+n}$ for some $n$ and $i$ indexes some increasing sequence. The length of each input sequence, the width of the interval which they cover, and their spacing, are up to you. Intuitively, I'd expect a regular grid covering 1 period to be a good place to start, with training sequences covering a wide range of values, rather than restricted to some interval.
(Jimenez-Guarneros, Magdiel
and Gomez-Gil, Pilar
and Fonseca-Delgado, Rigoberto
and Ramirez-Cortes, Manuel
and Alarcon-Aquino, Vicente, "Long-Term Prediction of a Sine Function Using a LSTM Neural Network", in Nature-Inspired Design of Hybrid Intelligent Systems)
|
How do I make my neural network better at predicting sine waves?
You're using a feed-forward network; the other answers are correct that FFNNs are not great at extrapolation beyond the range of the training data.
However, since the data has a periodic quality, the
|
10,915
|
How do I make my neural network better at predicting sine waves?
|
If what you want to do is learn simple periodic functions like this, then you could look into using Gaussian Processes. GPs allow you to enforce your domain knowledge to an extent by specifying an appropriate covariance function; in this example, since you know the data is periodic, you can choose a periodic kernel, then the model will extrapolate this structure.You can see an example in the picture; here, I'm trying to fit tide height data, so I know that it has a periodic structure. Because I'm using a periodic structure, the model extrapolates this periodicity (more or less) correctly. OFC if you're trying to learn about neural networks this isn't really relevant, but this might be a slightly nicer approach than hand-engineering features. Incidentally, neural networks and gp's are closely related in theory, so in principle there is some activation function you could choose that would do the same thing for a neural network
GPs aren't always useful because unlike neural nets, they are hard to scale to large datasets and deep networks, but if you're interested in low dimensional problems like this they will probably be faster and more reliable.
(in the picture, the black dots are training data and the red are the targets; you can see that even though it doesn't get it exactly right, the model learns the periodicity approximately. The coloured bands are the confidence intervals of the model's prediction)
|
How do I make my neural network better at predicting sine waves?
|
If what you want to do is learn simple periodic functions like this, then you could look into using Gaussian Processes. GPs allow you to enforce your domain knowledge to an extent by specifying an app
|
How do I make my neural network better at predicting sine waves?
If what you want to do is learn simple periodic functions like this, then you could look into using Gaussian Processes. GPs allow you to enforce your domain knowledge to an extent by specifying an appropriate covariance function; in this example, since you know the data is periodic, you can choose a periodic kernel, then the model will extrapolate this structure.You can see an example in the picture; here, I'm trying to fit tide height data, so I know that it has a periodic structure. Because I'm using a periodic structure, the model extrapolates this periodicity (more or less) correctly. OFC if you're trying to learn about neural networks this isn't really relevant, but this might be a slightly nicer approach than hand-engineering features. Incidentally, neural networks and gp's are closely related in theory, so in principle there is some activation function you could choose that would do the same thing for a neural network
GPs aren't always useful because unlike neural nets, they are hard to scale to large datasets and deep networks, but if you're interested in low dimensional problems like this they will probably be faster and more reliable.
(in the picture, the black dots are training data and the red are the targets; you can see that even though it doesn't get it exactly right, the model learns the periodicity approximately. The coloured bands are the confidence intervals of the model's prediction)
|
How do I make my neural network better at predicting sine waves?
If what you want to do is learn simple periodic functions like this, then you could look into using Gaussian Processes. GPs allow you to enforce your domain knowledge to an extent by specifying an app
|
10,916
|
How do I make my neural network better at predicting sine waves?
|
Machine learning algorithms - including neural networks - can learn to approximate arbitrary functions, but only in the interval where there is enough density of training data.
Statistics-based machine learning algorithms work best when they are performing interpolation - predicting values that are close to or in-between the training examples.
Outside of your training data, you are hoping for extrapolation. But there is no easy way to achieve that. A neural network never learns a function analytically, only approximately via statistics - this is true for nearly all supervised learning ML techniques. The more advanced algorithms can get arbitrarily close to a chosen function given enough examples (and free parameters in the model), but will still only do so in the range of supplied training data.
How the network (or other ML) behaves outside the range of your training data will depend on its architecture including the activation functions used.
The only way to have a machine learning algorithm predict a function analytically, is to build something into the assumptions of the model. For instance (and perhaps trivially), you could create features that equalled various $\sin$ functions of your input e.g $\text{sin}(x), \text{sin}(2x+\pi/4)$. The network - or even simpler, a linear regression - would learn to associate the most predictive value which is the closest $\sin$ function.
|
How do I make my neural network better at predicting sine waves?
|
Machine learning algorithms - including neural networks - can learn to approximate arbitrary functions, but only in the interval where there is enough density of training data.
Statistics-based machin
|
How do I make my neural network better at predicting sine waves?
Machine learning algorithms - including neural networks - can learn to approximate arbitrary functions, but only in the interval where there is enough density of training data.
Statistics-based machine learning algorithms work best when they are performing interpolation - predicting values that are close to or in-between the training examples.
Outside of your training data, you are hoping for extrapolation. But there is no easy way to achieve that. A neural network never learns a function analytically, only approximately via statistics - this is true for nearly all supervised learning ML techniques. The more advanced algorithms can get arbitrarily close to a chosen function given enough examples (and free parameters in the model), but will still only do so in the range of supplied training data.
How the network (or other ML) behaves outside the range of your training data will depend on its architecture including the activation functions used.
The only way to have a machine learning algorithm predict a function analytically, is to build something into the assumptions of the model. For instance (and perhaps trivially), you could create features that equalled various $\sin$ functions of your input e.g $\text{sin}(x), \text{sin}(2x+\pi/4)$. The network - or even simpler, a linear regression - would learn to associate the most predictive value which is the closest $\sin$ function.
|
How do I make my neural network better at predicting sine waves?
Machine learning algorithms - including neural networks - can learn to approximate arbitrary functions, but only in the interval where there is enough density of training data.
Statistics-based machin
|
10,917
|
How do I make my neural network better at predicting sine waves?
|
In some cases, @Neil Slater's suggested approach of transforming your features with a periodic function will work very well, and might be the best solution. The difficulty here is that you may need to choose the period/wavelength manually (see this question).
If you want the periodicity to be embedded more deeply into the network, the easiest way would be to use sin/cos as your activation function in one or more layers. This paper discusses potential difficulties and strategies for dealing with periodic activation functions.
Alternatively, this paper takes a different approach, where the weights of the network depend on a periodic function. The paper also suggests using splines instead of sin/cos, since they are more flexible. This was one of my favorite papers last year, so it's worth reading (or at least watching the video) even if you don't end up using its approach.
|
How do I make my neural network better at predicting sine waves?
|
In some cases, @Neil Slater's suggested approach of transforming your features with a periodic function will work very well, and might be the best solution. The difficulty here is that you may need to
|
How do I make my neural network better at predicting sine waves?
In some cases, @Neil Slater's suggested approach of transforming your features with a periodic function will work very well, and might be the best solution. The difficulty here is that you may need to choose the period/wavelength manually (see this question).
If you want the periodicity to be embedded more deeply into the network, the easiest way would be to use sin/cos as your activation function in one or more layers. This paper discusses potential difficulties and strategies for dealing with periodic activation functions.
Alternatively, this paper takes a different approach, where the weights of the network depend on a periodic function. The paper also suggests using splines instead of sin/cos, since they are more flexible. This was one of my favorite papers last year, so it's worth reading (or at least watching the video) even if you don't end up using its approach.
|
How do I make my neural network better at predicting sine waves?
In some cases, @Neil Slater's suggested approach of transforming your features with a periodic function will work very well, and might be the best solution. The difficulty here is that you may need to
|
10,918
|
How do I make my neural network better at predicting sine waves?
|
You took a wrong approach, nothing can be done with this approach to fix the issue.
There are several different ways to address the problem. I'll suggest the most obvious one through feature engineering. Instead of plugging time as a linear feature, put it as remainder of modulus T=1. For instance, t=0.2, 1.2 and 2.2 will all become a feature t1 = 0.1 etc. As long as T is larger than the period of wave, this will work out. Plug this thing into your net and see how it works.
Feature engineering is underrated. There's this trend in AI/ML where the sales men claim that you dump all your inputs into the net, and somehow it'll figure out what to do with them. Sure, it does, as you saw in your example, but then it breaks down as easily. This is a great example that show how important is to build good features even in some simplest cases.
Also, I hope you realize that this is the crudest example of feature engineering. It's just to give you an idea of what you could do with it.
|
How do I make my neural network better at predicting sine waves?
|
You took a wrong approach, nothing can be done with this approach to fix the issue.
There are several different ways to address the problem. I'll suggest the most obvious one through feature engineeri
|
How do I make my neural network better at predicting sine waves?
You took a wrong approach, nothing can be done with this approach to fix the issue.
There are several different ways to address the problem. I'll suggest the most obvious one through feature engineering. Instead of plugging time as a linear feature, put it as remainder of modulus T=1. For instance, t=0.2, 1.2 and 2.2 will all become a feature t1 = 0.1 etc. As long as T is larger than the period of wave, this will work out. Plug this thing into your net and see how it works.
Feature engineering is underrated. There's this trend in AI/ML where the sales men claim that you dump all your inputs into the net, and somehow it'll figure out what to do with them. Sure, it does, as you saw in your example, but then it breaks down as easily. This is a great example that show how important is to build good features even in some simplest cases.
Also, I hope you realize that this is the crudest example of feature engineering. It's just to give you an idea of what you could do with it.
|
How do I make my neural network better at predicting sine waves?
You took a wrong approach, nothing can be done with this approach to fix the issue.
There are several different ways to address the problem. I'll suggest the most obvious one through feature engineeri
|
10,919
|
How do I make my neural network better at predicting sine waves?
|
You can train the neural network on the autoregressive principle, i.e. based on N previous values. The value of the argument is not required. Forecasting is done in the same way based on previous values, including those predicted. This works fine:
from sklearn.neural_network import MLPRegressor
import numpy as np
step = 0.1
X = np.arange(0, 10, step)
real_sin = np.sin(X)
X_train,y_train = [],[]
start = 10 # training history
for i in range(0,len(real_sin)-start):
X_train.append(real_sin[i:i+start])
y_train.append(real_sin[i+start])
regr = MLPRegressor(max_iter=1000, hidden_layer_sizes= tuple([100]*10)).fit(X_train, y_train)
X_new,Y_new = [X[-1]],[real_sin[-1]]
X_in = y_train[-start:]
for i in range(200):
X_new.append(X_new[-1]+step)
next_y = regr.predict([X_in])[0]
Y_new.append(next_y)
X_in.append(next_y)
X_in.pop(0)
The result should look like this:
|
How do I make my neural network better at predicting sine waves?
|
You can train the neural network on the autoregressive principle, i.e. based on N previous values. The value of the argument is not required. Forecasting is done in the same way based on previous valu
|
How do I make my neural network better at predicting sine waves?
You can train the neural network on the autoregressive principle, i.e. based on N previous values. The value of the argument is not required. Forecasting is done in the same way based on previous values, including those predicted. This works fine:
from sklearn.neural_network import MLPRegressor
import numpy as np
step = 0.1
X = np.arange(0, 10, step)
real_sin = np.sin(X)
X_train,y_train = [],[]
start = 10 # training history
for i in range(0,len(real_sin)-start):
X_train.append(real_sin[i:i+start])
y_train.append(real_sin[i+start])
regr = MLPRegressor(max_iter=1000, hidden_layer_sizes= tuple([100]*10)).fit(X_train, y_train)
X_new,Y_new = [X[-1]],[real_sin[-1]]
X_in = y_train[-start:]
for i in range(200):
X_new.append(X_new[-1]+step)
next_y = regr.predict([X_in])[0]
Y_new.append(next_y)
X_in.append(next_y)
X_in.pop(0)
The result should look like this:
|
How do I make my neural network better at predicting sine waves?
You can train the neural network on the autoregressive principle, i.e. based on N previous values. The value of the argument is not required. Forecasting is done in the same way based on previous valu
|
10,920
|
How to project a new vector onto PCA space?
|
Well, @Srikant already gave you the right answer since the rotation (or loadings) matrix contains eigenvectors arranged column-wise, so that you just have to multiply (using %*%) your vector or matrix of new data with e.g. prcomp(X)$rotation. Be careful, however, with any extra centering or scaling parameters that were applied when computing PCA EVs.
In R, you may also find useful the predict() function, see ?predict.prcomp. BTW, you can check how projection of new data is implemented by simply entering:
getS3method("predict", "prcomp")
|
How to project a new vector onto PCA space?
|
Well, @Srikant already gave you the right answer since the rotation (or loadings) matrix contains eigenvectors arranged column-wise, so that you just have to multiply (using %*%) your vector or matrix
|
How to project a new vector onto PCA space?
Well, @Srikant already gave you the right answer since the rotation (or loadings) matrix contains eigenvectors arranged column-wise, so that you just have to multiply (using %*%) your vector or matrix of new data with e.g. prcomp(X)$rotation. Be careful, however, with any extra centering or scaling parameters that were applied when computing PCA EVs.
In R, you may also find useful the predict() function, see ?predict.prcomp. BTW, you can check how projection of new data is implemented by simply entering:
getS3method("predict", "prcomp")
|
How to project a new vector onto PCA space?
Well, @Srikant already gave you the right answer since the rotation (or loadings) matrix contains eigenvectors arranged column-wise, so that you just have to multiply (using %*%) your vector or matrix
|
10,921
|
How to project a new vector onto PCA space?
|
Just to add to @chl's fantastic answer (+1), you can use a more lightweight solution:
# perform principal components analysis
pca <- prcomp(data)
# project new data onto the PCA space
scale(newdata, pca$center, pca$scale) %*% pca$rotation
This is very useful if you do not want to save the entire pca object for projecting newdata onto the PCA space.
|
How to project a new vector onto PCA space?
|
Just to add to @chl's fantastic answer (+1), you can use a more lightweight solution:
# perform principal components analysis
pca <- prcomp(data)
# project new data onto the PCA space
scale(newdata,
|
How to project a new vector onto PCA space?
Just to add to @chl's fantastic answer (+1), you can use a more lightweight solution:
# perform principal components analysis
pca <- prcomp(data)
# project new data onto the PCA space
scale(newdata, pca$center, pca$scale) %*% pca$rotation
This is very useful if you do not want to save the entire pca object for projecting newdata onto the PCA space.
|
How to project a new vector onto PCA space?
Just to add to @chl's fantastic answer (+1), you can use a more lightweight solution:
# perform principal components analysis
pca <- prcomp(data)
# project new data onto the PCA space
scale(newdata,
|
10,922
|
How to project a new vector onto PCA space?
|
In SVD, if A is an m x n matrix, the top k rows of the right singular matrix V, is a k-dimension representation of the original columns of A where k <= n
A = UΣVt
=> At = VΣtUt = VΣUt
=> AtU = VΣUtU = VΣ -----------(because U is orthogonal)
=> AtUΣ-1=VΣΣ-1=V
So $V = A^tUΣ$-1
The rows of At or the columns of A map to the columns of V.
If the matrix of the new data on which to perform PCA for dimension reduction is Q, a q x n matrix, then use the formula to calculate $R = Q^tUΣ$-1, the result R is the desired result. R is an n by n matrix, and the top k rows of R (can be seen as a k by n matrix) is a new representation of Q's columns in the k-dimension space.
|
How to project a new vector onto PCA space?
|
In SVD, if A is an m x n matrix, the top k rows of the right singular matrix V, is a k-dimension representation of the original columns of A where k <= n
A = UΣVt
=> At = VΣtUt = VΣUt
=> AtU = VΣUtU
|
How to project a new vector onto PCA space?
In SVD, if A is an m x n matrix, the top k rows of the right singular matrix V, is a k-dimension representation of the original columns of A where k <= n
A = UΣVt
=> At = VΣtUt = VΣUt
=> AtU = VΣUtU = VΣ -----------(because U is orthogonal)
=> AtUΣ-1=VΣΣ-1=V
So $V = A^tUΣ$-1
The rows of At or the columns of A map to the columns of V.
If the matrix of the new data on which to perform PCA for dimension reduction is Q, a q x n matrix, then use the formula to calculate $R = Q^tUΣ$-1, the result R is the desired result. R is an n by n matrix, and the top k rows of R (can be seen as a k by n matrix) is a new representation of Q's columns in the k-dimension space.
|
How to project a new vector onto PCA space?
In SVD, if A is an m x n matrix, the top k rows of the right singular matrix V, is a k-dimension representation of the original columns of A where k <= n
A = UΣVt
=> At = VΣtUt = VΣUt
=> AtU = VΣUtU
|
10,923
|
How to project a new vector onto PCA space?
|
I believe that the eigenvectors (i.e., the principal components) should be arranged as columns.
|
How to project a new vector onto PCA space?
|
I believe that the eigenvectors (i.e., the principal components) should be arranged as columns.
|
How to project a new vector onto PCA space?
I believe that the eigenvectors (i.e., the principal components) should be arranged as columns.
|
How to project a new vector onto PCA space?
I believe that the eigenvectors (i.e., the principal components) should be arranged as columns.
|
10,924
|
Can a confounding factor hide a possible causal relationship? (as opposed to find a spurious one)
|
Yes
Rephrasing the opposite of a confounder: It is definitely possible that an unobserved variable yields the impression that there is no relationship, when there is one.
Confounding usually refers to a situation where an unobserved variable yields the illusion that there exists a relationship between two variables where there is none:
This is a special case of omitted-variable bias, which more generally refers to any situation wherein an unobserved variable biases the observed relationship:
It's easy to imagine a scenario where this would have a canceling effect on the estimate instead:
(I wrote $\rho=0$ for the illustration, but the unobserved relationship does not have to be linear.)
You could call this phenomenon omitted-variable bias, cancellation, or masking. Confounding usually refers to the kind of causal relationship shown in the first figure.
|
Can a confounding factor hide a possible causal relationship? (as opposed to find a spurious one)
|
Yes
Rephrasing the opposite of a confounder: It is definitely possible that an unobserved variable yields the impression that there is no relationship, when there is one.
Confounding usually refers t
|
Can a confounding factor hide a possible causal relationship? (as opposed to find a spurious one)
Yes
Rephrasing the opposite of a confounder: It is definitely possible that an unobserved variable yields the impression that there is no relationship, when there is one.
Confounding usually refers to a situation where an unobserved variable yields the illusion that there exists a relationship between two variables where there is none:
This is a special case of omitted-variable bias, which more generally refers to any situation wherein an unobserved variable biases the observed relationship:
It's easy to imagine a scenario where this would have a canceling effect on the estimate instead:
(I wrote $\rho=0$ for the illustration, but the unobserved relationship does not have to be linear.)
You could call this phenomenon omitted-variable bias, cancellation, or masking. Confounding usually refers to the kind of causal relationship shown in the first figure.
|
Can a confounding factor hide a possible causal relationship? (as opposed to find a spurious one)
Yes
Rephrasing the opposite of a confounder: It is definitely possible that an unobserved variable yields the impression that there is no relationship, when there is one.
Confounding usually refers t
|
10,925
|
Can a confounding factor hide a possible causal relationship? (as opposed to find a spurious one)
|
Following on existing answers, I wanted to give a concrete example. Imagine trying to figure out if the gas pedal affects the speed of a car. You observe how far the gas pedal is pressed and how fast the car is going at various times and see no correlations, so we conclude there's no causal effect between them. However, what we are missing is the fact that the car is going up and down hills and the gas often has to be floored when the car is going slowly up a hill. If we knew the slope of the road, we could control for that and find the true causal relationship.
This is an example of the last diagram of Frans's answer.
This example is even clearer if you try to associate the gas pedal to acceleration, rather than speed. The car's total acceleration will be (gas pedal) - (hill slope). Supposing you have cruise control on, then the cruise control will try to keep acceleration right around zero. So the gas will be set to cancel out the slope of the hill and will be entirely uncorrelated to the acceleration (which will be dominated by the changes in slope that the cruise control has yet to compensate for).
|
Can a confounding factor hide a possible causal relationship? (as opposed to find a spurious one)
|
Following on existing answers, I wanted to give a concrete example. Imagine trying to figure out if the gas pedal affects the speed of a car. You observe how far the gas pedal is pressed and how fast
|
Can a confounding factor hide a possible causal relationship? (as opposed to find a spurious one)
Following on existing answers, I wanted to give a concrete example. Imagine trying to figure out if the gas pedal affects the speed of a car. You observe how far the gas pedal is pressed and how fast the car is going at various times and see no correlations, so we conclude there's no causal effect between them. However, what we are missing is the fact that the car is going up and down hills and the gas often has to be floored when the car is going slowly up a hill. If we knew the slope of the road, we could control for that and find the true causal relationship.
This is an example of the last diagram of Frans's answer.
This example is even clearer if you try to associate the gas pedal to acceleration, rather than speed. The car's total acceleration will be (gas pedal) - (hill slope). Supposing you have cruise control on, then the cruise control will try to keep acceleration right around zero. So the gas will be set to cancel out the slope of the hill and will be entirely uncorrelated to the acceleration (which will be dominated by the changes in slope that the cruise control has yet to compensate for).
|
Can a confounding factor hide a possible causal relationship? (as opposed to find a spurious one)
Following on existing answers, I wanted to give a concrete example. Imagine trying to figure out if the gas pedal affects the speed of a car. You observe how far the gas pedal is pressed and how fast
|
10,926
|
Can a confounding factor hide a possible causal relationship? (as opposed to find a spurious one)
|
First, I think you are mixing the usage of "correlation" and "causal relationship". They are different things. To discuss the differences, and how to find "causal relationship", we need a lot of efforts.
Here I will only answer if a confounding variable can hide correlation.
Yes, here is an intuitive example (data is generated by y = c(runif(100), runif(100)+2), x = seq_along(y) in R):
We have x, y and the group variable. The group information is represented as a color of the points.
If we do not know the group / build a regression model using all data, we can say, x and y are positively correlated.
If we use group information / build a regression model on each group. we will say x and y have almost no correlation.
|
Can a confounding factor hide a possible causal relationship? (as opposed to find a spurious one)
|
First, I think you are mixing the usage of "correlation" and "causal relationship". They are different things. To discuss the differences, and how to find "causal relationship", we need a lot of effor
|
Can a confounding factor hide a possible causal relationship? (as opposed to find a spurious one)
First, I think you are mixing the usage of "correlation" and "causal relationship". They are different things. To discuss the differences, and how to find "causal relationship", we need a lot of efforts.
Here I will only answer if a confounding variable can hide correlation.
Yes, here is an intuitive example (data is generated by y = c(runif(100), runif(100)+2), x = seq_along(y) in R):
We have x, y and the group variable. The group information is represented as a color of the points.
If we do not know the group / build a regression model using all data, we can say, x and y are positively correlated.
If we use group information / build a regression model on each group. we will say x and y have almost no correlation.
|
Can a confounding factor hide a possible causal relationship? (as opposed to find a spurious one)
First, I think you are mixing the usage of "correlation" and "causal relationship". They are different things. To discuss the differences, and how to find "causal relationship", we need a lot of effor
|
10,927
|
Given true positive, false negative rates, can you calculate false positive, true negative?
|
There is quite a bit of terminological confusion in this area. Personally, I always find it useful to come back to a confusion matrix to think about this. In a classification / screening test, you can have four different situations:
Condition: A Not A
Test says “A” True positive | False positive
----------------------------------
Test says “Not A” False negative | True negative
In this table, “true positive”, “false negative”, “false positive” and “true negative” are events (or their probability). What you have is therefore probably a true positive rate and a false negative rate. The distinction matters because it emphasizes that both numbers have a numerator and a denominator.
Where things get a bit confusing is that you can find several definitions of “false positive rate” and “false negative rate”, with different denominators.
For example, Wikipedia provides the following definitions (they seem pretty standard):
True positive rate (or sensitivity): $TPR = TP/(TP + FN)$
False positive rate: $FPR = FP/(FP + TN)$
True negative rate (or specificity): $TNR = TN/(FP + TN)$
In all cases, the denominator is the column total. This also gives a cue to their interpretation: The true positive rate is the probability that the test says “A” when the real value is indeed A (i.e., it is a conditional probability, conditioned on A being true). This does not tell you how likely you are to be correct when calling “A” (i.e., the probability of a true positive, conditioned on the test result being “A”).
Assuming the false negative rate is defined in the same way, we then have $FNR = 1 - TPR$ (note that your numbers are consistent with this). We cannot however directly derive the false positive rate from either the true positive or false negative rates because they provide no information on the specificity, i.e., how the test behaves when “not A” is the correct answer. The answer to your question would therefore be “no, it's not possible” because you have no information on the right column of the confusion matrix.
There are however other definitions in the literature. For example, Fleiss (Statistical methods for rates and proportions) offers the following:
“[…] the false positive rate […] is the proportion of people, among those responding positive who are actually free of the disease.”
“The false negative rate […] is the proportion of people, among those responding negative on the test, who nevertheless have the disease.”
(He also acknowledges the previous definitions but considers them “wasteful of precious terminology”, precisely because they have a straightforward relationship with sensitivity and specificity.)
Referring to the confusion matrix, it means that $FPR = FP / (TP + FP)$ and $FNR = FN / (TN + FN)$ so the denominators are the row totals. Importantly, under these definitions, the false positive and false negative rates cannot directly be derived from the sensitivity and specificity of the test. You also need to know the prevalence (i.e., how frequent A is in the population of interest).
Fleiss does not use or define the phrases “true negative rate” or the “true positive rate” but if we assume those are also conditional probabilities given a particular test result / classification, then @guill11aume answer is the correct one.
In any case, you need to be careful with the definitions because there is no indisputable answer to your question.
|
Given true positive, false negative rates, can you calculate false positive, true negative?
|
There is quite a bit of terminological confusion in this area. Personally, I always find it useful to come back to a confusion matrix to think about this. In a classification / screening test, you can
|
Given true positive, false negative rates, can you calculate false positive, true negative?
There is quite a bit of terminological confusion in this area. Personally, I always find it useful to come back to a confusion matrix to think about this. In a classification / screening test, you can have four different situations:
Condition: A Not A
Test says “A” True positive | False positive
----------------------------------
Test says “Not A” False negative | True negative
In this table, “true positive”, “false negative”, “false positive” and “true negative” are events (or their probability). What you have is therefore probably a true positive rate and a false negative rate. The distinction matters because it emphasizes that both numbers have a numerator and a denominator.
Where things get a bit confusing is that you can find several definitions of “false positive rate” and “false negative rate”, with different denominators.
For example, Wikipedia provides the following definitions (they seem pretty standard):
True positive rate (or sensitivity): $TPR = TP/(TP + FN)$
False positive rate: $FPR = FP/(FP + TN)$
True negative rate (or specificity): $TNR = TN/(FP + TN)$
In all cases, the denominator is the column total. This also gives a cue to their interpretation: The true positive rate is the probability that the test says “A” when the real value is indeed A (i.e., it is a conditional probability, conditioned on A being true). This does not tell you how likely you are to be correct when calling “A” (i.e., the probability of a true positive, conditioned on the test result being “A”).
Assuming the false negative rate is defined in the same way, we then have $FNR = 1 - TPR$ (note that your numbers are consistent with this). We cannot however directly derive the false positive rate from either the true positive or false negative rates because they provide no information on the specificity, i.e., how the test behaves when “not A” is the correct answer. The answer to your question would therefore be “no, it's not possible” because you have no information on the right column of the confusion matrix.
There are however other definitions in the literature. For example, Fleiss (Statistical methods for rates and proportions) offers the following:
“[…] the false positive rate […] is the proportion of people, among those responding positive who are actually free of the disease.”
“The false negative rate […] is the proportion of people, among those responding negative on the test, who nevertheless have the disease.”
(He also acknowledges the previous definitions but considers them “wasteful of precious terminology”, precisely because they have a straightforward relationship with sensitivity and specificity.)
Referring to the confusion matrix, it means that $FPR = FP / (TP + FP)$ and $FNR = FN / (TN + FN)$ so the denominators are the row totals. Importantly, under these definitions, the false positive and false negative rates cannot directly be derived from the sensitivity and specificity of the test. You also need to know the prevalence (i.e., how frequent A is in the population of interest).
Fleiss does not use or define the phrases “true negative rate” or the “true positive rate” but if we assume those are also conditional probabilities given a particular test result / classification, then @guill11aume answer is the correct one.
In any case, you need to be careful with the definitions because there is no indisputable answer to your question.
|
Given true positive, false negative rates, can you calculate false positive, true negative?
There is quite a bit of terminological confusion in this area. Personally, I always find it useful to come back to a confusion matrix to think about this. In a classification / screening test, you can
|
10,928
|
Given true positive, false negative rates, can you calculate false positive, true negative?
|
EDIT: see the answer of Gaël Laurans, which is more accurate.
If your true positive rate is 0.25 it means that every time you call a positive, you have a probability of 0.75 of being wrong. This is your false positive rate. Similarly, every time you call a negative, you have a probability of 0.25 of being right, which is your true negative rate.
|
Given true positive, false negative rates, can you calculate false positive, true negative?
|
EDIT: see the answer of Gaël Laurans, which is more accurate.
If your true positive rate is 0.25 it means that every time you call a positive, you have a probability of 0.75 of being wrong. This is yo
|
Given true positive, false negative rates, can you calculate false positive, true negative?
EDIT: see the answer of Gaël Laurans, which is more accurate.
If your true positive rate is 0.25 it means that every time you call a positive, you have a probability of 0.75 of being wrong. This is your false positive rate. Similarly, every time you call a negative, you have a probability of 0.25 of being right, which is your true negative rate.
|
Given true positive, false negative rates, can you calculate false positive, true negative?
EDIT: see the answer of Gaël Laurans, which is more accurate.
If your true positive rate is 0.25 it means that every time you call a positive, you have a probability of 0.75 of being wrong. This is yo
|
10,929
|
Given true positive, false negative rates, can you calculate false positive, true negative?
|
None if this makes any sense if "positive" and "negative" do not make sense for the problem at hand. I see many problems where "positive" and "negative" are arbitrary forced choices on an ordinal or continuous variable. FP, TP, sens, spec are only useful for all-or-nothing phenomena.
|
Given true positive, false negative rates, can you calculate false positive, true negative?
|
None if this makes any sense if "positive" and "negative" do not make sense for the problem at hand. I see many problems where "positive" and "negative" are arbitrary forced choices on an ordinal or
|
Given true positive, false negative rates, can you calculate false positive, true negative?
None if this makes any sense if "positive" and "negative" do not make sense for the problem at hand. I see many problems where "positive" and "negative" are arbitrary forced choices on an ordinal or continuous variable. FP, TP, sens, spec are only useful for all-or-nothing phenomena.
|
Given true positive, false negative rates, can you calculate false positive, true negative?
None if this makes any sense if "positive" and "negative" do not make sense for the problem at hand. I see many problems where "positive" and "negative" are arbitrary forced choices on an ordinal or
|
10,930
|
Given true positive, false negative rates, can you calculate false positive, true negative?
|
Want to improve this post? Provide detailed answers to this question, including citations and an explanation of why your answer is correct. Answers without enough detail may be edited or deleted.
http://www.statsdirect.com/help/default.htm#clinical_epidemiology/screening_test.htm
1) True +ve and false -ve make 100%
2) False +ve and true -ve make 100%
3) There is no relation between true positives and false positives.
|
Given true positive, false negative rates, can you calculate false positive, true negative?
|
Want to improve this post? Provide detailed answers to this question, including citations and an explanation of why your answer is correct. Answers without enough detail may be edited or deleted.
|
Given true positive, false negative rates, can you calculate false positive, true negative?
Want to improve this post? Provide detailed answers to this question, including citations and an explanation of why your answer is correct. Answers without enough detail may be edited or deleted.
http://www.statsdirect.com/help/default.htm#clinical_epidemiology/screening_test.htm
1) True +ve and false -ve make 100%
2) False +ve and true -ve make 100%
3) There is no relation between true positives and false positives.
|
Given true positive, false negative rates, can you calculate false positive, true negative?
Want to improve this post? Provide detailed answers to this question, including citations and an explanation of why your answer is correct. Answers without enough detail may be edited or deleted.
|
10,931
|
Is the t-test miscalibrated in R?
|
t.test performs Welch's t-test if the argument var.equal is not explicitly set to TRUE. The distribution of the test statistic (under the null hypothesis) in Welch's t-test is only approximated by a t-distribution and this approximation gets better with increasing sample sizes. Therefore, the result of your simulation is not particularly surprising.
Addendum
The test statistics in Welch's t-test and Student's t-test coincide if the two sample sizes $n_1$ and $n_2$ (of group $1$ and $2$, respectively) are equal. Hence, the discrepancy in the (simulated) p-value distributions of the two tests (note that the one of Student's t-test is uniform on $\left[0,1\right]$) under the null hypothesis is due to the discrepancy between the estimated degrees of freedom $\nu$ in Welch's t-test and the degrees of freedom $\tilde\nu=2\left(n-1\right)$ in Student's t-test, where $n=n_1=n_2$.
It is easy to see that, if $n_1=n_2$, the estimated degrees of freedom are given by
$$
\nu = \frac{\left(n-1\right)\left(s_1^2 + s_2^2\right)^2}{s_1^4+s_2^4}
= \frac{\left(n-1\right)\left(s_1^4 + s_2^4 + 2s_1^2s_2^2 \right)}{s_1^4+s_2^4},
$$
where $s_1$ and $s_2$ are the Bessel-corrected sample standard deviations.
By the AM–GM inequality and the non-negativity of sample standard deviations, $2s_1^2s_2^2 \leq s_1^4 + s_2^4$ (with equality only if $s_1 = s_2$) and $2s_1^2s_2^2 \geq 0$, therefore $n-1 \leq \nu \leq 2\left(n-1\right)=\tilde\nu$. This shows that the estimated degrees of freedom can only underestimate (or$-$but almost never$-$coincide with) the true degrees of freedom in the given situation, which leads to the conservative p-values seen in your simulation.
This behavior is nicely illustrated in Thomas Lumley's answer.
Since $s_1$ will tend to be closer to $s_2$ with increasing $n$, we can also see that $\nu$ will tend to be closer to $\tilde\nu$ as $n$ increases. Additionally, for a fixed difference $\nu - \tilde\nu$ in degrees of freedom of two t-distributions, their PDFs become increasingly similar with increasing $\nu$, and $\nu$ increases with $n$ in our case. This explains the improvement of the approximation and hence the p-value distribution with increasing group/total sample size.
|
Is the t-test miscalibrated in R?
|
t.test performs Welch's t-test if the argument var.equal is not explicitly set to TRUE. The distribution of the test statistic (under the null hypothesis) in Welch's t-test is only approximated by a t
|
Is the t-test miscalibrated in R?
t.test performs Welch's t-test if the argument var.equal is not explicitly set to TRUE. The distribution of the test statistic (under the null hypothesis) in Welch's t-test is only approximated by a t-distribution and this approximation gets better with increasing sample sizes. Therefore, the result of your simulation is not particularly surprising.
Addendum
The test statistics in Welch's t-test and Student's t-test coincide if the two sample sizes $n_1$ and $n_2$ (of group $1$ and $2$, respectively) are equal. Hence, the discrepancy in the (simulated) p-value distributions of the two tests (note that the one of Student's t-test is uniform on $\left[0,1\right]$) under the null hypothesis is due to the discrepancy between the estimated degrees of freedom $\nu$ in Welch's t-test and the degrees of freedom $\tilde\nu=2\left(n-1\right)$ in Student's t-test, where $n=n_1=n_2$.
It is easy to see that, if $n_1=n_2$, the estimated degrees of freedom are given by
$$
\nu = \frac{\left(n-1\right)\left(s_1^2 + s_2^2\right)^2}{s_1^4+s_2^4}
= \frac{\left(n-1\right)\left(s_1^4 + s_2^4 + 2s_1^2s_2^2 \right)}{s_1^4+s_2^4},
$$
where $s_1$ and $s_2$ are the Bessel-corrected sample standard deviations.
By the AM–GM inequality and the non-negativity of sample standard deviations, $2s_1^2s_2^2 \leq s_1^4 + s_2^4$ (with equality only if $s_1 = s_2$) and $2s_1^2s_2^2 \geq 0$, therefore $n-1 \leq \nu \leq 2\left(n-1\right)=\tilde\nu$. This shows that the estimated degrees of freedom can only underestimate (or$-$but almost never$-$coincide with) the true degrees of freedom in the given situation, which leads to the conservative p-values seen in your simulation.
This behavior is nicely illustrated in Thomas Lumley's answer.
Since $s_1$ will tend to be closer to $s_2$ with increasing $n$, we can also see that $\nu$ will tend to be closer to $\tilde\nu$ as $n$ increases. Additionally, for a fixed difference $\nu - \tilde\nu$ in degrees of freedom of two t-distributions, their PDFs become increasingly similar with increasing $\nu$, and $\nu$ increases with $n$ in our case. This explains the improvement of the approximation and hence the p-value distribution with increasing group/total sample size.
|
Is the t-test miscalibrated in R?
t.test performs Welch's t-test if the argument var.equal is not explicitly set to TRUE. The distribution of the test statistic (under the null hypothesis) in Welch's t-test is only approximated by a t
|
10,932
|
Is the t-test miscalibrated in R?
|
Following up on @statmerkur's correct answer: first, here's what you get with var.equal=TRUE
which is well calibrated.
Second, here's the distribution of estimated degrees of freedom for the Welch t-test
As you can see, the estimated degrees of freedom are typically near 8, but occasionally quite a bit smaller. When the df is smaller, the p-value will be conservative.
Finally, here's the p-value distribution separately for estimated df>7 and $\leq 7$
|
Is the t-test miscalibrated in R?
|
Following up on @statmerkur's correct answer: first, here's what you get with var.equal=TRUE
which is well calibrated.
Second, here's the distribution of estimated degrees of freedom for the Welch t-
|
Is the t-test miscalibrated in R?
Following up on @statmerkur's correct answer: first, here's what you get with var.equal=TRUE
which is well calibrated.
Second, here's the distribution of estimated degrees of freedom for the Welch t-test
As you can see, the estimated degrees of freedom are typically near 8, but occasionally quite a bit smaller. When the df is smaller, the p-value will be conservative.
Finally, here's the p-value distribution separately for estimated df>7 and $\leq 7$
|
Is the t-test miscalibrated in R?
Following up on @statmerkur's correct answer: first, here's what you get with var.equal=TRUE
which is well calibrated.
Second, here's the distribution of estimated degrees of freedom for the Welch t-
|
10,933
|
Mean of a sliding window in R
|
Function rollapply in package zoo gets you close:
> require(zoo)
> TS <- zoo(c(4, 5, 7, 3, 9, 8))
> rollapply(TS, width = 3, by = 2, FUN = mean, align = "left")
1 3
5.333333 6.333333
It just won't compute the last value for you as it doesn't contain 3 observations. Maybe this will be sufficient for your real problem? Also, note that the returned object has the indices you want as the names of the returned vector.
Your example is making an assumption that there is an unobserved 0 in the last window. It might be more useful or realistic to pad with an NA to represent the missing information and tell mean to handle missing values. In this case we will have (8+9)/2 as our final windowed value.
> TS <- zoo(c(4, 5, 7, 3, 9, 8, NA))
> rollapply(TS, width = 3, by = 2, FUN = mean, na.rm = TRUE, align = "left")
1 3 5
5.333333 6.333333 8.500000
|
Mean of a sliding window in R
|
Function rollapply in package zoo gets you close:
> require(zoo)
> TS <- zoo(c(4, 5, 7, 3, 9, 8))
> rollapply(TS, width = 3, by = 2, FUN = mean, align = "left")
1 3
5.333333 6.333333
I
|
Mean of a sliding window in R
Function rollapply in package zoo gets you close:
> require(zoo)
> TS <- zoo(c(4, 5, 7, 3, 9, 8))
> rollapply(TS, width = 3, by = 2, FUN = mean, align = "left")
1 3
5.333333 6.333333
It just won't compute the last value for you as it doesn't contain 3 observations. Maybe this will be sufficient for your real problem? Also, note that the returned object has the indices you want as the names of the returned vector.
Your example is making an assumption that there is an unobserved 0 in the last window. It might be more useful or realistic to pad with an NA to represent the missing information and tell mean to handle missing values. In this case we will have (8+9)/2 as our final windowed value.
> TS <- zoo(c(4, 5, 7, 3, 9, 8, NA))
> rollapply(TS, width = 3, by = 2, FUN = mean, na.rm = TRUE, align = "left")
1 3 5
5.333333 6.333333 8.500000
|
Mean of a sliding window in R
Function rollapply in package zoo gets you close:
> require(zoo)
> TS <- zoo(c(4, 5, 7, 3, 9, 8))
> rollapply(TS, width = 3, by = 2, FUN = mean, align = "left")
1 3
5.333333 6.333333
I
|
10,934
|
Mean of a sliding window in R
|
Rollapply works great with a small dataset. However, if you are working with several million rows (genomics) it is quite slow.
The following function is super fast.
data <- c(runif(100000, min=0, max=.1),runif(100000, min=.05, max=.1),runif(10000, min=.05, max=1), runif(100000, min=0, max=.2))
slideFunct <- function(data, window, step){
total <- length(data)
spots <- seq(from=1, to=(total-window), by=step)
result <- vector(length = length(spots))
for(i in 1:length(spots)){
result[i] <- mean(data[spots[i]:(spots[i]+window)])
}
return(result)
}
http://coleoguy.blogspot.com/2014/04/sliding-window-analysis.html
|
Mean of a sliding window in R
|
Rollapply works great with a small dataset. However, if you are working with several million rows (genomics) it is quite slow.
The following function is super fast.
data <- c(runif(100000, min=0, max
|
Mean of a sliding window in R
Rollapply works great with a small dataset. However, if you are working with several million rows (genomics) it is quite slow.
The following function is super fast.
data <- c(runif(100000, min=0, max=.1),runif(100000, min=.05, max=.1),runif(10000, min=.05, max=1), runif(100000, min=0, max=.2))
slideFunct <- function(data, window, step){
total <- length(data)
spots <- seq(from=1, to=(total-window), by=step)
result <- vector(length = length(spots))
for(i in 1:length(spots)){
result[i] <- mean(data[spots[i]:(spots[i]+window)])
}
return(result)
}
http://coleoguy.blogspot.com/2014/04/sliding-window-analysis.html
|
Mean of a sliding window in R
Rollapply works great with a small dataset. However, if you are working with several million rows (genomics) it is quite slow.
The following function is super fast.
data <- c(runif(100000, min=0, max
|
10,935
|
Mean of a sliding window in R
|
This simple line of code does the thing:
((c(x,0,0) + c(0,x,0) + c(0,0,x))/3)[3:(length(x)-1)]
if x is the vector in question.
|
Mean of a sliding window in R
|
This simple line of code does the thing:
((c(x,0,0) + c(0,x,0) + c(0,0,x))/3)[3:(length(x)-1)]
if x is the vector in question.
|
Mean of a sliding window in R
This simple line of code does the thing:
((c(x,0,0) + c(0,x,0) + c(0,0,x))/3)[3:(length(x)-1)]
if x is the vector in question.
|
Mean of a sliding window in R
This simple line of code does the thing:
((c(x,0,0) + c(0,x,0) + c(0,0,x))/3)[3:(length(x)-1)]
if x is the vector in question.
|
10,936
|
Mean of a sliding window in R
|
library(zoo)
x=c(4, 5, 7, 3, 9, 8)
rollmean(x,3)
or
library(TTR)
x=c(4, 5, 7, 3, 9, 8)
SMA(x,3)
|
Mean of a sliding window in R
|
library(zoo)
x=c(4, 5, 7, 3, 9, 8)
rollmean(x,3)
or
library(TTR)
x=c(4, 5, 7, 3, 9, 8)
SMA(x,3)
|
Mean of a sliding window in R
library(zoo)
x=c(4, 5, 7, 3, 9, 8)
rollmean(x,3)
or
library(TTR)
x=c(4, 5, 7, 3, 9, 8)
SMA(x,3)
|
Mean of a sliding window in R
library(zoo)
x=c(4, 5, 7, 3, 9, 8)
rollmean(x,3)
or
library(TTR)
x=c(4, 5, 7, 3, 9, 8)
SMA(x,3)
|
10,937
|
Mean of a sliding window in R
|
shabbychef's answer in R:
slideMean<-function(x,windowsize=3,slide=2){
idx1<-seq(1,length(x),by=slide);
idx1+windowsize->idx2;
idx2[idx2>(length(x)+1)]<-length(x)+1;
c(0,cumsum(x))->cx;
return((cx[idx2]-cx[idx1])/windowsize);
}
EDIT: Indices you're looking for are just idx1... this function can be easily modified to return them also, but it is almost equally fast to recreate them with another call to seq(1,length(x),by=slide).
|
Mean of a sliding window in R
|
shabbychef's answer in R:
slideMean<-function(x,windowsize=3,slide=2){
idx1<-seq(1,length(x),by=slide);
idx1+windowsize->idx2;
idx2[idx2>(length(x)+1)]<-length(x)+1;
c(0,cumsum(x))->cx;
return((c
|
Mean of a sliding window in R
shabbychef's answer in R:
slideMean<-function(x,windowsize=3,slide=2){
idx1<-seq(1,length(x),by=slide);
idx1+windowsize->idx2;
idx2[idx2>(length(x)+1)]<-length(x)+1;
c(0,cumsum(x))->cx;
return((cx[idx2]-cx[idx1])/windowsize);
}
EDIT: Indices you're looking for are just idx1... this function can be easily modified to return them also, but it is almost equally fast to recreate them with another call to seq(1,length(x),by=slide).
|
Mean of a sliding window in R
shabbychef's answer in R:
slideMean<-function(x,windowsize=3,slide=2){
idx1<-seq(1,length(x),by=slide);
idx1+windowsize->idx2;
idx2[idx2>(length(x)+1)]<-length(x)+1;
c(0,cumsum(x))->cx;
return((c
|
10,938
|
Mean of a sliding window in R
|
I can do this easily in Matlab and duck while you downvote me:
%given vector x, windowsize, slide
idx1 = 1:slide:numel(x);
idx2 = min(numel(x) + 1,idx1 + windowsize); %sic on +1 here and no -1;
cx = [0;cumsum(x(:))]; %pad out a zero, perform a cumulative sum;
rv = (cx(idx2) - cx(idx1)) / windowsize; %tada! the answer!
as a side effect, idx1 is the index of the element in the sum. I am sure this can be easily translated into R. The idiom first:skip:last in Matlab gives the array first, first+skip, first+2skip, ..., first + n skip, where the last element in the array is no greater than last.
edit: I had omitted the averaging part (divide by windowsize).
|
Mean of a sliding window in R
|
I can do this easily in Matlab and duck while you downvote me:
%given vector x, windowsize, slide
idx1 = 1:slide:numel(x);
idx2 = min(numel(x) + 1,idx1 + windowsize); %sic on +1 here and no -1;
cx =
|
Mean of a sliding window in R
I can do this easily in Matlab and duck while you downvote me:
%given vector x, windowsize, slide
idx1 = 1:slide:numel(x);
idx2 = min(numel(x) + 1,idx1 + windowsize); %sic on +1 here and no -1;
cx = [0;cumsum(x(:))]; %pad out a zero, perform a cumulative sum;
rv = (cx(idx2) - cx(idx1)) / windowsize; %tada! the answer!
as a side effect, idx1 is the index of the element in the sum. I am sure this can be easily translated into R. The idiom first:skip:last in Matlab gives the array first, first+skip, first+2skip, ..., first + n skip, where the last element in the array is no greater than last.
edit: I had omitted the averaging part (divide by windowsize).
|
Mean of a sliding window in R
I can do this easily in Matlab and duck while you downvote me:
%given vector x, windowsize, slide
idx1 = 1:slide:numel(x);
idx2 = min(numel(x) + 1,idx1 + windowsize); %sic on +1 here and no -1;
cx =
|
10,939
|
Mean of a sliding window in R
|
This will get you the window means and the index of the first value of the window:
#The data
x <- c(4, 5, 7, 3, 9, 8)
#Set window size and slide
win.size <- 3
slide <- 2
#Set up the table of results
results <- data.frame(index = numeric(), win.mean = numeric())
#i indexes the first value of the window (the sill?)
i <- 1
#j indexes the row of the results to be added next
j <- 1
while(i < length(x)) {
#This mean preserves the denominator of 3
win.mean <- sum(x[i:(i+2)], na.rm = TRUE)/win.size
#Insert the results
results[j, ] <- c(i, win.mean)
#Increment the indices for the next pass
i <- i + slide
j <- j + 1
}
Various caveats apply: haven't tested this against anything but your sample data; I believe that appending to data frames like this can get really slow if you have lots of values (because it'll copy the data.frame each time); etc. But it does produce what you asked for.
|
Mean of a sliding window in R
|
This will get you the window means and the index of the first value of the window:
#The data
x <- c(4, 5, 7, 3, 9, 8)
#Set window size and slide
win.size <- 3
slide <- 2
#Set up the table of results
|
Mean of a sliding window in R
This will get you the window means and the index of the first value of the window:
#The data
x <- c(4, 5, 7, 3, 9, 8)
#Set window size and slide
win.size <- 3
slide <- 2
#Set up the table of results
results <- data.frame(index = numeric(), win.mean = numeric())
#i indexes the first value of the window (the sill?)
i <- 1
#j indexes the row of the results to be added next
j <- 1
while(i < length(x)) {
#This mean preserves the denominator of 3
win.mean <- sum(x[i:(i+2)], na.rm = TRUE)/win.size
#Insert the results
results[j, ] <- c(i, win.mean)
#Increment the indices for the next pass
i <- i + slide
j <- j + 1
}
Various caveats apply: haven't tested this against anything but your sample data; I believe that appending to data frames like this can get really slow if you have lots of values (because it'll copy the data.frame each time); etc. But it does produce what you asked for.
|
Mean of a sliding window in R
This will get you the window means and the index of the first value of the window:
#The data
x <- c(4, 5, 7, 3, 9, 8)
#Set window size and slide
win.size <- 3
slide <- 2
#Set up the table of results
|
10,940
|
Mean of a sliding window in R
|
You are doing a convolution operation. The implementation in R uses FFT internally and you are unlikely to beat it with loops and such things.
> vals=c(4, 5, 7, 3, 9, 8, 0)
> convolve(x=vals, y=c(1, 1, 1)/3, type="filter")
[1] 5.33 5.00 6.33 6.67 5.67
If you want to extract every second result.
> tmp <- convolve(x=vals, y=c(1, 1, 1)/3, type="filter")
> tmp[0:2*2+1]
[1] 5.33 6.33 5.67
|
Mean of a sliding window in R
|
You are doing a convolution operation. The implementation in R uses FFT internally and you are unlikely to beat it with loops and such things.
> vals=c(4, 5, 7, 3, 9, 8, 0)
> convolve(x=vals, y=c(1, 1
|
Mean of a sliding window in R
You are doing a convolution operation. The implementation in R uses FFT internally and you are unlikely to beat it with loops and such things.
> vals=c(4, 5, 7, 3, 9, 8, 0)
> convolve(x=vals, y=c(1, 1, 1)/3, type="filter")
[1] 5.33 5.00 6.33 6.67 5.67
If you want to extract every second result.
> tmp <- convolve(x=vals, y=c(1, 1, 1)/3, type="filter")
> tmp[0:2*2+1]
[1] 5.33 6.33 5.67
|
Mean of a sliding window in R
You are doing a convolution operation. The implementation in R uses FFT internally and you are unlikely to beat it with loops and such things.
> vals=c(4, 5, 7, 3, 9, 8, 0)
> convolve(x=vals, y=c(1, 1
|
10,941
|
Is probability theory the study of non-negative functions that integrate/sum to one?
|
At a purely formal level, one could call probability theory the study
of measure spaces with total measure one, but that would be like
calling number theory the study of strings of digits which terminate
-- from Terry Tao's Topics in random matrix theory.
I think this is the really fundamental thing. If we've got a probability space $(\Omega, \mathscr F, P)$ and a random variable $X : \Omega \to \mathbb R$ with pushforward measure $P_X := P \circ X^{-1}$, then the reason a density $f = \frac{\text d P_X}{\text d\mu}$ integrates to one is because $P(\Omega) = 1$. And that's more fundamental than pdfs vs pmfs.
Here's the proof:
$$
\int_{\mathbb R} f \,\text d\mu = \int_{\mathbb R} \,\text dP_X = P_X(\mathbb R) = P\left(\{\omega \in \Omega : X(\omega) \in \mathbb R\}\right) = P(\Omega) = 1.
$$
This is almost a rephrasing of AdamO's answer (+1) because all CDFs are càdlàg, and there's a one-to-one relationship between the set of CDFs on $\mathbb R$ and the set of all probability measures on $(\mathbb R, \mathbb B)$, but since the CDF of a RV is defined in terms of its distribution, I view probability spaces as the place to "start" with this kind of endeavor.
I'm updating to elaborate on the correspondence between CDFs and probability measures and how both are reasonable answers for this question.
We begin by starting with two probability measures and analyzing the corresponding CDFs. We conclude by instead starting with a CDF and looking at the measure induced by it.
Let $Q$ and $R$ be probability measures on $(\mathbb R, \mathbb B)$ and let $F_Q$ and $F_R$ be their respective CDFs (i.e. $F_Q(a) = Q\left((-\infty, a]\right)$ and similarly for $R$). $Q$ and $R$ both would represent pushforward measures of random variables (i.e. distributions) but it doesn't actually matter where they came from for this.
The key idea is this: if $Q$ and $R$ agree on a rich enough collection of sets, then they agree on the $\sigma$-algebra generated by those sets. Intuitively, if we've got a well-behaved collection of events that, through a countable number of complements, intersections, and unions forms all of $\mathbb B$, then agreeing on all of those sets leaves no wiggle room for disagreeing on any Borel set.
Let's formalize that. Let $\mathscr S = \{(-\infty, a] : a \in \mathbb R\}$ and let $\mathcal L = \{A \subseteq \mathbb R : Q(A) = R(A)\}$, i.e. $\mathcal L$ is the subset of $\mathcal P(\mathbb R)$ on which $Q$ and $R$ agree (and are defined). Note that we're allowing for them to agree on non-Borel sets since $\mathcal L$ as defined isn't necessarily a subset of $\mathbb B$. Our goal is to show that $\mathbb B \subseteq \mathcal L$.
It turns out that $\sigma(\mathscr S)$ (the $\sigma$-algebra generated by $\mathscr S$) is in fact $\mathbb B$, so we hope that $\mathscr S$ is a sufficiently big collection of events that if $Q = R$ everywhere on $\mathscr S$ then they're forced to be equal on all of $\mathbb B$.
Note that $\mathscr S$ is closed under finite intersections, and that $\mathcal L$ is closed under complements and countable disjoint intersections (this follows from $\sigma$-additivity). This means that $\mathscr S$ is a $\pi$-system and $\mathcal L$ is a $\lambda$-system. By the $\pi$-$\lambda$ theorem we therefore have that $\sigma(S) = \mathbb B \subseteq \mathcal L$. The elements of $\mathscr S$ are nowhere near being as complex as an arbitrary Borel set, but because any Borel set can be formed from a countable number of complements, unions, and intersections of elements of $\mathscr S$, if there is not a single disagreement between $Q$ and $R$ on elements of $\mathscr S$ then this will be followed through to there being no disagreements on any $B \in \mathbb B$.
We have just shown that if $F_Q = F_R$ then $Q = R$ (on $\mathbb B$), which means that the map $Q \mapsto F_Q$ from $\mathscr P := \{P : P \text { is a probability measure on } (\mathbb R, \mathbb B)\}$ to $\mathcal F := \{F : \mathbb R \to \mathbb R : F \text { is a CDF}\}$ is an injection.
Now if we want to think about going the other direction, we want to start with a CDF $F$ and show that there is a unique probability measure $Q$ such that $F(a) = Q\left((-\infty, a]\right)$. This will establish that our mapping $Q \mapsto F_Q$ is in fact a bijection. For this direction, we define $F$ without any reference to probability or measures.
We first define a Stieltjes measure function as a function $G : \mathbb R \to \mathbb R$ such that
$G$ is non-decreasing
$G$ is right-continuous
(and note how being càdlàg follows from this definition, but because of the extra non-decreasing constraint "most" càdlàg functions are not Stieltjes measure functions).
It can be shown that each Stieltjes function $G$ induces a unique measure $\mu$ on $(\mathbb R, \mathbb B)$ defined by
$$
\mu\left((a, b]\right) = G(b) - G(a)
$$
(see e.g. Durrett's Probability and Random Processes for details on this). For example, the Lebesgue measure is induced by $G(x) = x$.
Now noting that a CDF is a Stieltjes function $F$ with the additional properties that $\lim_{x\to-\infty} F(x) := F(-\infty) = 0$ and $\lim_{x\to\infty} F(x) := F(\infty) = 1$, we can apply that result to show that for every CDF $F$ we get a unique measure $Q$ on $(\mathbb R, \mathbb B)$ defined by
$$
Q\left((a, b]\right) = F(b) - F(a).
$$
Note how $Q\left((-\infty, a]\right) = F(a) - F(-\infty) = F(a)$ and $Q\left((-\infty, -\infty]\right) = F(\infty) - F(-\infty) = 1$ so $Q$ is a probability measure and is exactly the one we would have used to define $F$ if we were going the other direction.
All together we have now seen that the mapping $Q \mapsto F_Q$ is 1-1 and onto so we really do have a bijection between $\mathscr P$ and $\mathcal F$. Bringing this back to the actual question, this shows that we could equivalently hold up either CDFs or probability measures as our object which we declare probability to be the study of (while also recognizing that this is a somewhat facetious endeavor). I personally still prefer probability spaces because I feel like the theory more naturally flows in that direction but CDFs are not "wrong".
|
Is probability theory the study of non-negative functions that integrate/sum to one?
|
At a purely formal level, one could call probability theory the study
of measure spaces with total measure one, but that would be like
calling number theory the study of strings of digits which te
|
Is probability theory the study of non-negative functions that integrate/sum to one?
At a purely formal level, one could call probability theory the study
of measure spaces with total measure one, but that would be like
calling number theory the study of strings of digits which terminate
-- from Terry Tao's Topics in random matrix theory.
I think this is the really fundamental thing. If we've got a probability space $(\Omega, \mathscr F, P)$ and a random variable $X : \Omega \to \mathbb R$ with pushforward measure $P_X := P \circ X^{-1}$, then the reason a density $f = \frac{\text d P_X}{\text d\mu}$ integrates to one is because $P(\Omega) = 1$. And that's more fundamental than pdfs vs pmfs.
Here's the proof:
$$
\int_{\mathbb R} f \,\text d\mu = \int_{\mathbb R} \,\text dP_X = P_X(\mathbb R) = P\left(\{\omega \in \Omega : X(\omega) \in \mathbb R\}\right) = P(\Omega) = 1.
$$
This is almost a rephrasing of AdamO's answer (+1) because all CDFs are càdlàg, and there's a one-to-one relationship between the set of CDFs on $\mathbb R$ and the set of all probability measures on $(\mathbb R, \mathbb B)$, but since the CDF of a RV is defined in terms of its distribution, I view probability spaces as the place to "start" with this kind of endeavor.
I'm updating to elaborate on the correspondence between CDFs and probability measures and how both are reasonable answers for this question.
We begin by starting with two probability measures and analyzing the corresponding CDFs. We conclude by instead starting with a CDF and looking at the measure induced by it.
Let $Q$ and $R$ be probability measures on $(\mathbb R, \mathbb B)$ and let $F_Q$ and $F_R$ be their respective CDFs (i.e. $F_Q(a) = Q\left((-\infty, a]\right)$ and similarly for $R$). $Q$ and $R$ both would represent pushforward measures of random variables (i.e. distributions) but it doesn't actually matter where they came from for this.
The key idea is this: if $Q$ and $R$ agree on a rich enough collection of sets, then they agree on the $\sigma$-algebra generated by those sets. Intuitively, if we've got a well-behaved collection of events that, through a countable number of complements, intersections, and unions forms all of $\mathbb B$, then agreeing on all of those sets leaves no wiggle room for disagreeing on any Borel set.
Let's formalize that. Let $\mathscr S = \{(-\infty, a] : a \in \mathbb R\}$ and let $\mathcal L = \{A \subseteq \mathbb R : Q(A) = R(A)\}$, i.e. $\mathcal L$ is the subset of $\mathcal P(\mathbb R)$ on which $Q$ and $R$ agree (and are defined). Note that we're allowing for them to agree on non-Borel sets since $\mathcal L$ as defined isn't necessarily a subset of $\mathbb B$. Our goal is to show that $\mathbb B \subseteq \mathcal L$.
It turns out that $\sigma(\mathscr S)$ (the $\sigma$-algebra generated by $\mathscr S$) is in fact $\mathbb B$, so we hope that $\mathscr S$ is a sufficiently big collection of events that if $Q = R$ everywhere on $\mathscr S$ then they're forced to be equal on all of $\mathbb B$.
Note that $\mathscr S$ is closed under finite intersections, and that $\mathcal L$ is closed under complements and countable disjoint intersections (this follows from $\sigma$-additivity). This means that $\mathscr S$ is a $\pi$-system and $\mathcal L$ is a $\lambda$-system. By the $\pi$-$\lambda$ theorem we therefore have that $\sigma(S) = \mathbb B \subseteq \mathcal L$. The elements of $\mathscr S$ are nowhere near being as complex as an arbitrary Borel set, but because any Borel set can be formed from a countable number of complements, unions, and intersections of elements of $\mathscr S$, if there is not a single disagreement between $Q$ and $R$ on elements of $\mathscr S$ then this will be followed through to there being no disagreements on any $B \in \mathbb B$.
We have just shown that if $F_Q = F_R$ then $Q = R$ (on $\mathbb B$), which means that the map $Q \mapsto F_Q$ from $\mathscr P := \{P : P \text { is a probability measure on } (\mathbb R, \mathbb B)\}$ to $\mathcal F := \{F : \mathbb R \to \mathbb R : F \text { is a CDF}\}$ is an injection.
Now if we want to think about going the other direction, we want to start with a CDF $F$ and show that there is a unique probability measure $Q$ such that $F(a) = Q\left((-\infty, a]\right)$. This will establish that our mapping $Q \mapsto F_Q$ is in fact a bijection. For this direction, we define $F$ without any reference to probability or measures.
We first define a Stieltjes measure function as a function $G : \mathbb R \to \mathbb R$ such that
$G$ is non-decreasing
$G$ is right-continuous
(and note how being càdlàg follows from this definition, but because of the extra non-decreasing constraint "most" càdlàg functions are not Stieltjes measure functions).
It can be shown that each Stieltjes function $G$ induces a unique measure $\mu$ on $(\mathbb R, \mathbb B)$ defined by
$$
\mu\left((a, b]\right) = G(b) - G(a)
$$
(see e.g. Durrett's Probability and Random Processes for details on this). For example, the Lebesgue measure is induced by $G(x) = x$.
Now noting that a CDF is a Stieltjes function $F$ with the additional properties that $\lim_{x\to-\infty} F(x) := F(-\infty) = 0$ and $\lim_{x\to\infty} F(x) := F(\infty) = 1$, we can apply that result to show that for every CDF $F$ we get a unique measure $Q$ on $(\mathbb R, \mathbb B)$ defined by
$$
Q\left((a, b]\right) = F(b) - F(a).
$$
Note how $Q\left((-\infty, a]\right) = F(a) - F(-\infty) = F(a)$ and $Q\left((-\infty, -\infty]\right) = F(\infty) - F(-\infty) = 1$ so $Q$ is a probability measure and is exactly the one we would have used to define $F$ if we were going the other direction.
All together we have now seen that the mapping $Q \mapsto F_Q$ is 1-1 and onto so we really do have a bijection between $\mathscr P$ and $\mathcal F$. Bringing this back to the actual question, this shows that we could equivalently hold up either CDFs or probability measures as our object which we declare probability to be the study of (while also recognizing that this is a somewhat facetious endeavor). I personally still prefer probability spaces because I feel like the theory more naturally flows in that direction but CDFs are not "wrong".
|
Is probability theory the study of non-negative functions that integrate/sum to one?
At a purely formal level, one could call probability theory the study
of measure spaces with total measure one, but that would be like
calling number theory the study of strings of digits which te
|
10,942
|
Is probability theory the study of non-negative functions that integrate/sum to one?
|
No; the Cantor distribution is just such a counterexample. It's a random variable, but it has no density. It has a distribution function, however. I would say, therefore, that probability theory is the study of càdlàg functions, inclusive of the Cantor DF, that have left limits of 0 and right limits of 1.
EDIT: This abstraction is a necessary but not complete picture of what probability theory is. I think a more widespread and agreeable definition might be that probability theory is a study of probability spaces which are well defined and have quite a few abstract applications. The probability "function" is formally a measure with some additional constraints, which can be understood as an abstract form of "integrating/summing" things, the probability space has certain constraints on what those "things" are as well. Anyway, a rigorous definition can be found in some advanced theory books, Hogg and Craig 8th ed. give the most accessible definition in the introduction.
|
Is probability theory the study of non-negative functions that integrate/sum to one?
|
No; the Cantor distribution is just such a counterexample. It's a random variable, but it has no density. It has a distribution function, however. I would say, therefore, that probability theory is th
|
Is probability theory the study of non-negative functions that integrate/sum to one?
No; the Cantor distribution is just such a counterexample. It's a random variable, but it has no density. It has a distribution function, however. I would say, therefore, that probability theory is the study of càdlàg functions, inclusive of the Cantor DF, that have left limits of 0 and right limits of 1.
EDIT: This abstraction is a necessary but not complete picture of what probability theory is. I think a more widespread and agreeable definition might be that probability theory is a study of probability spaces which are well defined and have quite a few abstract applications. The probability "function" is formally a measure with some additional constraints, which can be understood as an abstract form of "integrating/summing" things, the probability space has certain constraints on what those "things" are as well. Anyway, a rigorous definition can be found in some advanced theory books, Hogg and Craig 8th ed. give the most accessible definition in the introduction.
|
Is probability theory the study of non-negative functions that integrate/sum to one?
No; the Cantor distribution is just such a counterexample. It's a random variable, but it has no density. It has a distribution function, however. I would say, therefore, that probability theory is th
|
10,943
|
Is probability theory the study of non-negative functions that integrate/sum to one?
|
I'm sure you'll get good answers, but will give you a slightly different perspective here.
You may have heard mathematicians saying that physics is pretty much mathematics, or just an application of mathematics to the most basic laws of nature. Some mathematicians (many?) actually do believe that this the case. I've heard that over and over in university. In this regard you're asking a similar question, though not as wide sweeping as this one.
Physicist usually don't bother even responding to this statement: it's too obvious to them that it's not true. However, if you try to respond it becomes clear that the answer is not so trivial, if you want to make it convincing.
My answer is that physics is not just a bunch of models and equations and theories. It's a field with its own set of approaches and tools and heuristics and the ways of thinking. That's one reason why although Poincare developed relativity theory before Einstein, he didn't realize all the implications and didn't pursue to get everyone on board. Einstein did, because he was a physicist and he got what it meant immediately. I'm not a fan of the guy, but his work on Brownian motion is another example of how a physicist builds a mathematical model. That paper is amazing, and is filled with intuition and traces of thinking that are unmistakenly physics-ey.
So, my answer to you is that even if it were the case that probability deals with the kind of functions you described, it would still not have been the study of those function. Nor it is a measure theory applied to some subclass of measures. Probability theory is the distinct field that studies probabilities, it's linked to a natural world through radioactive decay and quantum mechanics and gases etc. If it happens so that certain functions seem to be suitable to model probabilities, then we'll use them and study their properties too, but while doings so we'll keep an eye on the main prize - the probabilities.
|
Is probability theory the study of non-negative functions that integrate/sum to one?
|
I'm sure you'll get good answers, but will give you a slightly different perspective here.
You may have heard mathematicians saying that physics is pretty much mathematics, or just an application of m
|
Is probability theory the study of non-negative functions that integrate/sum to one?
I'm sure you'll get good answers, but will give you a slightly different perspective here.
You may have heard mathematicians saying that physics is pretty much mathematics, or just an application of mathematics to the most basic laws of nature. Some mathematicians (many?) actually do believe that this the case. I've heard that over and over in university. In this regard you're asking a similar question, though not as wide sweeping as this one.
Physicist usually don't bother even responding to this statement: it's too obvious to them that it's not true. However, if you try to respond it becomes clear that the answer is not so trivial, if you want to make it convincing.
My answer is that physics is not just a bunch of models and equations and theories. It's a field with its own set of approaches and tools and heuristics and the ways of thinking. That's one reason why although Poincare developed relativity theory before Einstein, he didn't realize all the implications and didn't pursue to get everyone on board. Einstein did, because he was a physicist and he got what it meant immediately. I'm not a fan of the guy, but his work on Brownian motion is another example of how a physicist builds a mathematical model. That paper is amazing, and is filled with intuition and traces of thinking that are unmistakenly physics-ey.
So, my answer to you is that even if it were the case that probability deals with the kind of functions you described, it would still not have been the study of those function. Nor it is a measure theory applied to some subclass of measures. Probability theory is the distinct field that studies probabilities, it's linked to a natural world through radioactive decay and quantum mechanics and gases etc. If it happens so that certain functions seem to be suitable to model probabilities, then we'll use them and study their properties too, but while doings so we'll keep an eye on the main prize - the probabilities.
|
Is probability theory the study of non-negative functions that integrate/sum to one?
I'm sure you'll get good answers, but will give you a slightly different perspective here.
You may have heard mathematicians saying that physics is pretty much mathematics, or just an application of m
|
10,944
|
Is probability theory the study of non-negative functions that integrate/sum to one?
|
Well, partially true, it lacks a second condition. Negative probabilities do not make sense. Hence, these functions have to satisfy two conditions:
Continuous distributions:
$$ \int_{\mathcal{D}}f(x) dx = 1 \quad \text{and} \quad f(x)>0 \; \forall x \in \mathcal{D}$$
Discrete distributions:
$$ \sum_{x \in \mathcal{D}}P(x) = 1 \quad \text{and} \quad 0<P(x) \leq 1 \; \forall x \in \mathcal{D}$$
Where $\mathcal{D}$ is the domain where probability distribution is defined.
|
Is probability theory the study of non-negative functions that integrate/sum to one?
|
Well, partially true, it lacks a second condition. Negative probabilities do not make sense. Hence, these functions have to satisfy two conditions:
Continuous distributions:
$$ \int_{\mathcal{D}}f(x)
|
Is probability theory the study of non-negative functions that integrate/sum to one?
Well, partially true, it lacks a second condition. Negative probabilities do not make sense. Hence, these functions have to satisfy two conditions:
Continuous distributions:
$$ \int_{\mathcal{D}}f(x) dx = 1 \quad \text{and} \quad f(x)>0 \; \forall x \in \mathcal{D}$$
Discrete distributions:
$$ \sum_{x \in \mathcal{D}}P(x) = 1 \quad \text{and} \quad 0<P(x) \leq 1 \; \forall x \in \mathcal{D}$$
Where $\mathcal{D}$ is the domain where probability distribution is defined.
|
Is probability theory the study of non-negative functions that integrate/sum to one?
Well, partially true, it lacks a second condition. Negative probabilities do not make sense. Hence, these functions have to satisfy two conditions:
Continuous distributions:
$$ \int_{\mathcal{D}}f(x)
|
10,945
|
Is probability theory the study of non-negative functions that integrate/sum to one?
|
I would say no, that's not what probability theory fundamentally is, but I would say it for different reasons than the other answers.
Fundamentally, I would say, probability theory is the study of two things:
Stochastic processes, and
Bayesian inference.
Stochastic processes includes things like rolling dice, drawing balls from urns, etc., as well as the more sophisticated models found in physics and mathematics. Bayesian inference is reasoning under uncertainty, using probabilities to represent the value of unknown quantities.
These two things are more closely related than they might at first appear. One reason we can study them under the same umbrella is that important aspects of both of them can be represented as non-negative functions that sum/integrate to one. But probability isn't just the study of those functions - their interpretation in terms of random processes and inference is also an important part of it.
For example, probability theory includes concepts such as conditional probabilities and random variables, and quantities such as the entropy, the mutual information, and the expectation and variance of random variables. While one could define these things purely in terms of normalised non-negative functions, the motivation for this would seem pretty weird without the interpretation in terms of random processes and inference.
Moreover, one sometimes comes across concepts in probability theory, particularly on the inference side, which cannot be expressed in terms of a non-negative function that normalises to one. The so-called "improper priors" come to mind here, and AdamO gave the Cantor distribution as another example.
There certainly are some areas of probability theory in which the main interest is in the mathematical properties of normalised non-negative functions, for which the two application domains I mentioned are not important. When this is the case, we often call it measure theory rather than probability theory. But probability theory is also - indeed, I would say mostly - an applied field, and the applications of probability distributions are in themselves a non-trivial component of the field.
|
Is probability theory the study of non-negative functions that integrate/sum to one?
|
I would say no, that's not what probability theory fundamentally is, but I would say it for different reasons than the other answers.
Fundamentally, I would say, probability theory is the study of two
|
Is probability theory the study of non-negative functions that integrate/sum to one?
I would say no, that's not what probability theory fundamentally is, but I would say it for different reasons than the other answers.
Fundamentally, I would say, probability theory is the study of two things:
Stochastic processes, and
Bayesian inference.
Stochastic processes includes things like rolling dice, drawing balls from urns, etc., as well as the more sophisticated models found in physics and mathematics. Bayesian inference is reasoning under uncertainty, using probabilities to represent the value of unknown quantities.
These two things are more closely related than they might at first appear. One reason we can study them under the same umbrella is that important aspects of both of them can be represented as non-negative functions that sum/integrate to one. But probability isn't just the study of those functions - their interpretation in terms of random processes and inference is also an important part of it.
For example, probability theory includes concepts such as conditional probabilities and random variables, and quantities such as the entropy, the mutual information, and the expectation and variance of random variables. While one could define these things purely in terms of normalised non-negative functions, the motivation for this would seem pretty weird without the interpretation in terms of random processes and inference.
Moreover, one sometimes comes across concepts in probability theory, particularly on the inference side, which cannot be expressed in terms of a non-negative function that normalises to one. The so-called "improper priors" come to mind here, and AdamO gave the Cantor distribution as another example.
There certainly are some areas of probability theory in which the main interest is in the mathematical properties of normalised non-negative functions, for which the two application domains I mentioned are not important. When this is the case, we often call it measure theory rather than probability theory. But probability theory is also - indeed, I would say mostly - an applied field, and the applications of probability distributions are in themselves a non-trivial component of the field.
|
Is probability theory the study of non-negative functions that integrate/sum to one?
I would say no, that's not what probability theory fundamentally is, but I would say it for different reasons than the other answers.
Fundamentally, I would say, probability theory is the study of two
|
10,946
|
Is ArXiv popular in the statistics community?
|
Yes, Arxiv is popular in the statistics and the data science community.
As the world of stats and data science evolves everyday, it is important for statisticians and data scientists to keep themselves adept with the latest happenings, techniques and algorithms.
It might not be as popular as it is in the physics community, but it does have its share of importance in the data-rich world.
You might be interested in Gitxiv, which puts together state-of-the-art research with the corresponding open source code/libraries.
|
Is ArXiv popular in the statistics community?
|
Yes, Arxiv is popular in the statistics and the data science community.
As the world of stats and data science evolves everyday, it is important for statisticians and data scientists to keep themselve
|
Is ArXiv popular in the statistics community?
Yes, Arxiv is popular in the statistics and the data science community.
As the world of stats and data science evolves everyday, it is important for statisticians and data scientists to keep themselves adept with the latest happenings, techniques and algorithms.
It might not be as popular as it is in the physics community, but it does have its share of importance in the data-rich world.
You might be interested in Gitxiv, which puts together state-of-the-art research with the corresponding open source code/libraries.
|
Is ArXiv popular in the statistics community?
Yes, Arxiv is popular in the statistics and the data science community.
As the world of stats and data science evolves everyday, it is important for statisticians and data scientists to keep themselve
|
10,947
|
Is ArXiv popular in the statistics community?
|
I shall give a definitive, evidence based answer. The answer is YES.
Look at Google Scholar metrics for probability and statistics, top 10 sources by h5-index:
Publication h5-index h5-median
1. Journal of Econometrics 62 93
2. The Annals of Statistics 58 81
3. arXiv Statistics Theory (math.ST) 57 80
4. Journal of Statistical Software 53 113
5. arXiv Probability (math.PR) 53 65
6. arXiv Methodology (stat.ME) 48 69
7. Journal of the American Statistical Association 48 66
8. Statistics in Medicine 42 62
9. Computational Statistics & Data Analysis 40 51
10. Journal of Business & Economic Statistics 39 67
Note, this list is not based on the number of publications, it's based on the the citation index.
Google's citation index is becoming as popular as Scopus and Reuters (ok, I don't have proof of this statement), so my answer is as objective as it gets.
Compare this to the list from Scimagojr.com on Statistics and Probability:
Title Type SJR H index Total Docs. (2014) Total Docs. (3years) Total Refs. Total Cites (3years) Citable Docs. (3years) Cites / Doc. (2years) Ref. / Doc. Country
1 Annals of Mathematics j Q1 8,551 72 46 209 1.572 647 207 3,05 34,17 US
2 Vital and health statistics. Series 10, Data from the National Health Survey k Q1 7,801 30 4 7 55 125 7 16,33 13,75 US
3 Journal of the Royal Statistical Society. Series B: Statistical Methodology j Q1 6,148 90 45 99 1.507 547 94 3,09 33,49 GB
4 Annals of Statistics j Q1 5,602 103 64 296 2.099 809 287 2,25 32,80 US
5 Journal of Statistical Software j Q1 5,003 64 67 220 2.540 1.364 220 3,91 37,91 US
6 Journal of the American Statistical Association j Q1 4,162 123 106 408 3.501 907 373 1,85 33,03 US
7 Probability Surveys j Q1 3,645 22 1 20 84 46 19 2,73 84,00 US
8 Bioinformatics j Q1 3,576 248 809 2.145 18.801 11.329 2.089 4,69 23,24 GB
9 Journal of Business and Economic Statistics j Q1 3,496 66 58 146 1.464 384 139 2,21 25,24 US
10 Biometrika j Q1 3,342 83 58 233 1.485 369 229 1,28 25,60 GB
There's good overlap with Google Scholar's top 10 list, as you can see. The latter list is also based on h-index, but it's not Google's citation. This only validates the former table, and conclusions from it: arXiv is popular among statisticians in academia.
SSRN is another place to dump the preprints. It's popular among econometricians.
|
Is ArXiv popular in the statistics community?
|
I shall give a definitive, evidence based answer. The answer is YES.
Look at Google Scholar metrics for probability and statistics, top 10 sources by h5-index:
Publication
|
Is ArXiv popular in the statistics community?
I shall give a definitive, evidence based answer. The answer is YES.
Look at Google Scholar metrics for probability and statistics, top 10 sources by h5-index:
Publication h5-index h5-median
1. Journal of Econometrics 62 93
2. The Annals of Statistics 58 81
3. arXiv Statistics Theory (math.ST) 57 80
4. Journal of Statistical Software 53 113
5. arXiv Probability (math.PR) 53 65
6. arXiv Methodology (stat.ME) 48 69
7. Journal of the American Statistical Association 48 66
8. Statistics in Medicine 42 62
9. Computational Statistics & Data Analysis 40 51
10. Journal of Business & Economic Statistics 39 67
Note, this list is not based on the number of publications, it's based on the the citation index.
Google's citation index is becoming as popular as Scopus and Reuters (ok, I don't have proof of this statement), so my answer is as objective as it gets.
Compare this to the list from Scimagojr.com on Statistics and Probability:
Title Type SJR H index Total Docs. (2014) Total Docs. (3years) Total Refs. Total Cites (3years) Citable Docs. (3years) Cites / Doc. (2years) Ref. / Doc. Country
1 Annals of Mathematics j Q1 8,551 72 46 209 1.572 647 207 3,05 34,17 US
2 Vital and health statistics. Series 10, Data from the National Health Survey k Q1 7,801 30 4 7 55 125 7 16,33 13,75 US
3 Journal of the Royal Statistical Society. Series B: Statistical Methodology j Q1 6,148 90 45 99 1.507 547 94 3,09 33,49 GB
4 Annals of Statistics j Q1 5,602 103 64 296 2.099 809 287 2,25 32,80 US
5 Journal of Statistical Software j Q1 5,003 64 67 220 2.540 1.364 220 3,91 37,91 US
6 Journal of the American Statistical Association j Q1 4,162 123 106 408 3.501 907 373 1,85 33,03 US
7 Probability Surveys j Q1 3,645 22 1 20 84 46 19 2,73 84,00 US
8 Bioinformatics j Q1 3,576 248 809 2.145 18.801 11.329 2.089 4,69 23,24 GB
9 Journal of Business and Economic Statistics j Q1 3,496 66 58 146 1.464 384 139 2,21 25,24 US
10 Biometrika j Q1 3,342 83 58 233 1.485 369 229 1,28 25,60 GB
There's good overlap with Google Scholar's top 10 list, as you can see. The latter list is also based on h-index, but it's not Google's citation. This only validates the former table, and conclusions from it: arXiv is popular among statisticians in academia.
SSRN is another place to dump the preprints. It's popular among econometricians.
|
Is ArXiv popular in the statistics community?
I shall give a definitive, evidence based answer. The answer is YES.
Look at Google Scholar metrics for probability and statistics, top 10 sources by h5-index:
Publication
|
10,948
|
Is ArXiv popular in the statistics community?
|
It is not a matter of personal opinion so let's look at some figures on terms appearing on arXiv pages (some random Google queries with few domain-specific terms):
cross validation site:arxiv.org returns
About 17,800 results
monte carlo site:arxiv.org returns
About 187,000 results
sampling site:arxiv.org returns
About 141,000 results
forecasting site:arxiv.org returns
About 11,300 results
regression site:arxiv.org returns
About 51,100 results
EDIT
As @Scortchi noticed, arXiv posts its own statistics. stat category appears in reports for the last three years as below:
year submissions % submissions
2014 2025 2.2%
2013 1602 1.7%
2012 1284 1.5%
This however may not fully represent the content of published papers since some of them may be highly related to statistics but be tagged as different domain (e.g. as math or cs).
Also, Xi'an's blog could pose as a case study. He writes much about Bayesian statistics and often mentions arXived papers (having their own tag).
It also seems that we mentioned "arXiv" on CrossValidated in 689 posts and comments until now (including here).
Does this make it popular or not? Still, hard to say, but for sure thousands of statistics-related papers were posted on arXiv and its popularity is growing.
|
Is ArXiv popular in the statistics community?
|
It is not a matter of personal opinion so let's look at some figures on terms appearing on arXiv pages (some random Google queries with few domain-specific terms):
cross validation site:arxiv.org retu
|
Is ArXiv popular in the statistics community?
It is not a matter of personal opinion so let's look at some figures on terms appearing on arXiv pages (some random Google queries with few domain-specific terms):
cross validation site:arxiv.org returns
About 17,800 results
monte carlo site:arxiv.org returns
About 187,000 results
sampling site:arxiv.org returns
About 141,000 results
forecasting site:arxiv.org returns
About 11,300 results
regression site:arxiv.org returns
About 51,100 results
EDIT
As @Scortchi noticed, arXiv posts its own statistics. stat category appears in reports for the last three years as below:
year submissions % submissions
2014 2025 2.2%
2013 1602 1.7%
2012 1284 1.5%
This however may not fully represent the content of published papers since some of them may be highly related to statistics but be tagged as different domain (e.g. as math or cs).
Also, Xi'an's blog could pose as a case study. He writes much about Bayesian statistics and often mentions arXived papers (having their own tag).
It also seems that we mentioned "arXiv" on CrossValidated in 689 posts and comments until now (including here).
Does this make it popular or not? Still, hard to say, but for sure thousands of statistics-related papers were posted on arXiv and its popularity is growing.
|
Is ArXiv popular in the statistics community?
It is not a matter of personal opinion so let's look at some figures on terms appearing on arXiv pages (some random Google queries with few domain-specific terms):
cross validation site:arxiv.org retu
|
10,949
|
Is ArXiv popular in the statistics community?
|
All journals published by the Institute of Mathematical Statistics (IMS) -- and that includes The Annals of Statistics (one of the very top statistics journals), The Annals of Applied Statistics, etc. -- explicitly encourage authors to put preprints on arXiv and, moreover, take care of putting postprints on arXiv too. I am actually not aware of any math or physics journal that uploads papers to arXiv if the authors did not do it themselves!
The IMS encourages all members to post their articles on arXiv.
(http://www.imstat.org/publications/arxiv.html)
All IMS articles 2004 and forward are freely available in a postprint format on arXiv, as well as those articles posted by authors.
ArXiv is an open access, fully automated electronic archive and distribution server for research articles, now owned and operated by Cornell University, and partially funded by NSF. The main fields it covers are physics, mathematics, non-linear science, computer science, and quantitative biology. Recently, arXiv has cooperated with IMS and the Bernoulli Society to open up a new statistics category within mathematics. We expect this category to eventually grow into a top level archive comparable to e.g. mathematics and physics.
(http://www.imstat.org/publications/eaccess.htm)
|
Is ArXiv popular in the statistics community?
|
All journals published by the Institute of Mathematical Statistics (IMS) -- and that includes The Annals of Statistics (one of the very top statistics journals), The Annals of Applied Statistics, etc.
|
Is ArXiv popular in the statistics community?
All journals published by the Institute of Mathematical Statistics (IMS) -- and that includes The Annals of Statistics (one of the very top statistics journals), The Annals of Applied Statistics, etc. -- explicitly encourage authors to put preprints on arXiv and, moreover, take care of putting postprints on arXiv too. I am actually not aware of any math or physics journal that uploads papers to arXiv if the authors did not do it themselves!
The IMS encourages all members to post their articles on arXiv.
(http://www.imstat.org/publications/arxiv.html)
All IMS articles 2004 and forward are freely available in a postprint format on arXiv, as well as those articles posted by authors.
ArXiv is an open access, fully automated electronic archive and distribution server for research articles, now owned and operated by Cornell University, and partially funded by NSF. The main fields it covers are physics, mathematics, non-linear science, computer science, and quantitative biology. Recently, arXiv has cooperated with IMS and the Bernoulli Society to open up a new statistics category within mathematics. We expect this category to eventually grow into a top level archive comparable to e.g. mathematics and physics.
(http://www.imstat.org/publications/eaccess.htm)
|
Is ArXiv popular in the statistics community?
All journals published by the Institute of Mathematical Statistics (IMS) -- and that includes The Annals of Statistics (one of the very top statistics journals), The Annals of Applied Statistics, etc.
|
10,950
|
AIC or p-value: which one to choose for model selection?
|
AIC is a goodness of fit measure that favours smaller residual error in the model, but penalises for including further predictors and helps avoiding overfitting. In your second set of models model 1 (the one with the lowest AIC) may perform best when used for prediction outside your dataset. A possible explanation why adding Var4 to model 2 results in a lower AIC, but higher p values is that Var4 is somewhat correlated with Var1, 2 and 3. The interpretation of model 2 is thus easier.
|
AIC or p-value: which one to choose for model selection?
|
AIC is a goodness of fit measure that favours smaller residual error in the model, but penalises for including further predictors and helps avoiding overfitting. In your second set of models model 1 (
|
AIC or p-value: which one to choose for model selection?
AIC is a goodness of fit measure that favours smaller residual error in the model, but penalises for including further predictors and helps avoiding overfitting. In your second set of models model 1 (the one with the lowest AIC) may perform best when used for prediction outside your dataset. A possible explanation why adding Var4 to model 2 results in a lower AIC, but higher p values is that Var4 is somewhat correlated with Var1, 2 and 3. The interpretation of model 2 is thus easier.
|
AIC or p-value: which one to choose for model selection?
AIC is a goodness of fit measure that favours smaller residual error in the model, but penalises for including further predictors and helps avoiding overfitting. In your second set of models model 1 (
|
10,951
|
AIC or p-value: which one to choose for model selection?
|
Looking at individual p-values can be misleading. If you have variables that are collinear (have high correlation), you will get big p-values. This does not mean the variables are useless.
As a quick rule of thumb, selecting your model with the AIC criteria is better than looking at p-values.
One reason one might not select the model with the lowest AIC is when your variable to datapoint ratio is large.
Note that model selection and prediction accuracy are somewhat distinct problems. If your goal is to get accurate predictions, I'd suggest cross-validating your model by separating your data in a training and testing set.
A paper on variable selection: Stochastic Stepwise Ensembles for Variable Selection
|
AIC or p-value: which one to choose for model selection?
|
Looking at individual p-values can be misleading. If you have variables that are collinear (have high correlation), you will get big p-values. This does not mean the variables are useless.
As a quick
|
AIC or p-value: which one to choose for model selection?
Looking at individual p-values can be misleading. If you have variables that are collinear (have high correlation), you will get big p-values. This does not mean the variables are useless.
As a quick rule of thumb, selecting your model with the AIC criteria is better than looking at p-values.
One reason one might not select the model with the lowest AIC is when your variable to datapoint ratio is large.
Note that model selection and prediction accuracy are somewhat distinct problems. If your goal is to get accurate predictions, I'd suggest cross-validating your model by separating your data in a training and testing set.
A paper on variable selection: Stochastic Stepwise Ensembles for Variable Selection
|
AIC or p-value: which one to choose for model selection?
Looking at individual p-values can be misleading. If you have variables that are collinear (have high correlation), you will get big p-values. This does not mean the variables are useless.
As a quick
|
10,952
|
AIC or p-value: which one to choose for model selection?
|
AIC is motivated by the estimation of the generalization error (like Mallow's CP, BIC,...).
If you want the model for predictions, better use one of these criteria.
If you want your model for explaining a phenomenon, use p-values.
Also, see here.
|
AIC or p-value: which one to choose for model selection?
|
AIC is motivated by the estimation of the generalization error (like Mallow's CP, BIC,...).
If you want the model for predictions, better use one of these criteria.
If you want your model for explain
|
AIC or p-value: which one to choose for model selection?
AIC is motivated by the estimation of the generalization error (like Mallow's CP, BIC,...).
If you want the model for predictions, better use one of these criteria.
If you want your model for explaining a phenomenon, use p-values.
Also, see here.
|
AIC or p-value: which one to choose for model selection?
AIC is motivated by the estimation of the generalization error (like Mallow's CP, BIC,...).
If you want the model for predictions, better use one of these criteria.
If you want your model for explain
|
10,953
|
Given big enough sample size, a test will always show significant result unless the true effect size is exactly zero. Why?
|
As a simple example, suppose that I am estimating your height using some statistical mumbo jumbo.
You've always stated to others that you are 177 cm (about 5 ft 10 in).
If I were to test this hypothesis (that your height is equal to 177 cm, $h = 177$), and I could reduce the error in my measurement enough, then I could prove that you are not in fact 177 cm. Eventually, if I estimate your height to enough decimal places, you would almost surely deviate from the stated height of 177.00000000 cm. Perhaps you are 177.02 cm; I only have to reduce my error to less than .02 to find out that you are not 177 cm.
How do I reduce the error in statistics? Get a bigger sample. If you get a large enough sample, the error gets so small that you can detect the most minuscule deviations from the null hypothesis.
|
Given big enough sample size, a test will always show significant result unless the true effect size
|
As a simple example, suppose that I am estimating your height using some statistical mumbo jumbo.
You've always stated to others that you are 177 cm (about 5 ft 10 in).
If I were to test this hypothes
|
Given big enough sample size, a test will always show significant result unless the true effect size is exactly zero. Why?
As a simple example, suppose that I am estimating your height using some statistical mumbo jumbo.
You've always stated to others that you are 177 cm (about 5 ft 10 in).
If I were to test this hypothesis (that your height is equal to 177 cm, $h = 177$), and I could reduce the error in my measurement enough, then I could prove that you are not in fact 177 cm. Eventually, if I estimate your height to enough decimal places, you would almost surely deviate from the stated height of 177.00000000 cm. Perhaps you are 177.02 cm; I only have to reduce my error to less than .02 to find out that you are not 177 cm.
How do I reduce the error in statistics? Get a bigger sample. If you get a large enough sample, the error gets so small that you can detect the most minuscule deviations from the null hypothesis.
|
Given big enough sample size, a test will always show significant result unless the true effect size
As a simple example, suppose that I am estimating your height using some statistical mumbo jumbo.
You've always stated to others that you are 177 cm (about 5 ft 10 in).
If I were to test this hypothes
|
10,954
|
Given big enough sample size, a test will always show significant result unless the true effect size is exactly zero. Why?
|
As @Kodiologist points out, this is really about what happens for large sample sizes. For small sample sizes there's no reason why you can't have false positives or false negatives.
I think the $z$-test makes the asymptotic case clearest. Suppose we have $X_1, \dots, X_n \stackrel{\text{iid}}\sim \mathcal N(\mu, 1)$ and we want to test $H_0: \mu = 0$ vs $H_A: \mu \neq 0$. Our test statistic is
$$
Z_n = \frac{\bar X_n - 0}{1 / \sqrt n} = \sqrt n\bar X_n.
$$
$\bar X_n \sim \mathcal N(\mu, \frac 1n)$ so $Z_n = \sqrt n \bar X_n \sim \mathcal N(\mu \sqrt n, 1)$. We are interested in $P(|Z_n| \geq \alpha)$.
$$
P(|Z_n| \geq \alpha) = P(Z_n \leq -\alpha)+ P(Z_n \geq \alpha)
$$
$$
= 1 + \Phi(-\alpha - \mu\sqrt n) - \Phi(\alpha - \mu \sqrt n).
$$
Let $Y \sim \mathcal N(0,1)$ be our reference variable. Under $H_0$ $\mu = 0$ so we have $P(|Z_n| \geq \alpha) = 1 - P(-\alpha \leq Y \leq \alpha)$ so we can choose $\alpha$ to control our type I error rate as desired. But under $H_A$ $\mu \sqrt n \neq 0$ so
$$
P(|Z_n| \geq \alpha) \to 1 + \Phi(\pm\infty) - \Phi(\pm\infty) = 1
$$
so with probability 1 we will reject $H_0$ if $\mu \neq 0$ (the $\pm$ is in case of $\mu < 0$, but either way the infinities have the same sign).
The point of this is that if $\mu$ exactly equals $0$ then our test statistic has the reference distribution and we'll reject 5% (or whatever we choose) of the time. But if $\mu$ is not exactly $0$, then the probability that we'll reject heads to $1$ as $n$ increases. The idea here is the consistency of a test, which is that under $H_A$ the power (probability of rejecting) heads to $1$ as $n \to \infty$.
It's the exact same story with the test statistic for testing $H_0 : \rho = \rho_0$ versus $H_A: \rho \neq \rho_0$ with the Pearson correlation coefficient. If the null hypothesis is false, then our test statistic gets larger and larger in probability, so the probability that we'll reject approaches $1$.
|
Given big enough sample size, a test will always show significant result unless the true effect size
|
As @Kodiologist points out, this is really about what happens for large sample sizes. For small sample sizes there's no reason why you can't have false positives or false negatives.
I think the $z$-t
|
Given big enough sample size, a test will always show significant result unless the true effect size is exactly zero. Why?
As @Kodiologist points out, this is really about what happens for large sample sizes. For small sample sizes there's no reason why you can't have false positives or false negatives.
I think the $z$-test makes the asymptotic case clearest. Suppose we have $X_1, \dots, X_n \stackrel{\text{iid}}\sim \mathcal N(\mu, 1)$ and we want to test $H_0: \mu = 0$ vs $H_A: \mu \neq 0$. Our test statistic is
$$
Z_n = \frac{\bar X_n - 0}{1 / \sqrt n} = \sqrt n\bar X_n.
$$
$\bar X_n \sim \mathcal N(\mu, \frac 1n)$ so $Z_n = \sqrt n \bar X_n \sim \mathcal N(\mu \sqrt n, 1)$. We are interested in $P(|Z_n| \geq \alpha)$.
$$
P(|Z_n| \geq \alpha) = P(Z_n \leq -\alpha)+ P(Z_n \geq \alpha)
$$
$$
= 1 + \Phi(-\alpha - \mu\sqrt n) - \Phi(\alpha - \mu \sqrt n).
$$
Let $Y \sim \mathcal N(0,1)$ be our reference variable. Under $H_0$ $\mu = 0$ so we have $P(|Z_n| \geq \alpha) = 1 - P(-\alpha \leq Y \leq \alpha)$ so we can choose $\alpha$ to control our type I error rate as desired. But under $H_A$ $\mu \sqrt n \neq 0$ so
$$
P(|Z_n| \geq \alpha) \to 1 + \Phi(\pm\infty) - \Phi(\pm\infty) = 1
$$
so with probability 1 we will reject $H_0$ if $\mu \neq 0$ (the $\pm$ is in case of $\mu < 0$, but either way the infinities have the same sign).
The point of this is that if $\mu$ exactly equals $0$ then our test statistic has the reference distribution and we'll reject 5% (or whatever we choose) of the time. But if $\mu$ is not exactly $0$, then the probability that we'll reject heads to $1$ as $n$ increases. The idea here is the consistency of a test, which is that under $H_A$ the power (probability of rejecting) heads to $1$ as $n \to \infty$.
It's the exact same story with the test statistic for testing $H_0 : \rho = \rho_0$ versus $H_A: \rho \neq \rho_0$ with the Pearson correlation coefficient. If the null hypothesis is false, then our test statistic gets larger and larger in probability, so the probability that we'll reject approaches $1$.
|
Given big enough sample size, a test will always show significant result unless the true effect size
As @Kodiologist points out, this is really about what happens for large sample sizes. For small sample sizes there's no reason why you can't have false positives or false negatives.
I think the $z$-t
|
10,955
|
Given big enough sample size, a test will always show significant result unless the true effect size is exactly zero. Why?
|
Arguably what they said is wrong, if for no other reason than their use of "this always happens".
I don't know if this is the crux of the confusion you're having, but I'll post it because I think many do and will get confused by this:
"$X$ happens if $n$ is large enough" does NOT mean "If $n > n_0$, then $X$."
Rather, it means $\lim\limits_{n\to\infty} \Pr (X) = 1$.
What they are literally saying translates to the following:
For any sample size $n$ above some minimum size $n_0$, the result of any non-null test is guaranteed to be significant if the true effect size is not exactly zero.
What they were trying to say, though, is the following:
For any significance level, as the sample size is increased, the probability that a non-null test yields a significant result approaches 1 if the true effect size is not exactly zero.
There are crucial differences here:
There is no guarantee. You are only more likely to get a significant result with a bigger sample.
Now, they could dodge part of the blame here, because so far it's just a terminology issue. In a probabilistic context, it is understood that the statement "if n is large enough then X" can also be interpreted to mean "X becomes more and more likely to be true as n grows large".
However, this interpretation goes out my window as soon as they say this "always" happens. The proper terminology here would have been to say this happens "with high probability"1.
This is secondary, but their wording is confusing—it seems to imply that you fix the sample size to be "large enough", and then the statement holds true for any significance level. However, regardless of what the precise mathematical statement is, that doesn't really make sense: you always first fix the significance level, and then you choose the sample size to be large enough.
But the suggestion that it can somehow be the other way around unfortunately emphasizes the $n > n_0$ interpretation of "large enough", so that makes the above problem even worse.
But once you understand the literature, you get what they're trying to say.
(Side note: incidentally, this is exactly one of the constant problems many people have with Wikipedia. Frequently, it's only possible to understand what they're saying if you already know the material, so it's only good for a reference or as a reminder, not as self-teaching material.)
1 For the fellow pedants (hi!), yes, the term has a more specific meaning than the one I linked to. The loosest technical term we probably want here is "asymptotically almost surely". See here.
|
Given big enough sample size, a test will always show significant result unless the true effect size
|
Arguably what they said is wrong, if for no other reason than their use of "this always happens".
I don't know if this is the crux of the confusion you're having, but I'll post it because I think many
|
Given big enough sample size, a test will always show significant result unless the true effect size is exactly zero. Why?
Arguably what they said is wrong, if for no other reason than their use of "this always happens".
I don't know if this is the crux of the confusion you're having, but I'll post it because I think many do and will get confused by this:
"$X$ happens if $n$ is large enough" does NOT mean "If $n > n_0$, then $X$."
Rather, it means $\lim\limits_{n\to\infty} \Pr (X) = 1$.
What they are literally saying translates to the following:
For any sample size $n$ above some minimum size $n_0$, the result of any non-null test is guaranteed to be significant if the true effect size is not exactly zero.
What they were trying to say, though, is the following:
For any significance level, as the sample size is increased, the probability that a non-null test yields a significant result approaches 1 if the true effect size is not exactly zero.
There are crucial differences here:
There is no guarantee. You are only more likely to get a significant result with a bigger sample.
Now, they could dodge part of the blame here, because so far it's just a terminology issue. In a probabilistic context, it is understood that the statement "if n is large enough then X" can also be interpreted to mean "X becomes more and more likely to be true as n grows large".
However, this interpretation goes out my window as soon as they say this "always" happens. The proper terminology here would have been to say this happens "with high probability"1.
This is secondary, but their wording is confusing—it seems to imply that you fix the sample size to be "large enough", and then the statement holds true for any significance level. However, regardless of what the precise mathematical statement is, that doesn't really make sense: you always first fix the significance level, and then you choose the sample size to be large enough.
But the suggestion that it can somehow be the other way around unfortunately emphasizes the $n > n_0$ interpretation of "large enough", so that makes the above problem even worse.
But once you understand the literature, you get what they're trying to say.
(Side note: incidentally, this is exactly one of the constant problems many people have with Wikipedia. Frequently, it's only possible to understand what they're saying if you already know the material, so it's only good for a reference or as a reminder, not as self-teaching material.)
1 For the fellow pedants (hi!), yes, the term has a more specific meaning than the one I linked to. The loosest technical term we probably want here is "asymptotically almost surely". See here.
|
Given big enough sample size, a test will always show significant result unless the true effect size
Arguably what they said is wrong, if for no other reason than their use of "this always happens".
I don't know if this is the crux of the confusion you're having, but I'll post it because I think many
|
10,956
|
Given big enough sample size, a test will always show significant result unless the true effect size is exactly zero. Why?
|
My favorite example is number of fingers by gender. The vast majority of people have 10 fingers. Some have lost fingers due to accidents. Some have extra fingers.
I don't know if men have more fingers than women (on average). All the easily available evidence suggests that men and women both have 10 fingers.
However, I am highly confident that if I did a census of all men and all women then I would learn that one gender has more fingers (on average) than the other.
|
Given big enough sample size, a test will always show significant result unless the true effect size
|
My favorite example is number of fingers by gender. The vast majority of people have 10 fingers. Some have lost fingers due to accidents. Some have extra fingers.
I don't know if men have more fing
|
Given big enough sample size, a test will always show significant result unless the true effect size is exactly zero. Why?
My favorite example is number of fingers by gender. The vast majority of people have 10 fingers. Some have lost fingers due to accidents. Some have extra fingers.
I don't know if men have more fingers than women (on average). All the easily available evidence suggests that men and women both have 10 fingers.
However, I am highly confident that if I did a census of all men and all women then I would learn that one gender has more fingers (on average) than the other.
|
Given big enough sample size, a test will always show significant result unless the true effect size
My favorite example is number of fingers by gender. The vast majority of people have 10 fingers. Some have lost fingers due to accidents. Some have extra fingers.
I don't know if men have more fing
|
10,957
|
Maximum number of independent variables that can be entered into a multiple regression equation
|
You need to think about what you mean by a "limit".
There are limits, such as when you have more predictors than cases, you run into issues in parameter estimation (see the little R simulation at the bottom of this answer).
However, I imagine you are talking more about soft limits related to statistical power and good statistical practice.
In this case the language of "limits" is not really appropriate.
Rather, bigger sample sizes tend to make it more reasonable to have more predictors and the threshold of how many predictors is reasonable arguably falls on a continuum of reasonableness.
You may find the discussion of rules of thumb for sample size in multiple regression relevant, as many such rules of thumb make reference to the number of predictors.
A few points
If you are concerned more with overall prediction than with statistical significance of individual predictors, then it is probably reasonable to include more predictors than if you are concerned with statistical significance of individual predictors.
If you are concerned more with testing a specific statistical model that relates to your research question (e.g., as is common in many social science applications), presumably you have reasons for including particular predictors.
However, you may also have opportunities to be selective in which predictors you include (e.g., if you have multiple variables that measure a similar construct, you might only include one of them).
When doing theory based model testing, there are a lot of choices, and the decision about which predictors to include involves close connection between your theory and research question.
I don't often see researchers using bonferroni corrections being applied to significance tests of regression coefficients.
One reasonable reason for this might be that researchers are more interested in appraising the overall properties of the model.
If you are interested in assessing relative importance of predictors, I find it useful to examine both the bivariate relationship between the predictor and the outcome, as well as the relationship between the predictor and outcome controlling for other predictors. If you include many predictors, it is often more likely that you include predictors that are highly intercorrelated. In such cases, interpretation of both the bivariate and model based importance indices can be useful, as a variable important in a bivariate sense might be hidden in a model by other correlated predictors (I elaborate more on this here with links).
A little R simulation
I wrote this little simulation to highlight the relationship between sample size and parameter estimation in multiple regression.
set.seed(1)
fitmodel <- function(n, k) {
# n: sample size
# k: number of predictors
# return linear model fit for given sample size and k predictors
x <- data.frame(matrix( rnorm(n*k), nrow=n))
names(x) <- paste("x", seq(k), sep="")
x$y <- rnorm(n)
lm(y~., data=x)
}
The fitmodel function takes two arguments n for the sample size and k for the number of predictors. I am not counting the constant as a predictor, but it is estimated.
I then generates random data and fits a regression model predicting a y variable from k predictor variables and returns the fit.
Given that you mentioned in your question that you were interested in whether 10 predictors is too much, the following function calls show what happens when the sample size is 9, 10, 11, and 12 respectively. I.e., sample size is one less than the number of predictors to two more than the number of predictors
summary(fitmodel(n=9, k=10))
summary(fitmodel(n=10, k=10))
summary(fitmodel(n=11, k=10))
summary(fitmodel(n=12, k=10))
> summary(fitmodel(n=9, k=10))
Call:
lm(formula = y ~ ., data = x)
Residuals:
ALL 9 residuals are 0: no residual degrees of freedom!
Coefficients: (2 not defined because of singularities)
Estimate Std. Error t value Pr(>|t|)
(Intercept) -0.31455 NA NA NA
x1 0.34139 NA NA NA
x2 -0.45924 NA NA NA
x3 0.42474 NA NA NA
x4 -0.87727 NA NA NA
x5 -0.07884 NA NA NA
x6 -0.03900 NA NA NA
x7 1.08482 NA NA NA
x8 0.62890 NA NA NA
x9 NA NA NA NA
x10 NA NA NA NA
Residual standard error: NaN on 0 degrees of freedom
Multiple R-squared: 1, Adjusted R-squared: NaN
F-statistic: NaN on 8 and 0 DF, p-value: NA
Sample size is one less than the number of predictors.
It is only possible to estimate 9 parameters, one of which is the constant.
> summary(fitmodel(n=10, k=10))
Call:
lm(formula = y ~ ., data = x)
Residuals:
ALL 10 residuals are 0: no residual degrees of freedom!
Coefficients: (1 not defined because of singularities)
Estimate Std. Error t value Pr(>|t|)
(Intercept) 0.1724 NA NA NA
x1 -0.3615 NA NA NA
x2 -0.4670 NA NA NA
x3 -0.6883 NA NA NA
x4 -0.1744 NA NA NA
x5 -1.0331 NA NA NA
x6 0.3886 NA NA NA
x7 -0.9886 NA NA NA
x8 0.2778 NA NA NA
x9 0.4616 NA NA NA
x10 NA NA NA NA
Residual standard error: NaN on 0 degrees of freedom
Multiple R-squared: 1, Adjusted R-squared: NaN
F-statistic: NaN on 9 and 0 DF, p-value: NA
Sample size is the same as the number of predictors.
It is only possible to estimate 10 parameters, one of which is the constant.
> summary(fitmodel(n=11, k=10))
Call:
lm(formula = y ~ ., data = x)
Residuals:
ALL 11 residuals are 0: no residual degrees of freedom!
Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) -0.9638 NA NA NA
x1 -0.8393 NA NA NA
x2 -1.5061 NA NA NA
x3 -0.4917 NA NA NA
x4 0.3251 NA NA NA
x5 4.4212 NA NA NA
x6 0.7614 NA NA NA
x7 -0.4195 NA NA NA
x8 0.2142 NA NA NA
x9 -0.9264 NA NA NA
x10 -1.2286 NA NA NA
Residual standard error: NaN on 0 degrees of freedom
Multiple R-squared: 1, Adjusted R-squared: NaN
F-statistic: NaN on 10 and 0 DF, p-value: NA
Sample size is one more than the number of predictors.
All parameters are estimated including the constant.
> summary(fitmodel(n=12, k=10))
Call:
lm(formula = y ~ ., data = x)
Residuals:
1 2 3 4 5 6 7 8 9 10 11
0.036530 -0.042154 -0.009044 -0.117590 0.171923 -0.007976 0.050542 -0.011462 0.010270 0.000914 -0.083533
12
0.001581
Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) 0.14680 0.11180 1.313 0.4144
x1 0.02498 0.09832 0.254 0.8416
x2 1.01950 0.13602 7.495 0.0844 .
x3 -1.76290 0.26094 -6.756 0.0936 .
x4 0.44832 0.16283 2.753 0.2218
x5 -0.76818 0.15651 -4.908 0.1280
x6 -0.33209 0.18554 -1.790 0.3244
x7 1.62276 0.21562 7.526 0.0841 .
x8 -0.47561 0.18468 -2.575 0.2358
x9 1.70578 0.31547 5.407 0.1164
x10 3.25415 0.46447 7.006 0.0903 .
---
Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
Residual standard error: 0.2375 on 1 degrees of freedom
Multiple R-squared: 0.995, Adjusted R-squared: 0.9452
F-statistic: 19.96 on 10 and 1 DF, p-value: 0.1726
Sample size is two more than the number of predictors, and it is finally possible to estimate the fit of the overall model.
|
Maximum number of independent variables that can be entered into a multiple regression equation
|
You need to think about what you mean by a "limit".
There are limits, such as when you have more predictors than cases, you run into issues in parameter estimation (see the little R simulation at the
|
Maximum number of independent variables that can be entered into a multiple regression equation
You need to think about what you mean by a "limit".
There are limits, such as when you have more predictors than cases, you run into issues in parameter estimation (see the little R simulation at the bottom of this answer).
However, I imagine you are talking more about soft limits related to statistical power and good statistical practice.
In this case the language of "limits" is not really appropriate.
Rather, bigger sample sizes tend to make it more reasonable to have more predictors and the threshold of how many predictors is reasonable arguably falls on a continuum of reasonableness.
You may find the discussion of rules of thumb for sample size in multiple regression relevant, as many such rules of thumb make reference to the number of predictors.
A few points
If you are concerned more with overall prediction than with statistical significance of individual predictors, then it is probably reasonable to include more predictors than if you are concerned with statistical significance of individual predictors.
If you are concerned more with testing a specific statistical model that relates to your research question (e.g., as is common in many social science applications), presumably you have reasons for including particular predictors.
However, you may also have opportunities to be selective in which predictors you include (e.g., if you have multiple variables that measure a similar construct, you might only include one of them).
When doing theory based model testing, there are a lot of choices, and the decision about which predictors to include involves close connection between your theory and research question.
I don't often see researchers using bonferroni corrections being applied to significance tests of regression coefficients.
One reasonable reason for this might be that researchers are more interested in appraising the overall properties of the model.
If you are interested in assessing relative importance of predictors, I find it useful to examine both the bivariate relationship between the predictor and the outcome, as well as the relationship between the predictor and outcome controlling for other predictors. If you include many predictors, it is often more likely that you include predictors that are highly intercorrelated. In such cases, interpretation of both the bivariate and model based importance indices can be useful, as a variable important in a bivariate sense might be hidden in a model by other correlated predictors (I elaborate more on this here with links).
A little R simulation
I wrote this little simulation to highlight the relationship between sample size and parameter estimation in multiple regression.
set.seed(1)
fitmodel <- function(n, k) {
# n: sample size
# k: number of predictors
# return linear model fit for given sample size and k predictors
x <- data.frame(matrix( rnorm(n*k), nrow=n))
names(x) <- paste("x", seq(k), sep="")
x$y <- rnorm(n)
lm(y~., data=x)
}
The fitmodel function takes two arguments n for the sample size and k for the number of predictors. I am not counting the constant as a predictor, but it is estimated.
I then generates random data and fits a regression model predicting a y variable from k predictor variables and returns the fit.
Given that you mentioned in your question that you were interested in whether 10 predictors is too much, the following function calls show what happens when the sample size is 9, 10, 11, and 12 respectively. I.e., sample size is one less than the number of predictors to two more than the number of predictors
summary(fitmodel(n=9, k=10))
summary(fitmodel(n=10, k=10))
summary(fitmodel(n=11, k=10))
summary(fitmodel(n=12, k=10))
> summary(fitmodel(n=9, k=10))
Call:
lm(formula = y ~ ., data = x)
Residuals:
ALL 9 residuals are 0: no residual degrees of freedom!
Coefficients: (2 not defined because of singularities)
Estimate Std. Error t value Pr(>|t|)
(Intercept) -0.31455 NA NA NA
x1 0.34139 NA NA NA
x2 -0.45924 NA NA NA
x3 0.42474 NA NA NA
x4 -0.87727 NA NA NA
x5 -0.07884 NA NA NA
x6 -0.03900 NA NA NA
x7 1.08482 NA NA NA
x8 0.62890 NA NA NA
x9 NA NA NA NA
x10 NA NA NA NA
Residual standard error: NaN on 0 degrees of freedom
Multiple R-squared: 1, Adjusted R-squared: NaN
F-statistic: NaN on 8 and 0 DF, p-value: NA
Sample size is one less than the number of predictors.
It is only possible to estimate 9 parameters, one of which is the constant.
> summary(fitmodel(n=10, k=10))
Call:
lm(formula = y ~ ., data = x)
Residuals:
ALL 10 residuals are 0: no residual degrees of freedom!
Coefficients: (1 not defined because of singularities)
Estimate Std. Error t value Pr(>|t|)
(Intercept) 0.1724 NA NA NA
x1 -0.3615 NA NA NA
x2 -0.4670 NA NA NA
x3 -0.6883 NA NA NA
x4 -0.1744 NA NA NA
x5 -1.0331 NA NA NA
x6 0.3886 NA NA NA
x7 -0.9886 NA NA NA
x8 0.2778 NA NA NA
x9 0.4616 NA NA NA
x10 NA NA NA NA
Residual standard error: NaN on 0 degrees of freedom
Multiple R-squared: 1, Adjusted R-squared: NaN
F-statistic: NaN on 9 and 0 DF, p-value: NA
Sample size is the same as the number of predictors.
It is only possible to estimate 10 parameters, one of which is the constant.
> summary(fitmodel(n=11, k=10))
Call:
lm(formula = y ~ ., data = x)
Residuals:
ALL 11 residuals are 0: no residual degrees of freedom!
Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) -0.9638 NA NA NA
x1 -0.8393 NA NA NA
x2 -1.5061 NA NA NA
x3 -0.4917 NA NA NA
x4 0.3251 NA NA NA
x5 4.4212 NA NA NA
x6 0.7614 NA NA NA
x7 -0.4195 NA NA NA
x8 0.2142 NA NA NA
x9 -0.9264 NA NA NA
x10 -1.2286 NA NA NA
Residual standard error: NaN on 0 degrees of freedom
Multiple R-squared: 1, Adjusted R-squared: NaN
F-statistic: NaN on 10 and 0 DF, p-value: NA
Sample size is one more than the number of predictors.
All parameters are estimated including the constant.
> summary(fitmodel(n=12, k=10))
Call:
lm(formula = y ~ ., data = x)
Residuals:
1 2 3 4 5 6 7 8 9 10 11
0.036530 -0.042154 -0.009044 -0.117590 0.171923 -0.007976 0.050542 -0.011462 0.010270 0.000914 -0.083533
12
0.001581
Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) 0.14680 0.11180 1.313 0.4144
x1 0.02498 0.09832 0.254 0.8416
x2 1.01950 0.13602 7.495 0.0844 .
x3 -1.76290 0.26094 -6.756 0.0936 .
x4 0.44832 0.16283 2.753 0.2218
x5 -0.76818 0.15651 -4.908 0.1280
x6 -0.33209 0.18554 -1.790 0.3244
x7 1.62276 0.21562 7.526 0.0841 .
x8 -0.47561 0.18468 -2.575 0.2358
x9 1.70578 0.31547 5.407 0.1164
x10 3.25415 0.46447 7.006 0.0903 .
---
Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
Residual standard error: 0.2375 on 1 degrees of freedom
Multiple R-squared: 0.995, Adjusted R-squared: 0.9452
F-statistic: 19.96 on 10 and 1 DF, p-value: 0.1726
Sample size is two more than the number of predictors, and it is finally possible to estimate the fit of the overall model.
|
Maximum number of independent variables that can be entered into a multiple regression equation
You need to think about what you mean by a "limit".
There are limits, such as when you have more predictors than cases, you run into issues in parameter estimation (see the little R simulation at the
|
10,958
|
Maximum number of independent variables that can be entered into a multiple regression equation
|
I often look at this from the standpoint of whether a model fitted with a certain number of parameters is likely to yield predictions out-of-sample that are as accurate as predictions made on the original model development sample. Calibration curves, mean squared errors of X*Beta, and indexes of predictive discrimination are some of the measures typically used. This is where some of the rules of thumb come from, such as the 15:1 rule (an effective sample size of 15 per parameter examined or estimated).
Regarding multiplicity, a perfect adjustment for multiplicity, assuming the model holds and distributional assumptions are met, is the global test that all betas (other than the intercept) are zero. This is typically tested using a likelihood ratio or an F test.
There are two overall approaches to model development that tend to work well. (1) Have an adequate sample size and fit the entire pre-specified model, and (2) used penalized maximum likelihood estimation to allow only as many effective degrees of freedom in the the regression as the current sample size will support. [Stepwise variable selection without penalization should play no role, as this is known not to work.]
|
Maximum number of independent variables that can be entered into a multiple regression equation
|
I often look at this from the standpoint of whether a model fitted with a certain number of parameters is likely to yield predictions out-of-sample that are as accurate as predictions made on the orig
|
Maximum number of independent variables that can be entered into a multiple regression equation
I often look at this from the standpoint of whether a model fitted with a certain number of parameters is likely to yield predictions out-of-sample that are as accurate as predictions made on the original model development sample. Calibration curves, mean squared errors of X*Beta, and indexes of predictive discrimination are some of the measures typically used. This is where some of the rules of thumb come from, such as the 15:1 rule (an effective sample size of 15 per parameter examined or estimated).
Regarding multiplicity, a perfect adjustment for multiplicity, assuming the model holds and distributional assumptions are met, is the global test that all betas (other than the intercept) are zero. This is typically tested using a likelihood ratio or an F test.
There are two overall approaches to model development that tend to work well. (1) Have an adequate sample size and fit the entire pre-specified model, and (2) used penalized maximum likelihood estimation to allow only as many effective degrees of freedom in the the regression as the current sample size will support. [Stepwise variable selection without penalization should play no role, as this is known not to work.]
|
Maximum number of independent variables that can be entered into a multiple regression equation
I often look at this from the standpoint of whether a model fitted with a certain number of parameters is likely to yield predictions out-of-sample that are as accurate as predictions made on the orig
|
10,959
|
Maximum number of independent variables that can be entered into a multiple regression equation
|
I would rephrase the question as follows: I have $n$ observations, and $p$ candidate predictors. Assume that the true model is a linear combination of $m$ variables among the $p$ candidate predictors. Is there an upper bound to $m$ (your limit), such that I can still identify this model? Intuitively, if $m$ is too large compared to $n$, or it is large compared to $p$, it may be hard to identify the correct model. In other terms: is there a limit to model selection?
To this question, Candes and Plan give an affirmative answer in their paper "Near-ideal model selection by $\ell_1$ minimization": $m \le K p \sigma_1/\log(p)$, where $\sigma_1$ is the largest singular value of the matrix of predictors $X$. This is a deep result, and although it relies on several technical conditions, it links the number of observations (through $\sigma_1$) and of $p$ to the number of predictors we can hope to estimate.
|
Maximum number of independent variables that can be entered into a multiple regression equation
|
I would rephrase the question as follows: I have $n$ observations, and $p$ candidate predictors. Assume that the true model is a linear combination of $m$ variables among the $p$ candidate predictors.
|
Maximum number of independent variables that can be entered into a multiple regression equation
I would rephrase the question as follows: I have $n$ observations, and $p$ candidate predictors. Assume that the true model is a linear combination of $m$ variables among the $p$ candidate predictors. Is there an upper bound to $m$ (your limit), such that I can still identify this model? Intuitively, if $m$ is too large compared to $n$, or it is large compared to $p$, it may be hard to identify the correct model. In other terms: is there a limit to model selection?
To this question, Candes and Plan give an affirmative answer in their paper "Near-ideal model selection by $\ell_1$ minimization": $m \le K p \sigma_1/\log(p)$, where $\sigma_1$ is the largest singular value of the matrix of predictors $X$. This is a deep result, and although it relies on several technical conditions, it links the number of observations (through $\sigma_1$) and of $p$ to the number of predictors we can hope to estimate.
|
Maximum number of independent variables that can be entered into a multiple regression equation
I would rephrase the question as follows: I have $n$ observations, and $p$ candidate predictors. Assume that the true model is a linear combination of $m$ variables among the $p$ candidate predictors.
|
10,960
|
Maximum number of independent variables that can be entered into a multiple regression equation
|
In principle, there is no limit per se to how many predictors you can have. You can estimate 2 billion "betas" in principle. But what happens in practice is that without sufficient data, or sufficient prior information, it will not prove a very fruitful exercise. No particular parameters will be determined very well, and you will not learn much from the analysis.
Now if you don't have a lot of prior information about your model (model structure, parameter values, noise, etc.) then you will need the data to provide this information. This is usually the most common situation, which makes sense, because you usually need a pretty good reason to collect data (and spend $$$) about something you already know pretty well. If this is your situation, then a reasonable limit is to have a large number of observations per parameter. You have 12 parameters (10 slope betas, 1 intercept, and a noise parameter), so anything over 100 observations should be able to determine your parameters well enough to be able to make some conclusions.
But there is no "hard and fast" rules. With only 10 predictors you should have no trouble with computation time (get a better computer if you do). It mainly means just doing more work, because you have 11 dimensions of data to absorb - making it difficult to visualise the data. The basic principles from regression with only 1 dependent variable aren't really that different.
The problem with bonferroni correction is that for it to be a reasonable way to adjust your significance level without sacrificing too much power, you require the hypothesis that you are correcting for to be independent (i.e. learning that one hypothesis is true tells you nothing about whether another hypothesis is true). This is not true for the standard "t-test" in multiple regression for a co-efficient being zero, for example. The test statistic depends on what else in the model - which is a roundabout way of saying the hypothesis are dependent. Or, a more frequentist way of saying this is that the sampling distribution of the t-value conditional on the ith predictor being zero depends on what other parameters are zero. So using the bonferroni correction here may be actually be giving you a lower "overall" significance level than what you think.
|
Maximum number of independent variables that can be entered into a multiple regression equation
|
In principle, there is no limit per se to how many predictors you can have. You can estimate 2 billion "betas" in principle. But what happens in practice is that without sufficient data, or sufficie
|
Maximum number of independent variables that can be entered into a multiple regression equation
In principle, there is no limit per se to how many predictors you can have. You can estimate 2 billion "betas" in principle. But what happens in practice is that without sufficient data, or sufficient prior information, it will not prove a very fruitful exercise. No particular parameters will be determined very well, and you will not learn much from the analysis.
Now if you don't have a lot of prior information about your model (model structure, parameter values, noise, etc.) then you will need the data to provide this information. This is usually the most common situation, which makes sense, because you usually need a pretty good reason to collect data (and spend $$$) about something you already know pretty well. If this is your situation, then a reasonable limit is to have a large number of observations per parameter. You have 12 parameters (10 slope betas, 1 intercept, and a noise parameter), so anything over 100 observations should be able to determine your parameters well enough to be able to make some conclusions.
But there is no "hard and fast" rules. With only 10 predictors you should have no trouble with computation time (get a better computer if you do). It mainly means just doing more work, because you have 11 dimensions of data to absorb - making it difficult to visualise the data. The basic principles from regression with only 1 dependent variable aren't really that different.
The problem with bonferroni correction is that for it to be a reasonable way to adjust your significance level without sacrificing too much power, you require the hypothesis that you are correcting for to be independent (i.e. learning that one hypothesis is true tells you nothing about whether another hypothesis is true). This is not true for the standard "t-test" in multiple regression for a co-efficient being zero, for example. The test statistic depends on what else in the model - which is a roundabout way of saying the hypothesis are dependent. Or, a more frequentist way of saying this is that the sampling distribution of the t-value conditional on the ith predictor being zero depends on what other parameters are zero. So using the bonferroni correction here may be actually be giving you a lower "overall" significance level than what you think.
|
Maximum number of independent variables that can be entered into a multiple regression equation
In principle, there is no limit per se to how many predictors you can have. You can estimate 2 billion "betas" in principle. But what happens in practice is that without sufficient data, or sufficie
|
10,961
|
Why does mean tend be more stable in different samples than median?
|
The median is maximally robust to outliers, but highly susceptible to noise. If you introduce a small amount of noise to each point, it will enter the median undampened as long as the noise is small enough to not change the relative order of the points. For the mean it's the other way around. Noise is averaged out, but a single outlier can change the mean arbitrarily.
mean median
original [1.0, 2.0, 3.0, 4.0, 5.0] 3 3
noise [1.1, 1.9, 3.1, 4.1, 4.9] 3.02 3.1
outlier [100, 2.0, 3.0, 4.0, 5.0] 22.8 4
Your test mostly measures robustness to noise, but you can easily create a sample where the median performs better. If you want an estimator that is robust to both outliers and noise, just throw away the top and bottom third and average the remainder.
|
Why does mean tend be more stable in different samples than median?
|
The median is maximally robust to outliers, but highly susceptible to noise. If you introduce a small amount of noise to each point, it will enter the median undampened as long as the noise is small e
|
Why does mean tend be more stable in different samples than median?
The median is maximally robust to outliers, but highly susceptible to noise. If you introduce a small amount of noise to each point, it will enter the median undampened as long as the noise is small enough to not change the relative order of the points. For the mean it's the other way around. Noise is averaged out, but a single outlier can change the mean arbitrarily.
mean median
original [1.0, 2.0, 3.0, 4.0, 5.0] 3 3
noise [1.1, 1.9, 3.1, 4.1, 4.9] 3.02 3.1
outlier [100, 2.0, 3.0, 4.0, 5.0] 22.8 4
Your test mostly measures robustness to noise, but you can easily create a sample where the median performs better. If you want an estimator that is robust to both outliers and noise, just throw away the top and bottom third and average the remainder.
|
Why does mean tend be more stable in different samples than median?
The median is maximally robust to outliers, but highly susceptible to noise. If you introduce a small amount of noise to each point, it will enter the median undampened as long as the noise is small e
|
10,962
|
Why does mean tend be more stable in different samples than median?
|
As @whuber and others have said, the statement is not true in general. And if you’re willing to be more intuitive — I can’t keep up with the deep math geeks around here — you might look at other ways mean and median are stable or not. For these examples, assume an odd number of points so I can keep my descriptions consistent and simple.
Imagine you have spread of points on a number line. Now imagine you take all of the points above the middle and move them up to 10x their values. The median is unchanged, the mean moved significantly. So the median seems more stable.
Now imagine these points are fairly spread out. Move the center point up and down. A one-unit move changes the median by one, but barely moved the mean. The median now seems less stable and more sensitive to small movements of a single point.
Now imagine taking the highest point and moving it smoothly from the highest to the lowest point. The mean will also smoothly move. But the median will not move continuously: it won’t move at all until your high point becomes lower than the previous median, then it starts following the point until it goes below the next point, then the median sticks to that point and again doesn’t move as you continue moving your point downwards. [Edited per comment]
So different transformations of your points cause either mean or median to look less smooth or stable in some sense. The math heavy-hitters here have shown you distributions from which you can sample, which more closely matches your experiment, but hopefully this intuition helps as well.
|
Why does mean tend be more stable in different samples than median?
|
As @whuber and others have said, the statement is not true in general. And if you’re willing to be more intuitive — I can’t keep up with the deep math geeks around here — you might look at other ways
|
Why does mean tend be more stable in different samples than median?
As @whuber and others have said, the statement is not true in general. And if you’re willing to be more intuitive — I can’t keep up with the deep math geeks around here — you might look at other ways mean and median are stable or not. For these examples, assume an odd number of points so I can keep my descriptions consistent and simple.
Imagine you have spread of points on a number line. Now imagine you take all of the points above the middle and move them up to 10x their values. The median is unchanged, the mean moved significantly. So the median seems more stable.
Now imagine these points are fairly spread out. Move the center point up and down. A one-unit move changes the median by one, but barely moved the mean. The median now seems less stable and more sensitive to small movements of a single point.
Now imagine taking the highest point and moving it smoothly from the highest to the lowest point. The mean will also smoothly move. But the median will not move continuously: it won’t move at all until your high point becomes lower than the previous median, then it starts following the point until it goes below the next point, then the median sticks to that point and again doesn’t move as you continue moving your point downwards. [Edited per comment]
So different transformations of your points cause either mean or median to look less smooth or stable in some sense. The math heavy-hitters here have shown you distributions from which you can sample, which more closely matches your experiment, but hopefully this intuition helps as well.
|
Why does mean tend be more stable in different samples than median?
As @whuber and others have said, the statement is not true in general. And if you’re willing to be more intuitive — I can’t keep up with the deep math geeks around here — you might look at other ways
|
10,963
|
Why does mean tend be more stable in different samples than median?
|
Suppose you have $n$ data points from some underlying continuous distribution with mean $\mu$ and variance $\sigma^2 < \infty$. Let $f$ be the density function for this distribution and let $m$ be its median. To simplify this result further, let $\tilde{f}$ be the corresponding standardised density function, given by $\tilde{f}(z) = \sigma \cdot f(\mu+\sigma z)$ for all $z \in \mathbb{R}$. The asymptotic variance of the sample mean and sample median are given respectively by:
$$\mathbb{V}(\bar{X}_n) = \frac{\sigma^2}{n}
\quad \quad \quad \quad \quad
\mathbb{V}(\tilde{X}_n) \rightarrow \frac{\sigma^2}{n} \cdot \frac{1}{4} \cdot \tilde{f}\Big( \frac{m-\mu}{\sigma} \Big)^{-2}.$$
We therefore have:
$$\frac{\mathbb{V}(\bar{X}_n)}{\mathbb{V}(\tilde{X}_n)} \rightarrow 4 \cdot \tilde{f}\Big( \frac{m-\mu}{\sigma} \Big)^2.$$
As you can see, the relative size of the variance of the sample mean and sample median is determined (asymptotically) by the standardised density value at the true median. Thus, for large $n$ we have the asymptotic correspondence:
$$\mathbb{V}(\bar{X}_n) < \mathbb{V}(\tilde{X}_n)
\quad \quad \iff \quad \quad
f_* \equiv \tilde{f} \Big( \frac{m-\mu}{\sigma} \Big) < \frac{1}{2}.$$
That is, for large $n$, and speaking asymptotically, the variance of the sample mean will be lower than the variance of the sample median if and only if the standardised density at the standardised median value is less than one-half. The data you used in your simulation example was generated from a normal distribution, so you have $f_* = 1 / \sqrt{2 \pi} = 0.3989423 < 1/2$. Thus, it is unsurprising that you found a higher variance for the sample median in that example.
|
Why does mean tend be more stable in different samples than median?
|
Suppose you have $n$ data points from some underlying continuous distribution with mean $\mu$ and variance $\sigma^2 < \infty$. Let $f$ be the density function for this distribution and let $m$ be it
|
Why does mean tend be more stable in different samples than median?
Suppose you have $n$ data points from some underlying continuous distribution with mean $\mu$ and variance $\sigma^2 < \infty$. Let $f$ be the density function for this distribution and let $m$ be its median. To simplify this result further, let $\tilde{f}$ be the corresponding standardised density function, given by $\tilde{f}(z) = \sigma \cdot f(\mu+\sigma z)$ for all $z \in \mathbb{R}$. The asymptotic variance of the sample mean and sample median are given respectively by:
$$\mathbb{V}(\bar{X}_n) = \frac{\sigma^2}{n}
\quad \quad \quad \quad \quad
\mathbb{V}(\tilde{X}_n) \rightarrow \frac{\sigma^2}{n} \cdot \frac{1}{4} \cdot \tilde{f}\Big( \frac{m-\mu}{\sigma} \Big)^{-2}.$$
We therefore have:
$$\frac{\mathbb{V}(\bar{X}_n)}{\mathbb{V}(\tilde{X}_n)} \rightarrow 4 \cdot \tilde{f}\Big( \frac{m-\mu}{\sigma} \Big)^2.$$
As you can see, the relative size of the variance of the sample mean and sample median is determined (asymptotically) by the standardised density value at the true median. Thus, for large $n$ we have the asymptotic correspondence:
$$\mathbb{V}(\bar{X}_n) < \mathbb{V}(\tilde{X}_n)
\quad \quad \iff \quad \quad
f_* \equiv \tilde{f} \Big( \frac{m-\mu}{\sigma} \Big) < \frac{1}{2}.$$
That is, for large $n$, and speaking asymptotically, the variance of the sample mean will be lower than the variance of the sample median if and only if the standardised density at the standardised median value is less than one-half. The data you used in your simulation example was generated from a normal distribution, so you have $f_* = 1 / \sqrt{2 \pi} = 0.3989423 < 1/2$. Thus, it is unsurprising that you found a higher variance for the sample median in that example.
|
Why does mean tend be more stable in different samples than median?
Suppose you have $n$ data points from some underlying continuous distribution with mean $\mu$ and variance $\sigma^2 < \infty$. Let $f$ be the density function for this distribution and let $m$ be it
|
10,964
|
Why does mean tend be more stable in different samples than median?
|
Comment: Just to echo back your simulation, using a distribution for which SDs of means and medians have the opposite result:
Specifically, nums are now from a Laplace distribution (also called 'double exponential'), which can be simulated as the difference of two exponential distribution with the same rate (here the default rate 1).
[Perhaps see Wikipedia on Laplace distributions.]
set.seed(2019)
nums = rexp(10^6) - rexp(10^6)
means=vector(mode = "numeric")
medians=vector(mode = "numeric")
for (i in 1:10^3) { b = sample(x=nums, 10^2);
medians[i]= median(b); means[i]=mean(b) }
sd(means)
[1] 0.1442126
sd(medians)
[1] 0.1095946 # <-- smaller
hist(nums, prob=T, br=70, ylim=c(0,.5), col="skyblue2")
curve(.5*exp(-abs(x)), add=T, col="red")
Note: Another easy possibility, explicitly mentioned in @whuber's link, is Cauchy, which
can be simulated as Student's t distribution with one degree of freedom, rt(10^6, 1). However, its tails are so heavy that making a nice histogram is problematic.
|
Why does mean tend be more stable in different samples than median?
|
Comment: Just to echo back your simulation, using a distribution for which SDs of means and medians have the opposite result:
Specifically, nums are now from a Laplace distribution (also called 'doubl
|
Why does mean tend be more stable in different samples than median?
Comment: Just to echo back your simulation, using a distribution for which SDs of means and medians have the opposite result:
Specifically, nums are now from a Laplace distribution (also called 'double exponential'), which can be simulated as the difference of two exponential distribution with the same rate (here the default rate 1).
[Perhaps see Wikipedia on Laplace distributions.]
set.seed(2019)
nums = rexp(10^6) - rexp(10^6)
means=vector(mode = "numeric")
medians=vector(mode = "numeric")
for (i in 1:10^3) { b = sample(x=nums, 10^2);
medians[i]= median(b); means[i]=mean(b) }
sd(means)
[1] 0.1442126
sd(medians)
[1] 0.1095946 # <-- smaller
hist(nums, prob=T, br=70, ylim=c(0,.5), col="skyblue2")
curve(.5*exp(-abs(x)), add=T, col="red")
Note: Another easy possibility, explicitly mentioned in @whuber's link, is Cauchy, which
can be simulated as Student's t distribution with one degree of freedom, rt(10^6, 1). However, its tails are so heavy that making a nice histogram is problematic.
|
Why does mean tend be more stable in different samples than median?
Comment: Just to echo back your simulation, using a distribution for which SDs of means and medians have the opposite result:
Specifically, nums are now from a Laplace distribution (also called 'doubl
|
10,965
|
What can one conclude about the data when arithmetic mean is very close to geometric mean?
|
The arithmetic mean is related to the geometric mean through the Arithmetic-Mean-Geometric-Mean (AMGM) inequality which states that:
$$\frac{x_1+x_2+\cdots+x_n} n \geq \sqrt[n]{x_1 x_2\cdots x_n},$$
where equality is achieved iff $x_1=x_2=\cdots=x_n$. So probably your data points are all very close to each other.
|
What can one conclude about the data when arithmetic mean is very close to geometric mean?
|
The arithmetic mean is related to the geometric mean through the Arithmetic-Mean-Geometric-Mean (AMGM) inequality which states that:
$$\frac{x_1+x_2+\cdots+x_n} n \geq \sqrt[n]{x_1 x_2\cdots x_n},$$
w
|
What can one conclude about the data when arithmetic mean is very close to geometric mean?
The arithmetic mean is related to the geometric mean through the Arithmetic-Mean-Geometric-Mean (AMGM) inequality which states that:
$$\frac{x_1+x_2+\cdots+x_n} n \geq \sqrt[n]{x_1 x_2\cdots x_n},$$
where equality is achieved iff $x_1=x_2=\cdots=x_n$. So probably your data points are all very close to each other.
|
What can one conclude about the data when arithmetic mean is very close to geometric mean?
The arithmetic mean is related to the geometric mean through the Arithmetic-Mean-Geometric-Mean (AMGM) inequality which states that:
$$\frac{x_1+x_2+\cdots+x_n} n \geq \sqrt[n]{x_1 x_2\cdots x_n},$$
w
|
10,966
|
What can one conclude about the data when arithmetic mean is very close to geometric mean?
|
Elaborating on the answer of @Alex R, one way to see the AMGM inequality is as a Jensen's inequality effect. By Jensen's inequality:
$$ \log\left( \frac{1}{n} \sum_i x_i \right) \geq \frac{1}{n} \sum_i \log x_i $$
Then take the exponential of both sides:
$$ \frac{1}{n} \sum_i x_i \geq \exp\left( \frac{1}{n} \sum_i \log x_i \right) $$
The right hand side is the geometric mean since $ \left(x_1 \cdot x_2 \cdot \ldots \cdot x_n \right)^{1/n}
= \exp\left(\frac{1}{n} \sum_i \log x_i \right) $
When does the AMGM inequality hold with near equality? When the Jensen's inequality effect is small. What drives the Jensen's inequality effect here is the concavity, the curvature of the logarithm. If your data is spread across an area where the logarithm has curvature, the effect will be big. If your data is spread across a region where the logarithm is basically affine, then the effect will be small.
For example, if the data has little variation, is clumped together in a sufficiently small neighborhood, then the logarithm will look like an affine function in that region (a theme of calculus is that if you zoom in enough on smooth, continuous function, that it will look like a line). For data sufficiently close together, the arithmetic mean of the data will be close to the geometric mean.
|
What can one conclude about the data when arithmetic mean is very close to geometric mean?
|
Elaborating on the answer of @Alex R, one way to see the AMGM inequality is as a Jensen's inequality effect. By Jensen's inequality:
$$ \log\left( \frac{1}{n} \sum_i x_i \right) \geq \frac{1}{n} \su
|
What can one conclude about the data when arithmetic mean is very close to geometric mean?
Elaborating on the answer of @Alex R, one way to see the AMGM inequality is as a Jensen's inequality effect. By Jensen's inequality:
$$ \log\left( \frac{1}{n} \sum_i x_i \right) \geq \frac{1}{n} \sum_i \log x_i $$
Then take the exponential of both sides:
$$ \frac{1}{n} \sum_i x_i \geq \exp\left( \frac{1}{n} \sum_i \log x_i \right) $$
The right hand side is the geometric mean since $ \left(x_1 \cdot x_2 \cdot \ldots \cdot x_n \right)^{1/n}
= \exp\left(\frac{1}{n} \sum_i \log x_i \right) $
When does the AMGM inequality hold with near equality? When the Jensen's inequality effect is small. What drives the Jensen's inequality effect here is the concavity, the curvature of the logarithm. If your data is spread across an area where the logarithm has curvature, the effect will be big. If your data is spread across a region where the logarithm is basically affine, then the effect will be small.
For example, if the data has little variation, is clumped together in a sufficiently small neighborhood, then the logarithm will look like an affine function in that region (a theme of calculus is that if you zoom in enough on smooth, continuous function, that it will look like a line). For data sufficiently close together, the arithmetic mean of the data will be close to the geometric mean.
|
What can one conclude about the data when arithmetic mean is very close to geometric mean?
Elaborating on the answer of @Alex R, one way to see the AMGM inequality is as a Jensen's inequality effect. By Jensen's inequality:
$$ \log\left( \frac{1}{n} \sum_i x_i \right) \geq \frac{1}{n} \su
|
10,967
|
What can one conclude about the data when arithmetic mean is very close to geometric mean?
|
Let's investigate the range of $x_1\le x_2 \le \cdots \le x_n$ given that their arithmetic mean (AM) is a small multiple $1+\delta$ of their geometric mean (GM) (with $\delta \ge 0$). In the question, $\delta\approx 0.001$ but we don't know $n$.
Since the ratio of these means does not change when the units of measurement are changed, pick a unit for which the GM is $1$. Thus, we seek to maximize $x_n$ subject to the constraint that $x_1+x_2+\cdots+x_n = n(1+\delta)$ and $x_1\cdot x_2\cdots x_n = 1$.
This will be done by making $x_1=x_2=\cdots=x_{n-1}=x$, say, and $x_n=z \ge x$. Thus
$$n(1+\delta) = x_1 + \cdots + x_n = (n-1)x + z$$
and
$$1 = x_1\cdot x_2 \cdots x_n = x^{n-1}z.$$
The solution $x$ is a root between $0$ and $1$ of
$$(1-n)x^n + n(1+\delta)x^{n-1} - 1.$$
It is easily found iteratively. Here are the graphs of the optimal $x$ and $z$ as a function of $\delta$ for $n=6, 20, 50, 150$, left to right:
As soon as $n$ reaches any appreciable size, even a tiny ratio of $1.001$ is consistent with one large outlying $x_n$ (the upper red curves) and a group of tightly clustered $x_i$ (the lower blue curves).
At the other extreme, suppose $n=2k$ is even (for simplicity). The minimum range is achieved when half the $x_i$ equal one value $x \le 1$ and the other half equal another value $z \ge 1$. Now the solution (which is easily checked) is
$$x^k = 1+\delta \pm \sqrt{\delta^2 + 2\delta}.$$
For tiny $\delta$, we may ignore the $\delta^2$ as an approximation and also approximate the $k^\text{th}$ root to first order, giving
$$x \approx 1 + \frac{\delta-\sqrt{2\delta}}{k};\ z \approx 1 + \frac{\delta+\sqrt{2\delta}}{k}.$$
The range is approximately $\sqrt{32\delta}/n$.
In this manner we have obtained upper and lower bounds on the possible range of the data. We have learned that they depend heavily on the amount of data $n$. The upper bound shows the range can be appreciable even for tiny $\delta$, thereby improving our sense of just how close to each other the data points really need to be--and placing a lower limit on their range, too.
Similar analyses, just as easily carried out, can inform you--quantitatively--of how tightly clustered the $x_i$ might be in terms of any other measure of spread, such as their variance or coefficient of variation.
|
What can one conclude about the data when arithmetic mean is very close to geometric mean?
|
Let's investigate the range of $x_1\le x_2 \le \cdots \le x_n$ given that their arithmetic mean (AM) is a small multiple $1+\delta$ of their geometric mean (GM) (with $\delta \ge 0$). In the question
|
What can one conclude about the data when arithmetic mean is very close to geometric mean?
Let's investigate the range of $x_1\le x_2 \le \cdots \le x_n$ given that their arithmetic mean (AM) is a small multiple $1+\delta$ of their geometric mean (GM) (with $\delta \ge 0$). In the question, $\delta\approx 0.001$ but we don't know $n$.
Since the ratio of these means does not change when the units of measurement are changed, pick a unit for which the GM is $1$. Thus, we seek to maximize $x_n$ subject to the constraint that $x_1+x_2+\cdots+x_n = n(1+\delta)$ and $x_1\cdot x_2\cdots x_n = 1$.
This will be done by making $x_1=x_2=\cdots=x_{n-1}=x$, say, and $x_n=z \ge x$. Thus
$$n(1+\delta) = x_1 + \cdots + x_n = (n-1)x + z$$
and
$$1 = x_1\cdot x_2 \cdots x_n = x^{n-1}z.$$
The solution $x$ is a root between $0$ and $1$ of
$$(1-n)x^n + n(1+\delta)x^{n-1} - 1.$$
It is easily found iteratively. Here are the graphs of the optimal $x$ and $z$ as a function of $\delta$ for $n=6, 20, 50, 150$, left to right:
As soon as $n$ reaches any appreciable size, even a tiny ratio of $1.001$ is consistent with one large outlying $x_n$ (the upper red curves) and a group of tightly clustered $x_i$ (the lower blue curves).
At the other extreme, suppose $n=2k$ is even (for simplicity). The minimum range is achieved when half the $x_i$ equal one value $x \le 1$ and the other half equal another value $z \ge 1$. Now the solution (which is easily checked) is
$$x^k = 1+\delta \pm \sqrt{\delta^2 + 2\delta}.$$
For tiny $\delta$, we may ignore the $\delta^2$ as an approximation and also approximate the $k^\text{th}$ root to first order, giving
$$x \approx 1 + \frac{\delta-\sqrt{2\delta}}{k};\ z \approx 1 + \frac{\delta+\sqrt{2\delta}}{k}.$$
The range is approximately $\sqrt{32\delta}/n$.
In this manner we have obtained upper and lower bounds on the possible range of the data. We have learned that they depend heavily on the amount of data $n$. The upper bound shows the range can be appreciable even for tiny $\delta$, thereby improving our sense of just how close to each other the data points really need to be--and placing a lower limit on their range, too.
Similar analyses, just as easily carried out, can inform you--quantitatively--of how tightly clustered the $x_i$ might be in terms of any other measure of spread, such as their variance or coefficient of variation.
|
What can one conclude about the data when arithmetic mean is very close to geometric mean?
Let's investigate the range of $x_1\le x_2 \le \cdots \le x_n$ given that their arithmetic mean (AM) is a small multiple $1+\delta$ of their geometric mean (GM) (with $\delta \ge 0$). In the question
|
10,968
|
Functional principal component analysis (FPCA): what is it all about?
|
Exactly, as you state in the question and as @tdc puts in his answer, in case of extremely high dimensions even if the geometric properties of PCA remain valid, the covariance matrix is no longer a good estimate of the real population covariance.
There's a very interesting paper "Functional Principal Component
Analysis of fMRI Data" (pdf) where they use functional PCA to visualize the variance:
...As in other explorative techniques, the objective is that of providing an initial assessment that will give the data a chance “to speak for themselves” before an appropriate model is chosen. [...]
In the paper they explain how exactly they've done it, and also provide theoretical reasoning:
The decisive advantage of this approach consists in the possibility of specifying a set of assumptions in the choice of the basis function set and in the error functional minimized by the fit. These assumptions will be weaker than the specification of a predefined hemodynamic function and a set of events or conditions as in F-masking, thus preserving the exploratory character of the procedure; however, the assumptions might remain stringent enough to overcome the difficulties of ordinary PCA.
|
Functional principal component analysis (FPCA): what is it all about?
|
Exactly, as you state in the question and as @tdc puts in his answer, in case of extremely high dimensions even if the geometric properties of PCA remain valid, the covariance matrix is no longer a go
|
Functional principal component analysis (FPCA): what is it all about?
Exactly, as you state in the question and as @tdc puts in his answer, in case of extremely high dimensions even if the geometric properties of PCA remain valid, the covariance matrix is no longer a good estimate of the real population covariance.
There's a very interesting paper "Functional Principal Component
Analysis of fMRI Data" (pdf) where they use functional PCA to visualize the variance:
...As in other explorative techniques, the objective is that of providing an initial assessment that will give the data a chance “to speak for themselves” before an appropriate model is chosen. [...]
In the paper they explain how exactly they've done it, and also provide theoretical reasoning:
The decisive advantage of this approach consists in the possibility of specifying a set of assumptions in the choice of the basis function set and in the error functional minimized by the fit. These assumptions will be weaker than the specification of a predefined hemodynamic function and a set of events or conditions as in F-masking, thus preserving the exploratory character of the procedure; however, the assumptions might remain stringent enough to overcome the difficulties of ordinary PCA.
|
Functional principal component analysis (FPCA): what is it all about?
Exactly, as you state in the question and as @tdc puts in his answer, in case of extremely high dimensions even if the geometric properties of PCA remain valid, the covariance matrix is no longer a go
|
10,969
|
Functional principal component analysis (FPCA): what is it all about?
|
I find "functional PCA" an unnecessarily confusing notion. It is not a separate thing at all, it is standard PCA applied to time series.
FPCA refers to the situations when each of the $n$ observations is a time series (i.e. a "function") observed at $t$ time points, so that the whole data matrix is of $n \times t$ size. Usually $t\gg n$, e.g. one can have $20$ time series sampled at $1000$ time points each. The point of the analysis is to find several "eigen-time-series" (also of length $t$), i.e. eigenvectors of the covariance matrix, that would describe "typical" shape of the observed time series.
One can definitely apply the standard PCA here. Apparently, in your quote the author is concerned that the resulting eigen-time-series will be too noisy. This can happen indeed! Two obvious ways to deal with that would be (a) to smooth the resulting eigen-time-series after PCA, or (b) to smooth the original time series before doing PCA.
A less obvious, more fancy, but almost equivalent approach, is to approximate each original time series with $k$ basis functions, effectively reducing the dimensionality from $t$ to $k$. Then one can perform PCA and obtain the eigen-time-series approximated by the same basis functions. This is what one usually sees in the FPCA tutorials. One would usually use smooth basis functions (Gaussians, or Fourier components), so as far as I can see this is essentially equivalent to the brain-dead simple option (b) above.
Tutorials on FPCA usually go into lengthy discussions of how to generalize PCA to the functional spaces of infinite dimensionality, but the practical relevance of that is totally beyond me, as in practice the functional data are always discretized to begin with.
Here is an illustration taken from Ramsay and Silverman "Functional Data Analysis" textbook, which seems to be the definitive monograph on "functional data analysis" including FPCA:
One can see that doing PCA on the "discretized data" (points) yields practically the same thing as doing FPCA on corresponding functions in Fourier basis (lines). Of course one could first do the discrete PCA and then fit a function in the same Fourier basis; it would yield more or less the same result.
PS. In this example $t=12$ which is a small number with $n>t$. Perhaps what the authors view as "functional PCA" in this case should result in a "function", i.e. "smooth curve", as opposed to 12 separate points. But this can be trivially approached by interpolating and then smoothing the resulting eigen-time-series. Again, it seems that "functional PCA" is not a separate thing, it is just an application of PCA.
|
Functional principal component analysis (FPCA): what is it all about?
|
I find "functional PCA" an unnecessarily confusing notion. It is not a separate thing at all, it is standard PCA applied to time series.
FPCA refers to the situations when each of the $n$ observations
|
Functional principal component analysis (FPCA): what is it all about?
I find "functional PCA" an unnecessarily confusing notion. It is not a separate thing at all, it is standard PCA applied to time series.
FPCA refers to the situations when each of the $n$ observations is a time series (i.e. a "function") observed at $t$ time points, so that the whole data matrix is of $n \times t$ size. Usually $t\gg n$, e.g. one can have $20$ time series sampled at $1000$ time points each. The point of the analysis is to find several "eigen-time-series" (also of length $t$), i.e. eigenvectors of the covariance matrix, that would describe "typical" shape of the observed time series.
One can definitely apply the standard PCA here. Apparently, in your quote the author is concerned that the resulting eigen-time-series will be too noisy. This can happen indeed! Two obvious ways to deal with that would be (a) to smooth the resulting eigen-time-series after PCA, or (b) to smooth the original time series before doing PCA.
A less obvious, more fancy, but almost equivalent approach, is to approximate each original time series with $k$ basis functions, effectively reducing the dimensionality from $t$ to $k$. Then one can perform PCA and obtain the eigen-time-series approximated by the same basis functions. This is what one usually sees in the FPCA tutorials. One would usually use smooth basis functions (Gaussians, or Fourier components), so as far as I can see this is essentially equivalent to the brain-dead simple option (b) above.
Tutorials on FPCA usually go into lengthy discussions of how to generalize PCA to the functional spaces of infinite dimensionality, but the practical relevance of that is totally beyond me, as in practice the functional data are always discretized to begin with.
Here is an illustration taken from Ramsay and Silverman "Functional Data Analysis" textbook, which seems to be the definitive monograph on "functional data analysis" including FPCA:
One can see that doing PCA on the "discretized data" (points) yields practically the same thing as doing FPCA on corresponding functions in Fourier basis (lines). Of course one could first do the discrete PCA and then fit a function in the same Fourier basis; it would yield more or less the same result.
PS. In this example $t=12$ which is a small number with $n>t$. Perhaps what the authors view as "functional PCA" in this case should result in a "function", i.e. "smooth curve", as opposed to 12 separate points. But this can be trivially approached by interpolating and then smoothing the resulting eigen-time-series. Again, it seems that "functional PCA" is not a separate thing, it is just an application of PCA.
|
Functional principal component analysis (FPCA): what is it all about?
I find "functional PCA" an unnecessarily confusing notion. It is not a separate thing at all, it is standard PCA applied to time series.
FPCA refers to the situations when each of the $n$ observations
|
10,970
|
Functional principal component analysis (FPCA): what is it all about?
|
I worked for several years with Jim Ramsay on FDA, so I can perhaps add a few clarifications to @amoeba's answer. I think on a practical level, @amoeba is basically right. At least, that's the conclusion I finally reached after studying FDA. However, the FDA framework gives an interesting theoretical insight into why smoothing the eigenvectors is more than just a kludge. It turns out that optmization in the function space, subject to an inner product that contains a smoothness penalty, gives a finite dimensional solution of basis splines. FDA uses the infinite dimensional function space, but the analysis does not require an infinite number of dimensions. It's like the kernel trick in Gaussian processes or SVM's. It's a lot like the kernel trick, actually.
Ramsay's original work dealt with situations where the main story in the data is obvious: the functions are more or less linear, or more or less periodic. The dominant eigenvectors of standard PCA will just reflect the overall level of the functions and the linear trend (or sine functions), basically telling us what we already know. The interesting features lie in the residuals, which are now several eigenvectors from the top of the list. And since each subsequent eigenvector has to be orthogonal to the previous ones, these constructs depend more and more on artifacts of the analysis and less on relevant features of the data. In factor analysis, oblique factor rotation aims to resolve this problem. Ramsay's idea was not to rotate the components, but rather to change the definition of orthogonality in a way that would better reflect the needs of the analysis. This meant that if you were concerned with periodic components, you would smooth on the basis of $D^3-D$, which eliminates sines and consines. If you wanted to remove a linear trend, you would smooth on the basis of $D^2$ which gives standard cubic splines.
One might object that it would be simpler to remove the trend with OLS and examine the residuals of that operation. I was never convinced that the value add of FDA was worth the enormous complexity of the method. But from a theoretical standpoint, it is worth considering the issues involved. Everything we do to the data messes things up. The residuals of OLS are correlated, even when the original data were independent. Smoothing a time series introduces autocorrelations that were not in the raw series. The idea of FDA was to ensure that the residuals we got from initial detrending were suited to the analysis of interest.
You have to remember that FDA originated in the early 80's when spline functions were under active study - think of Grace Wahba and her team. Many approaches to multivariate data have emerged since then - like SEM, growth curve analysis, Gaussian processes, further developments in stochastic process theory, and many more. I'm not sure that FDA remains the best approach to the questions it addresses. On the other hand, when I see applications of what purports to be FDA, I often wonder if the authors really understand what FDA was trying to do.
|
Functional principal component analysis (FPCA): what is it all about?
|
I worked for several years with Jim Ramsay on FDA, so I can perhaps add a few clarifications to @amoeba's answer. I think on a practical level, @amoeba is basically right. At least, that's the conclus
|
Functional principal component analysis (FPCA): what is it all about?
I worked for several years with Jim Ramsay on FDA, so I can perhaps add a few clarifications to @amoeba's answer. I think on a practical level, @amoeba is basically right. At least, that's the conclusion I finally reached after studying FDA. However, the FDA framework gives an interesting theoretical insight into why smoothing the eigenvectors is more than just a kludge. It turns out that optmization in the function space, subject to an inner product that contains a smoothness penalty, gives a finite dimensional solution of basis splines. FDA uses the infinite dimensional function space, but the analysis does not require an infinite number of dimensions. It's like the kernel trick in Gaussian processes or SVM's. It's a lot like the kernel trick, actually.
Ramsay's original work dealt with situations where the main story in the data is obvious: the functions are more or less linear, or more or less periodic. The dominant eigenvectors of standard PCA will just reflect the overall level of the functions and the linear trend (or sine functions), basically telling us what we already know. The interesting features lie in the residuals, which are now several eigenvectors from the top of the list. And since each subsequent eigenvector has to be orthogonal to the previous ones, these constructs depend more and more on artifacts of the analysis and less on relevant features of the data. In factor analysis, oblique factor rotation aims to resolve this problem. Ramsay's idea was not to rotate the components, but rather to change the definition of orthogonality in a way that would better reflect the needs of the analysis. This meant that if you were concerned with periodic components, you would smooth on the basis of $D^3-D$, which eliminates sines and consines. If you wanted to remove a linear trend, you would smooth on the basis of $D^2$ which gives standard cubic splines.
One might object that it would be simpler to remove the trend with OLS and examine the residuals of that operation. I was never convinced that the value add of FDA was worth the enormous complexity of the method. But from a theoretical standpoint, it is worth considering the issues involved. Everything we do to the data messes things up. The residuals of OLS are correlated, even when the original data were independent. Smoothing a time series introduces autocorrelations that were not in the raw series. The idea of FDA was to ensure that the residuals we got from initial detrending were suited to the analysis of interest.
You have to remember that FDA originated in the early 80's when spline functions were under active study - think of Grace Wahba and her team. Many approaches to multivariate data have emerged since then - like SEM, growth curve analysis, Gaussian processes, further developments in stochastic process theory, and many more. I'm not sure that FDA remains the best approach to the questions it addresses. On the other hand, when I see applications of what purports to be FDA, I often wonder if the authors really understand what FDA was trying to do.
|
Functional principal component analysis (FPCA): what is it all about?
I worked for several years with Jim Ramsay on FDA, so I can perhaps add a few clarifications to @amoeba's answer. I think on a practical level, @amoeba is basically right. At least, that's the conclus
|
10,971
|
Functional principal component analysis (FPCA): what is it all about?
|
I'm not sure about FPCA, but one thing to remember, is that in extremely high dimensions, there is a lot more "space", and points within the space start to look uniformly distributed (i.e. everything is far from everything else). At this point the covariance matrix will start to look essentially uniform, and will be very highly sensitive to noise. It therefore becomes a bad estimate of the "true" covariance. Perhaps FPCA gets round this somehow, but I'm not sure.
|
Functional principal component analysis (FPCA): what is it all about?
|
I'm not sure about FPCA, but one thing to remember, is that in extremely high dimensions, there is a lot more "space", and points within the space start to look uniformly distributed (i.e. everything
|
Functional principal component analysis (FPCA): what is it all about?
I'm not sure about FPCA, but one thing to remember, is that in extremely high dimensions, there is a lot more "space", and points within the space start to look uniformly distributed (i.e. everything is far from everything else). At this point the covariance matrix will start to look essentially uniform, and will be very highly sensitive to noise. It therefore becomes a bad estimate of the "true" covariance. Perhaps FPCA gets round this somehow, but I'm not sure.
|
Functional principal component analysis (FPCA): what is it all about?
I'm not sure about FPCA, but one thing to remember, is that in extremely high dimensions, there is a lot more "space", and points within the space start to look uniformly distributed (i.e. everything
|
10,972
|
Functional principal component analysis (FPCA): what is it all about?
|
Wikipedia has a comprehensive introduction to the functional principal component analysis. But it is too rigorous for people who have little experience in maths or statistics.
The name of functional PCA is "misleading" in some sense since theoretically, it operates on a stochastic process composed of infinite functions, rather than finite sample functions. The smoothing is a numerical "correction" for the limited samples, as well as the "discontinuous" observance across the domain in reality (for example time).
The Karhunen-Loève theory is the foundation of the functional PCA. It is an "eigendecomposition" of a covariance function of a centered, square-integrable stochastic process in $L^2$ metric space. On the other hand, PCA is an "eigendecomposition" of the variance-covariance matrix calculated from a centered finite dataset in $R^p$ metric space (p variables). Many similarities share between functional PCA and PCA once the correct "working directory" is set. So you have to figure out what is a stochastic process, what is $L^2$ metric space, in the first place. They are quite intuitionally accessible.
a funny "fact",
$$
\lim \limits_{\substack{sample~size~of~functions~ \rightarrow ~\infty \\
"discontinuity"~of~f \rightarrow ~ 0} } PCA \longrightarrow fPCA
$$
without smoothing.
|
Functional principal component analysis (FPCA): what is it all about?
|
Wikipedia has a comprehensive introduction to the functional principal component analysis. But it is too rigorous for people who have little experience in maths or statistics.
The name of functional
|
Functional principal component analysis (FPCA): what is it all about?
Wikipedia has a comprehensive introduction to the functional principal component analysis. But it is too rigorous for people who have little experience in maths or statistics.
The name of functional PCA is "misleading" in some sense since theoretically, it operates on a stochastic process composed of infinite functions, rather than finite sample functions. The smoothing is a numerical "correction" for the limited samples, as well as the "discontinuous" observance across the domain in reality (for example time).
The Karhunen-Loève theory is the foundation of the functional PCA. It is an "eigendecomposition" of a covariance function of a centered, square-integrable stochastic process in $L^2$ metric space. On the other hand, PCA is an "eigendecomposition" of the variance-covariance matrix calculated from a centered finite dataset in $R^p$ metric space (p variables). Many similarities share between functional PCA and PCA once the correct "working directory" is set. So you have to figure out what is a stochastic process, what is $L^2$ metric space, in the first place. They are quite intuitionally accessible.
a funny "fact",
$$
\lim \limits_{\substack{sample~size~of~functions~ \rightarrow ~\infty \\
"discontinuity"~of~f \rightarrow ~ 0} } PCA \longrightarrow fPCA
$$
without smoothing.
|
Functional principal component analysis (FPCA): what is it all about?
Wikipedia has a comprehensive introduction to the functional principal component analysis. But it is too rigorous for people who have little experience in maths or statistics.
The name of functional
|
10,973
|
Alternatives to classification trees, with better predictive (e.g: CV) performance?
|
I think it would be worth giving a try to Random Forests (randomForest); some references were provided in response to related questions: Feature selection for “final” model when performing cross-validation in machine learning; Can CART models be made robust?. Boosting/bagging render them more stable than a single CART which is known to be very sensitive to small perturbations. Some authors argued that it performed as well as penalized SVM or Gradient Boosting Machines (see, e.g. Cutler et al., 2009). I think they certainly outperform NNs.
Boulesteix and Strobl provides a nice overview of several classifiers in Optimal classifier selection and negative bias in error rate estimation: an empirical study on high-dimensional prediction (BMC MRM 2009 9: 85). I've heard of another good study at the IV EAM meeting, which should be under review in Statistics in Medicine,
João Maroco, Dina Silva, Manuela Guerreiro, Alexandre de Mendonça. Do
Random Forests Outperform Neural
Networks, Support Vector Machines and
Discriminant Analysis classifiers? A
case study in the evolution to
dementia in elderly patients with
cognitive complaints
I also like the caret package: it is well documented and allows to compare predictive accuracy of different classifiers on the same data set. It takes care of managing training /test samples, computing accuracy, etc in few user-friendly functions.
The glmnet package, from Friedman and coll., implements penalized GLM (see the review in the Journal of Statistical Software), so you remain in a well-known modeling framework.
Otherwise, you can also look for association rules based classifiers (see the CRAN Task View on Machine Learning or the Top 10 algorithms in data mining for a gentle introduction to some of them).
I'd like to mention another interesting approach that I plan to re-implement in R (actually, it's Matlab code) which is Discriminant Correspondence Analysis from Hervé Abdi. Although initially developed to cope with small-sample studies with a lot of explanatory variables (eventually grouped into coherent blocks), it seems to efficiently combine classical DA with data reduction techniques.
References
Cutler, A., Cutler, D.R., and Stevens, J.R. (2009). Tree-Based Methods, in High-Dimensional Data Analysis in Cancer Research, Li, X. and Xu, R. (eds.), pp. 83-101, Springer.
Saeys, Y., Inza, I., and Larrañaga, P. (2007). A review of feature selection techniques in bioinformatics. Bioinformatics, 23(19): 2507-2517.
|
Alternatives to classification trees, with better predictive (e.g: CV) performance?
|
I think it would be worth giving a try to Random Forests (randomForest); some references were provided in response to related questions: Feature selection for “final” model when performing cross-valid
|
Alternatives to classification trees, with better predictive (e.g: CV) performance?
I think it would be worth giving a try to Random Forests (randomForest); some references were provided in response to related questions: Feature selection for “final” model when performing cross-validation in machine learning; Can CART models be made robust?. Boosting/bagging render them more stable than a single CART which is known to be very sensitive to small perturbations. Some authors argued that it performed as well as penalized SVM or Gradient Boosting Machines (see, e.g. Cutler et al., 2009). I think they certainly outperform NNs.
Boulesteix and Strobl provides a nice overview of several classifiers in Optimal classifier selection and negative bias in error rate estimation: an empirical study on high-dimensional prediction (BMC MRM 2009 9: 85). I've heard of another good study at the IV EAM meeting, which should be under review in Statistics in Medicine,
João Maroco, Dina Silva, Manuela Guerreiro, Alexandre de Mendonça. Do
Random Forests Outperform Neural
Networks, Support Vector Machines and
Discriminant Analysis classifiers? A
case study in the evolution to
dementia in elderly patients with
cognitive complaints
I also like the caret package: it is well documented and allows to compare predictive accuracy of different classifiers on the same data set. It takes care of managing training /test samples, computing accuracy, etc in few user-friendly functions.
The glmnet package, from Friedman and coll., implements penalized GLM (see the review in the Journal of Statistical Software), so you remain in a well-known modeling framework.
Otherwise, you can also look for association rules based classifiers (see the CRAN Task View on Machine Learning or the Top 10 algorithms in data mining for a gentle introduction to some of them).
I'd like to mention another interesting approach that I plan to re-implement in R (actually, it's Matlab code) which is Discriminant Correspondence Analysis from Hervé Abdi. Although initially developed to cope with small-sample studies with a lot of explanatory variables (eventually grouped into coherent blocks), it seems to efficiently combine classical DA with data reduction techniques.
References
Cutler, A., Cutler, D.R., and Stevens, J.R. (2009). Tree-Based Methods, in High-Dimensional Data Analysis in Cancer Research, Li, X. and Xu, R. (eds.), pp. 83-101, Springer.
Saeys, Y., Inza, I., and Larrañaga, P. (2007). A review of feature selection techniques in bioinformatics. Bioinformatics, 23(19): 2507-2517.
|
Alternatives to classification trees, with better predictive (e.g: CV) performance?
I think it would be worth giving a try to Random Forests (randomForest); some references were provided in response to related questions: Feature selection for “final” model when performing cross-valid
|
10,974
|
Alternatives to classification trees, with better predictive (e.g: CV) performance?
|
It's important to bear in mind that there's no one algorithm that's always better than others. As stated by Wolpert and Macready, "any two algorithms are equivalent when their performance is averaged across all possible problems." (See Wikipedia for details.)
For a given application, the "best" one is generally one that is most closely aligned to your application in terms of the assumptions it makes, the kinds of data it can handle, the hypotheses it can represent, and so on.
So it's a good idea to characterise your data according to criteria such as:
Do I have a very large data set or a modest one?
Is the dimensionality high?
Are variables numerical (continuous/discrete) or symbolic, or a mix, and/or can they be transformed if necessary?
Are variables likely to be largely independent or quite dependent?
Are there likely to be redundant, noisy, or irrelevant variables?
Do I want to be able to inspect the model generated and try to make sense of it?
By answering these, you can eliminate some algorithms and identify others as potentially relevant, and then maybe end up with a small set of candidate methods that you have intelligently chosen as likely to be useful.
Sorry not to give you a simple answer, but I hope this helps nonetheless!
|
Alternatives to classification trees, with better predictive (e.g: CV) performance?
|
It's important to bear in mind that there's no one algorithm that's always better than others. As stated by Wolpert and Macready, "any two algorithms are equivalent when their performance is averaged
|
Alternatives to classification trees, with better predictive (e.g: CV) performance?
It's important to bear in mind that there's no one algorithm that's always better than others. As stated by Wolpert and Macready, "any two algorithms are equivalent when their performance is averaged across all possible problems." (See Wikipedia for details.)
For a given application, the "best" one is generally one that is most closely aligned to your application in terms of the assumptions it makes, the kinds of data it can handle, the hypotheses it can represent, and so on.
So it's a good idea to characterise your data according to criteria such as:
Do I have a very large data set or a modest one?
Is the dimensionality high?
Are variables numerical (continuous/discrete) or symbolic, or a mix, and/or can they be transformed if necessary?
Are variables likely to be largely independent or quite dependent?
Are there likely to be redundant, noisy, or irrelevant variables?
Do I want to be able to inspect the model generated and try to make sense of it?
By answering these, you can eliminate some algorithms and identify others as potentially relevant, and then maybe end up with a small set of candidate methods that you have intelligently chosen as likely to be useful.
Sorry not to give you a simple answer, but I hope this helps nonetheless!
|
Alternatives to classification trees, with better predictive (e.g: CV) performance?
It's important to bear in mind that there's no one algorithm that's always better than others. As stated by Wolpert and Macready, "any two algorithms are equivalent when their performance is averaged
|
10,975
|
Alternatives to classification trees, with better predictive (e.g: CV) performance?
|
For multi-class classification, support vector machines are also a good choice. I typically use the the R kernlab package for this.
See the following JSS paper for a good discussion: http://www.jstatsoft.org/v15/i09/
|
Alternatives to classification trees, with better predictive (e.g: CV) performance?
|
For multi-class classification, support vector machines are also a good choice. I typically use the the R kernlab package for this.
See the following JSS paper for a good discussion: http://www.jstat
|
Alternatives to classification trees, with better predictive (e.g: CV) performance?
For multi-class classification, support vector machines are also a good choice. I typically use the the R kernlab package for this.
See the following JSS paper for a good discussion: http://www.jstatsoft.org/v15/i09/
|
Alternatives to classification trees, with better predictive (e.g: CV) performance?
For multi-class classification, support vector machines are also a good choice. I typically use the the R kernlab package for this.
See the following JSS paper for a good discussion: http://www.jstat
|
10,976
|
Alternatives to classification trees, with better predictive (e.g: CV) performance?
|
As already mentioned Random Forests are a natural "upgrade" and, these days, SVM are generally the recommended technique to use.
I want to add that more often than not switching to SVM yields very disappointing results. Thing is, whilst techniques like random trees are almost trivial to use, SVM are a bit trickier.
I found this paper invaluable back when I used SVM for the first time (A Practical Guide to Support Vector Classication) http://www.csie.ntu.edu.tw/~cjlin/papers/guide/guide.pdf
In R you can use the the e1071 package for SVM, it links against the de facto standard (in free software at least!) libSVM library.
|
Alternatives to classification trees, with better predictive (e.g: CV) performance?
|
As already mentioned Random Forests are a natural "upgrade" and, these days, SVM are generally the recommended technique to use.
I want to add that more often than not switching to SVM yields very d
|
Alternatives to classification trees, with better predictive (e.g: CV) performance?
As already mentioned Random Forests are a natural "upgrade" and, these days, SVM are generally the recommended technique to use.
I want to add that more often than not switching to SVM yields very disappointing results. Thing is, whilst techniques like random trees are almost trivial to use, SVM are a bit trickier.
I found this paper invaluable back when I used SVM for the first time (A Practical Guide to Support Vector Classication) http://www.csie.ntu.edu.tw/~cjlin/papers/guide/guide.pdf
In R you can use the the e1071 package for SVM, it links against the de facto standard (in free software at least!) libSVM library.
|
Alternatives to classification trees, with better predictive (e.g: CV) performance?
As already mentioned Random Forests are a natural "upgrade" and, these days, SVM are generally the recommended technique to use.
I want to add that more often than not switching to SVM yields very d
|
10,977
|
Alternatives to classification trees, with better predictive (e.g: CV) performance?
|
Its worth to take a look at Naive Bayes classifiers. In R you can perform Naive Bayes classification in the packages e1071 and klaR.
|
Alternatives to classification trees, with better predictive (e.g: CV) performance?
|
Its worth to take a look at Naive Bayes classifiers. In R you can perform Naive Bayes classification in the packages e1071 and klaR.
|
Alternatives to classification trees, with better predictive (e.g: CV) performance?
Its worth to take a look at Naive Bayes classifiers. In R you can perform Naive Bayes classification in the packages e1071 and klaR.
|
Alternatives to classification trees, with better predictive (e.g: CV) performance?
Its worth to take a look at Naive Bayes classifiers. In R you can perform Naive Bayes classification in the packages e1071 and klaR.
|
10,978
|
Is Fisher's LSD as bad as they say it is?
|
Fisher's LSD is indeed a series of pairwise t-tests, with each test using the mean squared error from the significant ANOVA as its pooled variance estimate (and naturally taking the associated degrees of freedom). That the ANOVA be significant is an additional constraint of this test.
It restricts family-wise error rate to alpha in the special case of 3 groups only. Howell has a very good and relatively simple explanation of how it does so in Chapter 16 of his book Fundamental Statistics for the Behavioral Sciences, 8th edition, David C. Howell.
Above 3 groups alpha inflates rapidly (as @Alexis has noted above). It is not certainly appropriate for 6 groups. I believe that it is this limited applicability that causes most people to suggest ignoring it as an option.
|
Is Fisher's LSD as bad as they say it is?
|
Fisher's LSD is indeed a series of pairwise t-tests, with each test using the mean squared error from the significant ANOVA as its pooled variance estimate (and naturally taking the associated degrees
|
Is Fisher's LSD as bad as they say it is?
Fisher's LSD is indeed a series of pairwise t-tests, with each test using the mean squared error from the significant ANOVA as its pooled variance estimate (and naturally taking the associated degrees of freedom). That the ANOVA be significant is an additional constraint of this test.
It restricts family-wise error rate to alpha in the special case of 3 groups only. Howell has a very good and relatively simple explanation of how it does so in Chapter 16 of his book Fundamental Statistics for the Behavioral Sciences, 8th edition, David C. Howell.
Above 3 groups alpha inflates rapidly (as @Alexis has noted above). It is not certainly appropriate for 6 groups. I believe that it is this limited applicability that causes most people to suggest ignoring it as an option.
|
Is Fisher's LSD as bad as they say it is?
Fisher's LSD is indeed a series of pairwise t-tests, with each test using the mean squared error from the significant ANOVA as its pooled variance estimate (and naturally taking the associated degrees
|
10,979
|
Is Fisher's LSD as bad as they say it is?
|
How important are multiple comparisons when dealing with 6 groups? Well... with six groups you are dealing with a maximum of $\frac{6(6-1)}{2} = 15$ possible post hoc pairwise comparisons. I will let the inestimable Randall Munroe address the importance of multiple comparisons:
And I will add that if, as in your opening sentence, you suggest that sometimes you have seven groups, then the maximum number of post hoc pairwise tests is $\frac{7(7-1)}{2} = 21$, which is far too similar to the jellybean scenario just presented (which also presents 21 tests ;). So, really, unless you want to world to mock you by repeatedly sending you copies of xkcd 882, I would just go ahead and perform multiple comparisons adjustments (either FWER, like the Bonferroni or Holm-Sidak, or FDR like Benjamini and Hochberg).
|
Is Fisher's LSD as bad as they say it is?
|
How important are multiple comparisons when dealing with 6 groups? Well... with six groups you are dealing with a maximum of $\frac{6(6-1)}{2} = 15$ possible post hoc pairwise comparisons. I will let
|
Is Fisher's LSD as bad as they say it is?
How important are multiple comparisons when dealing with 6 groups? Well... with six groups you are dealing with a maximum of $\frac{6(6-1)}{2} = 15$ possible post hoc pairwise comparisons. I will let the inestimable Randall Munroe address the importance of multiple comparisons:
And I will add that if, as in your opening sentence, you suggest that sometimes you have seven groups, then the maximum number of post hoc pairwise tests is $\frac{7(7-1)}{2} = 21$, which is far too similar to the jellybean scenario just presented (which also presents 21 tests ;). So, really, unless you want to world to mock you by repeatedly sending you copies of xkcd 882, I would just go ahead and perform multiple comparisons adjustments (either FWER, like the Bonferroni or Holm-Sidak, or FDR like Benjamini and Hochberg).
|
Is Fisher's LSD as bad as they say it is?
How important are multiple comparisons when dealing with 6 groups? Well... with six groups you are dealing with a maximum of $\frac{6(6-1)}{2} = 15$ possible post hoc pairwise comparisons. I will let
|
10,980
|
Is Fisher's LSD as bad as they say it is?
|
Fisher's test is as bad as everyone says it is from a Neyman-Pearson point of view and if you do what your question implies---after a significant ANOVA test each individual difference. You can see this in many published papers. But, testing all the differences after an ANOVA, or any of them, is neither necessary nor recommended. And, Fisher's test wasn't crafted under a Neyman-Pearson theory of statistical inference.
It is important to keep in mind that, when Fisher proposed the LSD, he didn't really consider multiple testing an important problem because he didn't consider the significance cutoff a hard and fast rule for deciding whether results were important or not. One could construct an LSD as an easy way to peruse the data for where there might be significant results but not the arbiter of what was meaningful. Remember, it was Fisher who said that you should just run more subjects if p > 0.05.
And why would you think that testing everything is a good idea? Consider why you run an ANOVA in the first place. You were probably taught that it's because running multiple t-tests is problematic, as you intimate in your question. Then why are you running them, or their equivalent afterward? I know it happens but I have yet to ever need to run a test after an ANOVA. An ANOVA tells you that your pattern of data is not a set of equal values, that there may be some meaning in there. Many people get hung up on the caution that the test does not tell you where the meaningful bits are but they forget that the data, and theories, tell you that.
|
Is Fisher's LSD as bad as they say it is?
|
Fisher's test is as bad as everyone says it is from a Neyman-Pearson point of view and if you do what your question implies---after a significant ANOVA test each individual difference. You can see thi
|
Is Fisher's LSD as bad as they say it is?
Fisher's test is as bad as everyone says it is from a Neyman-Pearson point of view and if you do what your question implies---after a significant ANOVA test each individual difference. You can see this in many published papers. But, testing all the differences after an ANOVA, or any of them, is neither necessary nor recommended. And, Fisher's test wasn't crafted under a Neyman-Pearson theory of statistical inference.
It is important to keep in mind that, when Fisher proposed the LSD, he didn't really consider multiple testing an important problem because he didn't consider the significance cutoff a hard and fast rule for deciding whether results were important or not. One could construct an LSD as an easy way to peruse the data for where there might be significant results but not the arbiter of what was meaningful. Remember, it was Fisher who said that you should just run more subjects if p > 0.05.
And why would you think that testing everything is a good idea? Consider why you run an ANOVA in the first place. You were probably taught that it's because running multiple t-tests is problematic, as you intimate in your question. Then why are you running them, or their equivalent afterward? I know it happens but I have yet to ever need to run a test after an ANOVA. An ANOVA tells you that your pattern of data is not a set of equal values, that there may be some meaning in there. Many people get hung up on the caution that the test does not tell you where the meaningful bits are but they forget that the data, and theories, tell you that.
|
Is Fisher's LSD as bad as they say it is?
Fisher's test is as bad as everyone says it is from a Neyman-Pearson point of view and if you do what your question implies---after a significant ANOVA test each individual difference. You can see thi
|
10,981
|
Is Fisher's LSD as bad as they say it is?
|
The reasoning behind Fisher's LSD can be extended to cases beyond N=3.
I'll discuss the case of four groups in detail. To keep the familywise Type-I error rate at 0.05 or below, a multiple-comparison correction factor of 3 (i.e. a per-comparison alpha of 0.05/3) suffices, although there are six post-hoc comparisons among the four groups. This is because:
in case all four true means are equal, the omnibus Anova over the four groups limits the familywise error rate to 0.05;
in case three of the true means are equal and the fourth differs from them, there are only three comparisons that could potentially yield a Type-I error;
in case two of the true means are equal and differ from the other two, which are equal to each other, there are only two comparisons that could potentially yield a Type-I error.
This exhausts the possibilities. In all cases, the probability of finding one or more p-values below 0.05 for groups whose true means are equal, stays at or below 0.05 if the correction factor for multiple comparisons is 3, and this is the definition of the familywise error rate.
This reasoning for four groups is a generalization from Fisher's explanation for his three-group Least Significant Difference method. For N groups, the correction factor, if the omnibus Anova test is significant, is (N-1)(N-2)/2. So the Bonferroni correction, by a factor of N(N-1)/2, is too strong. It suffices to use an alpha correction factor of 1 for N=3 (this is why Fisher's LSD works for N=3), a factor of 3 for N=4, a factor of 6 for N=5, a factor of 10 for N=6, and so on.
|
Is Fisher's LSD as bad as they say it is?
|
The reasoning behind Fisher's LSD can be extended to cases beyond N=3.
I'll discuss the case of four groups in detail. To keep the familywise Type-I error rate at 0.05 or below, a multiple-comparison
|
Is Fisher's LSD as bad as they say it is?
The reasoning behind Fisher's LSD can be extended to cases beyond N=3.
I'll discuss the case of four groups in detail. To keep the familywise Type-I error rate at 0.05 or below, a multiple-comparison correction factor of 3 (i.e. a per-comparison alpha of 0.05/3) suffices, although there are six post-hoc comparisons among the four groups. This is because:
in case all four true means are equal, the omnibus Anova over the four groups limits the familywise error rate to 0.05;
in case three of the true means are equal and the fourth differs from them, there are only three comparisons that could potentially yield a Type-I error;
in case two of the true means are equal and differ from the other two, which are equal to each other, there are only two comparisons that could potentially yield a Type-I error.
This exhausts the possibilities. In all cases, the probability of finding one or more p-values below 0.05 for groups whose true means are equal, stays at or below 0.05 if the correction factor for multiple comparisons is 3, and this is the definition of the familywise error rate.
This reasoning for four groups is a generalization from Fisher's explanation for his three-group Least Significant Difference method. For N groups, the correction factor, if the omnibus Anova test is significant, is (N-1)(N-2)/2. So the Bonferroni correction, by a factor of N(N-1)/2, is too strong. It suffices to use an alpha correction factor of 1 for N=3 (this is why Fisher's LSD works for N=3), a factor of 3 for N=4, a factor of 6 for N=5, a factor of 10 for N=6, and so on.
|
Is Fisher's LSD as bad as they say it is?
The reasoning behind Fisher's LSD can be extended to cases beyond N=3.
I'll discuss the case of four groups in detail. To keep the familywise Type-I error rate at 0.05 or below, a multiple-comparison
|
10,982
|
How to present box plot with an extreme outlier?
|
I'd say that with data like these you really need to show results on a transformed scale. That is the first imperative and a more important issue than precisely how to draw a box plot.
But I echo Frank Harrell in urging something more informative than a minimal box plot, even with some extreme points identified. You have enough space to show much more information. Here is one of many examples, a hybrid box and quantile plot. As in your data, there are two groups being compared.
I will take these two points one by one and say more.
Transformed scale
In the simplest case, all your values may be positive and you should then first try using a logarithmic scale.
If you have exact zeros, a square root or cube root scale will still improve the extreme skewness. Some people are happy with log(value + constant), where constant is most commonly 1, as a way of coping with zeros.
The implications for box plots of using a transformed scale are subtle.
If you use the common Tukey convention of showing individually all points beyond upper quartile + 1.5 IQR or lower quartile - 1.5 IQR, then arguably those limits should be calculated on the transformed scale. That is not the same as calculating those limits on the original scale, then transforming.
Instead I'd support what appears to be still a minority convention of selecting quantiles for the ends of whiskers. One of several advantages of that is that transform of quantile = quantile of transform, at least closely enough for graphical purposes in most cases. (The small print is whenever quantiles are calculated by linear interpolation between adjacent order statistics.)
This quantile convention was suggested fairly prominently by Cleveland (1985). For the record, enhanced box plots with boxes to quartiles, thinner boxes to outer octiles (12.5 and 87.5% points) and strip plots of data were used in geography and climatology by (e.g.) Matthews (1936) and Grove (1956), under the name "dispersion diagrams".
More than box plots
Box plots were re-invented by Tukey around 1970 and most visibly promoted in his 1977 book. Much of his purpose was to promote graphs that could be quickly drawn using pen(cil) and paper in informal exploration. He was also suggesting ways of identifying possible outliers. That was fine, but now we all have access to computers it's no pain to draw graphs showing, if not all the data, then at least much more detail. The summary role of box plots is valuable, but a graph can show the fine structure too, just in case it is interesting or important. (And what researchers think is uninteresting or unimportant might be more striking to their readers.)
There is plenty of room for polite disagreement about exactly what works best, but bare box plots have been rather oversold, in my view.
Stata users can find more on the program that drew the figure in this Statalist post. Users of other software should find no difficulty in drawing something as good or better (else why use that software?).
Cleveland, W.S. 1985. Elements of graphing data. Monterey, CA: Wadsworth.
Grove, A.T. 1956. Soil erosion in Nigeria. In Steel, R.W. and Fisher, C.A. (Eds)
Geographical essays on British tropical lands. London: George Philip, 79-111.
Matthews, H.A. 1936. A new view of some familiar Indian rainfalls. Scottish Geographical Magazine 52: 84-97.
Tukey, J.W. 1977. Exploratory data analysis. Reading, MA: Addison-Wesley.
|
How to present box plot with an extreme outlier?
|
I'd say that with data like these you really need to show results on a transformed scale. That is the first imperative and a more important issue than precisely how to draw a box plot.
But I echo Fr
|
How to present box plot with an extreme outlier?
I'd say that with data like these you really need to show results on a transformed scale. That is the first imperative and a more important issue than precisely how to draw a box plot.
But I echo Frank Harrell in urging something more informative than a minimal box plot, even with some extreme points identified. You have enough space to show much more information. Here is one of many examples, a hybrid box and quantile plot. As in your data, there are two groups being compared.
I will take these two points one by one and say more.
Transformed scale
In the simplest case, all your values may be positive and you should then first try using a logarithmic scale.
If you have exact zeros, a square root or cube root scale will still improve the extreme skewness. Some people are happy with log(value + constant), where constant is most commonly 1, as a way of coping with zeros.
The implications for box plots of using a transformed scale are subtle.
If you use the common Tukey convention of showing individually all points beyond upper quartile + 1.5 IQR or lower quartile - 1.5 IQR, then arguably those limits should be calculated on the transformed scale. That is not the same as calculating those limits on the original scale, then transforming.
Instead I'd support what appears to be still a minority convention of selecting quantiles for the ends of whiskers. One of several advantages of that is that transform of quantile = quantile of transform, at least closely enough for graphical purposes in most cases. (The small print is whenever quantiles are calculated by linear interpolation between adjacent order statistics.)
This quantile convention was suggested fairly prominently by Cleveland (1985). For the record, enhanced box plots with boxes to quartiles, thinner boxes to outer octiles (12.5 and 87.5% points) and strip plots of data were used in geography and climatology by (e.g.) Matthews (1936) and Grove (1956), under the name "dispersion diagrams".
More than box plots
Box plots were re-invented by Tukey around 1970 and most visibly promoted in his 1977 book. Much of his purpose was to promote graphs that could be quickly drawn using pen(cil) and paper in informal exploration. He was also suggesting ways of identifying possible outliers. That was fine, but now we all have access to computers it's no pain to draw graphs showing, if not all the data, then at least much more detail. The summary role of box plots is valuable, but a graph can show the fine structure too, just in case it is interesting or important. (And what researchers think is uninteresting or unimportant might be more striking to their readers.)
There is plenty of room for polite disagreement about exactly what works best, but bare box plots have been rather oversold, in my view.
Stata users can find more on the program that drew the figure in this Statalist post. Users of other software should find no difficulty in drawing something as good or better (else why use that software?).
Cleveland, W.S. 1985. Elements of graphing data. Monterey, CA: Wadsworth.
Grove, A.T. 1956. Soil erosion in Nigeria. In Steel, R.W. and Fisher, C.A. (Eds)
Geographical essays on British tropical lands. London: George Philip, 79-111.
Matthews, H.A. 1936. A new view of some familiar Indian rainfalls. Scottish Geographical Magazine 52: 84-97.
Tukey, J.W. 1977. Exploratory data analysis. Reading, MA: Addison-Wesley.
|
How to present box plot with an extreme outlier?
I'd say that with data like these you really need to show results on a transformed scale. That is the first imperative and a more important issue than precisely how to draw a box plot.
But I echo Fr
|
10,983
|
How to present box plot with an extreme outlier?
|
Not to take anything away from Nick's excellent answer, which I think is well worth a tick and an upvote - but I wanted to explore some possibilities.
With such heavily skew data across several orders of magnitude, plotting on a log-scale is often quite revealing; note that you can still have tick marks and tick mark labels in original values. (I agree with Nick's points relating to transformations, so I won't expand further on that.)
Another option besides transformation is to do something like your first plot, but include an indication of all values not plotted (so it has all the information of the full plot, but shows the main part of the data better):
$\ $
That way you're not removing outliers, just displaying them differently.
However, I'd join Frank and Nick in suggesting using a more informative display than a plain boxplot - the combination of a boxplot with quantile plot in Nick's post seems a particularly good notion, though one might plot the quantile plot lightly over (or under, as here) the corresponding box instead of beside it:
$\ $
If you're not doing something like that (just going with a plain boxplot, say),
I'd suggest substantially narrower boxes.
|
How to present box plot with an extreme outlier?
|
Not to take anything away from Nick's excellent answer, which I think is well worth a tick and an upvote - but I wanted to explore some possibilities.
With such heavily skew data across several orders
|
How to present box plot with an extreme outlier?
Not to take anything away from Nick's excellent answer, which I think is well worth a tick and an upvote - but I wanted to explore some possibilities.
With such heavily skew data across several orders of magnitude, plotting on a log-scale is often quite revealing; note that you can still have tick marks and tick mark labels in original values. (I agree with Nick's points relating to transformations, so I won't expand further on that.)
Another option besides transformation is to do something like your first plot, but include an indication of all values not plotted (so it has all the information of the full plot, but shows the main part of the data better):
$\ $
That way you're not removing outliers, just displaying them differently.
However, I'd join Frank and Nick in suggesting using a more informative display than a plain boxplot - the combination of a boxplot with quantile plot in Nick's post seems a particularly good notion, though one might plot the quantile plot lightly over (or under, as here) the corresponding box instead of beside it:
$\ $
If you're not doing something like that (just going with a plain boxplot, say),
I'd suggest substantially narrower boxes.
|
How to present box plot with an extreme outlier?
Not to take anything away from Nick's excellent answer, which I think is well worth a tick and an upvote - but I wanted to explore some possibilities.
With such heavily skew data across several orders
|
10,984
|
How to present box plot with an extreme outlier?
|
I prefer extended box plot or violin plots because they contain so much more information. I scale extended box plots to the 0.01 and 0.99 quantiles of the combined samples. See https://hbiostat.org/doc/graphscourse.pdf for details.
|
How to present box plot with an extreme outlier?
|
I prefer extended box plot or violin plots because they contain so much more information. I scale extended box plots to the 0.01 and 0.99 quantiles of the combined samples. See https://hbiostat.org/
|
How to present box plot with an extreme outlier?
I prefer extended box plot or violin plots because they contain so much more information. I scale extended box plots to the 0.01 and 0.99 quantiles of the combined samples. See https://hbiostat.org/doc/graphscourse.pdf for details.
|
How to present box plot with an extreme outlier?
I prefer extended box plot or violin plots because they contain so much more information. I scale extended box plots to the 0.01 and 0.99 quantiles of the combined samples. See https://hbiostat.org/
|
10,985
|
What are the disadvantages of using mean for missing values?
|
Example with normal data. Suppose the real data are a random sample of size $n=200$ from $\mathsf{Norm}(\mu=100, \sigma=15),$ but you don't know $\mu$ or $\sigma$ and seek to estimate them. In the example below I'd estimate $\mu$ by $\bar X = 100.21$ and $\sigma$ by $S = 14.5,$ Both estimates are pretty good. (Simulation and computations in R.)
set.seed(402) # for reproducibility
x = rnorm(200, 100, 15)
mean(x); sd(x)
# [1] 100.2051 # aprx 100
# [1] 14.5031 # aprx 15
Now suppose that 25% of these data are missing. (That's a large proportion, but I'm
trying to make a point.) If I replace the missing observations by the mean of the 150 non-missing observations, let's see what my estimates of $\mu$ and $\sigma$ would be.
x.nonmis = x[51:200] # for simplicity suppose first 50 are missing
x.imputd = c( rep(mean(x.nonmis), 50), x.nonmis )
length(x.imputd); mean(x.imputd); sd(x.imputd)
# [1] 200 # 'x.imputd' has proper length 200
# [1] 100.3445 # aprx 100
# [1] 12.58591 # much smaller than 15
Now we estimate $\mu$ as $\bar X_{imp} = 100.3,$ which is not a bad estimate, but potentially (as here) worse than the mean of the actual data. However, we now estimate $\sigma$ as $S_{imp} = 12.6,$ which is quite a bit below both the true $\sigma$ and its better estimate 14.5 from actual data.
Example with exponential data. If the data are strongly right-skewed (as for data from an exponential population), then replacing missing data with the mean of nonmissing data could mask the skewness so that we may be surprised that the data do not reflect how heavy the right tail of the population really is.
set.seed(2020) # for reproducibility
x = rexp(200, .01)
mean(x); sd(x)
# [1] 108.0259 # aprx 100
# [1] 110.1757 # aprx 100
x.nonmis = x[51:200] # for simplicity suppose first 50 are missing
x.imputd = c( rep(mean(x.nonmis), 50), x.nonmis )
length(x.imputd); mean(x.imputd); sd(x.imputd)
# [1] 200
# [1] 106.7967 # aprx 100
# [1] 89.21266 # smaller than 100
boxplot(x, x.imputd, col="skyblue2", main="Data: Actual (left) and Imputed")
The boxplot shows more skewness in the actual data (many observations in high tail)
than in the 'imputed' data.
Example with bimodal data. Again here, when we substitute missing values with
the mean of the nonmissing observations, the population standard deviation is underestimated. Perhaps more seriously, the large number of imputed values at the center of the 'imputed' sample masks the bimodal nature of the data.
set.seed(1234) # for reproducibility
x1 = rnorm(100, 85, 10); x2 = rnorm(100, 115, 10)
x = sample(c(x1,x2)) # randomly scramble order
mean(x); sd(x)
# [1] 99.42241
# [1] 18.97779
x.nonmis = x[51:200] # for simplicity suppose first 50 are missing
x.imputd = c( rep(mean(x.nonmis), 50), x.nonmis )
length(x.imputd); mean(x.imputd); sd(x.imputd)
# [1] 200
# [1] 99.16315
# [1] 16.41451
par(mfrow=c(1,2))
hist(x, prob=T, col="skyblue2", main="Actual")
hist(x.imputd, prob=T, col="skyblue2", main="Imputed")
par(mfrow=c(1,1))
In general: Replacing missing data by the mean of nonmissing data causes the population SD to be underestimated, but may also obscure important
features of the population from which the data were sampled.
Note: As @benso8 observes, using the mean of nonmissing data to replace missing observations is not always a bad idea. As mentioned in the Question, this method does reduce the variability. There will necessarily be drawbacks to any scheme
for dealing with missing data. The Question asked for speculation about possible disadvantages other than variance reduction for this method. I tried to illustrate a couple of possibilities in my last two examples.
Tentative alternative method: I am no expert in data mining. So I very tentatively propose an alternative method. I don't claim it's a new idea.
Instead of replacing all $m$ missing items with the sample mean of the nonmissing ones, one might take a random sample of size $m$ from among the nonmissing observations, and scale it so that the $m$ items have the same mean and SD as the nonmissing data. Then combine the rescaled $m$ items with the nonmissing ones to get an 'imputed' sample with nearly the same mean and SD as the nonmissing part of the sample.
The result should not systematically underestimate the population SD, and may better preserve features of the population such as skewness and bimodality. (Comments welcome.)
This idea is explored for bimodal data below:
set.seed(4321) # for reproducibility
x1 = rnorm(100, 85, 10); x2 = rnorm(100, 115, 10)
x = sample(c(x1,x2)) # scrmble
mean(x); sd(x)
# [1] 100.5299
# [1] 17.03368
x.nonmis = x[51:200] # for simplicity suppose first 50 are missing
an = mean(x.nonmis); sn = sd(x.nonmis)
x.subt = sample(x.nonmis, 50) # temporary unscaled substitutes
as = mean(x.subt); ss = sd(x.subt)
x.sub = ((x.subt - as)/ss)*sn + an # scaled substitutes
x.imputd = c( x.sub, x.nonmis )
mean(x.imputd); sd(x.imputd)
# [1] 100.0694 # aprx same as mean of nonmissing
# [1] 16.83213 # aprx same os SD of nonmissing
par(mfrow=c(1,2))
hist(x, prob=T, col="skyblue2", main="Actual")
hist(x.imputd, prob=T, col="skyblue2", main="Imputed")
par(mfrow=c(1,1))
|
What are the disadvantages of using mean for missing values?
|
Example with normal data. Suppose the real data are a random sample of size $n=200$ from $\mathsf{Norm}(\mu=100, \sigma=15),$ but you don't know $\mu$ or $\sigma$ and seek to estimate them. In the exa
|
What are the disadvantages of using mean for missing values?
Example with normal data. Suppose the real data are a random sample of size $n=200$ from $\mathsf{Norm}(\mu=100, \sigma=15),$ but you don't know $\mu$ or $\sigma$ and seek to estimate them. In the example below I'd estimate $\mu$ by $\bar X = 100.21$ and $\sigma$ by $S = 14.5,$ Both estimates are pretty good. (Simulation and computations in R.)
set.seed(402) # for reproducibility
x = rnorm(200, 100, 15)
mean(x); sd(x)
# [1] 100.2051 # aprx 100
# [1] 14.5031 # aprx 15
Now suppose that 25% of these data are missing. (That's a large proportion, but I'm
trying to make a point.) If I replace the missing observations by the mean of the 150 non-missing observations, let's see what my estimates of $\mu$ and $\sigma$ would be.
x.nonmis = x[51:200] # for simplicity suppose first 50 are missing
x.imputd = c( rep(mean(x.nonmis), 50), x.nonmis )
length(x.imputd); mean(x.imputd); sd(x.imputd)
# [1] 200 # 'x.imputd' has proper length 200
# [1] 100.3445 # aprx 100
# [1] 12.58591 # much smaller than 15
Now we estimate $\mu$ as $\bar X_{imp} = 100.3,$ which is not a bad estimate, but potentially (as here) worse than the mean of the actual data. However, we now estimate $\sigma$ as $S_{imp} = 12.6,$ which is quite a bit below both the true $\sigma$ and its better estimate 14.5 from actual data.
Example with exponential data. If the data are strongly right-skewed (as for data from an exponential population), then replacing missing data with the mean of nonmissing data could mask the skewness so that we may be surprised that the data do not reflect how heavy the right tail of the population really is.
set.seed(2020) # for reproducibility
x = rexp(200, .01)
mean(x); sd(x)
# [1] 108.0259 # aprx 100
# [1] 110.1757 # aprx 100
x.nonmis = x[51:200] # for simplicity suppose first 50 are missing
x.imputd = c( rep(mean(x.nonmis), 50), x.nonmis )
length(x.imputd); mean(x.imputd); sd(x.imputd)
# [1] 200
# [1] 106.7967 # aprx 100
# [1] 89.21266 # smaller than 100
boxplot(x, x.imputd, col="skyblue2", main="Data: Actual (left) and Imputed")
The boxplot shows more skewness in the actual data (many observations in high tail)
than in the 'imputed' data.
Example with bimodal data. Again here, when we substitute missing values with
the mean of the nonmissing observations, the population standard deviation is underestimated. Perhaps more seriously, the large number of imputed values at the center of the 'imputed' sample masks the bimodal nature of the data.
set.seed(1234) # for reproducibility
x1 = rnorm(100, 85, 10); x2 = rnorm(100, 115, 10)
x = sample(c(x1,x2)) # randomly scramble order
mean(x); sd(x)
# [1] 99.42241
# [1] 18.97779
x.nonmis = x[51:200] # for simplicity suppose first 50 are missing
x.imputd = c( rep(mean(x.nonmis), 50), x.nonmis )
length(x.imputd); mean(x.imputd); sd(x.imputd)
# [1] 200
# [1] 99.16315
# [1] 16.41451
par(mfrow=c(1,2))
hist(x, prob=T, col="skyblue2", main="Actual")
hist(x.imputd, prob=T, col="skyblue2", main="Imputed")
par(mfrow=c(1,1))
In general: Replacing missing data by the mean of nonmissing data causes the population SD to be underestimated, but may also obscure important
features of the population from which the data were sampled.
Note: As @benso8 observes, using the mean of nonmissing data to replace missing observations is not always a bad idea. As mentioned in the Question, this method does reduce the variability. There will necessarily be drawbacks to any scheme
for dealing with missing data. The Question asked for speculation about possible disadvantages other than variance reduction for this method. I tried to illustrate a couple of possibilities in my last two examples.
Tentative alternative method: I am no expert in data mining. So I very tentatively propose an alternative method. I don't claim it's a new idea.
Instead of replacing all $m$ missing items with the sample mean of the nonmissing ones, one might take a random sample of size $m$ from among the nonmissing observations, and scale it so that the $m$ items have the same mean and SD as the nonmissing data. Then combine the rescaled $m$ items with the nonmissing ones to get an 'imputed' sample with nearly the same mean and SD as the nonmissing part of the sample.
The result should not systematically underestimate the population SD, and may better preserve features of the population such as skewness and bimodality. (Comments welcome.)
This idea is explored for bimodal data below:
set.seed(4321) # for reproducibility
x1 = rnorm(100, 85, 10); x2 = rnorm(100, 115, 10)
x = sample(c(x1,x2)) # scrmble
mean(x); sd(x)
# [1] 100.5299
# [1] 17.03368
x.nonmis = x[51:200] # for simplicity suppose first 50 are missing
an = mean(x.nonmis); sn = sd(x.nonmis)
x.subt = sample(x.nonmis, 50) # temporary unscaled substitutes
as = mean(x.subt); ss = sd(x.subt)
x.sub = ((x.subt - as)/ss)*sn + an # scaled substitutes
x.imputd = c( x.sub, x.nonmis )
mean(x.imputd); sd(x.imputd)
# [1] 100.0694 # aprx same as mean of nonmissing
# [1] 16.83213 # aprx same os SD of nonmissing
par(mfrow=c(1,2))
hist(x, prob=T, col="skyblue2", main="Actual")
hist(x.imputd, prob=T, col="skyblue2", main="Imputed")
par(mfrow=c(1,1))
|
What are the disadvantages of using mean for missing values?
Example with normal data. Suppose the real data are a random sample of size $n=200$ from $\mathsf{Norm}(\mu=100, \sigma=15),$ but you don't know $\mu$ or $\sigma$ and seek to estimate them. In the exa
|
10,986
|
What are the disadvantages of using mean for missing values?
|
Using the mean for missing values is not ALWAYS a bad thing. In econometrics, this is a recommended course of action in some cases provided you understand what the consequences may be and in what cases it is helpful. As you have read, replacing missing values with the mean can reduce the variance but there are other side effects as well. Consider for example what happens to a regression model when replacing missing values with the mean.
Note that for regression models the coefficient of determination $$R^2 = \frac{SSR}{SSTO} = \frac{\sum (\hat{y_i} - \bar{y})^2}{\sum (y_i - \bar{y})^2}.$$ Assuming you have missing $y$ values and you replace those with the sample mean then you can have a $R^2$ value that is not as realistic as it should be. More variance in the data means there is more data that is likely further away from the regression line. Since the $R^2$ value depends on individual observed $y$ values (see $y_i$ in $SSTO$), your $R^2$ could be inflated because $SSTO$ will be smaller.
Let's look at an example.
Say you have a value $x_3$ and the corresponding observation for that $x$ value was $y_3$. We do the calculation for that result for SSTO and we have
$$
(y_3 - \bar{y})^2
$$
and that result gets added to the sum for $SSTO$. Now, instead, let's say that value $y_3$ is missing. We then let the missing $y_3 = \bar{y}$. We then have
$$
(\bar{y} - \bar{y})^2 = 0.
$$.
As you can see, when we add this to the other results for the denominator the $SSTO$ sum will be smaller.
|
What are the disadvantages of using mean for missing values?
|
Using the mean for missing values is not ALWAYS a bad thing. In econometrics, this is a recommended course of action in some cases provided you understand what the consequences may be and in what ca
|
What are the disadvantages of using mean for missing values?
Using the mean for missing values is not ALWAYS a bad thing. In econometrics, this is a recommended course of action in some cases provided you understand what the consequences may be and in what cases it is helpful. As you have read, replacing missing values with the mean can reduce the variance but there are other side effects as well. Consider for example what happens to a regression model when replacing missing values with the mean.
Note that for regression models the coefficient of determination $$R^2 = \frac{SSR}{SSTO} = \frac{\sum (\hat{y_i} - \bar{y})^2}{\sum (y_i - \bar{y})^2}.$$ Assuming you have missing $y$ values and you replace those with the sample mean then you can have a $R^2$ value that is not as realistic as it should be. More variance in the data means there is more data that is likely further away from the regression line. Since the $R^2$ value depends on individual observed $y$ values (see $y_i$ in $SSTO$), your $R^2$ could be inflated because $SSTO$ will be smaller.
Let's look at an example.
Say you have a value $x_3$ and the corresponding observation for that $x$ value was $y_3$. We do the calculation for that result for SSTO and we have
$$
(y_3 - \bar{y})^2
$$
and that result gets added to the sum for $SSTO$. Now, instead, let's say that value $y_3$ is missing. We then let the missing $y_3 = \bar{y}$. We then have
$$
(\bar{y} - \bar{y})^2 = 0.
$$.
As you can see, when we add this to the other results for the denominator the $SSTO$ sum will be smaller.
|
What are the disadvantages of using mean for missing values?
Using the mean for missing values is not ALWAYS a bad thing. In econometrics, this is a recommended course of action in some cases provided you understand what the consequences may be and in what ca
|
10,987
|
What are the disadvantages of using mean for missing values?
|
Another possible disadvantage with using the mean for missing values is that the reason the values are missing in the first place could be dependent on the missing values themselves. (This is called missing not at random.)
For example, on a health questionnaire, heavier respondents may be less willing to disclose their weight. The mean of the observed values would be lower than the true mean for all respondents, and you'd be using that value in place of values that should actually be considerably higher.
Using the mean is less of an issue if the reason the values are missing is independent of the missing values themselves.
|
What are the disadvantages of using mean for missing values?
|
Another possible disadvantage with using the mean for missing values is that the reason the values are missing in the first place could be dependent on the missing values themselves. (This is called
|
What are the disadvantages of using mean for missing values?
Another possible disadvantage with using the mean for missing values is that the reason the values are missing in the first place could be dependent on the missing values themselves. (This is called missing not at random.)
For example, on a health questionnaire, heavier respondents may be less willing to disclose their weight. The mean of the observed values would be lower than the true mean for all respondents, and you'd be using that value in place of values that should actually be considerably higher.
Using the mean is less of an issue if the reason the values are missing is independent of the missing values themselves.
|
What are the disadvantages of using mean for missing values?
Another possible disadvantage with using the mean for missing values is that the reason the values are missing in the first place could be dependent on the missing values themselves. (This is called
|
10,988
|
What are the disadvantages of using mean for missing values?
|
The problem isn’t specifically that it reduces the variance, but that it changes the variance of the dataset, making it a less accurate estimate for the variance of the actual population. More generally, it will make the dataset a less accurate reflection of the population, in many ways.
It’s helpful to consider alternatives. Why would using 0 (or any other random value) for missing points be a bad idea? Because it would be changing the dataset in an artificial way, making it less reflective of the ideal population, and making conclusions you draw from the dataset less accurate. Why is using the mean for missing points less bad than using other values? Because it doesn’t change the mean of the dataset — and the mean is usually the most important single statistic. But it’s still just a single statistic! The whole point of data mining is that a dataset contains much more information besides the mean. Filling in missing points with the mean can affect all the rest of that information. So the filled-in dataset will be less accurate for drawing conclusions about the actual population. The variance is just one particular piece of that further information, that illustrates the changes clearly.
|
What are the disadvantages of using mean for missing values?
|
The problem isn’t specifically that it reduces the variance, but that it changes the variance of the dataset, making it a less accurate estimate for the variance of the actual population. More genera
|
What are the disadvantages of using mean for missing values?
The problem isn’t specifically that it reduces the variance, but that it changes the variance of the dataset, making it a less accurate estimate for the variance of the actual population. More generally, it will make the dataset a less accurate reflection of the population, in many ways.
It’s helpful to consider alternatives. Why would using 0 (or any other random value) for missing points be a bad idea? Because it would be changing the dataset in an artificial way, making it less reflective of the ideal population, and making conclusions you draw from the dataset less accurate. Why is using the mean for missing points less bad than using other values? Because it doesn’t change the mean of the dataset — and the mean is usually the most important single statistic. But it’s still just a single statistic! The whole point of data mining is that a dataset contains much more information besides the mean. Filling in missing points with the mean can affect all the rest of that information. So the filled-in dataset will be less accurate for drawing conclusions about the actual population. The variance is just one particular piece of that further information, that illustrates the changes clearly.
|
What are the disadvantages of using mean for missing values?
The problem isn’t specifically that it reduces the variance, but that it changes the variance of the dataset, making it a less accurate estimate for the variance of the actual population. More genera
|
10,989
|
What are the disadvantages of using mean for missing values?
|
"Why is this variance reduction considered as a bad thing?"
As an oversimplified example: imagine, for a moment, that you have an extremely small economy on an island somewhere, with just 5 people. Their Annual Incomes are as follows:
Person 1: ♦10,000
Person 2: ♦10,000
Person 3: ♦12,000
Person 4: ♦13,000
Person 5: ♦25,000
A car company seeking to "break into the market" decide to price their vehicles based on the Average Annual Earnings.
Mean: ♦14,000
Median: ♦12,000
Mode: ♦10,000
As you can see, using the Mode could exclude 80% of the population from buying their product, which makes it a very bad choice for building a business case!
|
What are the disadvantages of using mean for missing values?
|
"Why is this variance reduction considered as a bad thing?"
As an oversimplified example: imagine, for a moment, that you have an extremely small economy on an island somewhere, with just 5 people.
|
What are the disadvantages of using mean for missing values?
"Why is this variance reduction considered as a bad thing?"
As an oversimplified example: imagine, for a moment, that you have an extremely small economy on an island somewhere, with just 5 people. Their Annual Incomes are as follows:
Person 1: ♦10,000
Person 2: ♦10,000
Person 3: ♦12,000
Person 4: ♦13,000
Person 5: ♦25,000
A car company seeking to "break into the market" decide to price their vehicles based on the Average Annual Earnings.
Mean: ♦14,000
Median: ♦12,000
Mode: ♦10,000
As you can see, using the Mode could exclude 80% of the population from buying their product, which makes it a very bad choice for building a business case!
|
What are the disadvantages of using mean for missing values?
"Why is this variance reduction considered as a bad thing?"
As an oversimplified example: imagine, for a moment, that you have an extremely small economy on an island somewhere, with just 5 people.
|
10,990
|
What are the disadvantages of using mean for missing values?
|
Yes, I like to idea of sampling from a distribution, when one has many missing values, to get a replacement value for missing value k.
My choice, however, is a distribution centered at the sample median (not mean) and with variance given here https://www.jstor.org/stable/30037287?seq=1 .
Perhaps sample from a truncated normal based upon the above parameters.
|
What are the disadvantages of using mean for missing values?
|
Yes, I like to idea of sampling from a distribution, when one has many missing values, to get a replacement value for missing value k.
My choice, however, is a distribution centered at the sample medi
|
What are the disadvantages of using mean for missing values?
Yes, I like to idea of sampling from a distribution, when one has many missing values, to get a replacement value for missing value k.
My choice, however, is a distribution centered at the sample median (not mean) and with variance given here https://www.jstor.org/stable/30037287?seq=1 .
Perhaps sample from a truncated normal based upon the above parameters.
|
What are the disadvantages of using mean for missing values?
Yes, I like to idea of sampling from a distribution, when one has many missing values, to get a replacement value for missing value k.
My choice, however, is a distribution centered at the sample medi
|
10,991
|
Why is it so important to have principled and mathematical theories for Machine Learning?
|
There's no right answer to this but, maybe, "everything in moderation." While many recent improvements in machine learning, i.e., dropout, residual connections, dense connections, batch normalization, aren't rooted in particularly deep theory (most can be justified in a few paragraphs), I think there's ultimately a bottleneck for just how many such results can make a huge impact. At some point you have to sit down and work out some extra theory to make the next big leap. As well, theory can guide intuition because it can prove the quality or limitations of a model to within a reasonable doubt. This is particularly important for figuring if say, SGD is better than Momentum for a particular problem. That's the nice thing about theory: it forces you to abstract the problem you're solving, and in many cases this can be very beneficial because abstract objects are rigorously defined and you can easily see similarities between two seemingly different objects.
The big example that comes to mind is support vector machines. They were originally devised by Vapnik and Chervonenkis in the early 60s, but really took off in the early 90s when Vapnik and others realized that you can do nonlinear SVMs using the Kernel Trick. Vapnik and Chervonenkis also worked out the theory behind VC dimension, which is an attempt at coming up with a complexity measure for machine learning. I can't think of any practical application of VC dimension, but I think the idea of SVMs was likely influenced by their work on this. The Kernel Trick itself comes from abstract-nonsense mathematics about Hilbert spaces. It might be a stretch to say that it's necessary to know this abstract nonsense to come up with SVMs, but, I think it probably helped out quite a bit, especially because it got a lot of mathematicians excited about machine learning.
On the subject of ResNet, there's been some really neat work recently suggesting that Residual architectures really don't need to be 100s of layers deep. In fact some work suggests that the residual connections are very similar to RNNs, for example Bridging the Gaps Between Residual Learning,
Recurrent Neural Networks and Visual Cortex", Liao et al. I think this definitely makes it worth looking into deeper because it suggests that theoretically, ResNet with many layers is in fact incredibly inefficient and bloated.
The ideas for gradient clipping for RNNs were very well justified in the now famous paper "On the difficulty of training recurrent neural networks" - Pascanu, et. al. While you could probably come up with gradient clipping without all the theory, I think it goes a long way toward understanding why RNNs are so darn hard to train without doing something fancy, especially by drawing analogies to dynamical system maps (as the paper above does).
There's a lot of excitement about Entropy Stochastic Gradient Descent methods. These were derived from Langevin dynamics, and much of the theoretical results are rooted firmly in classical theoretical PDE theory and statistical physics. The results are promising because they cast SGD in a new light, in terms of how it gets stuck in local fluctuations of the loss function, and how one can locally smooth the loss function to make SGD be much more efficient. It goes a long way toward understanding when SGD is useful and when it behaves poorly. This isn't something you can derive empirically by trying SGD on different kinds of models.
In the paper Intriguing properties of neural networks, the authors summarize that neural networks are sensitive to adversarial examples (defined as calculated, sleight perturbations of an image) due to high Lipchitz constants between layers. This is still an active area of research and can only be understood better through more theoretical derivations.
There's also the example of Topological Data Analysis, around which at least one company (Ayasdi)has formed. This is a particularly interesting example because the techniques used for it are so specific and abstract that even from today, it will still take a lot of time to see where the ideas from this theory end up. My understanding is that the computational complexity of the algorithms involved tends to be quite high (but then again it was equally high for neural networks even 20 years ago).
|
Why is it so important to have principled and mathematical theories for Machine Learning?
|
There's no right answer to this but, maybe, "everything in moderation." While many recent improvements in machine learning, i.e., dropout, residual connections, dense connections, batch normalization,
|
Why is it so important to have principled and mathematical theories for Machine Learning?
There's no right answer to this but, maybe, "everything in moderation." While many recent improvements in machine learning, i.e., dropout, residual connections, dense connections, batch normalization, aren't rooted in particularly deep theory (most can be justified in a few paragraphs), I think there's ultimately a bottleneck for just how many such results can make a huge impact. At some point you have to sit down and work out some extra theory to make the next big leap. As well, theory can guide intuition because it can prove the quality or limitations of a model to within a reasonable doubt. This is particularly important for figuring if say, SGD is better than Momentum for a particular problem. That's the nice thing about theory: it forces you to abstract the problem you're solving, and in many cases this can be very beneficial because abstract objects are rigorously defined and you can easily see similarities between two seemingly different objects.
The big example that comes to mind is support vector machines. They were originally devised by Vapnik and Chervonenkis in the early 60s, but really took off in the early 90s when Vapnik and others realized that you can do nonlinear SVMs using the Kernel Trick. Vapnik and Chervonenkis also worked out the theory behind VC dimension, which is an attempt at coming up with a complexity measure for machine learning. I can't think of any practical application of VC dimension, but I think the idea of SVMs was likely influenced by their work on this. The Kernel Trick itself comes from abstract-nonsense mathematics about Hilbert spaces. It might be a stretch to say that it's necessary to know this abstract nonsense to come up with SVMs, but, I think it probably helped out quite a bit, especially because it got a lot of mathematicians excited about machine learning.
On the subject of ResNet, there's been some really neat work recently suggesting that Residual architectures really don't need to be 100s of layers deep. In fact some work suggests that the residual connections are very similar to RNNs, for example Bridging the Gaps Between Residual Learning,
Recurrent Neural Networks and Visual Cortex", Liao et al. I think this definitely makes it worth looking into deeper because it suggests that theoretically, ResNet with many layers is in fact incredibly inefficient and bloated.
The ideas for gradient clipping for RNNs were very well justified in the now famous paper "On the difficulty of training recurrent neural networks" - Pascanu, et. al. While you could probably come up with gradient clipping without all the theory, I think it goes a long way toward understanding why RNNs are so darn hard to train without doing something fancy, especially by drawing analogies to dynamical system maps (as the paper above does).
There's a lot of excitement about Entropy Stochastic Gradient Descent methods. These were derived from Langevin dynamics, and much of the theoretical results are rooted firmly in classical theoretical PDE theory and statistical physics. The results are promising because they cast SGD in a new light, in terms of how it gets stuck in local fluctuations of the loss function, and how one can locally smooth the loss function to make SGD be much more efficient. It goes a long way toward understanding when SGD is useful and when it behaves poorly. This isn't something you can derive empirically by trying SGD on different kinds of models.
In the paper Intriguing properties of neural networks, the authors summarize that neural networks are sensitive to adversarial examples (defined as calculated, sleight perturbations of an image) due to high Lipchitz constants between layers. This is still an active area of research and can only be understood better through more theoretical derivations.
There's also the example of Topological Data Analysis, around which at least one company (Ayasdi)has formed. This is a particularly interesting example because the techniques used for it are so specific and abstract that even from today, it will still take a lot of time to see where the ideas from this theory end up. My understanding is that the computational complexity of the algorithms involved tends to be quite high (but then again it was equally high for neural networks even 20 years ago).
|
Why is it so important to have principled and mathematical theories for Machine Learning?
There's no right answer to this but, maybe, "everything in moderation." While many recent improvements in machine learning, i.e., dropout, residual connections, dense connections, batch normalization,
|
10,992
|
Why is it so important to have principled and mathematical theories for Machine Learning?
|
The answer to this question is actually very simple. With theoretical justification behind the machine learning model we at least can prove that when some more or less realistic conditions are met, there are some guarantees of optimality for the solution. Without it, we don't have any guarantees whatsoever. Sure, you can say "let's just check what works and use it for the particular problem", but this isn't feasible since there is a infinite number of ways how you could solve any machine learning problem.
Say that you want to predict some $Y$, given some $X$. How do you know that $X + 42$ is not an optimal way to solve it? What about $X + 42.5$? Or, $\sqrt{X - 42}$? Maybe just return $42$ as your prediction? Or if $X$ is odd use $X+42$ and otherwise return $0$? Sure, all those suggestions sound absurd, but how can you be sure, without any theory, that one of them wouldn't be optimal? With an infinite number of possible solutions, even the simplest problem becomes unsolvable. Theory limits your "search space" of the feasible models for some class of the problems (you know which models are worth considering and which not).
|
Why is it so important to have principled and mathematical theories for Machine Learning?
|
The answer to this question is actually very simple. With theoretical justification behind the machine learning model we at least can prove that when some more or less realistic conditions are met, th
|
Why is it so important to have principled and mathematical theories for Machine Learning?
The answer to this question is actually very simple. With theoretical justification behind the machine learning model we at least can prove that when some more or less realistic conditions are met, there are some guarantees of optimality for the solution. Without it, we don't have any guarantees whatsoever. Sure, you can say "let's just check what works and use it for the particular problem", but this isn't feasible since there is a infinite number of ways how you could solve any machine learning problem.
Say that you want to predict some $Y$, given some $X$. How do you know that $X + 42$ is not an optimal way to solve it? What about $X + 42.5$? Or, $\sqrt{X - 42}$? Maybe just return $42$ as your prediction? Or if $X$ is odd use $X+42$ and otherwise return $0$? Sure, all those suggestions sound absurd, but how can you be sure, without any theory, that one of them wouldn't be optimal? With an infinite number of possible solutions, even the simplest problem becomes unsolvable. Theory limits your "search space" of the feasible models for some class of the problems (you know which models are worth considering and which not).
|
Why is it so important to have principled and mathematical theories for Machine Learning?
The answer to this question is actually very simple. With theoretical justification behind the machine learning model we at least can prove that when some more or less realistic conditions are met, th
|
10,993
|
Why is it so important to have principled and mathematical theories for Machine Learning?
|
Just looking at the question: Is theoretical and principled pursue of machine learning really that important?
Define what you mean by "important". Coming from a philosophical point of view it's a fundamental distinction if you want to describe something or understand something. In a somewhat crude answer it is the difference between being scientific or something else.
The practical part of it is of no concern to the underlying question. If something is too hard to prove, or even impossible to prove this in itself is an important discovery. (Enter Goedel et al.) But this does not mean it is irrelevant. It may at least seem irrelevant from a pragmatic point of view. But it should be at least be recognized as something of principal importance and value.
Consider an analogy: medicine as a whole (and from its past) is non scientific. In certain ways it can actually never be. It is a discipline that is entirely governed by its outcome. In most cases there is nothing like "truth". But it turns out, that some parts can actually be scientific -- and this is where most of the planned progress is happening.
Another extremely short description might be: without theory you can make a lot of money. If it's really useful for a "greater good", then you even might get a Nobel prize for it. But you will never ever get the Fields medal.
|
Why is it so important to have principled and mathematical theories for Machine Learning?
|
Just looking at the question: Is theoretical and principled pursue of machine learning really that important?
Define what you mean by "important". Coming from a philosophical point of view it's a fund
|
Why is it so important to have principled and mathematical theories for Machine Learning?
Just looking at the question: Is theoretical and principled pursue of machine learning really that important?
Define what you mean by "important". Coming from a philosophical point of view it's a fundamental distinction if you want to describe something or understand something. In a somewhat crude answer it is the difference between being scientific or something else.
The practical part of it is of no concern to the underlying question. If something is too hard to prove, or even impossible to prove this in itself is an important discovery. (Enter Goedel et al.) But this does not mean it is irrelevant. It may at least seem irrelevant from a pragmatic point of view. But it should be at least be recognized as something of principal importance and value.
Consider an analogy: medicine as a whole (and from its past) is non scientific. In certain ways it can actually never be. It is a discipline that is entirely governed by its outcome. In most cases there is nothing like "truth". But it turns out, that some parts can actually be scientific -- and this is where most of the planned progress is happening.
Another extremely short description might be: without theory you can make a lot of money. If it's really useful for a "greater good", then you even might get a Nobel prize for it. But you will never ever get the Fields medal.
|
Why is it so important to have principled and mathematical theories for Machine Learning?
Just looking at the question: Is theoretical and principled pursue of machine learning really that important?
Define what you mean by "important". Coming from a philosophical point of view it's a fund
|
10,994
|
Why is it so important to have principled and mathematical theories for Machine Learning?
|
Here's a simple example from my own work.
I fit a lot of neural nets to continuous outcomes. One determines the weights by backpropagation. Eventually, it'll converge.
Now, the top-layer activation function is identity, and my loss is squared error. Because of theory, I know that the top-level weight vector that minimizes the squared-error loss is good old
$$
\mathbf{\left(A^TA\right)^{-1}A^Ty}
$$
where $\mathbf{A}$ are the activations at the top level and $y$ are the outcomes. When I short-circuit backprop by using a closed-form solution for the top-level weights, I only need backprop for optimizing the lower-level weights.
My net converges way faster.
Thank you, theory.
|
Why is it so important to have principled and mathematical theories for Machine Learning?
|
Here's a simple example from my own work.
I fit a lot of neural nets to continuous outcomes. One determines the weights by backpropagation. Eventually, it'll converge.
Now, the top-layer activation f
|
Why is it so important to have principled and mathematical theories for Machine Learning?
Here's a simple example from my own work.
I fit a lot of neural nets to continuous outcomes. One determines the weights by backpropagation. Eventually, it'll converge.
Now, the top-layer activation function is identity, and my loss is squared error. Because of theory, I know that the top-level weight vector that minimizes the squared-error loss is good old
$$
\mathbf{\left(A^TA\right)^{-1}A^Ty}
$$
where $\mathbf{A}$ are the activations at the top level and $y$ are the outcomes. When I short-circuit backprop by using a closed-form solution for the top-level weights, I only need backprop for optimizing the lower-level weights.
My net converges way faster.
Thank you, theory.
|
Why is it so important to have principled and mathematical theories for Machine Learning?
Here's a simple example from my own work.
I fit a lot of neural nets to continuous outcomes. One determines the weights by backpropagation. Eventually, it'll converge.
Now, the top-layer activation f
|
10,995
|
Why is it so important to have principled and mathematical theories for Machine Learning?
|
Humans have been able to build ships, carriages and buildings for centuries without the laws of physics. But since modern science, we have been able to take those technologies to a whole new level. A proven theory allows to make improvements in a principled manner. We would have never made it to the moon or have computers without a mathematical theory of matter and computation.
Machine learning is just another field of science and engineering like any other. A principled approach to machine learning has provided us with kernel machines, structured learning, and ensemble methods (boosting, random forests).
|
Why is it so important to have principled and mathematical theories for Machine Learning?
|
Humans have been able to build ships, carriages and buildings for centuries without the laws of physics. But since modern science, we have been able to take those technologies to a whole new level. A
|
Why is it so important to have principled and mathematical theories for Machine Learning?
Humans have been able to build ships, carriages and buildings for centuries without the laws of physics. But since modern science, we have been able to take those technologies to a whole new level. A proven theory allows to make improvements in a principled manner. We would have never made it to the moon or have computers without a mathematical theory of matter and computation.
Machine learning is just another field of science and engineering like any other. A principled approach to machine learning has provided us with kernel machines, structured learning, and ensemble methods (boosting, random forests).
|
Why is it so important to have principled and mathematical theories for Machine Learning?
Humans have been able to build ships, carriages and buildings for centuries without the laws of physics. But since modern science, we have been able to take those technologies to a whole new level. A
|
10,996
|
Why is it so important to have principled and mathematical theories for Machine Learning?
|
Empiricism vs Theory
You wrote:
One of the biggest criticism of theory is that because its so hard to do, they usually end up studying some very restricted case or the assumptions that have to be brought essentially make the results useless.
This I think demonstrates the main divide between the two views which we can call empirical and theoretical.
From an empirical point of view, as you described as well, theorems are useless because they are never complex enough to model the real world. They talk about simplified ideal scenarios which don't apply anywhere in the real world. So what's the point in doing theory.
However from a theoretical point of view the opposite is true. What can empiricism teach us beyond "I ran this method on this dataset and it was better than running that other method on this same dataset". This is useful for one instance but says little about the problem.
What theory does is provides some guarantees. It also allows us to study simplified scenarios exactly so that we can start understanding what is going on.
Example
Imagine an actual example: you want to see how concept drift (when the data changes over time) affects your ability to learn. How would a pure empiricist approach this question? All he can do really is to start applying different methods and think about tricks he can do. The whole procedure might be similar to this:
Take past 300 days and try to detect if the mean of that variable has changed. OK it somewhat worked.
What if we try 200 days instead?
OK better, let's try to change the algorithm once the drift occurs.
Obtain more datasets and see which method developed so far works best.
Results are not conclusive, maybe guess there are more than one type of concept drifts going on?
Try simulations. What if we simulate some concept drift and then apply different methods using different number of days used to detect if change has occurred.
What we have here is quite precise results on a few data sets. Maybe the data was so that updating the learning algorithm based on observations of 200 past days gave the highest accuracy. But will the same work for other data? How reliable is this 200 days estimate? Simulations help - but they don't reflect real world - same problem theory had.
Now imagine the same from a theoretical standpoint:
Simplify the scenario to an absurd level. Maybe use a 2-variate normal distribution with a mean suddenly changing over time.
Choose your conditions clearly - pick the model that is optimal on normal data. Assume you know that the data is normal. All you don't know is when the shift in means occur.
Device a method for detecting when the shift has occurred. Again can start with 200 past observations.
Based on these setting we should be able to calculate the average error for the classifier, average time it takes for the algorithm do detect if change has occurred and update. Maybe worst case scenarios and guarantees within 95% chance level.
Now this scenario is clearer - we were able to isolate the problem by fixing all the details. We know the average error of our classifiers. Can probably estimate the number of days it would take to detect that change has occurred. Deduce what parameters this depends on (like maybe the size of the change). And now based on something produce a practical solution. But most importantly of all: this result (if correctly calculated) is unchanging. It's here forever and anyone can learn from it.
Like one of the fathers of modern machine learning - Jürgen Schmidhuber likes to say:
Heuristics come and go – theorems are for eternity.
Lessons from other fields
Also briefly wanted to mention some parallels to physics. I think they used to have this dilemma as well. Physicists were studying frictionless objects of infinite mass moving inside infinite space. At first glance what can this tell us about reality where we want to know how snowflakes move in the wind. But it feels like theory carried them quite a long way.
|
Why is it so important to have principled and mathematical theories for Machine Learning?
|
Empiricism vs Theory
You wrote:
One of the biggest criticism of theory is that because its so hard to do, they usually end up studying some very restricted case or the assumptions that have to be bro
|
Why is it so important to have principled and mathematical theories for Machine Learning?
Empiricism vs Theory
You wrote:
One of the biggest criticism of theory is that because its so hard to do, they usually end up studying some very restricted case or the assumptions that have to be brought essentially make the results useless.
This I think demonstrates the main divide between the two views which we can call empirical and theoretical.
From an empirical point of view, as you described as well, theorems are useless because they are never complex enough to model the real world. They talk about simplified ideal scenarios which don't apply anywhere in the real world. So what's the point in doing theory.
However from a theoretical point of view the opposite is true. What can empiricism teach us beyond "I ran this method on this dataset and it was better than running that other method on this same dataset". This is useful for one instance but says little about the problem.
What theory does is provides some guarantees. It also allows us to study simplified scenarios exactly so that we can start understanding what is going on.
Example
Imagine an actual example: you want to see how concept drift (when the data changes over time) affects your ability to learn. How would a pure empiricist approach this question? All he can do really is to start applying different methods and think about tricks he can do. The whole procedure might be similar to this:
Take past 300 days and try to detect if the mean of that variable has changed. OK it somewhat worked.
What if we try 200 days instead?
OK better, let's try to change the algorithm once the drift occurs.
Obtain more datasets and see which method developed so far works best.
Results are not conclusive, maybe guess there are more than one type of concept drifts going on?
Try simulations. What if we simulate some concept drift and then apply different methods using different number of days used to detect if change has occurred.
What we have here is quite precise results on a few data sets. Maybe the data was so that updating the learning algorithm based on observations of 200 past days gave the highest accuracy. But will the same work for other data? How reliable is this 200 days estimate? Simulations help - but they don't reflect real world - same problem theory had.
Now imagine the same from a theoretical standpoint:
Simplify the scenario to an absurd level. Maybe use a 2-variate normal distribution with a mean suddenly changing over time.
Choose your conditions clearly - pick the model that is optimal on normal data. Assume you know that the data is normal. All you don't know is when the shift in means occur.
Device a method for detecting when the shift has occurred. Again can start with 200 past observations.
Based on these setting we should be able to calculate the average error for the classifier, average time it takes for the algorithm do detect if change has occurred and update. Maybe worst case scenarios and guarantees within 95% chance level.
Now this scenario is clearer - we were able to isolate the problem by fixing all the details. We know the average error of our classifiers. Can probably estimate the number of days it would take to detect that change has occurred. Deduce what parameters this depends on (like maybe the size of the change). And now based on something produce a practical solution. But most importantly of all: this result (if correctly calculated) is unchanging. It's here forever and anyone can learn from it.
Like one of the fathers of modern machine learning - Jürgen Schmidhuber likes to say:
Heuristics come and go – theorems are for eternity.
Lessons from other fields
Also briefly wanted to mention some parallels to physics. I think they used to have this dilemma as well. Physicists were studying frictionless objects of infinite mass moving inside infinite space. At first glance what can this tell us about reality where we want to know how snowflakes move in the wind. But it feels like theory carried them quite a long way.
|
Why is it so important to have principled and mathematical theories for Machine Learning?
Empiricism vs Theory
You wrote:
One of the biggest criticism of theory is that because its so hard to do, they usually end up studying some very restricted case or the assumptions that have to be bro
|
10,997
|
Why is it so important to have principled and mathematical theories for Machine Learning?
|
You mentioned some reasons, of which the ability to interpret ML results is the most important, in my opinion. Let us say the AI driven property guard decided to shoot the neighbor's dog. It would be important to understand why it did so. If not to prevent this from happening in future, then at least to understand who's liable and who's going to pay the owner compensation.
However, to me the most important reason is that understanding the principles on which the algorithm is founded allows to understand its limitations and improve its performance. Consider use of euclidean distance in ML. In many clustering algorithms you start with the definition of the distance between example, then proceed finding the boundaries between the features of examples that group them proximity. Once you increase the number of features, the euclidean distance stops working at some point. You can spend a lot of time trying to make it work, or - if you know that euclidean distance as a proximity measure doesn't work in infinite dimensional limit - simply switch to some other distance metric, such as Manhattan, then proceed to work on real problems. You can find a ton of examples such as this one, where knowing the theory saves a lot of time.
|
Why is it so important to have principled and mathematical theories for Machine Learning?
|
You mentioned some reasons, of which the ability to interpret ML results is the most important, in my opinion. Let us say the AI driven property guard decided to shoot the neighbor's dog. It would be
|
Why is it so important to have principled and mathematical theories for Machine Learning?
You mentioned some reasons, of which the ability to interpret ML results is the most important, in my opinion. Let us say the AI driven property guard decided to shoot the neighbor's dog. It would be important to understand why it did so. If not to prevent this from happening in future, then at least to understand who's liable and who's going to pay the owner compensation.
However, to me the most important reason is that understanding the principles on which the algorithm is founded allows to understand its limitations and improve its performance. Consider use of euclidean distance in ML. In many clustering algorithms you start with the definition of the distance between example, then proceed finding the boundaries between the features of examples that group them proximity. Once you increase the number of features, the euclidean distance stops working at some point. You can spend a lot of time trying to make it work, or - if you know that euclidean distance as a proximity measure doesn't work in infinite dimensional limit - simply switch to some other distance metric, such as Manhattan, then proceed to work on real problems. You can find a ton of examples such as this one, where knowing the theory saves a lot of time.
|
Why is it so important to have principled and mathematical theories for Machine Learning?
You mentioned some reasons, of which the ability to interpret ML results is the most important, in my opinion. Let us say the AI driven property guard decided to shoot the neighbor's dog. It would be
|
10,998
|
Why is it so important to have principled and mathematical theories for Machine Learning?
|
I think it is very difficult for this not to be a philosophical discussion. My answer is really a rewording of good points already mentioned here (+1s for all); I just want to point to a quote from Andrew Gelman that really spoke to me as someone who trained as a computer scientist. I have the impression that many of the people who call what they do machine learning also come from computer science. The quote is from a talk that Gelman gave at the 2017 New York R Conference called Theoretical Statistics is the Theory of Applied Statistics:
Theory is scalable.
Theory tells you what makes sense and what does not under certain conditions. Do we want to do thousands or tens of thousands or millions of simulations to get an idea of the truth? Do we want to do empirical comparisons on more and more benchmark datasets? It's going to take a while, and our results may still be brittle. Further, how do we know that the comparisons we do make sense? How do we know that our new Deep Learner with 99.5% accuracy is really better than the old one that had 99.1% accuracy? Some theory will help here.
I'm a big fan of simulations and I use them a lot to make sense of the world (or even make sense of the theory), but theoretical machine learning is the theory of applied machine learning.
|
Why is it so important to have principled and mathematical theories for Machine Learning?
|
I think it is very difficult for this not to be a philosophical discussion. My answer is really a rewording of good points already mentioned here (+1s for all); I just want to point to a quote from An
|
Why is it so important to have principled and mathematical theories for Machine Learning?
I think it is very difficult for this not to be a philosophical discussion. My answer is really a rewording of good points already mentioned here (+1s for all); I just want to point to a quote from Andrew Gelman that really spoke to me as someone who trained as a computer scientist. I have the impression that many of the people who call what they do machine learning also come from computer science. The quote is from a talk that Gelman gave at the 2017 New York R Conference called Theoretical Statistics is the Theory of Applied Statistics:
Theory is scalable.
Theory tells you what makes sense and what does not under certain conditions. Do we want to do thousands or tens of thousands or millions of simulations to get an idea of the truth? Do we want to do empirical comparisons on more and more benchmark datasets? It's going to take a while, and our results may still be brittle. Further, how do we know that the comparisons we do make sense? How do we know that our new Deep Learner with 99.5% accuracy is really better than the old one that had 99.1% accuracy? Some theory will help here.
I'm a big fan of simulations and I use them a lot to make sense of the world (or even make sense of the theory), but theoretical machine learning is the theory of applied machine learning.
|
Why is it so important to have principled and mathematical theories for Machine Learning?
I think it is very difficult for this not to be a philosophical discussion. My answer is really a rewording of good points already mentioned here (+1s for all); I just want to point to a quote from An
|
10,999
|
How do I check if my data fits an exponential distribution?
|
I would do it by first estimating the only distribution parameter rate using fitdistr. This won't tell you if the distribution fits or not, so you must then use goodness of fit test. For this, you can use ks.test:
require(vcd)
require(MASS)
# data generation
ex <- rexp(10000, rate = 1.85) # generate some exponential distribution
control <- abs(rnorm(10000)) # generate some other distribution
# estimate the parameters
fit1 <- fitdistr(ex, "exponential")
fit2 <- fitdistr(control, "exponential")
# goodness of fit test
ks.test(ex, "pexp", fit1$estimate) # p-value > 0.05 -> distribution not refused
ks.test(control, "pexp", fit2$estimate) # significant p-value -> distribution refused
# plot a graph
hist(ex, freq = FALSE, breaks = 100, xlim = c(0, quantile(ex, 0.99)))
curve(dexp(x, rate = fit1$estimate), from = 0, col = "red", add = TRUE)
From my personal experience (though I have never found it officially anywhere, please confirm or correct me), ks.test will only run if you supply the parameter estimate first. You cannot let it estimate the parameters automatically as e.g. goodfit does it. That's why you need this two step procedure with fitdistr.
For more info follow the excellent guide of Ricci: FITTING DISTRIBUTIONS WITH R.
|
How do I check if my data fits an exponential distribution?
|
I would do it by first estimating the only distribution parameter rate using fitdistr. This won't tell you if the distribution fits or not, so you must then use goodness of fit test. For this, you can
|
How do I check if my data fits an exponential distribution?
I would do it by first estimating the only distribution parameter rate using fitdistr. This won't tell you if the distribution fits or not, so you must then use goodness of fit test. For this, you can use ks.test:
require(vcd)
require(MASS)
# data generation
ex <- rexp(10000, rate = 1.85) # generate some exponential distribution
control <- abs(rnorm(10000)) # generate some other distribution
# estimate the parameters
fit1 <- fitdistr(ex, "exponential")
fit2 <- fitdistr(control, "exponential")
# goodness of fit test
ks.test(ex, "pexp", fit1$estimate) # p-value > 0.05 -> distribution not refused
ks.test(control, "pexp", fit2$estimate) # significant p-value -> distribution refused
# plot a graph
hist(ex, freq = FALSE, breaks = 100, xlim = c(0, quantile(ex, 0.99)))
curve(dexp(x, rate = fit1$estimate), from = 0, col = "red", add = TRUE)
From my personal experience (though I have never found it officially anywhere, please confirm or correct me), ks.test will only run if you supply the parameter estimate first. You cannot let it estimate the parameters automatically as e.g. goodfit does it. That's why you need this two step procedure with fitdistr.
For more info follow the excellent guide of Ricci: FITTING DISTRIBUTIONS WITH R.
|
How do I check if my data fits an exponential distribution?
I would do it by first estimating the only distribution parameter rate using fitdistr. This won't tell you if the distribution fits or not, so you must then use goodness of fit test. For this, you can
|
11,000
|
How do I check if my data fits an exponential distribution?
|
While I'd normally recommend checking exponentiality by use of diagnostic plots (such as Q-Q plots), I'll discuss tests, since people often want them:
As Tomas suggests, the Kolmogorov-Smirnov test is not suitable for testing exponentiality with an unspecified parameter.
However, if you adjust the tables for the parameter estimation, you get Lilliefors' test for the exponential distribution.
Lilliefors, H. (1969), "On the Kolmogorov–Smirnov test for the exponential distribution with mean unknown", Journal of the American Statistical Association, Vol. 64 . pp. 387–389.
The use of this test is discussed in Conover's Practical Nonparametric Statistics.
However, in D'Agostino & Stephens' Goodness of Fit Techniques, they discuss a similar modification of the Anderson-Darling test (somewhat obliquely if I recall right, but I think all the required information on how to approach it for the exponential case is to be found in the book), and that's almost certain to have more power against most of the interesting alternatives (but likely less power against a distribution that has a lighter right tail and lower left end, especially in small to moderate sample sizes).
Similarly, one might estimate something like a Shapiro-Francia test (akin to but simpler than the Shapiro-Wilk), by basing a test on $n(1-r^2)$ where $r$ is the correlation between the order statistics and exponential scores (expected exponential order statistics). This corresponds to testing the correlation in the Q-Q plot.
Finally, one might take the smooth test approach, as in the book by Rayner & Best (Smooth Tests of Goodness of Fit, 1990 - though I believe there's a more recent one, with Thas and "in R" added to the title). The exponential case is also covered in:
J. C. W. Rayner and D. J. Best (1990),
"Smooth Tests of Goodness of Fit: An Overview",
International Statistical Review,
Vol. 58, No. 1 (Apr., 1990), pp. 9-17
Cosma Shalizi also discusses smooth tests in one chapter of his Undergraduate Advanced Data Analysis lecture notes, or see Ch15 of his book Advanced Data Analysis from an Elementary Point of View.
For some of the above, you may need to simulate the distribution of the test statistic; for others tables are available (but in some of those cases, it may be easier to simulate anyway, or even more accurate to simulate yourself, as with the Lilliefors test, due to limited simulation size in the original).
Of all of those, I'd lean toward doing the one that's the exponential equivalent to the Shapiro-Francia (that is, I'd test the correlation in the Q-Q plot [or if I was making tables, perhaps use $n(1-r^2)$, which will reject the same cases] - it should be powerful enough to be competitive with the better tests, but is very easy to do, and has the pleasing correspondence to the visual appearance of the Q-Q plot (one could even choose to add the correlation and the p-value to the plot, if desired).
|
How do I check if my data fits an exponential distribution?
|
While I'd normally recommend checking exponentiality by use of diagnostic plots (such as Q-Q plots), I'll discuss tests, since people often want them:
As Tomas suggests, the Kolmogorov-Smirnov test is
|
How do I check if my data fits an exponential distribution?
While I'd normally recommend checking exponentiality by use of diagnostic plots (such as Q-Q plots), I'll discuss tests, since people often want them:
As Tomas suggests, the Kolmogorov-Smirnov test is not suitable for testing exponentiality with an unspecified parameter.
However, if you adjust the tables for the parameter estimation, you get Lilliefors' test for the exponential distribution.
Lilliefors, H. (1969), "On the Kolmogorov–Smirnov test for the exponential distribution with mean unknown", Journal of the American Statistical Association, Vol. 64 . pp. 387–389.
The use of this test is discussed in Conover's Practical Nonparametric Statistics.
However, in D'Agostino & Stephens' Goodness of Fit Techniques, they discuss a similar modification of the Anderson-Darling test (somewhat obliquely if I recall right, but I think all the required information on how to approach it for the exponential case is to be found in the book), and that's almost certain to have more power against most of the interesting alternatives (but likely less power against a distribution that has a lighter right tail and lower left end, especially in small to moderate sample sizes).
Similarly, one might estimate something like a Shapiro-Francia test (akin to but simpler than the Shapiro-Wilk), by basing a test on $n(1-r^2)$ where $r$ is the correlation between the order statistics and exponential scores (expected exponential order statistics). This corresponds to testing the correlation in the Q-Q plot.
Finally, one might take the smooth test approach, as in the book by Rayner & Best (Smooth Tests of Goodness of Fit, 1990 - though I believe there's a more recent one, with Thas and "in R" added to the title). The exponential case is also covered in:
J. C. W. Rayner and D. J. Best (1990),
"Smooth Tests of Goodness of Fit: An Overview",
International Statistical Review,
Vol. 58, No. 1 (Apr., 1990), pp. 9-17
Cosma Shalizi also discusses smooth tests in one chapter of his Undergraduate Advanced Data Analysis lecture notes, or see Ch15 of his book Advanced Data Analysis from an Elementary Point of View.
For some of the above, you may need to simulate the distribution of the test statistic; for others tables are available (but in some of those cases, it may be easier to simulate anyway, or even more accurate to simulate yourself, as with the Lilliefors test, due to limited simulation size in the original).
Of all of those, I'd lean toward doing the one that's the exponential equivalent to the Shapiro-Francia (that is, I'd test the correlation in the Q-Q plot [or if I was making tables, perhaps use $n(1-r^2)$, which will reject the same cases] - it should be powerful enough to be competitive with the better tests, but is very easy to do, and has the pleasing correspondence to the visual appearance of the Q-Q plot (one could even choose to add the correlation and the p-value to the plot, if desired).
|
How do I check if my data fits an exponential distribution?
While I'd normally recommend checking exponentiality by use of diagnostic plots (such as Q-Q plots), I'll discuss tests, since people often want them:
As Tomas suggests, the Kolmogorov-Smirnov test is
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.