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
13,601
Roll a die until it lands on any number other than 4. What is the probability the result is > 4?
Note: This is an answer to the initial question, rather than the recurrence. If she rolls a 4, then it essentially doesn't count, because the next roll is independent. In other words, after rolling a 4 the situation is the same as when she started. So you can ignore the 4. Then the outcomes that could matter are 1-3 and 5-6. There are 5 distinct outcomes, 2 of which are winning. So the answer is 2/5 = 0.4 = 40%.
Roll a die until it lands on any number other than 4. What is the probability the result is > 4?
Note: This is an answer to the initial question, rather than the recurrence. If she rolls a 4, then it essentially doesn't count, because the next roll is independent. In other words, after rolling a
Roll a die until it lands on any number other than 4. What is the probability the result is > 4? Note: This is an answer to the initial question, rather than the recurrence. If she rolls a 4, then it essentially doesn't count, because the next roll is independent. In other words, after rolling a 4 the situation is the same as when she started. So you can ignore the 4. Then the outcomes that could matter are 1-3 and 5-6. There are 5 distinct outcomes, 2 of which are winning. So the answer is 2/5 = 0.4 = 40%.
Roll a die until it lands on any number other than 4. What is the probability the result is > 4? Note: This is an answer to the initial question, rather than the recurrence. If she rolls a 4, then it essentially doesn't count, because the next roll is independent. In other words, after rolling a
13,602
Roll a die until it lands on any number other than 4. What is the probability the result is > 4?
The answers by dsaxton (https://stats.stackexchange.com/a/232107/90759) and GeoMatt22 (https://stats.stackexchange.com/a/232107/90759) give the best approaches to the problem. Another is to realize that your expression $$P(W) = \frac13+\frac16\left(\frac13+\frac16(\cdots)\right)$$ Is really a geometric progression: $$\frac13+\frac16\frac13+\frac1{6^2}\frac13+\cdots$$ In general we have $$\sum_{n=0}^{\infty}a_0q^n = \frac{a_0}{1-q}$$ so here we have $$P(W) = \frac{\frac13}{1-\frac16} = \frac13:\frac56=\frac{6}{15}=\frac25.$$ Of course, the way to prove the general formula for the sum of a geometric progression, is by using an algebraic solution similarly to dsaxton.
Roll a die until it lands on any number other than 4. What is the probability the result is > 4?
The answers by dsaxton (https://stats.stackexchange.com/a/232107/90759) and GeoMatt22 (https://stats.stackexchange.com/a/232107/90759) give the best approaches to the problem. Another is to realize th
Roll a die until it lands on any number other than 4. What is the probability the result is > 4? The answers by dsaxton (https://stats.stackexchange.com/a/232107/90759) and GeoMatt22 (https://stats.stackexchange.com/a/232107/90759) give the best approaches to the problem. Another is to realize that your expression $$P(W) = \frac13+\frac16\left(\frac13+\frac16(\cdots)\right)$$ Is really a geometric progression: $$\frac13+\frac16\frac13+\frac1{6^2}\frac13+\cdots$$ In general we have $$\sum_{n=0}^{\infty}a_0q^n = \frac{a_0}{1-q}$$ so here we have $$P(W) = \frac{\frac13}{1-\frac16} = \frac13:\frac56=\frac{6}{15}=\frac25.$$ Of course, the way to prove the general formula for the sum of a geometric progression, is by using an algebraic solution similarly to dsaxton.
Roll a die until it lands on any number other than 4. What is the probability the result is > 4? The answers by dsaxton (https://stats.stackexchange.com/a/232107/90759) and GeoMatt22 (https://stats.stackexchange.com/a/232107/90759) give the best approaches to the problem. Another is to realize th
13,603
Roll a die until it lands on any number other than 4. What is the probability the result is > 4?
All of the above answers are correct, but they don't explain why they are correct, and why you can ignore so many details and avoid having to solve a complicated recurrence relation. The reason why the other answers are correct is the Strong Markov property, which for a discrete Markov Chain is equivalent to the regular Markov property. https://en.wikipedia.org/wiki/Markov_property#Strong_Markov_property Basically the idea is that the random variable $\tau:=($the number of times until the die does not land on 4 for the first time) is a stopping time. https://en.wikipedia.org/wiki/Stopping_time A stopping time is a random variable which doesn't depend on any future information. In order to tell whether the $n$th roll of the die is the first one which has not landed on a 4 (i.e. in order to decide whether $\tau=n$), you only need to know the value of the current roll, and of all previous rolls, but not of any future rolls -- thus $\tau$ is a stopping time, and the Strong Markov property applies. What does the Strong Markov property say? It says that the number which the die lands on at the $\tau$th roll, as a random variable, $X_{\tau}$, is independent of the values of ALL previous rolls. So if the die rolls 4 once, twice, ..., 50 million times, ..., $\tau -1$ times before finally landing on another value for the $\tau$th roll, it won't affect the probability of the event that $X_{\tau} > 4$. $$\mathbb{P}(X_{\tau}>4|\tau=1)=\mathbb{P}(X_{\tau}>4|\tau=2)=\dots = \mathbb{P}(X_{\tau}>4|\tau=50,000,000)=\dots $$ Therefore we can assume, without loss of generality, that $\tau=1$. This is just the probability that the die lands a value greater than 4 given that it does not land on 4, which we can calculate very easily: $$\mathbb{P}(X_1>4|X\not=4) = \frac{\mathbb{P}(X_1 > 4 \cap X_1 \not=4)}{\mathbb{P}(X_1 \not= 4)} = \frac{\mathbb{P}(X_1 > 4)}{\mathbb{P}(X_1 \not=4)}=\frac{\frac{1}{3}}{\frac{5}{6}}=\frac{1}{3}\cdot\frac{6}{5}=\frac{2}{5} $$ which of course is the correct answer. You can read more about stopping times and the Strong Markov property in Section 8.3 of (the 4th edition of) Durrett's Probability Theory and Examples, p. 365.
Roll a die until it lands on any number other than 4. What is the probability the result is > 4?
All of the above answers are correct, but they don't explain why they are correct, and why you can ignore so many details and avoid having to solve a complicated recurrence relation. The reason why th
Roll a die until it lands on any number other than 4. What is the probability the result is > 4? All of the above answers are correct, but they don't explain why they are correct, and why you can ignore so many details and avoid having to solve a complicated recurrence relation. The reason why the other answers are correct is the Strong Markov property, which for a discrete Markov Chain is equivalent to the regular Markov property. https://en.wikipedia.org/wiki/Markov_property#Strong_Markov_property Basically the idea is that the random variable $\tau:=($the number of times until the die does not land on 4 for the first time) is a stopping time. https://en.wikipedia.org/wiki/Stopping_time A stopping time is a random variable which doesn't depend on any future information. In order to tell whether the $n$th roll of the die is the first one which has not landed on a 4 (i.e. in order to decide whether $\tau=n$), you only need to know the value of the current roll, and of all previous rolls, but not of any future rolls -- thus $\tau$ is a stopping time, and the Strong Markov property applies. What does the Strong Markov property say? It says that the number which the die lands on at the $\tau$th roll, as a random variable, $X_{\tau}$, is independent of the values of ALL previous rolls. So if the die rolls 4 once, twice, ..., 50 million times, ..., $\tau -1$ times before finally landing on another value for the $\tau$th roll, it won't affect the probability of the event that $X_{\tau} > 4$. $$\mathbb{P}(X_{\tau}>4|\tau=1)=\mathbb{P}(X_{\tau}>4|\tau=2)=\dots = \mathbb{P}(X_{\tau}>4|\tau=50,000,000)=\dots $$ Therefore we can assume, without loss of generality, that $\tau=1$. This is just the probability that the die lands a value greater than 4 given that it does not land on 4, which we can calculate very easily: $$\mathbb{P}(X_1>4|X\not=4) = \frac{\mathbb{P}(X_1 > 4 \cap X_1 \not=4)}{\mathbb{P}(X_1 \not= 4)} = \frac{\mathbb{P}(X_1 > 4)}{\mathbb{P}(X_1 \not=4)}=\frac{\frac{1}{3}}{\frac{5}{6}}=\frac{1}{3}\cdot\frac{6}{5}=\frac{2}{5} $$ which of course is the correct answer. You can read more about stopping times and the Strong Markov property in Section 8.3 of (the 4th edition of) Durrett's Probability Theory and Examples, p. 365.
Roll a die until it lands on any number other than 4. What is the probability the result is > 4? All of the above answers are correct, but they don't explain why they are correct, and why you can ignore so many details and avoid having to solve a complicated recurrence relation. The reason why th
13,604
Roll a die until it lands on any number other than 4. What is the probability the result is > 4?
Another way to look at the problem. Lets call a 'real result' a 1,2,3,5 or 6. What is the probability of winning on the first roll, if you got a 'real result'? 2/5 What is the probability of winning on the second roll, if the second roll is the first time you got a 'real result'? 2/5 Same for third, fourth. So, you can break your sample in (infinte) smaller samples, and those samples all give the same probability.
Roll a die until it lands on any number other than 4. What is the probability the result is > 4?
Another way to look at the problem. Lets call a 'real result' a 1,2,3,5 or 6. What is the probability of winning on the first roll, if you got a 'real result'? 2/5 What is the probability of winning o
Roll a die until it lands on any number other than 4. What is the probability the result is > 4? Another way to look at the problem. Lets call a 'real result' a 1,2,3,5 or 6. What is the probability of winning on the first roll, if you got a 'real result'? 2/5 What is the probability of winning on the second roll, if the second roll is the first time you got a 'real result'? 2/5 Same for third, fourth. So, you can break your sample in (infinte) smaller samples, and those samples all give the same probability.
Roll a die until it lands on any number other than 4. What is the probability the result is > 4? Another way to look at the problem. Lets call a 'real result' a 1,2,3,5 or 6. What is the probability of winning on the first roll, if you got a 'real result'? 2/5 What is the probability of winning o
13,605
Why isn't variance defined as the difference between every value following each other?
The most obvious reason is that there is often no time sequence in the values. So if you jumble the data, it makes no difference in the information conveyed by the data. If we follow your method, then every time you jumble the data you get a different sample variance. The more theoretical answer is that sample variance estimates the true variance of a random variable. The true variance of a random variable $X$ is $$E\left[ (X - EX)^2 \right]. $$ Here $E$ represents expectation or "average value". So the definition of the variance is the average squared distance between the variable from its average value. When you look at this definition, there is no "time order" here since there is no data. It is just an attribute of the random variable. When you collect iid data from this distribution, you have realizations $x_1, x_2, \dots, x_n$. The best way to estimate the expectation is to take the sample averages. The key here is that we got iid data, and thus there is no ordering to the data. The sample $x_1, x_2, \dots, x_n$ is the same as the sample $x_2, x_5, x_1, x_n..$ EDIT Sample variance measures a specific kind of dispersion for the sample, the one that measures the average distance from the mean. There are other kinds of dispersion like range of data, and Inter-Quantile range. Even if you sort your values in ascending order, that does not change the characteristics of the sample. The sample (data) you get are realizations from a variable. Calculating the sample variance is akin to understanding how much dispersion is in the variable. So for example, if you sample 20 people, and calculate their height, then those are 20 "realizations" from the random variable $X = $ height of people. Now the sample variance is supposed to measure the variability in the height of individuals in general. If you order the data $$ 100, 110, 123, 124, \dots,$$ that does not change the information in the sample. Lets look at one more example. lets say you have 100 observations from a random variable ordered in this way $$1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, ... 100.$$ Then the average subsequent distance is 1 units, so by your method the variance will be 1. The way to interpret "variance" or "dispersion" is to understand what range of values are likely for the data. In this case you will get a range of .99 unit, which of course does not represent the variation well. If instead of taking average you just sum the subsequent differences, then your variance will be 99. Of course that does not represent the variability in the sample, because 99 gives you the range of the data, not a sense of variability.
Why isn't variance defined as the difference between every value following each other?
The most obvious reason is that there is often no time sequence in the values. So if you jumble the data, it makes no difference in the information conveyed by the data. If we follow your method, then
Why isn't variance defined as the difference between every value following each other? The most obvious reason is that there is often no time sequence in the values. So if you jumble the data, it makes no difference in the information conveyed by the data. If we follow your method, then every time you jumble the data you get a different sample variance. The more theoretical answer is that sample variance estimates the true variance of a random variable. The true variance of a random variable $X$ is $$E\left[ (X - EX)^2 \right]. $$ Here $E$ represents expectation or "average value". So the definition of the variance is the average squared distance between the variable from its average value. When you look at this definition, there is no "time order" here since there is no data. It is just an attribute of the random variable. When you collect iid data from this distribution, you have realizations $x_1, x_2, \dots, x_n$. The best way to estimate the expectation is to take the sample averages. The key here is that we got iid data, and thus there is no ordering to the data. The sample $x_1, x_2, \dots, x_n$ is the same as the sample $x_2, x_5, x_1, x_n..$ EDIT Sample variance measures a specific kind of dispersion for the sample, the one that measures the average distance from the mean. There are other kinds of dispersion like range of data, and Inter-Quantile range. Even if you sort your values in ascending order, that does not change the characteristics of the sample. The sample (data) you get are realizations from a variable. Calculating the sample variance is akin to understanding how much dispersion is in the variable. So for example, if you sample 20 people, and calculate their height, then those are 20 "realizations" from the random variable $X = $ height of people. Now the sample variance is supposed to measure the variability in the height of individuals in general. If you order the data $$ 100, 110, 123, 124, \dots,$$ that does not change the information in the sample. Lets look at one more example. lets say you have 100 observations from a random variable ordered in this way $$1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, ... 100.$$ Then the average subsequent distance is 1 units, so by your method the variance will be 1. The way to interpret "variance" or "dispersion" is to understand what range of values are likely for the data. In this case you will get a range of .99 unit, which of course does not represent the variation well. If instead of taking average you just sum the subsequent differences, then your variance will be 99. Of course that does not represent the variability in the sample, because 99 gives you the range of the data, not a sense of variability.
Why isn't variance defined as the difference between every value following each other? The most obvious reason is that there is often no time sequence in the values. So if you jumble the data, it makes no difference in the information conveyed by the data. If we follow your method, then
13,606
Why isn't variance defined as the difference between every value following each other?
It is defined that way! Here's the algebra. Let the values be $\mathbf{x}=(x_1, x_2, \ldots, x_n)$. Denote by $F$ the empirical distribution function of these values (which means each $x_i$ contributes a probability mass of $1/n$ at the value $x_i$) and let $X$ and $Y$ be independent random variables with distribution $F$. By virtue of basic properties of variance (namely, it is a quadratic form) as well as the definition of $F$ and the fact $X$ and $Y$ have the same mean, $$\eqalign{ \operatorname{Var}(\mathbf{x})&=\operatorname{Var}(X) = \frac{1}{2}\left(\operatorname{Var}(X) + \operatorname{Var}(Y)\right)=\frac{1}{2}\left(\operatorname{Var}(X-Y)\right)\\ &=\frac{1}{2}\left(\mathbb{E}((X-Y)^2) - \mathbb{E}(X-Y)^2\right)\\ &=\mathbb{E}\left(\frac{1}{2}(X-Y)^2\right) - 0\\ &=\frac{1}{n^2}\sum_{i,j}\frac{1}{2}(x_i - x_j)^2. }$$ This formula does not depend on the way $\mathbf{x}$ is ordered: it uses all possible pairs of components, comparing them using half their squared differences. It can, however, be related to an average over all possible orderings (the group $\mathfrak{S}(n)$ of all $n!$ permutations of the indices $1,2,\ldots, n$). Namely, $$\operatorname{Var}(\mathbf{x})=\frac{1}{n^2}\sum_{i,j}\frac{1}{2}(x_i - x_j)^2 = \frac{1}{n!}\sum_{\sigma\in\mathfrak{S}(n)} \frac{1}{n} \sum_{i=1}^{n-1} \frac{1}{2}(x_{\sigma(i)} - x_{\sigma(i+1)})^2.$$ That inner summation takes the reordered values $x_{\sigma(1)}, x_{\sigma(2)}, \ldots, x_{\sigma(n)}$ and sums the (half) squared differences between all $n-1$ successive pairs. The division by $n$ essentially averages these successive squared differences. It computes what is known as the lag-1 semivariance. The outer summation does this for all possible orderings. These two equivalent algebraic views of the standard variance formula give new insight into what the variance means. The semivariance is an inverse measure of the serial covariance of a sequence: the covariance is high (and the numbers are positively correlated) when the semivariance is low, and conversely. The variance of an unordered dataset, then, is a kind of average of all possible semivariances obtainable under arbitrary reorderings.
Why isn't variance defined as the difference between every value following each other?
It is defined that way! Here's the algebra. Let the values be $\mathbf{x}=(x_1, x_2, \ldots, x_n)$. Denote by $F$ the empirical distribution function of these values (which means each $x_i$ contribu
Why isn't variance defined as the difference between every value following each other? It is defined that way! Here's the algebra. Let the values be $\mathbf{x}=(x_1, x_2, \ldots, x_n)$. Denote by $F$ the empirical distribution function of these values (which means each $x_i$ contributes a probability mass of $1/n$ at the value $x_i$) and let $X$ and $Y$ be independent random variables with distribution $F$. By virtue of basic properties of variance (namely, it is a quadratic form) as well as the definition of $F$ and the fact $X$ and $Y$ have the same mean, $$\eqalign{ \operatorname{Var}(\mathbf{x})&=\operatorname{Var}(X) = \frac{1}{2}\left(\operatorname{Var}(X) + \operatorname{Var}(Y)\right)=\frac{1}{2}\left(\operatorname{Var}(X-Y)\right)\\ &=\frac{1}{2}\left(\mathbb{E}((X-Y)^2) - \mathbb{E}(X-Y)^2\right)\\ &=\mathbb{E}\left(\frac{1}{2}(X-Y)^2\right) - 0\\ &=\frac{1}{n^2}\sum_{i,j}\frac{1}{2}(x_i - x_j)^2. }$$ This formula does not depend on the way $\mathbf{x}$ is ordered: it uses all possible pairs of components, comparing them using half their squared differences. It can, however, be related to an average over all possible orderings (the group $\mathfrak{S}(n)$ of all $n!$ permutations of the indices $1,2,\ldots, n$). Namely, $$\operatorname{Var}(\mathbf{x})=\frac{1}{n^2}\sum_{i,j}\frac{1}{2}(x_i - x_j)^2 = \frac{1}{n!}\sum_{\sigma\in\mathfrak{S}(n)} \frac{1}{n} \sum_{i=1}^{n-1} \frac{1}{2}(x_{\sigma(i)} - x_{\sigma(i+1)})^2.$$ That inner summation takes the reordered values $x_{\sigma(1)}, x_{\sigma(2)}, \ldots, x_{\sigma(n)}$ and sums the (half) squared differences between all $n-1$ successive pairs. The division by $n$ essentially averages these successive squared differences. It computes what is known as the lag-1 semivariance. The outer summation does this for all possible orderings. These two equivalent algebraic views of the standard variance formula give new insight into what the variance means. The semivariance is an inverse measure of the serial covariance of a sequence: the covariance is high (and the numbers are positively correlated) when the semivariance is low, and conversely. The variance of an unordered dataset, then, is a kind of average of all possible semivariances obtainable under arbitrary reorderings.
Why isn't variance defined as the difference between every value following each other? It is defined that way! Here's the algebra. Let the values be $\mathbf{x}=(x_1, x_2, \ldots, x_n)$. Denote by $F$ the empirical distribution function of these values (which means each $x_i$ contribu
13,607
Why isn't variance defined as the difference between every value following each other?
Just a complement to the other answers, variance can be computed as the squared difference between terms: $$\begin{align} &\text{Var}(X) = \\ &\frac{1}{2\cdot n^2}\sum_i^n\sum_j^n \left(x_i-x_j\right)^2 = \\ &\frac{1}{2\cdot n^2}\sum_i^n\sum_j^n \left(x_i - \overline x -x_j + \overline x\right)^2 = \\ &\frac{1}{2\cdot n^2}\sum_i^n\sum_j^n \left((x_i - \overline x) -(x_j - \overline x\right))^2 = \\ &\frac{1}{n}\sum_i^n \left(x_i - \overline x \right)^2 \end{align}$$ I think this is the closest to the OP proposition. Remember the variance is a measure of dispersion of every observation at once, not only between "neighboring" numbers in the set. UPDATE Using your example: $X = {1, 2, 3, 4, 5}$. We know the variance is $Var(X) = 2$. With your proposed method $Var(X) = 1$, so we know beforehand taking the differences between neighbors as variance doesn't add up. What I meant was taking every possible difference squared then summed: $$Var(X) = \\ = \frac{(5-1)^2+(5-2)^2+(5-3)^2+(5-4)^2+(5-5)^2+(4-1)^2+(4-2)^2+(4-3)^2+(4-4)^2+(4-5)^2+(3-1)^2+(3-2)^2+(3-3)^2+(3-4)^2+(3-5)^2+(2-1)^2+(2-2)^2+(2-3)^2+(2-4)^2+(2-5)^2+(1-1)^2+(1-2)^2+(1-3)^2+(1-4)^2+(1-5)^2}{2 \cdot 5^2} = \\ =\frac{16+9+4+1+9+4+1+1+4+1+1+4+1+1+4+9+1+4+9+16}{50} = \\ =2$$
Why isn't variance defined as the difference between every value following each other?
Just a complement to the other answers, variance can be computed as the squared difference between terms: $$\begin{align} &\text{Var}(X) = \\ &\frac{1}{2\cdot n^2}\sum_i^n\sum_j^n \left(x_i-x_j\right)
Why isn't variance defined as the difference between every value following each other? Just a complement to the other answers, variance can be computed as the squared difference between terms: $$\begin{align} &\text{Var}(X) = \\ &\frac{1}{2\cdot n^2}\sum_i^n\sum_j^n \left(x_i-x_j\right)^2 = \\ &\frac{1}{2\cdot n^2}\sum_i^n\sum_j^n \left(x_i - \overline x -x_j + \overline x\right)^2 = \\ &\frac{1}{2\cdot n^2}\sum_i^n\sum_j^n \left((x_i - \overline x) -(x_j - \overline x\right))^2 = \\ &\frac{1}{n}\sum_i^n \left(x_i - \overline x \right)^2 \end{align}$$ I think this is the closest to the OP proposition. Remember the variance is a measure of dispersion of every observation at once, not only between "neighboring" numbers in the set. UPDATE Using your example: $X = {1, 2, 3, 4, 5}$. We know the variance is $Var(X) = 2$. With your proposed method $Var(X) = 1$, so we know beforehand taking the differences between neighbors as variance doesn't add up. What I meant was taking every possible difference squared then summed: $$Var(X) = \\ = \frac{(5-1)^2+(5-2)^2+(5-3)^2+(5-4)^2+(5-5)^2+(4-1)^2+(4-2)^2+(4-3)^2+(4-4)^2+(4-5)^2+(3-1)^2+(3-2)^2+(3-3)^2+(3-4)^2+(3-5)^2+(2-1)^2+(2-2)^2+(2-3)^2+(2-4)^2+(2-5)^2+(1-1)^2+(1-2)^2+(1-3)^2+(1-4)^2+(1-5)^2}{2 \cdot 5^2} = \\ =\frac{16+9+4+1+9+4+1+1+4+1+1+4+1+1+4+9+1+4+9+16}{50} = \\ =2$$
Why isn't variance defined as the difference between every value following each other? Just a complement to the other answers, variance can be computed as the squared difference between terms: $$\begin{align} &\text{Var}(X) = \\ &\frac{1}{2\cdot n^2}\sum_i^n\sum_j^n \left(x_i-x_j\right)
13,608
Why isn't variance defined as the difference between every value following each other?
Others have answered about the usefulness of variance defined as usual. Anyway, we just have two legitimate definitions of different things: the usual definition of variance, and your definition. Then, the main question is why the first one is called variance and not yours. That is just a matter of convention. Until 1918 you could have invented anything you want and called it "variance", but in 1918 Fisher used that name to what is still called variance, and if you want to define anything else you will need to find another name to name it. The other question is if the thing you defined might be useful for anything. Others have pointed its problems to be used as a measure of dispersion, but it's up to you to find applications for it. Maybe you find so useful applications that in a century your thing is more famous than variance.
Why isn't variance defined as the difference between every value following each other?
Others have answered about the usefulness of variance defined as usual. Anyway, we just have two legitimate definitions of different things: the usual definition of variance, and your definition. Then
Why isn't variance defined as the difference between every value following each other? Others have answered about the usefulness of variance defined as usual. Anyway, we just have two legitimate definitions of different things: the usual definition of variance, and your definition. Then, the main question is why the first one is called variance and not yours. That is just a matter of convention. Until 1918 you could have invented anything you want and called it "variance", but in 1918 Fisher used that name to what is still called variance, and if you want to define anything else you will need to find another name to name it. The other question is if the thing you defined might be useful for anything. Others have pointed its problems to be used as a measure of dispersion, but it's up to you to find applications for it. Maybe you find so useful applications that in a century your thing is more famous than variance.
Why isn't variance defined as the difference between every value following each other? Others have answered about the usefulness of variance defined as usual. Anyway, we just have two legitimate definitions of different things: the usual definition of variance, and your definition. Then
13,609
Why isn't variance defined as the difference between every value following each other?
@GreenParker answer is more complete, but an intuitive example might be useful to illustrate the drawback to your approach. In your question, you seem to assume that the order in which realisations of a random variable appear matters. However, it is easy to think of examples in which it doesn't. Consider the example of the height of individuals in a population. The order in which individuals are measured is irrelevant to both the mean height in the population and the variance (how spread out those values are around the mean). Your method would seem odd applied to such a case.
Why isn't variance defined as the difference between every value following each other?
@GreenParker answer is more complete, but an intuitive example might be useful to illustrate the drawback to your approach. In your question, you seem to assume that the order in which realisations o
Why isn't variance defined as the difference between every value following each other? @GreenParker answer is more complete, but an intuitive example might be useful to illustrate the drawback to your approach. In your question, you seem to assume that the order in which realisations of a random variable appear matters. However, it is easy to think of examples in which it doesn't. Consider the example of the height of individuals in a population. The order in which individuals are measured is irrelevant to both the mean height in the population and the variance (how spread out those values are around the mean). Your method would seem odd applied to such a case.
Why isn't variance defined as the difference between every value following each other? @GreenParker answer is more complete, but an intuitive example might be useful to illustrate the drawback to your approach. In your question, you seem to assume that the order in which realisations o
13,610
Why isn't variance defined as the difference between every value following each other?
Although there are many good answers to this question I believe some important points where left behind and since this question came up with a really interesting point I would like to provide yet another point of view. Why isn't variance defined as the difference between every value following each other instead of the difference to the average of the values? The first thing to have in mind is that the variance is a particular kind of parameter, and not a certain type of calculation. There is a rigorous mathematical definition of what a parameter is but for the time been we can think of then as mathematical operations on the distribution of a random variable. For example if $X$ is a random variable with distribution function $F_X$ then its mean $\mu_x$, which is also a parameter, is: $$\mu_X = \int_{-\infty}^{+\infty}xdF_{X}(x)$$ and the variance of $X$, $\sigma^2_X$, is: $$\sigma^2_X = \int_{-\infty}^{+\infty}(x - \mu_X)^2dF_{X}(x)$$ The role of estimation in statistics is to provide, from a set of realizations of a r.v., a good approximation for the parameters of interest. What I wanted to show is that there is a big difference in the concepts of a parameters (the variance for this particular question) and the statistic we use to estimate it. Why isn't the variance calculated this way? So we want to estimate the variance of a random variable $X$ from a set of independent realizations of it, lets say $x = \{x_1,\ldots,x_n\}$. The way you propose doing it is by computing the absolute value of successive differences, summing and taking the mean: $$\psi(x) = \frac{1}{n}\sum_{i = 2}^{n}|x_i - x_{i-1}|$$ and the usual statistic is: $$S^2(x) = \frac{1}{n-1}\sum_{i = i}^{n}(x_i - \bar{x})^2,$$ where $\bar{x}$ is the sample mean. When comparing two estimator of a parameter the usual criterion for the best one is that which has minimal mean square error (MSE), and a important property of MSE is that it can be decomposed in two components: MSE = estimator bias + estimator variance. Using this criterion the usual statistic, $S^2$, has some advantages over the one you suggests. First it is a unbiased estimator of the variance but your statistic is not unbiased. One other important thing is that if we are working with the normal distribution then $S^2$ is the best unbiased estimator of $\sigma^2$ in the sense that it has the smallest variance among all unbiased estimators and thus minimizes the MSE. When normality is assumed, as is the case in many applications, $S^2$ is the natural choice when you want to estimate the variance.
Why isn't variance defined as the difference between every value following each other?
Although there are many good answers to this question I believe some important points where left behind and since this question came up with a really interesting point I would like to provide yet anot
Why isn't variance defined as the difference between every value following each other? Although there are many good answers to this question I believe some important points where left behind and since this question came up with a really interesting point I would like to provide yet another point of view. Why isn't variance defined as the difference between every value following each other instead of the difference to the average of the values? The first thing to have in mind is that the variance is a particular kind of parameter, and not a certain type of calculation. There is a rigorous mathematical definition of what a parameter is but for the time been we can think of then as mathematical operations on the distribution of a random variable. For example if $X$ is a random variable with distribution function $F_X$ then its mean $\mu_x$, which is also a parameter, is: $$\mu_X = \int_{-\infty}^{+\infty}xdF_{X}(x)$$ and the variance of $X$, $\sigma^2_X$, is: $$\sigma^2_X = \int_{-\infty}^{+\infty}(x - \mu_X)^2dF_{X}(x)$$ The role of estimation in statistics is to provide, from a set of realizations of a r.v., a good approximation for the parameters of interest. What I wanted to show is that there is a big difference in the concepts of a parameters (the variance for this particular question) and the statistic we use to estimate it. Why isn't the variance calculated this way? So we want to estimate the variance of a random variable $X$ from a set of independent realizations of it, lets say $x = \{x_1,\ldots,x_n\}$. The way you propose doing it is by computing the absolute value of successive differences, summing and taking the mean: $$\psi(x) = \frac{1}{n}\sum_{i = 2}^{n}|x_i - x_{i-1}|$$ and the usual statistic is: $$S^2(x) = \frac{1}{n-1}\sum_{i = i}^{n}(x_i - \bar{x})^2,$$ where $\bar{x}$ is the sample mean. When comparing two estimator of a parameter the usual criterion for the best one is that which has minimal mean square error (MSE), and a important property of MSE is that it can be decomposed in two components: MSE = estimator bias + estimator variance. Using this criterion the usual statistic, $S^2$, has some advantages over the one you suggests. First it is a unbiased estimator of the variance but your statistic is not unbiased. One other important thing is that if we are working with the normal distribution then $S^2$ is the best unbiased estimator of $\sigma^2$ in the sense that it has the smallest variance among all unbiased estimators and thus minimizes the MSE. When normality is assumed, as is the case in many applications, $S^2$ is the natural choice when you want to estimate the variance.
Why isn't variance defined as the difference between every value following each other? Although there are many good answers to this question I believe some important points where left behind and since this question came up with a really interesting point I would like to provide yet anot
13,611
Why isn't variance defined as the difference between every value following each other?
The time-stepped difference is indeed used in one form, the Allan Variance. http://www.allanstime.com/AllanVariance/
Why isn't variance defined as the difference between every value following each other?
The time-stepped difference is indeed used in one form, the Allan Variance. http://www.allanstime.com/AllanVariance/
Why isn't variance defined as the difference between every value following each other? The time-stepped difference is indeed used in one form, the Allan Variance. http://www.allanstime.com/AllanVariance/
Why isn't variance defined as the difference between every value following each other? The time-stepped difference is indeed used in one form, the Allan Variance. http://www.allanstime.com/AllanVariance/
13,612
Why isn't variance defined as the difference between every value following each other?
Lots of good answers here, but I'll add a few. The way it is defined now has proven useful. For example, normal distributions appear all the time in data and a normal distribution is defined by its mean and variance. Edit: as @whuber pointed out in a comment, there are various other ways specify a normal distribution. But none of them, as far as I'm aware, deal with pairs of points in sequence. Variance as normally defined gives you a measure of how spread out the data is. For example, lets say you have a lot of data points with a mean of zero but when you look at it, you see that the data is mostly either around -1 or around 1. Your variance would be about 1. However, under your measure, you would get a total of zero. Which one is more useful? Well, it depends, but its not clear to me that a measure of zero for its "variance" would make sense. It lets you do other stuff. Just an example, in my stats class we saw a video about comparing pitchers (in baseball) over time. As I remember it, pitchers appeared to be getting worse since the proportion of pitches that were hit (or were home-runs) was going up. One reason is that batters were getting better. This made it hard to compare pitchers over time. However, they could use the z-score of the pitchers to compare them over time. Nonetheless, as @Pere said, your metric might prove itself very useful in the future.
Why isn't variance defined as the difference between every value following each other?
Lots of good answers here, but I'll add a few. The way it is defined now has proven useful. For example, normal distributions appear all the time in data and a normal distribution is defined by its m
Why isn't variance defined as the difference between every value following each other? Lots of good answers here, but I'll add a few. The way it is defined now has proven useful. For example, normal distributions appear all the time in data and a normal distribution is defined by its mean and variance. Edit: as @whuber pointed out in a comment, there are various other ways specify a normal distribution. But none of them, as far as I'm aware, deal with pairs of points in sequence. Variance as normally defined gives you a measure of how spread out the data is. For example, lets say you have a lot of data points with a mean of zero but when you look at it, you see that the data is mostly either around -1 or around 1. Your variance would be about 1. However, under your measure, you would get a total of zero. Which one is more useful? Well, it depends, but its not clear to me that a measure of zero for its "variance" would make sense. It lets you do other stuff. Just an example, in my stats class we saw a video about comparing pitchers (in baseball) over time. As I remember it, pitchers appeared to be getting worse since the proportion of pitches that were hit (or were home-runs) was going up. One reason is that batters were getting better. This made it hard to compare pitchers over time. However, they could use the z-score of the pitchers to compare them over time. Nonetheless, as @Pere said, your metric might prove itself very useful in the future.
Why isn't variance defined as the difference between every value following each other? Lots of good answers here, but I'll add a few. The way it is defined now has proven useful. For example, normal distributions appear all the time in data and a normal distribution is defined by its m
13,613
Three questions about the article "Ditch p-values. Use Bootstrap confidence intervals instead"
1 They don’t mean what people think they mean Am I right that this is not a p-value (which is the probability to see this or more extreme value of a test statistic)? Is it a correct procedure for a statistical testing? I have a gut feeling that it is a wrong situation to apply hypothesis testing, but I can not formally answer why. One could argue that technically speaking it is a p-value. But, it is a rather meaningless p-value. There are two ways to look at it as a meaningless p-value Neyman and Pearson suggest that, in order to compute the p-value, you choose the region where the likelihood ratio (between the null hypothesis and alternative hypothesis) is the highest. You count observations as 'extreme' when a deviation from the null hypothesis would mean more likelihood to make that extreme observation. This is not the case with the US citizen example. If the null hypothesis 'Robert is a US citizen' is false, then the observation 'Robert is a US senator' is in no way more likely. So from the viewpoint of Neyman's and Pearson's approach to hypothesis testing, this is a very bad type of calculation for a p-value. From the viewpoint of Fisher's approach to hypothesis testing, you have a measurement of some effect and the point of the p-value is to quantify the statistical significance. It is useful as an expression of the precision of an experiment. The p-value quantifies how good/accurate the experiment is in the quantification of the deviation. Statistically speaking effects will always occur to some extent due to random fluctuations in the measurements. An observation is seen as statistically significant when it is a fluctuation of a sufficiently large size such that it has a low probability that we observe a seemingly effect when there is actually no effect (when the null hypothesis is true). Experiments that have a high probability that we observe an effect while there is actually no effect are not very useful. We use p-values to express this probability. By reporting p-values researchers can show that their experiments have sufficiently small noise and sufficiently large sample size, such that the observed effects are statistically significant (unlikely to be just noise). Fisher's p-values are an expression of the noise and random fluctuations, they are a sort of expression of signal/noise ratio. The advice is to only reject a hypothesis when an effect is sufficiently large compared to the noise level. Even though there is no alternative hypothesis in Fisher's viewpoint, when we express a p-value then this is done for the measurement of some effect as a deviation relative to a null (no effect) hypothesis. There must be some sense of a direction that can be considered to be an effect or a deviation. In the case of the experiment with US citizenship, the measurement of 'Robert is a US senator' has nothing to do with the measurement of some effect or a deviation from the null hypothesis. Expressing a p-value for it is meaningless. The example with US citizenship may be a bit weird and wrong. However, it is not meant to be correct. The point is to show that simply a p-value is not very meaningful and correct. What we need to consider is also the power of a test (and that is missing in the example with US citizenship). A low p-value might be nice, but what if the p-value would be just as well low, or even lower, for an alternative explanation? If you have a bad hypothesis test then we could 'reject a hypothesis' based on a (crappy) low p-value while actually, no alternative hypothesis is better suitable. Example 1: Say you have two jars one with 50% gold and 50% silver coins, the other with 75% gold and 25% silver coins. You take 10 coins out of one jar, and they are all silver, which jar do we have? We could say that the prior odds were 1:1 and the posterior odds are 1:1024. We can say that the jar is very likely the one with 50:50 gold:silver, but both hypotheses are unlikely when we observe 10 silver coins and maybe we should mistrust our model. Example 2: Say you have data that is distributed by a quadratic curve y = a + c x^2. But you fit it with a straight linear line y = a + b x. When we fit a model we find that the p-value is extremely low for a zero slope (no effect) since the data does not match a flat line (as it is following a quadratic curve). But does that mean that we should reject the hypothesis that the coefficient b is zero? The discrepancy, low p-value, is not because the null hypothesis is false, but because out entire model is false (that is the actual conclusion when the p-value is low, the null hypothesis and/or the statistical model is false). 2 They rely on hidden assumptions It seems to be wrong, but the question is: can we say that non-parametric tests also rely on some regular statistical distributions? Not only they have assumptions, but also, technically, their statistics also follow some distributions The point of non-parametric tests is that we make no assumptions about the data. But the statistic that we compute may follow some distribution. Example: We wonder whether one sample is larger than another sample. Let's say that the samples are paired. Then without knowing anything about the distribution we can just count which of the pairs is larger. Independent of the distribution of the population from which the sample has been taken, this sign statistic will follow a binomial distribution. So the point of non-parametric tests is not that the statistic that is being computed has no distribution, but that the distribution of the statistic is independent from the distribution of the data. The point of this "They rely on hidden assumptions" is correct. However, it is a bit harsh and sketches the assumptions in a limited sense (as if assumptions are only simplifications to make computations easy). Indeed many models are simplifications. But I would say that the parametric distributions are still useful, even when we have much more computation power nowadays and simplifications are not necessary. The reason is that parametric distributions are not always simplifications. On the one hand: Bootstrapping or other simulations can approach the same result as a computation, and when the computation makes assumptions, approximations and simplifications then the bootstrapping may even do better. On the other hand: The parametric distribution, if it is true, gives you information that bootstrapping can't give you. When you have only little amount of data then you can't get a proper estimate of p-values or confidence intervals. With parametric distributions you can fill the gap. Example: if you have ten samples from a distribution, then you might estimate the quantile at multiples of 10%, but you won't be able to estimate smaller quantiles. If you know that the distribution can be approximated by some distribution (based on theory and previous knowledge such assumptions might not be bad) then you can use a fit with the parametric distribution to interpolate and extrapolate the ten samples to other quantiles. Example 2: The representation of parametric tests as being only useful for making calculations easier is a straw man argument. It is not true because it is far from the only reason. The main reason why people use parametric tests is because they are more powerful. Compare for instance the parametric t-test with the non-parametric Mann-Whitney U test. The choice for the former is not because the computation is easier, but because it can be more powerfull. 3 They detract from the real questions Can we, based on confidence intervals, say, what is an expected value? Is in this situation a clear decision? I always thought that confidence intervals are not necessarily symmetric, but I started to doubt here. No, confidence intervals do not give full information. You should instead compute some cost function that quantifies all consideration in the decision (requiring the full distribution). But confidence intervals may be a reasonable indication. The step from a single point estimate to a range is a big difference and adds an entire new dimension to the representation. Your criticism here is also exactly the point of the author of the blogpost. You criticize the confidence intervals not giving full information. But the means 0.08 for action A and 0.001 for action B have even less information than the confidence intervals, and that is what the author is pointing out. This third point is more a matter of point estimate versus interval estimates. Maybe p-values promote the use of point estimates, but it is a bit far-fetched to use it as criticism against p-values. The example is not even a case that is about p-values and it is about a Bayesian posterior for two situations.
Three questions about the article "Ditch p-values. Use Bootstrap confidence intervals instead"
1 They don’t mean what people think they mean Am I right that this is not a p-value (which is the probability to see this or more extreme value of a test statistic)? Is it a correct procedure for a s
Three questions about the article "Ditch p-values. Use Bootstrap confidence intervals instead" 1 They don’t mean what people think they mean Am I right that this is not a p-value (which is the probability to see this or more extreme value of a test statistic)? Is it a correct procedure for a statistical testing? I have a gut feeling that it is a wrong situation to apply hypothesis testing, but I can not formally answer why. One could argue that technically speaking it is a p-value. But, it is a rather meaningless p-value. There are two ways to look at it as a meaningless p-value Neyman and Pearson suggest that, in order to compute the p-value, you choose the region where the likelihood ratio (between the null hypothesis and alternative hypothesis) is the highest. You count observations as 'extreme' when a deviation from the null hypothesis would mean more likelihood to make that extreme observation. This is not the case with the US citizen example. If the null hypothesis 'Robert is a US citizen' is false, then the observation 'Robert is a US senator' is in no way more likely. So from the viewpoint of Neyman's and Pearson's approach to hypothesis testing, this is a very bad type of calculation for a p-value. From the viewpoint of Fisher's approach to hypothesis testing, you have a measurement of some effect and the point of the p-value is to quantify the statistical significance. It is useful as an expression of the precision of an experiment. The p-value quantifies how good/accurate the experiment is in the quantification of the deviation. Statistically speaking effects will always occur to some extent due to random fluctuations in the measurements. An observation is seen as statistically significant when it is a fluctuation of a sufficiently large size such that it has a low probability that we observe a seemingly effect when there is actually no effect (when the null hypothesis is true). Experiments that have a high probability that we observe an effect while there is actually no effect are not very useful. We use p-values to express this probability. By reporting p-values researchers can show that their experiments have sufficiently small noise and sufficiently large sample size, such that the observed effects are statistically significant (unlikely to be just noise). Fisher's p-values are an expression of the noise and random fluctuations, they are a sort of expression of signal/noise ratio. The advice is to only reject a hypothesis when an effect is sufficiently large compared to the noise level. Even though there is no alternative hypothesis in Fisher's viewpoint, when we express a p-value then this is done for the measurement of some effect as a deviation relative to a null (no effect) hypothesis. There must be some sense of a direction that can be considered to be an effect or a deviation. In the case of the experiment with US citizenship, the measurement of 'Robert is a US senator' has nothing to do with the measurement of some effect or a deviation from the null hypothesis. Expressing a p-value for it is meaningless. The example with US citizenship may be a bit weird and wrong. However, it is not meant to be correct. The point is to show that simply a p-value is not very meaningful and correct. What we need to consider is also the power of a test (and that is missing in the example with US citizenship). A low p-value might be nice, but what if the p-value would be just as well low, or even lower, for an alternative explanation? If you have a bad hypothesis test then we could 'reject a hypothesis' based on a (crappy) low p-value while actually, no alternative hypothesis is better suitable. Example 1: Say you have two jars one with 50% gold and 50% silver coins, the other with 75% gold and 25% silver coins. You take 10 coins out of one jar, and they are all silver, which jar do we have? We could say that the prior odds were 1:1 and the posterior odds are 1:1024. We can say that the jar is very likely the one with 50:50 gold:silver, but both hypotheses are unlikely when we observe 10 silver coins and maybe we should mistrust our model. Example 2: Say you have data that is distributed by a quadratic curve y = a + c x^2. But you fit it with a straight linear line y = a + b x. When we fit a model we find that the p-value is extremely low for a zero slope (no effect) since the data does not match a flat line (as it is following a quadratic curve). But does that mean that we should reject the hypothesis that the coefficient b is zero? The discrepancy, low p-value, is not because the null hypothesis is false, but because out entire model is false (that is the actual conclusion when the p-value is low, the null hypothesis and/or the statistical model is false). 2 They rely on hidden assumptions It seems to be wrong, but the question is: can we say that non-parametric tests also rely on some regular statistical distributions? Not only they have assumptions, but also, technically, their statistics also follow some distributions The point of non-parametric tests is that we make no assumptions about the data. But the statistic that we compute may follow some distribution. Example: We wonder whether one sample is larger than another sample. Let's say that the samples are paired. Then without knowing anything about the distribution we can just count which of the pairs is larger. Independent of the distribution of the population from which the sample has been taken, this sign statistic will follow a binomial distribution. So the point of non-parametric tests is not that the statistic that is being computed has no distribution, but that the distribution of the statistic is independent from the distribution of the data. The point of this "They rely on hidden assumptions" is correct. However, it is a bit harsh and sketches the assumptions in a limited sense (as if assumptions are only simplifications to make computations easy). Indeed many models are simplifications. But I would say that the parametric distributions are still useful, even when we have much more computation power nowadays and simplifications are not necessary. The reason is that parametric distributions are not always simplifications. On the one hand: Bootstrapping or other simulations can approach the same result as a computation, and when the computation makes assumptions, approximations and simplifications then the bootstrapping may even do better. On the other hand: The parametric distribution, if it is true, gives you information that bootstrapping can't give you. When you have only little amount of data then you can't get a proper estimate of p-values or confidence intervals. With parametric distributions you can fill the gap. Example: if you have ten samples from a distribution, then you might estimate the quantile at multiples of 10%, but you won't be able to estimate smaller quantiles. If you know that the distribution can be approximated by some distribution (based on theory and previous knowledge such assumptions might not be bad) then you can use a fit with the parametric distribution to interpolate and extrapolate the ten samples to other quantiles. Example 2: The representation of parametric tests as being only useful for making calculations easier is a straw man argument. It is not true because it is far from the only reason. The main reason why people use parametric tests is because they are more powerful. Compare for instance the parametric t-test with the non-parametric Mann-Whitney U test. The choice for the former is not because the computation is easier, but because it can be more powerfull. 3 They detract from the real questions Can we, based on confidence intervals, say, what is an expected value? Is in this situation a clear decision? I always thought that confidence intervals are not necessarily symmetric, but I started to doubt here. No, confidence intervals do not give full information. You should instead compute some cost function that quantifies all consideration in the decision (requiring the full distribution). But confidence intervals may be a reasonable indication. The step from a single point estimate to a range is a big difference and adds an entire new dimension to the representation. Your criticism here is also exactly the point of the author of the blogpost. You criticize the confidence intervals not giving full information. But the means 0.08 for action A and 0.001 for action B have even less information than the confidence intervals, and that is what the author is pointing out. This third point is more a matter of point estimate versus interval estimates. Maybe p-values promote the use of point estimates, but it is a bit far-fetched to use it as criticism against p-values. The example is not even a case that is about p-values and it is about a Bayesian posterior for two situations.
Three questions about the article "Ditch p-values. Use Bootstrap confidence intervals instead" 1 They don’t mean what people think they mean Am I right that this is not a p-value (which is the probability to see this or more extreme value of a test statistic)? Is it a correct procedure for a s
13,614
Three questions about the article "Ditch p-values. Use Bootstrap confidence intervals instead"
"Am I right that this is not a p-value (which is the probability to see this or more extreme value of a test statistic)?" Good question! Yes, you're right, it's not a p-value. What's more the example is not a hypothesis test and it's not a significance test. Anyone who uses it as an argument to discard p-values or hypothesis tests is either confused or attempting to confuse. The alleged p-value 100 / 300,000,000 is actually the likelihood of a person who is observed to be a US citizen being a senator! Not a p-value and, ironically, calculated on the assumption that the person is a citizen! The example of US senators is badly adapted from Cohen's original (1994) that was intended to cast doubt on the utility of 'Fisher's disjunction' that underlies the evidential use of p-values. On Cohen's argument against Fisher's disjunction: [I've lifted this section from a paper (unpublished: rejected!) that I wrote a decade ago.] A very highly cited paper that claims Fisher's disjunction is flawed is that of Cohen (1994), who illustrates his claim by drawing an analogy between Fisher's disjunction and this syllogism: If a person is an American, then he is probably not a member of Congress. This person is a member of Congress. Therefore, he is probably not an American. As Cohen says, the last line of his syllogism about the American is false even though it would be true if the word `probably' were omitted from the first and last lines. However, he is incorrect in suggesting that it is directly analogous to Fisher's disjunction. As Hagen (1997) pointed out in a response published a few years after Cohen's paper, the null hypothesis in Fisher's disjunction refers to the population, whereas in Cohen's syllogism it refers to the sample. Fisher's disjunction looks like this when put into the form of a syllogism: Extreme P-values from random samples are rare under the null hypothesis. An extreme P-value has been observed. (Therefore, either a rare event has occurred or the null hypothesis is false.) Therefore, the null hypothesis is probably false. There is nothing wrong with that, although the line in parentheses is not logically necessary. When Cohen's syllogism is altered to refer to the population, it also is true: Members of Congress are rare in the population of Americans. This person is a member of Congress. (Therefore, either a rare event has occurred or this person is not a random sample from the population of Americans.) Therefore, this person is probably not a random sample from the population of Americans. If a selected person turns out to be a member of Congress then an unusual event has occurred, or the person is a member of a non-American population in which members of Congress are more common, or the selection was not random. Assuming that all members of the American Congress are American there is no relevant non-American population from which the person might have been randomly selected, so the observation casts doubt on the random selection aspect. Cohen is incorrect in his assertion that the Fisher's disjunction lacks logical integrity. (It is worth noting, parenthetically, that Cohen's paper contains many criticisms of null hypothesis testing that refer to problems arising from the use of what he describes as "mechanical dichotomous decisions around the sacred .05 criterion". He is correct in that, but the criticisms do not directly apply to P-values used as indices of evidence.) Cohen, J. (1994). The earth is round (p <.05). American Psychologist, 49(12), 997. Hagen, R. L. (1997). In praise of the null hypothesis statistical test. American Psychologist, 52(1), 15-24.
Three questions about the article "Ditch p-values. Use Bootstrap confidence intervals instead"
"Am I right that this is not a p-value (which is the probability to see this or more extreme value of a test statistic)?" Good question! Yes, you're right, it's not a p-value. What's more the example
Three questions about the article "Ditch p-values. Use Bootstrap confidence intervals instead" "Am I right that this is not a p-value (which is the probability to see this or more extreme value of a test statistic)?" Good question! Yes, you're right, it's not a p-value. What's more the example is not a hypothesis test and it's not a significance test. Anyone who uses it as an argument to discard p-values or hypothesis tests is either confused or attempting to confuse. The alleged p-value 100 / 300,000,000 is actually the likelihood of a person who is observed to be a US citizen being a senator! Not a p-value and, ironically, calculated on the assumption that the person is a citizen! The example of US senators is badly adapted from Cohen's original (1994) that was intended to cast doubt on the utility of 'Fisher's disjunction' that underlies the evidential use of p-values. On Cohen's argument against Fisher's disjunction: [I've lifted this section from a paper (unpublished: rejected!) that I wrote a decade ago.] A very highly cited paper that claims Fisher's disjunction is flawed is that of Cohen (1994), who illustrates his claim by drawing an analogy between Fisher's disjunction and this syllogism: If a person is an American, then he is probably not a member of Congress. This person is a member of Congress. Therefore, he is probably not an American. As Cohen says, the last line of his syllogism about the American is false even though it would be true if the word `probably' were omitted from the first and last lines. However, he is incorrect in suggesting that it is directly analogous to Fisher's disjunction. As Hagen (1997) pointed out in a response published a few years after Cohen's paper, the null hypothesis in Fisher's disjunction refers to the population, whereas in Cohen's syllogism it refers to the sample. Fisher's disjunction looks like this when put into the form of a syllogism: Extreme P-values from random samples are rare under the null hypothesis. An extreme P-value has been observed. (Therefore, either a rare event has occurred or the null hypothesis is false.) Therefore, the null hypothesis is probably false. There is nothing wrong with that, although the line in parentheses is not logically necessary. When Cohen's syllogism is altered to refer to the population, it also is true: Members of Congress are rare in the population of Americans. This person is a member of Congress. (Therefore, either a rare event has occurred or this person is not a random sample from the population of Americans.) Therefore, this person is probably not a random sample from the population of Americans. If a selected person turns out to be a member of Congress then an unusual event has occurred, or the person is a member of a non-American population in which members of Congress are more common, or the selection was not random. Assuming that all members of the American Congress are American there is no relevant non-American population from which the person might have been randomly selected, so the observation casts doubt on the random selection aspect. Cohen is incorrect in his assertion that the Fisher's disjunction lacks logical integrity. (It is worth noting, parenthetically, that Cohen's paper contains many criticisms of null hypothesis testing that refer to problems arising from the use of what he describes as "mechanical dichotomous decisions around the sacred .05 criterion". He is correct in that, but the criticisms do not directly apply to P-values used as indices of evidence.) Cohen, J. (1994). The earth is round (p <.05). American Psychologist, 49(12), 997. Hagen, R. L. (1997). In praise of the null hypothesis statistical test. American Psychologist, 52(1), 15-24.
Three questions about the article "Ditch p-values. Use Bootstrap confidence intervals instead" "Am I right that this is not a p-value (which is the probability to see this or more extreme value of a test statistic)?" Good question! Yes, you're right, it's not a p-value. What's more the example
13,615
Three questions about the article "Ditch p-values. Use Bootstrap confidence intervals instead"
The author of the article suffers from not understanding that hypothesis tests and confidence intervals serve different inferential purposes: The confidence interval (bootstrap or otherwise) serves to provide a plausible range of estimates for a target parameter. The hypothesis test serves to make a decision as to whether there is evidence or lack of evidence for a specific claim about a target parameter.
Three questions about the article "Ditch p-values. Use Bootstrap confidence intervals instead"
The author of the article suffers from not understanding that hypothesis tests and confidence intervals serve different inferential purposes: The confidence interval (bootstrap or otherwise) serves t
Three questions about the article "Ditch p-values. Use Bootstrap confidence intervals instead" The author of the article suffers from not understanding that hypothesis tests and confidence intervals serve different inferential purposes: The confidence interval (bootstrap or otherwise) serves to provide a plausible range of estimates for a target parameter. The hypothesis test serves to make a decision as to whether there is evidence or lack of evidence for a specific claim about a target parameter.
Three questions about the article "Ditch p-values. Use Bootstrap confidence intervals instead" The author of the article suffers from not understanding that hypothesis tests and confidence intervals serve different inferential purposes: The confidence interval (bootstrap or otherwise) serves t
13,616
Three questions about the article "Ditch p-values. Use Bootstrap confidence intervals instead"
I agree that confidence intervals provide a lot more for performing inference than a single p-value for a single hypothesis, but there is no reason to ditch the p-value and no reason to rely solely on bootstrap confidence intervals. The confidence interval is the set of all hypotheses that are not significant (one would fail to reject) at a specific alpha level. The confidence interval is the inversion of a hypothesis test. If one uses percentiles from a bootstrapped sampling distribution this is a crude approximate confidence interval that does not follow proper construction, but works well nevertheless particularly when the parameter estimator is approximately normally distributed. I find the confidence curve to be a great way to visualize frequentist inference. It shows p-values and confidence intervals of all levels for a parameter of interest, analogous to the Bayesian posterior. The best solution is to raise awareness and promote continuing education, rather than discarding methods. Here is a link to a great paper by Eric Gibson on the topic. Here is a link to one of my papers regarding confidence curves and visualizing inference. Gibson, E. (2020). The Role of p-Values in Judging the Strength of Evidence and Realistic Replication Expectations. Statistics in Biopharmaceutical Research. 13(1):1-13 Johnson, G. S. (2021). Decision Making in Drug Development via Inference on Power. Manuscript.
Three questions about the article "Ditch p-values. Use Bootstrap confidence intervals instead"
I agree that confidence intervals provide a lot more for performing inference than a single p-value for a single hypothesis, but there is no reason to ditch the p-value and no reason to rely solely on
Three questions about the article "Ditch p-values. Use Bootstrap confidence intervals instead" I agree that confidence intervals provide a lot more for performing inference than a single p-value for a single hypothesis, but there is no reason to ditch the p-value and no reason to rely solely on bootstrap confidence intervals. The confidence interval is the set of all hypotheses that are not significant (one would fail to reject) at a specific alpha level. The confidence interval is the inversion of a hypothesis test. If one uses percentiles from a bootstrapped sampling distribution this is a crude approximate confidence interval that does not follow proper construction, but works well nevertheless particularly when the parameter estimator is approximately normally distributed. I find the confidence curve to be a great way to visualize frequentist inference. It shows p-values and confidence intervals of all levels for a parameter of interest, analogous to the Bayesian posterior. The best solution is to raise awareness and promote continuing education, rather than discarding methods. Here is a link to a great paper by Eric Gibson on the topic. Here is a link to one of my papers regarding confidence curves and visualizing inference. Gibson, E. (2020). The Role of p-Values in Judging the Strength of Evidence and Realistic Replication Expectations. Statistics in Biopharmaceutical Research. 13(1):1-13 Johnson, G. S. (2021). Decision Making in Drug Development via Inference on Power. Manuscript.
Three questions about the article "Ditch p-values. Use Bootstrap confidence intervals instead" I agree that confidence intervals provide a lot more for performing inference than a single p-value for a single hypothesis, but there is no reason to ditch the p-value and no reason to rely solely on
13,617
Three questions about the article "Ditch p-values. Use Bootstrap confidence intervals instead"
1. Citizenship example This seems to be a poor but valid test. It makes sense with an extreme p-value cut off $\alpha = 0$. This way we would only reject those citizens whose profession is not found anywhere in the US. So maybe we would say "Robbert cannot be a US citizen because he is a suicide bomber and there are no suicide bombers in the united states" - a valid conclusion. The same in hypothesis testing terms: "$p = 0$ and so the null hypothesis is rejected (obtaining observed sample from H0 is impossible)." Different p-value cut-offs are then just compromise thresholds about how strict we want to be. 2. p-values, calculations by hand, and assumptions p-values are not tied to computations other than counting the number of occurrences when generating samples for the null hypothesis. And that generation can be performed by physical experiments in the real world. Moreover, we can use p-values for testing non-quantifiable or subjective things. So p-values can stand on their own as a philosophical construction without the need for concrete calculations, and there is no point in stating that they were invented in the age when calculations were performed by hand. And p-values themselves don't assume anything. It's the statistical tests that have assumptions. And even they are very flexible about that. Sometimes, for example, the assumption is about the sampling distribution of the parameter, and not the observations themselves. In addition, and I think author acknowledges this in the text, non-parametric tests also make one big assumption - they assume that the observed sample represents all the points from the population. The question is then simply which assumption is more warranted. A simplistic obvious case is with frequencies. Say you want to test if the chance of manufacturing defect is bigger than 5%, you get 10 samples and all of them are without defects. What would you be bootstrapping with 10 zeroes? 3. Confidence intervals Confidence intervals are a flip-side of the p-value. With p-value you test how surprising your observed sample is given some theoretical null hypothesis and with a confidence interval you define a set (mostly an interval) of hypotheses that would not be surprising given the observed sample. It's somewhat strange to me that so many people criticise one for the other. 4. Other One different point made against p-values in the text is about business people, to whom the values were reported, didn't understand them. But the answer is simple - don't show people things they might misunderstand. And I really doubt that someone not familiar with the intricacies of a p-value will be able to interpret confidence intervals without mistakes. "The job of a p-value is to prevent you from making a fool of yourself, and not report things as significant" - quoting someone (forgot who, sorry).
Three questions about the article "Ditch p-values. Use Bootstrap confidence intervals instead"
1. Citizenship example This seems to be a poor but valid test. It makes sense with an extreme p-value cut off $\alpha = 0$. This way we would only reject those citizens whose profession is not found a
Three questions about the article "Ditch p-values. Use Bootstrap confidence intervals instead" 1. Citizenship example This seems to be a poor but valid test. It makes sense with an extreme p-value cut off $\alpha = 0$. This way we would only reject those citizens whose profession is not found anywhere in the US. So maybe we would say "Robbert cannot be a US citizen because he is a suicide bomber and there are no suicide bombers in the united states" - a valid conclusion. The same in hypothesis testing terms: "$p = 0$ and so the null hypothesis is rejected (obtaining observed sample from H0 is impossible)." Different p-value cut-offs are then just compromise thresholds about how strict we want to be. 2. p-values, calculations by hand, and assumptions p-values are not tied to computations other than counting the number of occurrences when generating samples for the null hypothesis. And that generation can be performed by physical experiments in the real world. Moreover, we can use p-values for testing non-quantifiable or subjective things. So p-values can stand on their own as a philosophical construction without the need for concrete calculations, and there is no point in stating that they were invented in the age when calculations were performed by hand. And p-values themselves don't assume anything. It's the statistical tests that have assumptions. And even they are very flexible about that. Sometimes, for example, the assumption is about the sampling distribution of the parameter, and not the observations themselves. In addition, and I think author acknowledges this in the text, non-parametric tests also make one big assumption - they assume that the observed sample represents all the points from the population. The question is then simply which assumption is more warranted. A simplistic obvious case is with frequencies. Say you want to test if the chance of manufacturing defect is bigger than 5%, you get 10 samples and all of them are without defects. What would you be bootstrapping with 10 zeroes? 3. Confidence intervals Confidence intervals are a flip-side of the p-value. With p-value you test how surprising your observed sample is given some theoretical null hypothesis and with a confidence interval you define a set (mostly an interval) of hypotheses that would not be surprising given the observed sample. It's somewhat strange to me that so many people criticise one for the other. 4. Other One different point made against p-values in the text is about business people, to whom the values were reported, didn't understand them. But the answer is simple - don't show people things they might misunderstand. And I really doubt that someone not familiar with the intricacies of a p-value will be able to interpret confidence intervals without mistakes. "The job of a p-value is to prevent you from making a fool of yourself, and not report things as significant" - quoting someone (forgot who, sorry).
Three questions about the article "Ditch p-values. Use Bootstrap confidence intervals instead" 1. Citizenship example This seems to be a poor but valid test. It makes sense with an extreme p-value cut off $\alpha = 0$. This way we would only reject those citizens whose profession is not found a
13,618
When to drop a term from a regression model?
I have never understood the wish for parsimony. Seeking parsimony destroys all aspects of statistical inference (bias of regression coefficients, standard errors, confidence intervals, P-values). A good reason to keep variables is that this preserves the accuracy of confidence intervals and other quantities. Think of it this way: there have only been developed two unbiased estimators of residual variance in ordinary multiple regression: (1) the estimate from the pre-specified (big) model, and (2) the estimate from a reduced model substituting generalized degrees of freedom (GDF) for apparent (reduced) regression degrees of freedom. GDF will be much closer to the number of candidate parameters than to the number of final "significant" parameters. Here's another way to think of it. Suppose you were doing an ANOVA to compare 5 treatments, getting a 4 d.f. F-test. Then for some reason you look at pairwise differences between treatments using t-tests and decided to combine or remove some of the treatments (this is the same as doing stepwise selection using P, AIC, BIC, Cp on the 4 dummy variables). The resulting F-test with 1, 2, or 3 d.f. will have inflated type I error. The original F-test with 4 d.f. contained a perfect multiplicity adjustment.
When to drop a term from a regression model?
I have never understood the wish for parsimony. Seeking parsimony destroys all aspects of statistical inference (bias of regression coefficients, standard errors, confidence intervals, P-values). A
When to drop a term from a regression model? I have never understood the wish for parsimony. Seeking parsimony destroys all aspects of statistical inference (bias of regression coefficients, standard errors, confidence intervals, P-values). A good reason to keep variables is that this preserves the accuracy of confidence intervals and other quantities. Think of it this way: there have only been developed two unbiased estimators of residual variance in ordinary multiple regression: (1) the estimate from the pre-specified (big) model, and (2) the estimate from a reduced model substituting generalized degrees of freedom (GDF) for apparent (reduced) regression degrees of freedom. GDF will be much closer to the number of candidate parameters than to the number of final "significant" parameters. Here's another way to think of it. Suppose you were doing an ANOVA to compare 5 treatments, getting a 4 d.f. F-test. Then for some reason you look at pairwise differences between treatments using t-tests and decided to combine or remove some of the treatments (this is the same as doing stepwise selection using P, AIC, BIC, Cp on the 4 dummy variables). The resulting F-test with 1, 2, or 3 d.f. will have inflated type I error. The original F-test with 4 d.f. contained a perfect multiplicity adjustment.
When to drop a term from a regression model? I have never understood the wish for parsimony. Seeking parsimony destroys all aspects of statistical inference (bias of regression coefficients, standard errors, confidence intervals, P-values). A
13,619
When to drop a term from a regression model?
These answers about selection of variables all assume that the cost of the observation of variables is 0. And that is not true. While the issue of selection of variables for a given model may or may not involve selection, the implications for future behavior DOES involve selection. Consider the problem of predicting which college lineman will do best in the NFL. You are a scout. You must consider which qualities of the current linemen in the NFL are most predictive of their success. You measure 500 quantities, and begin the task of the selection of the quantities which will be needed in the future. What should you do? Should you retain all 500? Should some (astrological sign, day of the week born on) be eliminated? This is an important question, and is not academic. There is a cost to the observation of data, and the framework of cost-effectiveness suggests that some variables NEED NOT be observed in the future, since their value is low.
When to drop a term from a regression model?
These answers about selection of variables all assume that the cost of the observation of variables is 0. And that is not true. While the issue of selection of variables for a given model may or may
When to drop a term from a regression model? These answers about selection of variables all assume that the cost of the observation of variables is 0. And that is not true. While the issue of selection of variables for a given model may or may not involve selection, the implications for future behavior DOES involve selection. Consider the problem of predicting which college lineman will do best in the NFL. You are a scout. You must consider which qualities of the current linemen in the NFL are most predictive of their success. You measure 500 quantities, and begin the task of the selection of the quantities which will be needed in the future. What should you do? Should you retain all 500? Should some (astrological sign, day of the week born on) be eliminated? This is an important question, and is not academic. There is a cost to the observation of data, and the framework of cost-effectiveness suggests that some variables NEED NOT be observed in the future, since their value is low.
When to drop a term from a regression model? These answers about selection of variables all assume that the cost of the observation of variables is 0. And that is not true. While the issue of selection of variables for a given model may or may
13,620
When to drop a term from a regression model?
The most common advice these days is to get the AIC of the two models and take the one with the lower AIC. So, if your full model has an AIC of -20 and the model without the weakest predictor has an AIC > -20 then you keep the full model. Some might argue that if the difference < 3 you keep the simpler one. I prefer the advice that you could use the BIC to break "ties" when the AIC's are within 3 of each other. If you're using R then the command to get the AIC is... AIC. I do have a textbook on modelling here from the early 90s suggesting that you drop all of your predictors that are not significant. However, this really means you'll drop independent of the complexity the predictor adds or subtracts from the model. It's also only for ANOVA where significance is about variability explained rather than the magnitude of the slope in light of what other things have been explained. The more modern advice of using AIC takes these factors into consideration. There's all kinds of reasons the non-significant predictor should be included even if it's not significant. For example, there may be correlation issues with other predictors to it may be a relatively simple predictor. If you want the simplest advice go with AIC and use BIC to break ties and use a difference of 3 as your window of equality. Otherwise, provide many many more details about the model and you could get more specific advice for your situation.
When to drop a term from a regression model?
The most common advice these days is to get the AIC of the two models and take the one with the lower AIC. So, if your full model has an AIC of -20 and the model without the weakest predictor has an
When to drop a term from a regression model? The most common advice these days is to get the AIC of the two models and take the one with the lower AIC. So, if your full model has an AIC of -20 and the model without the weakest predictor has an AIC > -20 then you keep the full model. Some might argue that if the difference < 3 you keep the simpler one. I prefer the advice that you could use the BIC to break "ties" when the AIC's are within 3 of each other. If you're using R then the command to get the AIC is... AIC. I do have a textbook on modelling here from the early 90s suggesting that you drop all of your predictors that are not significant. However, this really means you'll drop independent of the complexity the predictor adds or subtracts from the model. It's also only for ANOVA where significance is about variability explained rather than the magnitude of the slope in light of what other things have been explained. The more modern advice of using AIC takes these factors into consideration. There's all kinds of reasons the non-significant predictor should be included even if it's not significant. For example, there may be correlation issues with other predictors to it may be a relatively simple predictor. If you want the simplest advice go with AIC and use BIC to break ties and use a difference of 3 as your window of equality. Otherwise, provide many many more details about the model and you could get more specific advice for your situation.
When to drop a term from a regression model? The most common advice these days is to get the AIC of the two models and take the one with the lower AIC. So, if your full model has an AIC of -20 and the model without the weakest predictor has an
13,621
When to drop a term from a regression model?
There are at least two other possible reasons for keeping a variable: 1) It affects the parameters for OTHER variables. 2) The fact that it is small is clinically interesting in itself To see about 1, you can look at the predicted values for each person from a model with and without the variable in the model. I suggest making a scatterplot of these two sets of values. If there are no big differences, then that's an argument against this reason For 2, think about why you had this variable in the list of possible variables. Is it based on theory? Did other research find a large effect size?
When to drop a term from a regression model?
There are at least two other possible reasons for keeping a variable: 1) It affects the parameters for OTHER variables. 2) The fact that it is small is clinically interesting in itself To see about 1,
When to drop a term from a regression model? There are at least two other possible reasons for keeping a variable: 1) It affects the parameters for OTHER variables. 2) The fact that it is small is clinically interesting in itself To see about 1, you can look at the predicted values for each person from a model with and without the variable in the model. I suggest making a scatterplot of these two sets of values. If there are no big differences, then that's an argument against this reason For 2, think about why you had this variable in the list of possible variables. Is it based on theory? Did other research find a large effect size?
When to drop a term from a regression model? There are at least two other possible reasons for keeping a variable: 1) It affects the parameters for OTHER variables. 2) The fact that it is small is clinically interesting in itself To see about 1,
13,622
When to drop a term from a regression model?
What are you using this model for? Is parsimony an important goal? More parsimonious models are preferred in some situations, but I wouldn't say parsimony is a good thing in itself. Parsimonious models can be understood and communicated more easily, and parsimony can help guard against over-fitting, but often times these issues are not major concerns or can be addressed another way. Approaching from the opposite direction, including an extra term in a regression equation has some benefits even in situations in which the extra term itself isn't of interest and it doesn't improve the model fit much... you may not think that it is an important variable to control for, but others might. Of course, there are other very important substantive reasons to exclude a variable, e.g. it might be caused by the outcome.
When to drop a term from a regression model?
What are you using this model for? Is parsimony an important goal? More parsimonious models are preferred in some situations, but I wouldn't say parsimony is a good thing in itself. Parsimonious mod
When to drop a term from a regression model? What are you using this model for? Is parsimony an important goal? More parsimonious models are preferred in some situations, but I wouldn't say parsimony is a good thing in itself. Parsimonious models can be understood and communicated more easily, and parsimony can help guard against over-fitting, but often times these issues are not major concerns or can be addressed another way. Approaching from the opposite direction, including an extra term in a regression equation has some benefits even in situations in which the extra term itself isn't of interest and it doesn't improve the model fit much... you may not think that it is an important variable to control for, but others might. Of course, there are other very important substantive reasons to exclude a variable, e.g. it might be caused by the outcome.
When to drop a term from a regression model? What are you using this model for? Is parsimony an important goal? More parsimonious models are preferred in some situations, but I wouldn't say parsimony is a good thing in itself. Parsimonious mod
13,623
When to drop a term from a regression model?
From your wording it sounds as if you're inclined to drop the last predictor because its predictive value is low; a substantial change on that predictor would not imply a substantial change on the response variable. If that is the case, then i like this criterion for including/dropping the predictor. It's more grounded in practical reality than the AIC or BIC can be, and more explainable to your audience for this research.
When to drop a term from a regression model?
From your wording it sounds as if you're inclined to drop the last predictor because its predictive value is low; a substantial change on that predictor would not imply a substantial change on the res
When to drop a term from a regression model? From your wording it sounds as if you're inclined to drop the last predictor because its predictive value is low; a substantial change on that predictor would not imply a substantial change on the response variable. If that is the case, then i like this criterion for including/dropping the predictor. It's more grounded in practical reality than the AIC or BIC can be, and more explainable to your audience for this research.
When to drop a term from a regression model? From your wording it sounds as if you're inclined to drop the last predictor because its predictive value is low; a substantial change on that predictor would not imply a substantial change on the res
13,624
To maximize the chance of correctly guessing the result of a coin flip, should I always choose the most probable outcome?
You're right. If $P(H) = 0.2$, and you're using zero-one loss (that is, you need to guess an actual outcome as opposed to a probability or something, and furthermore, getting heads when you guessed tails is equally as bad as getting tails when you guessed heads), you should guess tails every time. People often mistakenly think that the answer is to guess tails on a randomly selected 80% of trials and heads on the remainder. This strategy is called "probability matching" and has been studied extensively in behavioral decision-making. See, for example, West, R. F., & Stanovich, K. E. (2003). Is probability matching smart? Associations between probabilistic choices and cognitive ability. Memory & Cognition, 31, 243–251. doi:10.3758/BF03194383
To maximize the chance of correctly guessing the result of a coin flip, should I always choose the m
You're right. If $P(H) = 0.2$, and you're using zero-one loss (that is, you need to guess an actual outcome as opposed to a probability or something, and furthermore, getting heads when you guessed ta
To maximize the chance of correctly guessing the result of a coin flip, should I always choose the most probable outcome? You're right. If $P(H) = 0.2$, and you're using zero-one loss (that is, you need to guess an actual outcome as opposed to a probability or something, and furthermore, getting heads when you guessed tails is equally as bad as getting tails when you guessed heads), you should guess tails every time. People often mistakenly think that the answer is to guess tails on a randomly selected 80% of trials and heads on the remainder. This strategy is called "probability matching" and has been studied extensively in behavioral decision-making. See, for example, West, R. F., & Stanovich, K. E. (2003). Is probability matching smart? Associations between probabilistic choices and cognitive ability. Memory & Cognition, 31, 243–251. doi:10.3758/BF03194383
To maximize the chance of correctly guessing the result of a coin flip, should I always choose the m You're right. If $P(H) = 0.2$, and you're using zero-one loss (that is, you need to guess an actual outcome as opposed to a probability or something, and furthermore, getting heads when you guessed ta
13,625
To maximize the chance of correctly guessing the result of a coin flip, should I always choose the most probable outcome?
You are essentially asking a very interesting question: should I predict using "MAP Bayesian" Maximum a posteriori estimation or "Real Bayesian". Suppose you know the true distribution that $P(H)=0.2$, then using the MAP estimation, suppose you want to make 100 predictions on next 100 flip outcomes. You should always guess the flip is tail, NOT guessing $20$ head and $80$ tail. This is called "MAP Bayesian", basically you are doing $$\arg\max_ \theta f(x|\theta)$$ It is not hard to prove that by doing so you can minimize the predicted error (0-1 loss). The proof can be found in ~page 53 of Introduction to Statistical Learning. There is another way of doing this called "Real Bayesian" approach. Basically you are not trying to "select the outcome with highest probability, but consider all the cases probablistically" So, if someone ask you to "predict next 100" flips, you should pause him/her, because when you given 100 binary outcomes, the probabilistic information for each outcome disappears. Instead, you should ask, what you want to do AFTER knowing the results. Suppose he/her has some Loss Function (not necessary to 0-1 loss, for example, the loss function can be, if you miss a head, you need to pay \$1, but if you miss a tail, you need to pay \$5, i.e., imbalanced loss) on your prediction, then you should using your knowledge about the outcome distribution to minimize loss over the whole distribution $$\sum_x \sum_y p(x,y) L(f(x),y)$$ , i.e., incorporate your knowledge about the distribution to loss, instead of "stage-wised way", getting the predictions and do next steps. What's more, you have a very good intuition about what will have when there are many possible outcomes. MAP estimation will not work well if the number of outcome is large and the probability mass is widely spread. Think about you have a 100 side-dice, and you know the true distribution. Where $P(S_1)=0.1$, and $P(S_2)=P(S_3)=P(S_{100})=0.9/99=0.009090$. Now what you do with MAP? You will always guess you get the first side $S_1$, since it has largest probability comparing to others. However you will get wrong $90\%$ of the times!!
To maximize the chance of correctly guessing the result of a coin flip, should I always choose the m
You are essentially asking a very interesting question: should I predict using "MAP Bayesian" Maximum a posteriori estimation or "Real Bayesian". Suppose you know the true distribution that $P(H)=0.2$
To maximize the chance of correctly guessing the result of a coin flip, should I always choose the most probable outcome? You are essentially asking a very interesting question: should I predict using "MAP Bayesian" Maximum a posteriori estimation or "Real Bayesian". Suppose you know the true distribution that $P(H)=0.2$, then using the MAP estimation, suppose you want to make 100 predictions on next 100 flip outcomes. You should always guess the flip is tail, NOT guessing $20$ head and $80$ tail. This is called "MAP Bayesian", basically you are doing $$\arg\max_ \theta f(x|\theta)$$ It is not hard to prove that by doing so you can minimize the predicted error (0-1 loss). The proof can be found in ~page 53 of Introduction to Statistical Learning. There is another way of doing this called "Real Bayesian" approach. Basically you are not trying to "select the outcome with highest probability, but consider all the cases probablistically" So, if someone ask you to "predict next 100" flips, you should pause him/her, because when you given 100 binary outcomes, the probabilistic information for each outcome disappears. Instead, you should ask, what you want to do AFTER knowing the results. Suppose he/her has some Loss Function (not necessary to 0-1 loss, for example, the loss function can be, if you miss a head, you need to pay \$1, but if you miss a tail, you need to pay \$5, i.e., imbalanced loss) on your prediction, then you should using your knowledge about the outcome distribution to minimize loss over the whole distribution $$\sum_x \sum_y p(x,y) L(f(x),y)$$ , i.e., incorporate your knowledge about the distribution to loss, instead of "stage-wised way", getting the predictions and do next steps. What's more, you have a very good intuition about what will have when there are many possible outcomes. MAP estimation will not work well if the number of outcome is large and the probability mass is widely spread. Think about you have a 100 side-dice, and you know the true distribution. Where $P(S_1)=0.1$, and $P(S_2)=P(S_3)=P(S_{100})=0.9/99=0.009090$. Now what you do with MAP? You will always guess you get the first side $S_1$, since it has largest probability comparing to others. However you will get wrong $90\%$ of the times!!
To maximize the chance of correctly guessing the result of a coin flip, should I always choose the m You are essentially asking a very interesting question: should I predict using "MAP Bayesian" Maximum a posteriori estimation or "Real Bayesian". Suppose you know the true distribution that $P(H)=0.2$
13,626
To maximize the chance of correctly guessing the result of a coin flip, should I always choose the most probable outcome?
Due to independence your expectation value is always maximized if you guess the most likely case. There isn't a better strategy because each flip/roll doesn't give you any additional information about the coin/die. Anywhere you guess a less likely outcome your expectation of winning is less than if you had guessed the most likely case, thus you are better off just guessing the most likely case. If you wanted to make it so that you did need to change your strategy as you flipped you might consider a coin/die where you don't know the odds initially and you have to figure them out as you roll.
To maximize the chance of correctly guessing the result of a coin flip, should I always choose the m
Due to independence your expectation value is always maximized if you guess the most likely case. There isn't a better strategy because each flip/roll doesn't give you any additional information about
To maximize the chance of correctly guessing the result of a coin flip, should I always choose the most probable outcome? Due to independence your expectation value is always maximized if you guess the most likely case. There isn't a better strategy because each flip/roll doesn't give you any additional information about the coin/die. Anywhere you guess a less likely outcome your expectation of winning is less than if you had guessed the most likely case, thus you are better off just guessing the most likely case. If you wanted to make it so that you did need to change your strategy as you flipped you might consider a coin/die where you don't know the odds initially and you have to figure them out as you roll.
To maximize the chance of correctly guessing the result of a coin flip, should I always choose the m Due to independence your expectation value is always maximized if you guess the most likely case. There isn't a better strategy because each flip/roll doesn't give you any additional information about
13,627
Using ANOVA on percentages?
There is a difference between having a binary variable as your dependent variable and having a proportion as your dependent variable. Binary dependent variable: This sounds like what you have. (i.e., each mother either smoked or she did not smoke) In this case I would not use ANOVA. Logistic regression with some form of coding (perhaps dummy coding) for the categorical predictor variable is the obvious choice if you are conceptualising the binary variable as the dependent variable (otherwise you could do chi-square). Proportion as dependent variable: This does not sound like what you have. (i.e., you don't have data on the proportion of total waking time that a mother was smoking during pregnancy in a sample of smoking pregnant women). In this case, ANOVA and standard linear model approaches in general may or may not be reasonable for your purposes. See @Ben Bolker's answer for a discussion of the issues.
Using ANOVA on percentages?
There is a difference between having a binary variable as your dependent variable and having a proportion as your dependent variable. Binary dependent variable: This sounds like what you have. (i.e
Using ANOVA on percentages? There is a difference between having a binary variable as your dependent variable and having a proportion as your dependent variable. Binary dependent variable: This sounds like what you have. (i.e., each mother either smoked or she did not smoke) In this case I would not use ANOVA. Logistic regression with some form of coding (perhaps dummy coding) for the categorical predictor variable is the obvious choice if you are conceptualising the binary variable as the dependent variable (otherwise you could do chi-square). Proportion as dependent variable: This does not sound like what you have. (i.e., you don't have data on the proportion of total waking time that a mother was smoking during pregnancy in a sample of smoking pregnant women). In this case, ANOVA and standard linear model approaches in general may or may not be reasonable for your purposes. See @Ben Bolker's answer for a discussion of the issues.
Using ANOVA on percentages? There is a difference between having a binary variable as your dependent variable and having a proportion as your dependent variable. Binary dependent variable: This sounds like what you have. (i.e
13,628
Using ANOVA on percentages?
It depends on how close the responses within different groups are to 0 or 100%. If there are a lot of extreme values (i.e. many values piled up on 0 or 100%) this will be difficult. (If you don't know the "denominators", i.e. the numbers of subjects from which the percentages are calculated, then you can't use contingency table approaches anyway.) If the values within groups are more reasonable, then you can transform the response variable (e.g. classical arcsine-square-root or perhaps logit transform). There are a variety of graphical (preferred) and null-hypothesis testing (less preferred) approaches for deciding whether your transformed data meet the assumptions of ANOVA adequately (homogeneity of variance and normality, the former more important than the latter). Graphical tests: boxplots (homogeneity of variance) and Q-Q plots (normality) [the latter should be done within groups, or on residuals]. Null-hypothesis tests: e.g. Bartlett or Fligner test (homogeneity of variance), Shapiro-Wilk, Jarque-Bera, etc.
Using ANOVA on percentages?
It depends on how close the responses within different groups are to 0 or 100%. If there are a lot of extreme values (i.e. many values piled up on 0 or 100%) this will be difficult. (If you don't kn
Using ANOVA on percentages? It depends on how close the responses within different groups are to 0 or 100%. If there are a lot of extreme values (i.e. many values piled up on 0 or 100%) this will be difficult. (If you don't know the "denominators", i.e. the numbers of subjects from which the percentages are calculated, then you can't use contingency table approaches anyway.) If the values within groups are more reasonable, then you can transform the response variable (e.g. classical arcsine-square-root or perhaps logit transform). There are a variety of graphical (preferred) and null-hypothesis testing (less preferred) approaches for deciding whether your transformed data meet the assumptions of ANOVA adequately (homogeneity of variance and normality, the former more important than the latter). Graphical tests: boxplots (homogeneity of variance) and Q-Q plots (normality) [the latter should be done within groups, or on residuals]. Null-hypothesis tests: e.g. Bartlett or Fligner test (homogeneity of variance), Shapiro-Wilk, Jarque-Bera, etc.
Using ANOVA on percentages? It depends on how close the responses within different groups are to 0 or 100%. If there are a lot of extreme values (i.e. many values piled up on 0 or 100%) this will be difficult. (If you don't kn
13,629
Using ANOVA on percentages?
You need to have the raw data, so that the response variable is 0/1 (not smoke, smoke). Then you can use binary logistic regression. It is not correct to group BMI into intervals. The cutpoints are not correct, probably don't exist, and you are not officially testing whether BMI is associated with smoking. You are currently testing whether BMI with much of its information discarded is associated with smoking. You'll find that especially the outer BMI intervals are quite heterogeneous.
Using ANOVA on percentages?
You need to have the raw data, so that the response variable is 0/1 (not smoke, smoke). Then you can use binary logistic regression. It is not correct to group BMI into intervals. The cutpoints are
Using ANOVA on percentages? You need to have the raw data, so that the response variable is 0/1 (not smoke, smoke). Then you can use binary logistic regression. It is not correct to group BMI into intervals. The cutpoints are not correct, probably don't exist, and you are not officially testing whether BMI is associated with smoking. You are currently testing whether BMI with much of its information discarded is associated with smoking. You'll find that especially the outer BMI intervals are quite heterogeneous.
Using ANOVA on percentages? You need to have the raw data, so that the response variable is 0/1 (not smoke, smoke). Then you can use binary logistic regression. It is not correct to group BMI into intervals. The cutpoints are
13,630
Using ANOVA on percentages?
If you choose to do an ordinary ANOVA on proportional data, it is crucial to verify the assumption of homogeneous error variances. If (as is common with percentage data), the error variances are not constant, a more realistic alternative is to try beta regression, which can account for this heteroscedasticity in the model. Here is a paper discussing various alternative ways of dealing with a response variable that is a percentage or proportion: http://www.ime.usp.br/~sferrari/beta.pdf If you use R, the package betareg may be useful.
Using ANOVA on percentages?
If you choose to do an ordinary ANOVA on proportional data, it is crucial to verify the assumption of homogeneous error variances. If (as is common with percentage data), the error variances are not c
Using ANOVA on percentages? If you choose to do an ordinary ANOVA on proportional data, it is crucial to verify the assumption of homogeneous error variances. If (as is common with percentage data), the error variances are not constant, a more realistic alternative is to try beta regression, which can account for this heteroscedasticity in the model. Here is a paper discussing various alternative ways of dealing with a response variable that is a percentage or proportion: http://www.ime.usp.br/~sferrari/beta.pdf If you use R, the package betareg may be useful.
Using ANOVA on percentages? If you choose to do an ordinary ANOVA on proportional data, it is crucial to verify the assumption of homogeneous error variances. If (as is common with percentage data), the error variances are not c
13,631
Software for easy-yet-robust data exploration
I program in Python for 95% of my work and the rest in R or MATLAB or IDL/PV-WAVE (and soon SAS). But, I am in an environment where time-to-results is often a huge driver of the analysis chosen and so I often use point-and-click tools as well. In my experience, there is no single, robust, flexible GUI tool for doing analytics, much like there is not a single language. I typically cobble together a collection of the following free and commercial software Weka KNIME Excel and its plugins (like Solver) Alteryx MVP Stats I have not used JMP, Stata, Statistica, etc, but would like to. Using these tools involves learning different GUIs and multiple abstractions of modeling, which is a pain at the time but let's me get faster ad hoc results later. I am in the same boat as the OP because while most of the folks I work with are really smart, they do not care to learn a language, nor multiple GUIs and application specific terminology. So, I have resigned myself to accepting that Excel drives 90% of analysis in the business world. Accordingly, I am looking in to using things like pyinex to let me provide better analytics to the same Excel presentation layer that the vast majority of my colleagues expect. UPDATE: Continuing down the Do-modeling-with-programming-but-make-Excel-the-presentation-layer theme, I just came across this guy's website offering Tufte-style graphics to embed in Excel cells. Simply awesome and free!
Software for easy-yet-robust data exploration
I program in Python for 95% of my work and the rest in R or MATLAB or IDL/PV-WAVE (and soon SAS). But, I am in an environment where time-to-results is often a huge driver of the analysis chosen and so
Software for easy-yet-robust data exploration I program in Python for 95% of my work and the rest in R or MATLAB or IDL/PV-WAVE (and soon SAS). But, I am in an environment where time-to-results is often a huge driver of the analysis chosen and so I often use point-and-click tools as well. In my experience, there is no single, robust, flexible GUI tool for doing analytics, much like there is not a single language. I typically cobble together a collection of the following free and commercial software Weka KNIME Excel and its plugins (like Solver) Alteryx MVP Stats I have not used JMP, Stata, Statistica, etc, but would like to. Using these tools involves learning different GUIs and multiple abstractions of modeling, which is a pain at the time but let's me get faster ad hoc results later. I am in the same boat as the OP because while most of the folks I work with are really smart, they do not care to learn a language, nor multiple GUIs and application specific terminology. So, I have resigned myself to accepting that Excel drives 90% of analysis in the business world. Accordingly, I am looking in to using things like pyinex to let me provide better analytics to the same Excel presentation layer that the vast majority of my colleagues expect. UPDATE: Continuing down the Do-modeling-with-programming-but-make-Excel-the-presentation-layer theme, I just came across this guy's website offering Tufte-style graphics to embed in Excel cells. Simply awesome and free!
Software for easy-yet-robust data exploration I program in Python for 95% of my work and the rest in R or MATLAB or IDL/PV-WAVE (and soon SAS). But, I am in an environment where time-to-results is often a huge driver of the analysis chosen and so
13,632
Software for easy-yet-robust data exploration
As far as exploratory (possibly interactive) data analysis is concerned, I would suggest to take a look at: Weka, originally targets data-mining applications, but can be used for data summaries. Mondrian, for interactive data visualization. KNIME, which relies on the idea of building data flows and is compatible with Weka and R. All three accept data in arff or csv format. In my view, Stata does not require so much programming expertise. This is even part of its attractiveness, in fact: Most of basic analysis can be done by point-and-click user actions, with dialog boxes for customizing specific parameters, say, for prediction in a linear model. The same applies, albeit to a lesser extent, to R when you use external GUIs like Rcmdr, Deducer, etc. as said by @gsk3.
Software for easy-yet-robust data exploration
As far as exploratory (possibly interactive) data analysis is concerned, I would suggest to take a look at: Weka, originally targets data-mining applications, but can be used for data summaries. Mond
Software for easy-yet-robust data exploration As far as exploratory (possibly interactive) data analysis is concerned, I would suggest to take a look at: Weka, originally targets data-mining applications, but can be used for data summaries. Mondrian, for interactive data visualization. KNIME, which relies on the idea of building data flows and is compatible with Weka and R. All three accept data in arff or csv format. In my view, Stata does not require so much programming expertise. This is even part of its attractiveness, in fact: Most of basic analysis can be done by point-and-click user actions, with dialog boxes for customizing specific parameters, say, for prediction in a linear model. The same applies, albeit to a lesser extent, to R when you use external GUIs like Rcmdr, Deducer, etc. as said by @gsk3.
Software for easy-yet-robust data exploration As far as exploratory (possibly interactive) data analysis is concerned, I would suggest to take a look at: Weka, originally targets data-mining applications, but can be used for data summaries. Mond
13,633
Software for easy-yet-robust data exploration
Some people think of programming as simply entering a command line statement. At that point then perhaps you are a bit lost in encouraging them. However, if they are using spreadsheets already then they already have to enter formulas. These are akin to command line statements. If they really mean they don't want to do any programming in the sense of logical and automated analysis then you can tell them that they can still do the analyses in R or Stata without any programming at all. If they can do their stats in the spreadsheet... all that they want to do... then all of the statistical analyses they wish to accomplish can be done without 'programming' in R or Stata as well. They could arrange and organize the data in the spreadsheet and then just export it as text. Then the analysis is carried out without any programming at all. That's how I do intro to R sometimes. No programming is required to do the data analysis you could do in a spreadsheet. If you get them hooked that way then just reel the fish in slowly... :) In a couple of years compliment them on what a good programmer they've become. You might also want to show this document to your colleagues or at least read it yourself to better make your points.
Software for easy-yet-robust data exploration
Some people think of programming as simply entering a command line statement. At that point then perhaps you are a bit lost in encouraging them. However, if they are using spreadsheets already then
Software for easy-yet-robust data exploration Some people think of programming as simply entering a command line statement. At that point then perhaps you are a bit lost in encouraging them. However, if they are using spreadsheets already then they already have to enter formulas. These are akin to command line statements. If they really mean they don't want to do any programming in the sense of logical and automated analysis then you can tell them that they can still do the analyses in R or Stata without any programming at all. If they can do their stats in the spreadsheet... all that they want to do... then all of the statistical analyses they wish to accomplish can be done without 'programming' in R or Stata as well. They could arrange and organize the data in the spreadsheet and then just export it as text. Then the analysis is carried out without any programming at all. That's how I do intro to R sometimes. No programming is required to do the data analysis you could do in a spreadsheet. If you get them hooked that way then just reel the fish in slowly... :) In a couple of years compliment them on what a good programmer they've become. You might also want to show this document to your colleagues or at least read it yourself to better make your points.
Software for easy-yet-robust data exploration Some people think of programming as simply entering a command line statement. At that point then perhaps you are a bit lost in encouraging them. However, if they are using spreadsheets already then
13,634
Software for easy-yet-robust data exploration
I'm going to put a pitch in here for JMP. I have a couple reasons why it's my preferred non-programming data exploration tool of choice: Really good visualization tools. More most basic EDA-type plots, it's as good as R is, and considerably easier to use for producing something approaching a publication-ready plot. It's also got some extremely flexible visualization tools, so you can twist and bend your data around to get the full story. Surprisingly powerful. It took me until my...4th year of grad school to find something JMP couldn't do right out of the box. That's not bad. Scriptability. This is a big thing for me. The main weakness of GUIs is that its very hard to replicate what you did. JMP allows you to script the GUI - and generating those scripts is pretty point and click.
Software for easy-yet-robust data exploration
I'm going to put a pitch in here for JMP. I have a couple reasons why it's my preferred non-programming data exploration tool of choice: Really good visualization tools. More most basic EDA-type plot
Software for easy-yet-robust data exploration I'm going to put a pitch in here for JMP. I have a couple reasons why it's my preferred non-programming data exploration tool of choice: Really good visualization tools. More most basic EDA-type plots, it's as good as R is, and considerably easier to use for producing something approaching a publication-ready plot. It's also got some extremely flexible visualization tools, so you can twist and bend your data around to get the full story. Surprisingly powerful. It took me until my...4th year of grad school to find something JMP couldn't do right out of the box. That's not bad. Scriptability. This is a big thing for me. The main weakness of GUIs is that its very hard to replicate what you did. JMP allows you to script the GUI - and generating those scripts is pretty point and click.
Software for easy-yet-robust data exploration I'm going to put a pitch in here for JMP. I have a couple reasons why it's my preferred non-programming data exploration tool of choice: Really good visualization tools. More most basic EDA-type plot
13,635
Software for easy-yet-robust data exploration
I can recommend Tableau as a good tool for data exploration and visualization, simply because of the different ways that you can explore and view the data, simply by dragging and dropping. The graphs are fairly sharp and you can easily output to PDF for presentation purposes. If you want you can extend it with some "programming". I regularly use this tool along with "R" and SAS and they all work together well.
Software for easy-yet-robust data exploration
I can recommend Tableau as a good tool for data exploration and visualization, simply because of the different ways that you can explore and view the data, simply by dragging and dropping. The graphs
Software for easy-yet-robust data exploration I can recommend Tableau as a good tool for data exploration and visualization, simply because of the different ways that you can explore and view the data, simply by dragging and dropping. The graphs are fairly sharp and you can easily output to PDF for presentation purposes. If you want you can extend it with some "programming". I regularly use this tool along with "R" and SAS and they all work together well.
Software for easy-yet-robust data exploration I can recommend Tableau as a good tool for data exploration and visualization, simply because of the different ways that you can explore and view the data, simply by dragging and dropping. The graphs
13,636
Software for easy-yet-robust data exploration
As John said, data exploration doesn't require much programming in R. Here's a list of data exploration commands you can give people. (I just came up with this; you can surely expand it.) Export the data from whatever package it's in. (Exporting numerical data without quotation marks is convenient.) Then read the data in R. ChickWeight=read.csv('chickweight.csv') Make a table. table(ChickWeight$Diet) Let R guess what sort of graphic to give you. It sometimes works very nicely. plot(ChickWeight) plot(ChickWeight$weight) plot(ChickWeight$weight~ChickWeight$Diet) A bunch of specific plotting functions work quite simply on single variables. hist(ChickWeight$weight) Taking subsets plot(subset(ChickWeight,Diet=='2')) SQL-like syntax in case people are used to that (more here) library(sqldf) plot(sqldf('select * from ChickWeight where Diet == "2"')) PCA (You'd have more than two variables of course.) princomp(~ ChickWeight$weight + ChickWeight$Time)
Software for easy-yet-robust data exploration
As John said, data exploration doesn't require much programming in R. Here's a list of data exploration commands you can give people. (I just came up with this; you can surely expand it.) Export the d
Software for easy-yet-robust data exploration As John said, data exploration doesn't require much programming in R. Here's a list of data exploration commands you can give people. (I just came up with this; you can surely expand it.) Export the data from whatever package it's in. (Exporting numerical data without quotation marks is convenient.) Then read the data in R. ChickWeight=read.csv('chickweight.csv') Make a table. table(ChickWeight$Diet) Let R guess what sort of graphic to give you. It sometimes works very nicely. plot(ChickWeight) plot(ChickWeight$weight) plot(ChickWeight$weight~ChickWeight$Diet) A bunch of specific plotting functions work quite simply on single variables. hist(ChickWeight$weight) Taking subsets plot(subset(ChickWeight,Diet=='2')) SQL-like syntax in case people are used to that (more here) library(sqldf) plot(sqldf('select * from ChickWeight where Diet == "2"')) PCA (You'd have more than two variables of course.) princomp(~ ChickWeight$weight + ChickWeight$Time)
Software for easy-yet-robust data exploration As John said, data exploration doesn't require much programming in R. Here's a list of data exploration commands you can give people. (I just came up with this; you can surely expand it.) Export the d
13,637
Software for easy-yet-robust data exploration
This is more of a lament than an answer... The best software I've seen for this is Arc, which is built on top of Xlisp-Stat. It's fantastic software for data exploration with lots of built in interactive graphics, as well as lots of statistical inference capabilities. In my opinion nothing else has come close to its ease of use for data exploration and ability to extend it further with Lisp programming. In my opinion, interactivity in R is just starting to be able to used in ways like Arc, ten long years later. And as far as I know, no one has yet used these capabilities to build up an interactive interface that is anywhere near as useful as Arc. Unfortunately, it never really caught on so the developers have since almost all switched to working in R; it was last updated in July of 2004. The PC and Linux/Unix versions still work and might be worth a try, depending on your needs; for Macs the best option is to try the Linux/Unix version under X11, I've gotten it working on a couple systems that way. The Mac version mentioned on the site only works on "Classic" Macs. I'll also mention briefly Mondrian, which I've only tried briefly, but seems to have terrific graphical interactivity for data exploration, though (as I recall) no easy way to extend the abilities or do statistical inference.
Software for easy-yet-robust data exploration
This is more of a lament than an answer... The best software I've seen for this is Arc, which is built on top of Xlisp-Stat. It's fantastic software for data exploration with lots of built in interac
Software for easy-yet-robust data exploration This is more of a lament than an answer... The best software I've seen for this is Arc, which is built on top of Xlisp-Stat. It's fantastic software for data exploration with lots of built in interactive graphics, as well as lots of statistical inference capabilities. In my opinion nothing else has come close to its ease of use for data exploration and ability to extend it further with Lisp programming. In my opinion, interactivity in R is just starting to be able to used in ways like Arc, ten long years later. And as far as I know, no one has yet used these capabilities to build up an interactive interface that is anywhere near as useful as Arc. Unfortunately, it never really caught on so the developers have since almost all switched to working in R; it was last updated in July of 2004. The PC and Linux/Unix versions still work and might be worth a try, depending on your needs; for Macs the best option is to try the Linux/Unix version under X11, I've gotten it working on a couple systems that way. The Mac version mentioned on the site only works on "Classic" Macs. I'll also mention briefly Mondrian, which I've only tried briefly, but seems to have terrific graphical interactivity for data exploration, though (as I recall) no easy way to extend the abilities or do statistical inference.
Software for easy-yet-robust data exploration This is more of a lament than an answer... The best software I've seen for this is Arc, which is built on top of Xlisp-Stat. It's fantastic software for data exploration with lots of built in interac
13,638
Software for easy-yet-robust data exploration
A new software system that looks promising for this purpose is Deducer, built on top of R. Unfortunately, being new, I suspect it does not yet cover the breadth of questions that people might ask, but it does meet the toe-in-the-water criterion of leading people towards a true package should they so decide later. I've also used JMP in the past, which had a nice interactivity to it. I am worried that some of the interface might be too complicated for these purposes. And it's non-free, which makes it harder for potential spreadsheet refugees to try out on a whim. There's also Rattle which looks somewhat promising.
Software for easy-yet-robust data exploration
A new software system that looks promising for this purpose is Deducer, built on top of R. Unfortunately, being new, I suspect it does not yet cover the breadth of questions that people might ask, bu
Software for easy-yet-robust data exploration A new software system that looks promising for this purpose is Deducer, built on top of R. Unfortunately, being new, I suspect it does not yet cover the breadth of questions that people might ask, but it does meet the toe-in-the-water criterion of leading people towards a true package should they so decide later. I've also used JMP in the past, which had a nice interactivity to it. I am worried that some of the interface might be too complicated for these purposes. And it's non-free, which makes it harder for potential spreadsheet refugees to try out on a whim. There's also Rattle which looks somewhat promising.
Software for easy-yet-robust data exploration A new software system that looks promising for this purpose is Deducer, built on top of R. Unfortunately, being new, I suspect it does not yet cover the breadth of questions that people might ask, bu
13,639
Software for easy-yet-robust data exploration
For the exploration of what data contain and cleaning it up the former Google Refine, now Open Refine, is a pretty good GUI. It's much more powerful for the preparation and cleaning than something like Excel. Then switch to something like R-Commander for your analyses.
Software for easy-yet-robust data exploration
For the exploration of what data contain and cleaning it up the former Google Refine, now Open Refine, is a pretty good GUI. It's much more powerful for the preparation and cleaning than something lik
Software for easy-yet-robust data exploration For the exploration of what data contain and cleaning it up the former Google Refine, now Open Refine, is a pretty good GUI. It's much more powerful for the preparation and cleaning than something like Excel. Then switch to something like R-Commander for your analyses.
Software for easy-yet-robust data exploration For the exploration of what data contain and cleaning it up the former Google Refine, now Open Refine, is a pretty good GUI. It's much more powerful for the preparation and cleaning than something lik
13,640
Software for easy-yet-robust data exploration
Anyone who answers R, or any of it's "GUIs" didn't read the question. There is a program specifically designed for this and it's called JMP. Yes, it's expensive, though it has a free trial, and is incredibly cheap for students or college staff (like $50 cheap). There is also RapidMiner, which is a workflow-based GUI for data mining and statistical analysis. It's free and open source.
Software for easy-yet-robust data exploration
Anyone who answers R, or any of it's "GUIs" didn't read the question. There is a program specifically designed for this and it's called JMP. Yes, it's expensive, though it has a free trial, and is in
Software for easy-yet-robust data exploration Anyone who answers R, or any of it's "GUIs" didn't read the question. There is a program specifically designed for this and it's called JMP. Yes, it's expensive, though it has a free trial, and is incredibly cheap for students or college staff (like $50 cheap). There is also RapidMiner, which is a workflow-based GUI for data mining and statistical analysis. It's free and open source.
Software for easy-yet-robust data exploration Anyone who answers R, or any of it's "GUIs" didn't read the question. There is a program specifically designed for this and it's called JMP. Yes, it's expensive, though it has a free trial, and is in
13,641
Software for easy-yet-robust data exploration
Well, this particular tool is popular in my industry (though it is not industry-specific by design): http://www.umetrics.com/simca It allows you to do latent variable type multivariate analysis (PCA and PLS), and it includes all the attendant interpretative plots / calculations and interrogation tools like contribution plots, variable importance plots, Q2 calculations etc. It is often used on high-dimensional (and often highly correlated/collinear) industrial datasets where OLS/MLR type methods are unsuitable (e.g. info from a boatload of sensors, log info, etc.). It operates in a fully GUI environment, and the user does not have to write a single line of code. Unfortunately it is not free, and cannot be extended via programming.
Software for easy-yet-robust data exploration
Well, this particular tool is popular in my industry (though it is not industry-specific by design): http://www.umetrics.com/simca It allows you to do latent variable type multivariate analysis (PCA a
Software for easy-yet-robust data exploration Well, this particular tool is popular in my industry (though it is not industry-specific by design): http://www.umetrics.com/simca It allows you to do latent variable type multivariate analysis (PCA and PLS), and it includes all the attendant interpretative plots / calculations and interrogation tools like contribution plots, variable importance plots, Q2 calculations etc. It is often used on high-dimensional (and often highly correlated/collinear) industrial datasets where OLS/MLR type methods are unsuitable (e.g. info from a boatload of sensors, log info, etc.). It operates in a fully GUI environment, and the user does not have to write a single line of code. Unfortunately it is not free, and cannot be extended via programming.
Software for easy-yet-robust data exploration Well, this particular tool is popular in my industry (though it is not industry-specific by design): http://www.umetrics.com/simca It allows you to do latent variable type multivariate analysis (PCA a
13,642
Software for easy-yet-robust data exploration
In my opinion, if you don't code yourself the test, you are prone to errors and misunderstandings of the results. I think that you should recommend them to hire a statistician that has computer skills. If it is to do always the same thing, then indeed you can use a small tool (blackbox) that will do the stuff. But I am not sure this is still called data exploration.
Software for easy-yet-robust data exploration
In my opinion, if you don't code yourself the test, you are prone to errors and misunderstandings of the results. I think that you should recommend them to hire a statistician that has computer skills
Software for easy-yet-robust data exploration In my opinion, if you don't code yourself the test, you are prone to errors and misunderstandings of the results. I think that you should recommend them to hire a statistician that has computer skills. If it is to do always the same thing, then indeed you can use a small tool (blackbox) that will do the stuff. But I am not sure this is still called data exploration.
Software for easy-yet-robust data exploration In my opinion, if you don't code yourself the test, you are prone to errors and misunderstandings of the results. I think that you should recommend them to hire a statistician that has computer skills
13,643
Software for easy-yet-robust data exploration
I would recommend John Fox's R package called R commander: http://socserv.mcmaster.ca/jfox/Misc/Rcmdr/ It creates a user interface similar to SPSS (or the like) that is great for beginners and does not require the user to input any code at all. It is all done via drop-down boxes (you can even minimize the R console while working). To me, the benefit of this package is that you can take advantage of all the great computational ability of R while having a user interface that is completely operational for beginners.
Software for easy-yet-robust data exploration
I would recommend John Fox's R package called R commander: http://socserv.mcmaster.ca/jfox/Misc/Rcmdr/ It creates a user interface similar to SPSS (or the like) that is great for beginners and does no
Software for easy-yet-robust data exploration I would recommend John Fox's R package called R commander: http://socserv.mcmaster.ca/jfox/Misc/Rcmdr/ It creates a user interface similar to SPSS (or the like) that is great for beginners and does not require the user to input any code at all. It is all done via drop-down boxes (you can even minimize the R console while working). To me, the benefit of this package is that you can take advantage of all the great computational ability of R while having a user interface that is completely operational for beginners.
Software for easy-yet-robust data exploration I would recommend John Fox's R package called R commander: http://socserv.mcmaster.ca/jfox/Misc/Rcmdr/ It creates a user interface similar to SPSS (or the like) that is great for beginners and does no
13,644
Software for easy-yet-robust data exploration
Another useful tool, although just for Windows, is Spotfire -- I found it quite useful for quickly looking at various histograms and scatter plots for single and pairs of variables. A research tool that helps you rank single variables as well as pairs based on simple statistics -- Hierarchical Clustering Explorer from HCIL. It is nice for finding most interesting variables/pairs of variables.
Software for easy-yet-robust data exploration
Another useful tool, although just for Windows, is Spotfire -- I found it quite useful for quickly looking at various histograms and scatter plots for single and pairs of variables. A research tool th
Software for easy-yet-robust data exploration Another useful tool, although just for Windows, is Spotfire -- I found it quite useful for quickly looking at various histograms and scatter plots for single and pairs of variables. A research tool that helps you rank single variables as well as pairs based on simple statistics -- Hierarchical Clustering Explorer from HCIL. It is nice for finding most interesting variables/pairs of variables.
Software for easy-yet-robust data exploration Another useful tool, although just for Windows, is Spotfire -- I found it quite useful for quickly looking at various histograms and scatter plots for single and pairs of variables. A research tool th
13,645
Which comes first - domain expertise or an experimental approach?
This will probably be closed quickly as opinion-based, but here is a point you may want to consider. 200 features is a lot, and 30k rows is less than it sounds like. A "fishing expedition" to find relevant features is quite likely to overfit and select spurious features. The danger is that when you go to your domain experts with these features you "found" to be relevant, they may not push back. Instead, it's a very common human reaction to start telling stories about how these features are indeed useful, because we humans are very good at explaining stuff, even stuff that is simply noise. Talking to your domain experts first will not completely avoid this problem, but it may reduce the number of wild goose chases. You may be interested in my answer to "How to know that your machine learning problem is hopeless?".
Which comes first - domain expertise or an experimental approach?
This will probably be closed quickly as opinion-based, but here is a point you may want to consider. 200 features is a lot, and 30k rows is less than it sounds like. A "fishing expedition" to find rel
Which comes first - domain expertise or an experimental approach? This will probably be closed quickly as opinion-based, but here is a point you may want to consider. 200 features is a lot, and 30k rows is less than it sounds like. A "fishing expedition" to find relevant features is quite likely to overfit and select spurious features. The danger is that when you go to your domain experts with these features you "found" to be relevant, they may not push back. Instead, it's a very common human reaction to start telling stories about how these features are indeed useful, because we humans are very good at explaining stuff, even stuff that is simply noise. Talking to your domain experts first will not completely avoid this problem, but it may reduce the number of wild goose chases. You may be interested in my answer to "How to know that your machine learning problem is hopeless?".
Which comes first - domain expertise or an experimental approach? This will probably be closed quickly as opinion-based, but here is a point you may want to consider. 200 features is a lot, and 30k rows is less than it sounds like. A "fishing expedition" to find rel
13,646
Which comes first - domain expertise or an experimental approach?
John Elder in 2005 gave a (now classic) presentation called: "Top 10 Data Mining Mistakes". Number 4 in that list is: Listen (only) to the data. Specifically for business environments where it is almost certain that we act using incomplete information (e.g. client priorities, financial and physical resources, legal framework, etc.) which affects our outcome of interest, ignoring prior knowledge can be very detrimental. At best we will duplicate work and/or produce trivial results; at worst we will get nonsensical "data-driven" findings. To be fully bearish on this as Twyman's law states: "Any figure that looks interesting or different is usually wrong". Some points specifically to your question: Finding "the important features through experiments" will entail a full experimental design. If they are will to invest the time and money to it, go for it. Also familiarise yourself with the "Analysis of Observational Data" (yes, it is "unsexy" to read about survey analysis but treating a biased sample as being random is catastrophic.) This is good point in an analysis project life to consider applications of Bayesian inference as a way to formalise modelling assumptions. Simply put, if we have 200 features some have to be more likely to affect our outcome than others; use priors to encapsulate that. Respect the physics of the environment you operate in (until you don't have too). Signal strength diminishes as distance increases; average client in Luxenbourg has more disposal income than one in Bulgaria. Use well-established hypotheses as priors/starting points of the analysis; update wisely. Read the literature. Really, this is not just an academic activity. Very often we can get reasonable answers by curated resources if we make formal searches. Similarly, if there is nothing available this is even more of a reason to revisit points 1 & 2 in greater detail. To recap: absolutely talk to domain experts (or work hard to become a budding one yourself). It can save you a world of pain; if anything downstream you will have a better idea on how to present your findings and what were/are usual contention points.
Which comes first - domain expertise or an experimental approach?
John Elder in 2005 gave a (now classic) presentation called: "Top 10 Data Mining Mistakes". Number 4 in that list is: Listen (only) to the data. Specifically for business environments where it is almo
Which comes first - domain expertise or an experimental approach? John Elder in 2005 gave a (now classic) presentation called: "Top 10 Data Mining Mistakes". Number 4 in that list is: Listen (only) to the data. Specifically for business environments where it is almost certain that we act using incomplete information (e.g. client priorities, financial and physical resources, legal framework, etc.) which affects our outcome of interest, ignoring prior knowledge can be very detrimental. At best we will duplicate work and/or produce trivial results; at worst we will get nonsensical "data-driven" findings. To be fully bearish on this as Twyman's law states: "Any figure that looks interesting or different is usually wrong". Some points specifically to your question: Finding "the important features through experiments" will entail a full experimental design. If they are will to invest the time and money to it, go for it. Also familiarise yourself with the "Analysis of Observational Data" (yes, it is "unsexy" to read about survey analysis but treating a biased sample as being random is catastrophic.) This is good point in an analysis project life to consider applications of Bayesian inference as a way to formalise modelling assumptions. Simply put, if we have 200 features some have to be more likely to affect our outcome than others; use priors to encapsulate that. Respect the physics of the environment you operate in (until you don't have too). Signal strength diminishes as distance increases; average client in Luxenbourg has more disposal income than one in Bulgaria. Use well-established hypotheses as priors/starting points of the analysis; update wisely. Read the literature. Really, this is not just an academic activity. Very often we can get reasonable answers by curated resources if we make formal searches. Similarly, if there is nothing available this is even more of a reason to revisit points 1 & 2 in greater detail. To recap: absolutely talk to domain experts (or work hard to become a budding one yourself). It can save you a world of pain; if anything downstream you will have a better idea on how to present your findings and what were/are usual contention points.
Which comes first - domain expertise or an experimental approach? John Elder in 2005 gave a (now classic) presentation called: "Top 10 Data Mining Mistakes". Number 4 in that list is: Listen (only) to the data. Specifically for business environments where it is almo
13,647
Which comes first - domain expertise or an experimental approach?
The problem you are dealing with is a selection of variables problem, and so standard principles and methods apply. In particular, if you have a large number of initial variables/features to select from, there is a danger of overfitting if you fail to adopt appropriate methods that account for multiple comparisons. In the case where you have an exogenous source of information about the variables from subject matter experts, this can be used for prior information to guide your selection method --- e.g., to narrow down the model/comparisons you will make. You are correct to have serious misgivings about the proposal made to you. The idea of first using statistical methods to find relevant features, and then giving this information to the business team to inform their feedback sounds like a terrible idea to me. By doing this you take a potential form of a priori exogenous information and you bias it heavily by feeding in your statistical results first. It will certainly bias the feedback of the business team and so whatever information they give you after that is likely to be contaminated and useless. If you then narrow your model/fitting to focus on the features/variables they "confirm", this will effectively over-weight the data in your original model fit (since they will largely just feed back the posterior results as prior information) and you will almost certainly overfit your model. I recommend reading Gelman and Loken (2013) on the "garden of forking paths" that occurs when making research/modelling choices.
Which comes first - domain expertise or an experimental approach?
The problem you are dealing with is a selection of variables problem, and so standard principles and methods apply. In particular, if you have a large number of initial variables/features to select f
Which comes first - domain expertise or an experimental approach? The problem you are dealing with is a selection of variables problem, and so standard principles and methods apply. In particular, if you have a large number of initial variables/features to select from, there is a danger of overfitting if you fail to adopt appropriate methods that account for multiple comparisons. In the case where you have an exogenous source of information about the variables from subject matter experts, this can be used for prior information to guide your selection method --- e.g., to narrow down the model/comparisons you will make. You are correct to have serious misgivings about the proposal made to you. The idea of first using statistical methods to find relevant features, and then giving this information to the business team to inform their feedback sounds like a terrible idea to me. By doing this you take a potential form of a priori exogenous information and you bias it heavily by feeding in your statistical results first. It will certainly bias the feedback of the business team and so whatever information they give you after that is likely to be contaminated and useless. If you then narrow your model/fitting to focus on the features/variables they "confirm", this will effectively over-weight the data in your original model fit (since they will largely just feed back the posterior results as prior information) and you will almost certainly overfit your model. I recommend reading Gelman and Loken (2013) on the "garden of forking paths" that occurs when making research/modelling choices.
Which comes first - domain expertise or an experimental approach? The problem you are dealing with is a selection of variables problem, and so standard principles and methods apply. In particular, if you have a large number of initial variables/features to select f
13,648
Which comes first - domain expertise or an experimental approach?
There are two aspects here causal inference and explainability. From a causal inference perspective, domain expertise should guide the process of building relevant factors on a given purpose, targets, that are really linked and not just correlations explored or discovered by data scientists. Inference and Intervention: Causal Models for Business, by Ryall-Bramson (2013), routledge provides set of case studies on how domain knowledge can guide building causal models. In purely machine learning projects, bottom line is model's performance. So called feature discovery and extraction is usually performed without domain experts input, and best performing model is generated by data scientist. Domain experts involvement in this approach appears to be in ensuring to set to right business target in machine learning models. If it is a regulated environment or a requirement is there, then the machine learning model explainability work might require intervention from domain expert, see Interpretable Machine Learning.
Which comes first - domain expertise or an experimental approach?
There are two aspects here causal inference and explainability. From a causal inference perspective, domain expertise should guide the process of building relevant factors on a given purpose, targets,
Which comes first - domain expertise or an experimental approach? There are two aspects here causal inference and explainability. From a causal inference perspective, domain expertise should guide the process of building relevant factors on a given purpose, targets, that are really linked and not just correlations explored or discovered by data scientists. Inference and Intervention: Causal Models for Business, by Ryall-Bramson (2013), routledge provides set of case studies on how domain knowledge can guide building causal models. In purely machine learning projects, bottom line is model's performance. So called feature discovery and extraction is usually performed without domain experts input, and best performing model is generated by data scientist. Domain experts involvement in this approach appears to be in ensuring to set to right business target in machine learning models. If it is a regulated environment or a requirement is there, then the machine learning model explainability work might require intervention from domain expert, see Interpretable Machine Learning.
Which comes first - domain expertise or an experimental approach? There are two aspects here causal inference and explainability. From a causal inference perspective, domain expertise should guide the process of building relevant factors on a given purpose, targets,
13,649
How do I perform a regression on non-normal data which remain non-normal when transformed?
You don't need to assume Normal distributions to do regression. Least squares regression is the BLUE estimator (Best Linear, Unbiased Estimator) regardless of the distributions. See the Gauss-Markov Theorem (e.g. wikipedia) A normal distribution is only used to show that the estimator is also the maximum likelihood estimator. It is a common misunderstanding that OLS somehow assumes normally distributed data. It does not. It is far more general.
How do I perform a regression on non-normal data which remain non-normal when transformed?
You don't need to assume Normal distributions to do regression. Least squares regression is the BLUE estimator (Best Linear, Unbiased Estimator) regardless of the distributions. See the Gauss-Markov T
How do I perform a regression on non-normal data which remain non-normal when transformed? You don't need to assume Normal distributions to do regression. Least squares regression is the BLUE estimator (Best Linear, Unbiased Estimator) regardless of the distributions. See the Gauss-Markov Theorem (e.g. wikipedia) A normal distribution is only used to show that the estimator is also the maximum likelihood estimator. It is a common misunderstanding that OLS somehow assumes normally distributed data. It does not. It is far more general.
How do I perform a regression on non-normal data which remain non-normal when transformed? You don't need to assume Normal distributions to do regression. Least squares regression is the BLUE estimator (Best Linear, Unbiased Estimator) regardless of the distributions. See the Gauss-Markov T
13,650
How do I perform a regression on non-normal data which remain non-normal when transformed?
First, OLS regression makes no assumptions about the data, it makes assumptions about the errors, as estimated by residuals. Second, transforming data to make in fit a model is, in my opinion, the wrong approach. You want your model to fit your problem, not the other way round. In the old days, OLS regression was "the only game in town" because of slow computers, but that is no longer true. Third, I don't use SPSS so I can't help there, but I'd be amazed if it didn't offer some forms of nonlinear regression. Some possibilities are quantile regression, regression trees and robust regression. Fourth, I am a bit worried about your statement: I really want/need to perform a regression analysis to see which items on the questionnaire predict the response to an overall item (satisfaction) If the items were summed or somehow combined to make the overall scale, then regression is not the right approach at all. You probably want factor analysis.
How do I perform a regression on non-normal data which remain non-normal when transformed?
First, OLS regression makes no assumptions about the data, it makes assumptions about the errors, as estimated by residuals. Second, transforming data to make in fit a model is, in my opinion, the wro
How do I perform a regression on non-normal data which remain non-normal when transformed? First, OLS regression makes no assumptions about the data, it makes assumptions about the errors, as estimated by residuals. Second, transforming data to make in fit a model is, in my opinion, the wrong approach. You want your model to fit your problem, not the other way round. In the old days, OLS regression was "the only game in town" because of slow computers, but that is no longer true. Third, I don't use SPSS so I can't help there, but I'd be amazed if it didn't offer some forms of nonlinear regression. Some possibilities are quantile regression, regression trees and robust regression. Fourth, I am a bit worried about your statement: I really want/need to perform a regression analysis to see which items on the questionnaire predict the response to an overall item (satisfaction) If the items were summed or somehow combined to make the overall scale, then regression is not the right approach at all. You probably want factor analysis.
How do I perform a regression on non-normal data which remain non-normal when transformed? First, OLS regression makes no assumptions about the data, it makes assumptions about the errors, as estimated by residuals. Second, transforming data to make in fit a model is, in my opinion, the wro
13,651
How do I perform a regression on non-normal data which remain non-normal when transformed?
Rather than relying on a test for normality of the residuals, try assessing the normality with rational judgment. Normality tests do not tell you that your data is normal, only that it's not. But given that the data are a sample you can be quite certain they're not actually normal without a test. The requirement is approximately normal. The test can't tell you that. Tests also get very sensitive at large N's or more seriously, vary in sensitivity with N. Your N is in that range where sensitivity starts getting high. If you run the following simulation in R a number of times and look at the plots then you'll see that the normality test is saying "not normal" on a good number of normal distributions. # set the plot area to show two plots side by side (make the window wide) par(mfrow = c(1, 2)) n <- 158 # use the N we're concerned about # Run this a few times to get an idea of what data from a # normal distribution should look like. # especially note how variable the histograms look y <- rnorm(n) # n numbers from normal distribution # view the distribution hist(y) qqnorm(y);qqline(y) # run this section several times to get an idea what data from a normal # distribution that fails the normality test looks like # the following code block generates random normal distributions until one # fails a normality test p <- 1 # set p to a dummy value to start with while(p >= 0.05) { y <- rnorm(n) p <- shapiro.test(y)$p.value } # view the distribution that failed hist(y) qqnorm(y);qqline(y) Hopefully, after going through the simulations you can see that a normality test can easily reject pretty normal looking data and that data from a normal distribution can look quite far from normal. If you want to see an extreme value of that try n <- 1000. The distributions will all look normal but still fail the test at about the same rate as lower N values. And conversely, with a low N distributions that pass the test can look very far from normal. The standard residual plot in SPSS is not terribly useful for assessing normality. You can see outliers, the range, goodness of fit, and perhaps even leverage. But normality is difficult to derive from it. Try the following simulation comparing histograms, quantile-quantile normal plots, and residual plots. par(mfrow = c(1, 3)) # making 3 graphs in a row now y <- rnorm(n) hist(y) qqnorm(y); qqline(y) plot(y); abline(h = 0) It's extraordinarily difficult to tell normality, or much of anything, from the last plot and therefore not terribly diagnostic of normality. In summary, it's generally recommended to not rely on normality tests but rather diagnostic plots of the residuals. Without those plots or the actual values in your question it's very hard for anyone to give you solid advice on what your data need in terms of analysis or transformation. To get the best help, provide the raw data.
How do I perform a regression on non-normal data which remain non-normal when transformed?
Rather than relying on a test for normality of the residuals, try assessing the normality with rational judgment. Normality tests do not tell you that your data is normal, only that it's not. But give
How do I perform a regression on non-normal data which remain non-normal when transformed? Rather than relying on a test for normality of the residuals, try assessing the normality with rational judgment. Normality tests do not tell you that your data is normal, only that it's not. But given that the data are a sample you can be quite certain they're not actually normal without a test. The requirement is approximately normal. The test can't tell you that. Tests also get very sensitive at large N's or more seriously, vary in sensitivity with N. Your N is in that range where sensitivity starts getting high. If you run the following simulation in R a number of times and look at the plots then you'll see that the normality test is saying "not normal" on a good number of normal distributions. # set the plot area to show two plots side by side (make the window wide) par(mfrow = c(1, 2)) n <- 158 # use the N we're concerned about # Run this a few times to get an idea of what data from a # normal distribution should look like. # especially note how variable the histograms look y <- rnorm(n) # n numbers from normal distribution # view the distribution hist(y) qqnorm(y);qqline(y) # run this section several times to get an idea what data from a normal # distribution that fails the normality test looks like # the following code block generates random normal distributions until one # fails a normality test p <- 1 # set p to a dummy value to start with while(p >= 0.05) { y <- rnorm(n) p <- shapiro.test(y)$p.value } # view the distribution that failed hist(y) qqnorm(y);qqline(y) Hopefully, after going through the simulations you can see that a normality test can easily reject pretty normal looking data and that data from a normal distribution can look quite far from normal. If you want to see an extreme value of that try n <- 1000. The distributions will all look normal but still fail the test at about the same rate as lower N values. And conversely, with a low N distributions that pass the test can look very far from normal. The standard residual plot in SPSS is not terribly useful for assessing normality. You can see outliers, the range, goodness of fit, and perhaps even leverage. But normality is difficult to derive from it. Try the following simulation comparing histograms, quantile-quantile normal plots, and residual plots. par(mfrow = c(1, 3)) # making 3 graphs in a row now y <- rnorm(n) hist(y) qqnorm(y); qqline(y) plot(y); abline(h = 0) It's extraordinarily difficult to tell normality, or much of anything, from the last plot and therefore not terribly diagnostic of normality. In summary, it's generally recommended to not rely on normality tests but rather diagnostic plots of the residuals. Without those plots or the actual values in your question it's very hard for anyone to give you solid advice on what your data need in terms of analysis or transformation. To get the best help, provide the raw data.
How do I perform a regression on non-normal data which remain non-normal when transformed? Rather than relying on a test for normality of the residuals, try assessing the normality with rational judgment. Normality tests do not tell you that your data is normal, only that it's not. But give
13,652
How do I perform a regression on non-normal data which remain non-normal when transformed?
Broadly, there are two possible approaches to your problem: one which is well-justified from a theoretical perspective, but potentially impossible to implement in practice, while the other is more heuristic. The theoretically optimal approach (which you probably won't actually be able to use, unfortunately) is to calculate a regression by reverting to direct application of the so-called method of maximum likelihood. The connection between maximum likelihood estimation (which is really the antecedent and more fundamental mathematical concept) and ordinary least squares (OLS) regression (the usual approach, valid for the specific but extremely common case where the observation variables are all independently random and normally distributed) is described in many textbooks on statistics; one discussion that I particularly like is section 7.1 of "Statistical Data Analysis" by Glen Cowan. In cases where your observation variables aren't normally distributed, but you do actually know or have a pretty strong hunch about what the correct mathematical description of the distribution should be, you simply avoid taking advantage of the OLS simplification, and revert to the more fundamental concept, maximum likelihood estimation. In this case, since you don't appear to actually know the underlying distribution that governs your observation variables (i.e., the only thing known for sure is that it's definitely not Gaussian, but not what it actually is), the above approach won't work for you. Usually, when OLS fails or returns a crazy result, it's because of too many outlier points. The outlier points, which are what actually break the assumption of normally distributed observation variables, contribute way too much weight to the fit, because points in OLS are weighted by the squares of their deviation from the regression curve, and for the outliers, that deviation is large. The usual heuristic approach in this case is to develop some tweak or modification to OLS which results in the contribution from the outlier points becoming de-emphasized or de-weighted, relative to the baseline OLS method. Collectively, these are usually known as robust regression. A list containing some examples of specific robust estimation techniques that you might want to try may be found here.
How do I perform a regression on non-normal data which remain non-normal when transformed?
Broadly, there are two possible approaches to your problem: one which is well-justified from a theoretical perspective, but potentially impossible to implement in practice, while the other is more heu
How do I perform a regression on non-normal data which remain non-normal when transformed? Broadly, there are two possible approaches to your problem: one which is well-justified from a theoretical perspective, but potentially impossible to implement in practice, while the other is more heuristic. The theoretically optimal approach (which you probably won't actually be able to use, unfortunately) is to calculate a regression by reverting to direct application of the so-called method of maximum likelihood. The connection between maximum likelihood estimation (which is really the antecedent and more fundamental mathematical concept) and ordinary least squares (OLS) regression (the usual approach, valid for the specific but extremely common case where the observation variables are all independently random and normally distributed) is described in many textbooks on statistics; one discussion that I particularly like is section 7.1 of "Statistical Data Analysis" by Glen Cowan. In cases where your observation variables aren't normally distributed, but you do actually know or have a pretty strong hunch about what the correct mathematical description of the distribution should be, you simply avoid taking advantage of the OLS simplification, and revert to the more fundamental concept, maximum likelihood estimation. In this case, since you don't appear to actually know the underlying distribution that governs your observation variables (i.e., the only thing known for sure is that it's definitely not Gaussian, but not what it actually is), the above approach won't work for you. Usually, when OLS fails or returns a crazy result, it's because of too many outlier points. The outlier points, which are what actually break the assumption of normally distributed observation variables, contribute way too much weight to the fit, because points in OLS are weighted by the squares of their deviation from the regression curve, and for the outliers, that deviation is large. The usual heuristic approach in this case is to develop some tweak or modification to OLS which results in the contribution from the outlier points becoming de-emphasized or de-weighted, relative to the baseline OLS method. Collectively, these are usually known as robust regression. A list containing some examples of specific robust estimation techniques that you might want to try may be found here.
How do I perform a regression on non-normal data which remain non-normal when transformed? Broadly, there are two possible approaches to your problem: one which is well-justified from a theoretical perspective, but potentially impossible to implement in practice, while the other is more heu
13,653
Law of Large Numbers for whole distributions
While the law of large numbers is framed in terms of "means" this actually gives you a large amount of flexibility to show convergence of other types of quantities. In particular, you can use indicator functions to get convergence results for the probabilities of any specified event. To see how to do this, suppose we start with a sequence $X_1,X_2,X_3 ,... \sim \text{IID } F_X$ and note that the law of large numbers says that (in various probabilistic senses) we have the following convergence: $$\frac{1}{n} \sum_{i=1}^n X_i \rightarrow \mathbb{E}(X) \quad \quad \quad \quad \quad \text{as } n \rightarrow \infty.$$ In the sections below I will show how you can use this basic result to show that the empirical CDF converges to the true CDF of the underlying distribution in certain useful senses. This will also show you how the law of large numbers can be applied in a creative way to prove convergence results for other things that don't look like "means" of quantities (but actually are). Pointwise convergence of the empirical CDF to the true CDF: In your question you are interested in the convergence of the empirical distribution function to the true distribution function $F_X$. Let's start by looking at a particular point $x$ by examining the sequence of values $Y_1,Y_2,Y_3 ,...$ defined by $Y_i \equiv \mathbb{I}(X_i \leqslant x)$. This latter sequence is also IID, so the law of large numbers says that (in various probabilistic senses) we have the following convergence: $$\frac{1}{n} \sum_{i=1}^n Y_i \rightarrow \mathbb{E}(Y) \quad \quad \quad \quad \quad \text{as } n \rightarrow \infty.$$ Now, at the point $x$ the empirical distribution function for the sequence $\mathbf{X}$ and the true CDF for the distribution can be written respectively as: $$\begin{align} \hat{F}_n(x) &\equiv \frac{1}{n} \sum_{i=1}^n \mathbb{I}(X_i \leqslant x) = \frac{1}{n} \sum_{i=1}^n Y_i, \\[12pt] F_X(x) &\equiv \mathbb{P}(X_i \leqslant x) = \mathbb{E}(Y). \\[6pt] \end{align}$$ (The latter result follows from the fact that $\mathbb{E}(Y) = \mathbb{P}(Y=1)$ for any indicator variable $Y$.) We can therefore re-frame the previous convergence statement from the law of large numbers to give the pointwise convergence result: $$\hat{F}_n(x) \rightarrow F_X(x) \quad \quad \quad \quad \quad \text{as } n \rightarrow \infty.$$ You can see that this demonstrates that the empirical CDF converges pointwise to the true CDF for IID data; this is a direct consequence of the law of large numbers. Specifically, the weak law of large numbers establishes pointwise convergence in probability, and the strong law of large numbers establishes pointwise convergence almost surely. Uniform convergence of the empirical CDF to the true CDF: To go further than the above result, you need to use the uniform law of large numbers—or some other similar theorem—to establish uniform convergence of the empirical CDF to the true CDF. If you use the uniform law of large numbers then you can establish uniform convergence of the empirical CDF under some restrictive assumptions on the underlying CDF. However, there is actually a stronger theorem called the Glivenko–Cantelli theorem that establishes uniform convergence of the empirical CDF to the true CDF (almost surely) for any IID sequence of data. That is, the theorem proves that: $$\sup_x | \hat{F}_n(x) - F_X(x) | \overset{\text{a.s}}{\rightarrow} 0 \quad \quad \quad \quad \quad \text{as } n \rightarrow \infty.$$ If you would like to learn more about this part, it is worth having a look at the proofs of the uniform law of large numbers and the Glivenko–Cantelli theorem to see how each of them work to establish uniform convergence. The former theorem is broader, but it comes with some restrictions on the input function. The latter theorem applies specifically to the empirical CDF of IID data, but it establishes uniform convergence (almost surely) without any additional assumptions.
Law of Large Numbers for whole distributions
While the law of large numbers is framed in terms of "means" this actually gives you a large amount of flexibility to show convergence of other types of quantities. In particular, you can use indicat
Law of Large Numbers for whole distributions While the law of large numbers is framed in terms of "means" this actually gives you a large amount of flexibility to show convergence of other types of quantities. In particular, you can use indicator functions to get convergence results for the probabilities of any specified event. To see how to do this, suppose we start with a sequence $X_1,X_2,X_3 ,... \sim \text{IID } F_X$ and note that the law of large numbers says that (in various probabilistic senses) we have the following convergence: $$\frac{1}{n} \sum_{i=1}^n X_i \rightarrow \mathbb{E}(X) \quad \quad \quad \quad \quad \text{as } n \rightarrow \infty.$$ In the sections below I will show how you can use this basic result to show that the empirical CDF converges to the true CDF of the underlying distribution in certain useful senses. This will also show you how the law of large numbers can be applied in a creative way to prove convergence results for other things that don't look like "means" of quantities (but actually are). Pointwise convergence of the empirical CDF to the true CDF: In your question you are interested in the convergence of the empirical distribution function to the true distribution function $F_X$. Let's start by looking at a particular point $x$ by examining the sequence of values $Y_1,Y_2,Y_3 ,...$ defined by $Y_i \equiv \mathbb{I}(X_i \leqslant x)$. This latter sequence is also IID, so the law of large numbers says that (in various probabilistic senses) we have the following convergence: $$\frac{1}{n} \sum_{i=1}^n Y_i \rightarrow \mathbb{E}(Y) \quad \quad \quad \quad \quad \text{as } n \rightarrow \infty.$$ Now, at the point $x$ the empirical distribution function for the sequence $\mathbf{X}$ and the true CDF for the distribution can be written respectively as: $$\begin{align} \hat{F}_n(x) &\equiv \frac{1}{n} \sum_{i=1}^n \mathbb{I}(X_i \leqslant x) = \frac{1}{n} \sum_{i=1}^n Y_i, \\[12pt] F_X(x) &\equiv \mathbb{P}(X_i \leqslant x) = \mathbb{E}(Y). \\[6pt] \end{align}$$ (The latter result follows from the fact that $\mathbb{E}(Y) = \mathbb{P}(Y=1)$ for any indicator variable $Y$.) We can therefore re-frame the previous convergence statement from the law of large numbers to give the pointwise convergence result: $$\hat{F}_n(x) \rightarrow F_X(x) \quad \quad \quad \quad \quad \text{as } n \rightarrow \infty.$$ You can see that this demonstrates that the empirical CDF converges pointwise to the true CDF for IID data; this is a direct consequence of the law of large numbers. Specifically, the weak law of large numbers establishes pointwise convergence in probability, and the strong law of large numbers establishes pointwise convergence almost surely. Uniform convergence of the empirical CDF to the true CDF: To go further than the above result, you need to use the uniform law of large numbers—or some other similar theorem—to establish uniform convergence of the empirical CDF to the true CDF. If you use the uniform law of large numbers then you can establish uniform convergence of the empirical CDF under some restrictive assumptions on the underlying CDF. However, there is actually a stronger theorem called the Glivenko–Cantelli theorem that establishes uniform convergence of the empirical CDF to the true CDF (almost surely) for any IID sequence of data. That is, the theorem proves that: $$\sup_x | \hat{F}_n(x) - F_X(x) | \overset{\text{a.s}}{\rightarrow} 0 \quad \quad \quad \quad \quad \text{as } n \rightarrow \infty.$$ If you would like to learn more about this part, it is worth having a look at the proofs of the uniform law of large numbers and the Glivenko–Cantelli theorem to see how each of them work to establish uniform convergence. The former theorem is broader, but it comes with some restrictions on the input function. The latter theorem applies specifically to the empirical CDF of IID data, but it establishes uniform convergence (almost surely) without any additional assumptions.
Law of Large Numbers for whole distributions While the law of large numbers is framed in terms of "means" this actually gives you a large amount of flexibility to show convergence of other types of quantities. In particular, you can use indicat
13,654
Law of Large Numbers for whole distributions
You may be asking for the Glivenko-Cantelli theorem. https://en.wikipedia.org/wiki/Glivenko%E2%80%93Cantelli_theorem Note that this is about cumulative distribution functions, i.e., for data sets relative frequencies that observations are below any given value $x$, or by implication in any interval $[x_1,x_2]$. Histograms are not a standard basis for such a result, as there are many ways to set up a histogram (bar widths etc.), whereas the cdf is uniquely defined.
Law of Large Numbers for whole distributions
You may be asking for the Glivenko-Cantelli theorem. https://en.wikipedia.org/wiki/Glivenko%E2%80%93Cantelli_theorem Note that this is about cumulative distribution functions, i.e., for data sets rela
Law of Large Numbers for whole distributions You may be asking for the Glivenko-Cantelli theorem. https://en.wikipedia.org/wiki/Glivenko%E2%80%93Cantelli_theorem Note that this is about cumulative distribution functions, i.e., for data sets relative frequencies that observations are below any given value $x$, or by implication in any interval $[x_1,x_2]$. Histograms are not a standard basis for such a result, as there are many ways to set up a histogram (bar widths etc.), whereas the cdf is uniquely defined.
Law of Large Numbers for whole distributions You may be asking for the Glivenko-Cantelli theorem. https://en.wikipedia.org/wiki/Glivenko%E2%80%93Cantelli_theorem Note that this is about cumulative distribution functions, i.e., for data sets rela
13,655
Law of Large Numbers for whole distributions
As an alternative to Glivenko–Cantelli, you can look at Sanov's theorem, which uses the Kullback–Leibler divergence as the distance measure. For any set $A$ of frequency distributions, this theorem upper-bounds the probability that the observed frequency distribution $f$ (for $n$ IID instances of a random variable with distribution $q$ on an alphabet $X$) lies in $A$, as follows: $$P[f\in A] \leq (n+1)^{\left|X\right|} 2^{-d_\mathrm{min} n},$$ where $d_\mathrm{min} = \min_{f\in A} D_\mathrm{KL}(f||q)$ is the minimum KL divergence between frequencies in $A$ and the true distribution $q$. To apply this to directly address the question asked, this result implies that if $\mathcal{B}^{D_\mathrm{KL}}_d(q)$ denotes the "ball" of frequency distributions with KL divergence $<d$ from the true distribution $q$, we can upper-bound the probability of getting a frequency distribution outside this ball as $$P[f\notin \mathcal{B}^{D_\mathrm{KL}}_d(q)] \leq (n+1)^{\left|X\right|} 2^{-d n}.$$ This expression has the advantage of being an explicit bound for finite sample size, in case you need something more than an asymptotic convergence result. (A weaker option is provided by the asymptotic equipartition property, but the set considered in that theorem potentially includes some number of frequency distributions that are "very far" from the true distribution.)
Law of Large Numbers for whole distributions
As an alternative to Glivenko–Cantelli, you can look at Sanov's theorem, which uses the Kullback–Leibler divergence as the distance measure. For any set $A$ of frequency distributions, this theorem up
Law of Large Numbers for whole distributions As an alternative to Glivenko–Cantelli, you can look at Sanov's theorem, which uses the Kullback–Leibler divergence as the distance measure. For any set $A$ of frequency distributions, this theorem upper-bounds the probability that the observed frequency distribution $f$ (for $n$ IID instances of a random variable with distribution $q$ on an alphabet $X$) lies in $A$, as follows: $$P[f\in A] \leq (n+1)^{\left|X\right|} 2^{-d_\mathrm{min} n},$$ where $d_\mathrm{min} = \min_{f\in A} D_\mathrm{KL}(f||q)$ is the minimum KL divergence between frequencies in $A$ and the true distribution $q$. To apply this to directly address the question asked, this result implies that if $\mathcal{B}^{D_\mathrm{KL}}_d(q)$ denotes the "ball" of frequency distributions with KL divergence $<d$ from the true distribution $q$, we can upper-bound the probability of getting a frequency distribution outside this ball as $$P[f\notin \mathcal{B}^{D_\mathrm{KL}}_d(q)] \leq (n+1)^{\left|X\right|} 2^{-d n}.$$ This expression has the advantage of being an explicit bound for finite sample size, in case you need something more than an asymptotic convergence result. (A weaker option is provided by the asymptotic equipartition property, but the set considered in that theorem potentially includes some number of frequency distributions that are "very far" from the true distribution.)
Law of Large Numbers for whole distributions As an alternative to Glivenko–Cantelli, you can look at Sanov's theorem, which uses the Kullback–Leibler divergence as the distance measure. For any set $A$ of frequency distributions, this theorem up
13,656
Law of Large Numbers for whole distributions
We can define an indicator function that gives whether an observation is inside or outside of an interval, which will have a Bernoulli distribution, and for a sample of multiple observations we have a binomial distribution. We can then apply the CLT to show that the mean converges to the probability mass of the original PDF in the interval. The error in absolute terms converges uniformly to zero, but I don't think the error as a percentage of the expected probability does.
Law of Large Numbers for whole distributions
We can define an indicator function that gives whether an observation is inside or outside of an interval, which will have a Bernoulli distribution, and for a sample of multiple observations we have
Law of Large Numbers for whole distributions We can define an indicator function that gives whether an observation is inside or outside of an interval, which will have a Bernoulli distribution, and for a sample of multiple observations we have a binomial distribution. We can then apply the CLT to show that the mean converges to the probability mass of the original PDF in the interval. The error in absolute terms converges uniformly to zero, but I don't think the error as a percentage of the expected probability does.
Law of Large Numbers for whole distributions We can define an indicator function that gives whether an observation is inside or outside of an interval, which will have a Bernoulli distribution, and for a sample of multiple observations we have
13,657
Linear regression with slope constraint
I want to perform ... linear regression in R. ... I would like the slope to be inside an interval, let's say, between 1.4 and 1.6. How can this be done? (i) Simple way: fit the regression. If it's in the bounds, you're done. If it's not in the bounds, set the slope to the nearest bound, and estimate the intercept as the average of $(y - ax)$ over all observations. (ii) More complex way: do least squares with box constraints on the slope; many optimizaton routines implement box constraints, e.g. nlminb (which comes with R) does. Edit: actually (as mentioned in the example below), in vanilla R, nls can do box constraints; as shown in the example, that's really very easy to do. You can use constrained regression more directly; I think the pcls function from the package "mgcv" and the nnls function from the package "nnls" both do. -- Edit to answer followup question - I was going to show you how to use it with nlminb since that comes with R, but I realized that nls already uses the same routines (the PORT routines) to implement constrained least squares, so my example below does that case. NB: in my example below, $a$ is the intercept and $b$ is the slope (the more common convention in stats). I realized after I put it in here that you started the other way around; I'm going to leave the example 'backward' relative to your question, though. First, set up some data with the 'true' slope inside the range: set.seed(seed=439812L) x=runif(35,10,30) y = 5.8 + 1.53*x + rnorm(35,s=5) # population slope is in range plot(x,y) lm(y~x) Call: lm(formula = y ~ x) Coefficients: (Intercept) x 12.681 1.217 ... but LS estimate is well outside it, just caused by random variation. So lets use the constrained regression in nls: nls(y~a+b*x,algorithm="port", start=c(a=0,b=1.5),lower=c(a=-Inf,b=1.4),upper=c(a=Inf,b=1.6)) Nonlinear regression model model: y ~ a + b * x data: parent.frame() a b 9.019 1.400 residual sum-of-squares: 706.2 Algorithm "port", convergence message: both X-convergence and relative convergence (5) As you see, you get a slope right on the boundary. If you pass the fitted model to summary it will even produce standard errors and t-values but I am not sure how meaningful/interpretable these are. So how does my suggestion (1) compare? (i.e. set the slope to the nearest bound and average the residuals $y-bx$ to estimate the intercept) b=1.4 c(a=mean(y-x*b),b=b) a b 9.019376 1.400000 It's the same estimate ... In the plot below, the blue line is least squares and the red line is the constrained least squares:
Linear regression with slope constraint
I want to perform ... linear regression in R. ... I would like the slope to be inside an interval, let's say, between 1.4 and 1.6. How can this be done? (i) Simple way: fit the regression. If it's i
Linear regression with slope constraint I want to perform ... linear regression in R. ... I would like the slope to be inside an interval, let's say, between 1.4 and 1.6. How can this be done? (i) Simple way: fit the regression. If it's in the bounds, you're done. If it's not in the bounds, set the slope to the nearest bound, and estimate the intercept as the average of $(y - ax)$ over all observations. (ii) More complex way: do least squares with box constraints on the slope; many optimizaton routines implement box constraints, e.g. nlminb (which comes with R) does. Edit: actually (as mentioned in the example below), in vanilla R, nls can do box constraints; as shown in the example, that's really very easy to do. You can use constrained regression more directly; I think the pcls function from the package "mgcv" and the nnls function from the package "nnls" both do. -- Edit to answer followup question - I was going to show you how to use it with nlminb since that comes with R, but I realized that nls already uses the same routines (the PORT routines) to implement constrained least squares, so my example below does that case. NB: in my example below, $a$ is the intercept and $b$ is the slope (the more common convention in stats). I realized after I put it in here that you started the other way around; I'm going to leave the example 'backward' relative to your question, though. First, set up some data with the 'true' slope inside the range: set.seed(seed=439812L) x=runif(35,10,30) y = 5.8 + 1.53*x + rnorm(35,s=5) # population slope is in range plot(x,y) lm(y~x) Call: lm(formula = y ~ x) Coefficients: (Intercept) x 12.681 1.217 ... but LS estimate is well outside it, just caused by random variation. So lets use the constrained regression in nls: nls(y~a+b*x,algorithm="port", start=c(a=0,b=1.5),lower=c(a=-Inf,b=1.4),upper=c(a=Inf,b=1.6)) Nonlinear regression model model: y ~ a + b * x data: parent.frame() a b 9.019 1.400 residual sum-of-squares: 706.2 Algorithm "port", convergence message: both X-convergence and relative convergence (5) As you see, you get a slope right on the boundary. If you pass the fitted model to summary it will even produce standard errors and t-values but I am not sure how meaningful/interpretable these are. So how does my suggestion (1) compare? (i.e. set the slope to the nearest bound and average the residuals $y-bx$ to estimate the intercept) b=1.4 c(a=mean(y-x*b),b=b) a b 9.019376 1.400000 It's the same estimate ... In the plot below, the blue line is least squares and the red line is the constrained least squares:
Linear regression with slope constraint I want to perform ... linear regression in R. ... I would like the slope to be inside an interval, let's say, between 1.4 and 1.6. How can this be done? (i) Simple way: fit the regression. If it's i
13,658
Linear regression with slope constraint
Glen_b's second method, using least squares with a box constraint can be more easily implemented via ridge regression. The solution to ridge regression can be viewed as the Lagrangian for a regression with a bound on the magnitude of the norm of the weight vector (and hence its slope). So following whuber's suggestion below, the approach would be to subtract a trend of (1.6+1.4)/2 = 1.5 and then apply ridge regression and gradually increase the ridge parameter until the magnitude of the slope is less than or equal to 0.1. The benefit of this approach is that no fancy optimisation tools are required, just ridge regresson, which is already available in R (and many other packages). However Glen_b's simple solution (i) seems sensible to me (+1)
Linear regression with slope constraint
Glen_b's second method, using least squares with a box constraint can be more easily implemented via ridge regression. The solution to ridge regression can be viewed as the Lagrangian for a regressio
Linear regression with slope constraint Glen_b's second method, using least squares with a box constraint can be more easily implemented via ridge regression. The solution to ridge regression can be viewed as the Lagrangian for a regression with a bound on the magnitude of the norm of the weight vector (and hence its slope). So following whuber's suggestion below, the approach would be to subtract a trend of (1.6+1.4)/2 = 1.5 and then apply ridge regression and gradually increase the ridge parameter until the magnitude of the slope is less than or equal to 0.1. The benefit of this approach is that no fancy optimisation tools are required, just ridge regresson, which is already available in R (and many other packages). However Glen_b's simple solution (i) seems sensible to me (+1)
Linear regression with slope constraint Glen_b's second method, using least squares with a box constraint can be more easily implemented via ridge regression. The solution to ridge regression can be viewed as the Lagrangian for a regressio
13,659
Linear regression with slope constraint
Another approach would be to use Bayesian methods to fit the regression and choose a prior distribution on $a$ that only has support in the region you want, e.g. a uniform from 1.4 to 1.6, or a beta distribution shifted and scaled to that domain. There are many examples on the web and in software of using Bayesian methods for regression, you can just follow one of those examples and change the prior on $a$. This result will still give credible intervals of the parameters of interest (of course the meaningfulness of these intervals will be based on the reasonableness of your prior information about the slope).
Linear regression with slope constraint
Another approach would be to use Bayesian methods to fit the regression and choose a prior distribution on $a$ that only has support in the region you want, e.g. a uniform from 1.4 to 1.6, or a beta d
Linear regression with slope constraint Another approach would be to use Bayesian methods to fit the regression and choose a prior distribution on $a$ that only has support in the region you want, e.g. a uniform from 1.4 to 1.6, or a beta distribution shifted and scaled to that domain. There are many examples on the web and in software of using Bayesian methods for regression, you can just follow one of those examples and change the prior on $a$. This result will still give credible intervals of the parameters of interest (of course the meaningfulness of these intervals will be based on the reasonableness of your prior information about the slope).
Linear regression with slope constraint Another approach would be to use Bayesian methods to fit the regression and choose a prior distribution on $a$ that only has support in the region you want, e.g. a uniform from 1.4 to 1.6, or a beta d
13,660
Linear regression with slope constraint
Another approach might be to reformulate your regression as an optimization problem and use an optimizer. I'm not sure if it can be reformulated this way, but I thought of this question when I read this blog posting on R optimizers: http://zoonek.free.fr/blosxom/R/2012-06-01_Optimization.html
Linear regression with slope constraint
Another approach might be to reformulate your regression as an optimization problem and use an optimizer. I'm not sure if it can be reformulated this way, but I thought of this question when I read th
Linear regression with slope constraint Another approach might be to reformulate your regression as an optimization problem and use an optimizer. I'm not sure if it can be reformulated this way, but I thought of this question when I read this blog posting on R optimizers: http://zoonek.free.fr/blosxom/R/2012-06-01_Optimization.html
Linear regression with slope constraint Another approach might be to reformulate your regression as an optimization problem and use an optimizer. I'm not sure if it can be reformulated this way, but I thought of this question when I read th
13,661
Recommended terminology for "statistically significant"
I don't think the objection is to just the term "statistically significant" but to the abuse of the whole concept of statistical significance testing and to the misinterpretation of results that are (or are not) statistically significant. In particular, look at these six statements: P-values can indicate how incompatible the data are with a specified statistical model. P-values do not measure the probability that the studied hypothesis is true, or the probability that the data were produced by random chance alone. Scientific conclusions and business or policy decisions should not be based only on whether a p-value passes a specific threshold. Proper inference requires full reporting and transparency. A p-value, or statistical significance, does not measure the size of an effect or the importance of a result. By itself, a p-value does not provide a good measure of evidence regarding a model or hypothesis. So, they are recommending a more comprehensive way of doing and reporting analysis than simply just giving a p value, or even a p value with a CI. I think this is wise and I don't think it ought to be controversial. Now, going from their statement to my own views, I'd say that we often shouldn't mention the p value at all. In many cases, it doesn't provide useful information. Nearly always, we know in advance that the null is not exactly true and, quite often, we know it is not even close to true. What to do instead? I highly recommend Robert Abelson's MAGIC criteria: Magnitude, Articulation, Generality, Interestingness and Credibility. I say much more about this in my blog post: Statistics 101: The MAGIC criteria. (My views, unlike those of the ASA, are controversial. Many people disagree with them).
Recommended terminology for "statistically significant"
I don't think the objection is to just the term "statistically significant" but to the abuse of the whole concept of statistical significance testing and to the misinterpretation of results that are (
Recommended terminology for "statistically significant" I don't think the objection is to just the term "statistically significant" but to the abuse of the whole concept of statistical significance testing and to the misinterpretation of results that are (or are not) statistically significant. In particular, look at these six statements: P-values can indicate how incompatible the data are with a specified statistical model. P-values do not measure the probability that the studied hypothesis is true, or the probability that the data were produced by random chance alone. Scientific conclusions and business or policy decisions should not be based only on whether a p-value passes a specific threshold. Proper inference requires full reporting and transparency. A p-value, or statistical significance, does not measure the size of an effect or the importance of a result. By itself, a p-value does not provide a good measure of evidence regarding a model or hypothesis. So, they are recommending a more comprehensive way of doing and reporting analysis than simply just giving a p value, or even a p value with a CI. I think this is wise and I don't think it ought to be controversial. Now, going from their statement to my own views, I'd say that we often shouldn't mention the p value at all. In many cases, it doesn't provide useful information. Nearly always, we know in advance that the null is not exactly true and, quite often, we know it is not even close to true. What to do instead? I highly recommend Robert Abelson's MAGIC criteria: Magnitude, Articulation, Generality, Interestingness and Credibility. I say much more about this in my blog post: Statistics 101: The MAGIC criteria. (My views, unlike those of the ASA, are controversial. Many people disagree with them).
Recommended terminology for "statistically significant" I don't think the objection is to just the term "statistically significant" but to the abuse of the whole concept of statistical significance testing and to the misinterpretation of results that are (
13,662
Recommended terminology for "statistically significant"
In my opinion one of more honest yet non-technical phrasing would be something like: The obtained result is surprising/unexpected (p = 0.03) under the assumption of no mean difference between the groups. Or, permitting the format, it could be expanded: The obtained difference of $\Delta m$ would be quite surprising (p = 0.03) under the scenario of two normally distributed groups with equal means and a standard deviation of $\sigma$. Since our data does not deviate too much from the distributions used within the test the obtained result suggests either that the actual means of two groups are different or that a rare sampling outcome has occurred.
Recommended terminology for "statistically significant"
In my opinion one of more honest yet non-technical phrasing would be something like: The obtained result is surprising/unexpected (p = 0.03) under the assumption of no mean difference between the gro
Recommended terminology for "statistically significant" In my opinion one of more honest yet non-technical phrasing would be something like: The obtained result is surprising/unexpected (p = 0.03) under the assumption of no mean difference between the groups. Or, permitting the format, it could be expanded: The obtained difference of $\Delta m$ would be quite surprising (p = 0.03) under the scenario of two normally distributed groups with equal means and a standard deviation of $\sigma$. Since our data does not deviate too much from the distributions used within the test the obtained result suggests either that the actual means of two groups are different or that a rare sampling outcome has occurred.
Recommended terminology for "statistically significant" In my opinion one of more honest yet non-technical phrasing would be something like: The obtained result is surprising/unexpected (p = 0.03) under the assumption of no mean difference between the gro
13,663
Recommended terminology for "statistically significant"
I agree with the answer by Peter Flom, but would like to add an additional point on the use of the term "significance" in statistical hypothesis testing. Most hypothesis tests of interest in statistics have a null hypothesis that posits a zero value for some "effect" and an alternative hypothesis that posits a non-zero (or positive, or negative) value for that "effect". Properly construed, the p-value is a measure of evidence in favour of the alternative hypothesis, relative to the null hypothesis (and under the stipulated model). It is not a measure of the magnitude of the effect that is stipulated to be non-zero under the alternative hypothesis.$^\dagger$ In view of this, my view is that the best practice for reporting results is to refer to something like "significant evidence of a non-zero effect". The important thing here is that the quantifier "significant" is appended to the "evidence", not the "effect". In my view, saying something like "there is a significant effect" is a dangerous shorthand that commits the quantifier shift fallacy --- in lay parlance, significant evidence of a non-zero effect is very different to evidence of a significant effect. Such language invites the reader to misunderstand the meaning of the p-value, and conflate statistical significance with practical significance. This is the most common abuse of the term "significance" I see in published papers and elsewhere. It is ubiquitous to see references to a "significant effect" or "statistically significant effect", rather than the more accurate "significance evidence of a non-zero effect". $^\dagger$ Although obviously these things are mathematically related. Broadly speaking, the larger the true effect, the more concentrated is the distribution of the p-value near zero. Notwithstanding this fact, the p-value should not generally be used as a measure of the magnitude of the effect.
Recommended terminology for "statistically significant"
I agree with the answer by Peter Flom, but would like to add an additional point on the use of the term "significance" in statistical hypothesis testing. Most hypothesis tests of interest in statisti
Recommended terminology for "statistically significant" I agree with the answer by Peter Flom, but would like to add an additional point on the use of the term "significance" in statistical hypothesis testing. Most hypothesis tests of interest in statistics have a null hypothesis that posits a zero value for some "effect" and an alternative hypothesis that posits a non-zero (or positive, or negative) value for that "effect". Properly construed, the p-value is a measure of evidence in favour of the alternative hypothesis, relative to the null hypothesis (and under the stipulated model). It is not a measure of the magnitude of the effect that is stipulated to be non-zero under the alternative hypothesis.$^\dagger$ In view of this, my view is that the best practice for reporting results is to refer to something like "significant evidence of a non-zero effect". The important thing here is that the quantifier "significant" is appended to the "evidence", not the "effect". In my view, saying something like "there is a significant effect" is a dangerous shorthand that commits the quantifier shift fallacy --- in lay parlance, significant evidence of a non-zero effect is very different to evidence of a significant effect. Such language invites the reader to misunderstand the meaning of the p-value, and conflate statistical significance with practical significance. This is the most common abuse of the term "significance" I see in published papers and elsewhere. It is ubiquitous to see references to a "significant effect" or "statistically significant effect", rather than the more accurate "significance evidence of a non-zero effect". $^\dagger$ Although obviously these things are mathematically related. Broadly speaking, the larger the true effect, the more concentrated is the distribution of the p-value near zero. Notwithstanding this fact, the p-value should not generally be used as a measure of the magnitude of the effect.
Recommended terminology for "statistically significant" I agree with the answer by Peter Flom, but would like to add an additional point on the use of the term "significance" in statistical hypothesis testing. Most hypothesis tests of interest in statisti
13,664
Recommended terminology for "statistically significant"
In general, I agree with the following statements in the editorial Moving to a World Beyond "p < 0.05" which is part of the special issue Statistical Inference in the 21st Century: A World Beyond p < 0.05 of The American Statistician: What you will NOT find in this issue is one solution that majestically replaces the outsized role that statistical significance has come to play. The statistical community has not yet converged on a simple paradigm for the use of statistical inference in scientific research—and in fact it may never do so. We summarize our recommendations in two sentences totaling seven words: Accept uncertainty. Be thoughtful, open, and modest. Remember “ATOM.” The authors of the 43 papers of the special issue each provide (different) answers to your question. Personally, I really like the following set of suggestions that Sander Greenland gives (copy-pasted from the editorial mentioned above): Replace any statements about statistical significance of a result with the p-value from the test, and present the p-value as an equality, not an inequality. For example, if p = 0.03 then “…was statistically significant” would be replaced by “…had p = 0.03,” and “p < 0.05” would be replaced by “p = 0.03.” (An exception: If p is so small that the accuracy becomes very poor then an inequality reflecting that limit is appropriate; e.g., depending on the sample size, p-values from normal or $\chi^2$ approximations to discrete data often lack even 1-digit accuracy when p < 0.0001.) In parallel, if p = 0.25 then “…was not statistically significant” would be replaced by “…had p = 0.25,” and “p > 0.05” would be replaced by “p = 0.25.” Present p-values for more than one possibility when testing a targeted parameter. For example, if you discuss the p-value from a test of a null hypothesis, also discuss alongside this null p-value another p-value for a plausible alternative parameter possibility (ideally the one used to calculate power in the study proposal). As another example: if you do an equivalence test, present the p-values for both the lower and upper bounds of the equivalence interval (which are used for equivalence tests based on two one-sided tests). Show confidence intervals for targeted study parameters, but also supplement them with p-values for testing relevant hypotheses (e.g., the p-values for both the null and the alternative hypotheses used for the study design or proposal, as in #2). Confidence intervals only show clearly what is in or out of the interval (i.e., a 95% interval only shows clearly what has p > 0.05 or p ≤ 0.05), but more detail is often desirable for key hypotheses under contention. [...] Supplement a focal p-value p with its Shannon information transform (s-value or surprisal) $s = -log_2(p)$. This measures the amount of information supplied by the test against the tested hypothesis (or model): Rounded off, the s-value s shows the number of heads in a row one would need to see when tossing a coin to get the same amount of information against the tosses being “fair” (independent with “heads” probability of 1/2) instead of being loaded for heads. For example, if p = 0.03, this represents $–log_2(0.03) = 5$ bits of information against the hypothesis (like getting 5 heads in a trial of “fairness” with 5 coin tosses); and if p = 0.25, this represents only $–log_2(0.25) = 2$ bits of information against the hypothesis (like getting 2 heads in a trial of “fairness” with only 2 coin tosses).
Recommended terminology for "statistically significant"
In general, I agree with the following statements in the editorial Moving to a World Beyond "p < 0.05" which is part of the special issue Statistical Inference in the 21st Century: A World Beyond p <
Recommended terminology for "statistically significant" In general, I agree with the following statements in the editorial Moving to a World Beyond "p < 0.05" which is part of the special issue Statistical Inference in the 21st Century: A World Beyond p < 0.05 of The American Statistician: What you will NOT find in this issue is one solution that majestically replaces the outsized role that statistical significance has come to play. The statistical community has not yet converged on a simple paradigm for the use of statistical inference in scientific research—and in fact it may never do so. We summarize our recommendations in two sentences totaling seven words: Accept uncertainty. Be thoughtful, open, and modest. Remember “ATOM.” The authors of the 43 papers of the special issue each provide (different) answers to your question. Personally, I really like the following set of suggestions that Sander Greenland gives (copy-pasted from the editorial mentioned above): Replace any statements about statistical significance of a result with the p-value from the test, and present the p-value as an equality, not an inequality. For example, if p = 0.03 then “…was statistically significant” would be replaced by “…had p = 0.03,” and “p < 0.05” would be replaced by “p = 0.03.” (An exception: If p is so small that the accuracy becomes very poor then an inequality reflecting that limit is appropriate; e.g., depending on the sample size, p-values from normal or $\chi^2$ approximations to discrete data often lack even 1-digit accuracy when p < 0.0001.) In parallel, if p = 0.25 then “…was not statistically significant” would be replaced by “…had p = 0.25,” and “p > 0.05” would be replaced by “p = 0.25.” Present p-values for more than one possibility when testing a targeted parameter. For example, if you discuss the p-value from a test of a null hypothesis, also discuss alongside this null p-value another p-value for a plausible alternative parameter possibility (ideally the one used to calculate power in the study proposal). As another example: if you do an equivalence test, present the p-values for both the lower and upper bounds of the equivalence interval (which are used for equivalence tests based on two one-sided tests). Show confidence intervals for targeted study parameters, but also supplement them with p-values for testing relevant hypotheses (e.g., the p-values for both the null and the alternative hypotheses used for the study design or proposal, as in #2). Confidence intervals only show clearly what is in or out of the interval (i.e., a 95% interval only shows clearly what has p > 0.05 or p ≤ 0.05), but more detail is often desirable for key hypotheses under contention. [...] Supplement a focal p-value p with its Shannon information transform (s-value or surprisal) $s = -log_2(p)$. This measures the amount of information supplied by the test against the tested hypothesis (or model): Rounded off, the s-value s shows the number of heads in a row one would need to see when tossing a coin to get the same amount of information against the tosses being “fair” (independent with “heads” probability of 1/2) instead of being loaded for heads. For example, if p = 0.03, this represents $–log_2(0.03) = 5$ bits of information against the hypothesis (like getting 5 heads in a trial of “fairness” with 5 coin tosses); and if p = 0.25, this represents only $–log_2(0.25) = 2$ bits of information against the hypothesis (like getting 2 heads in a trial of “fairness” with only 2 coin tosses).
Recommended terminology for "statistically significant" In general, I agree with the following statements in the editorial Moving to a World Beyond "p < 0.05" which is part of the special issue Statistical Inference in the 21st Century: A World Beyond p <
13,665
Recommended terminology for "statistically significant"
If we know the null hypothesis is not exactly true, yet the result is not statistically significant, then that is an issue of sample size, or statistical power. Statistical significance is not really a goal, it's a necessity that one achieves with appropriate statistical power. Given the same effect size, the results of two experiments can be statistically significant or not depending on the sample size. However, I trust the statistically significant effect size more than the other because it had a bigger sample size.
Recommended terminology for "statistically significant"
If we know the null hypothesis is not exactly true, yet the result is not statistically significant, then that is an issue of sample size, or statistical power. Statistical significance is not really
Recommended terminology for "statistically significant" If we know the null hypothesis is not exactly true, yet the result is not statistically significant, then that is an issue of sample size, or statistical power. Statistical significance is not really a goal, it's a necessity that one achieves with appropriate statistical power. Given the same effect size, the results of two experiments can be statistically significant or not depending on the sample size. However, I trust the statistically significant effect size more than the other because it had a bigger sample size.
Recommended terminology for "statistically significant" If we know the null hypothesis is not exactly true, yet the result is not statistically significant, then that is an issue of sample size, or statistical power. Statistical significance is not really
13,666
Recommended terminology for "statistically significant"
You can just state the result: "On average, Gurples were 10 cm taller than Cheebles (Difference in Height = 10 [5, 14]; mean, 95% CI, p=0.03)."
Recommended terminology for "statistically significant"
You can just state the result: "On average, Gurples were 10 cm taller than Cheebles (Difference in Height = 10 [5, 14]; mean, 95% CI, p=0.03)."
Recommended terminology for "statistically significant" You can just state the result: "On average, Gurples were 10 cm taller than Cheebles (Difference in Height = 10 [5, 14]; mean, 95% CI, p=0.03)."
Recommended terminology for "statistically significant" You can just state the result: "On average, Gurples were 10 cm taller than Cheebles (Difference in Height = 10 [5, 14]; mean, 95% CI, p=0.03)."
13,667
What is the 'fundamental' idea of machine learning for estimating parameters?
If statistics is all about maximizing likelihood, then machine learning is all about minimizing loss. Since you don't know the loss you will incur on future data, you minimize an approximation, ie empirical loss. For instance, if you have a prediction task and are evaluated by the number of misclassifications, you could train parameters so that resulting model produces the smallest number of misclassifications on the training data. "Number of misclassifications" (ie, 0-1 loss) is a hard loss function to work with because it's not differentiable, so you approximate it with a smooth "surrogate". For instance, log loss is an upper bound on 0-1 loss, so you could minimize that instead, and this will turn out to be the same as maximizing conditional likelihood of the data. With parametric model this approach becomes equivalent to logistic regression. In a structured modeling task, and log-loss approximation of 0-1 loss, you get something different from maximum conditional likelihood, you will instead maximize product of (conditional) marginal likelihoods. To get better approximation of loss, people noticed that training model to minimize loss and using that loss as an estimate of future loss is an overly optimistic estimate. So for more accurate (true future loss) minimization they add a bias correction term to empirical loss and minimize that, this is known as structured risk minimization. In practice, figuring out the right bias correction term may be too hard, so you add an expression "in the spirit" of the bias correction term, for instance, sum of squares of parameters. In the end, almost all parametric machine learning supervised classification approaches end up training the model to minimize the following $\sum_{i} L(\textrm{m}(x_i,w),y_i) + P(w)$ where $\textrm{m}$ is your model parametrized by vector $w$, $i$ is taken over all datapoints $\{x_i,y_i\}$, $L$ is some computationally nice approximation of your true loss and $P(w)$ is some bias-correction/regularization term For instance if your $x \in \{-1,1\}^d$, $y \in \{-1,1\}$, a typical approach would be to let $\textrm{m}(x)=\textrm{sign}(w \cdot x)$, $L(\textrm{m}(x),y)=-\log(y \times (x \cdot w))$, $P(w)=q \times (w \cdot w)$, and choose $q$ by cross validation
What is the 'fundamental' idea of machine learning for estimating parameters?
If statistics is all about maximizing likelihood, then machine learning is all about minimizing loss. Since you don't know the loss you will incur on future data, you minimize an approximation, ie emp
What is the 'fundamental' idea of machine learning for estimating parameters? If statistics is all about maximizing likelihood, then machine learning is all about minimizing loss. Since you don't know the loss you will incur on future data, you minimize an approximation, ie empirical loss. For instance, if you have a prediction task and are evaluated by the number of misclassifications, you could train parameters so that resulting model produces the smallest number of misclassifications on the training data. "Number of misclassifications" (ie, 0-1 loss) is a hard loss function to work with because it's not differentiable, so you approximate it with a smooth "surrogate". For instance, log loss is an upper bound on 0-1 loss, so you could minimize that instead, and this will turn out to be the same as maximizing conditional likelihood of the data. With parametric model this approach becomes equivalent to logistic regression. In a structured modeling task, and log-loss approximation of 0-1 loss, you get something different from maximum conditional likelihood, you will instead maximize product of (conditional) marginal likelihoods. To get better approximation of loss, people noticed that training model to minimize loss and using that loss as an estimate of future loss is an overly optimistic estimate. So for more accurate (true future loss) minimization they add a bias correction term to empirical loss and minimize that, this is known as structured risk minimization. In practice, figuring out the right bias correction term may be too hard, so you add an expression "in the spirit" of the bias correction term, for instance, sum of squares of parameters. In the end, almost all parametric machine learning supervised classification approaches end up training the model to minimize the following $\sum_{i} L(\textrm{m}(x_i,w),y_i) + P(w)$ where $\textrm{m}$ is your model parametrized by vector $w$, $i$ is taken over all datapoints $\{x_i,y_i\}$, $L$ is some computationally nice approximation of your true loss and $P(w)$ is some bias-correction/regularization term For instance if your $x \in \{-1,1\}^d$, $y \in \{-1,1\}$, a typical approach would be to let $\textrm{m}(x)=\textrm{sign}(w \cdot x)$, $L(\textrm{m}(x),y)=-\log(y \times (x \cdot w))$, $P(w)=q \times (w \cdot w)$, and choose $q$ by cross validation
What is the 'fundamental' idea of machine learning for estimating parameters? If statistics is all about maximizing likelihood, then machine learning is all about minimizing loss. Since you don't know the loss you will incur on future data, you minimize an approximation, ie emp
13,668
What is the 'fundamental' idea of machine learning for estimating parameters?
I will give an itemized answer. Can provide more citations on demand, although this is not really controversial. Statistics is not all about maximizing (log)-likelihood. That's anathema to principled bayesians who just update their posteriors or propagate their beliefs through an appropriate model. A lot of statistics is about loss minimization. And so is a lot of Machine Learning. Empirical loss minimization has a different meaning in ML. For a clear, narrative view, check out Vapnik's "The nature of statistical learning" Machine Learning is not all about loss minimization. First, because there are a lot of bayesians in ML; second, because a number of applications in ML have to do with temporal learning and approximate DP. Sure, there is an objective function, but it has a very different meaning than in "statistical" learning. I don't think there is a gap between the fields, just many different approaches, all overlapping to some degree. I don't feel the need to make them into systematic disciplines with well-defined differences and similarities, and given the speed at which they evolve, I think it's a doomed enterprise anyway.
What is the 'fundamental' idea of machine learning for estimating parameters?
I will give an itemized answer. Can provide more citations on demand, although this is not really controversial. Statistics is not all about maximizing (log)-likelihood. That's anathema to principled
What is the 'fundamental' idea of machine learning for estimating parameters? I will give an itemized answer. Can provide more citations on demand, although this is not really controversial. Statistics is not all about maximizing (log)-likelihood. That's anathema to principled bayesians who just update their posteriors or propagate their beliefs through an appropriate model. A lot of statistics is about loss minimization. And so is a lot of Machine Learning. Empirical loss minimization has a different meaning in ML. For a clear, narrative view, check out Vapnik's "The nature of statistical learning" Machine Learning is not all about loss minimization. First, because there are a lot of bayesians in ML; second, because a number of applications in ML have to do with temporal learning and approximate DP. Sure, there is an objective function, but it has a very different meaning than in "statistical" learning. I don't think there is a gap between the fields, just many different approaches, all overlapping to some degree. I don't feel the need to make them into systematic disciplines with well-defined differences and similarities, and given the speed at which they evolve, I think it's a doomed enterprise anyway.
What is the 'fundamental' idea of machine learning for estimating parameters? I will give an itemized answer. Can provide more citations on demand, although this is not really controversial. Statistics is not all about maximizing (log)-likelihood. That's anathema to principled
13,669
What is the 'fundamental' idea of machine learning for estimating parameters?
I can't post a comment (the appropriate place for this comment) as I don't have enough reputation, but the answer accepted as the best answer by the question owner misses the point. "If statistics is all about maximizing likelihood, then machine learning is all about minimizing loss." The likelihood is a loss function. Maximising likelihood is the same as minimising a loss function: the deviance, which is just -2 times the log-likelihood function. Similarly finding a least squares solution is about minimising the loss function describing the residual sum of squares. Both ML and stats use algorithms to optimise the fit of some function (in the broadest terms) to data. Optimisation necessarily involves minimising some loss function.
What is the 'fundamental' idea of machine learning for estimating parameters?
I can't post a comment (the appropriate place for this comment) as I don't have enough reputation, but the answer accepted as the best answer by the question owner misses the point. "If statistics is
What is the 'fundamental' idea of machine learning for estimating parameters? I can't post a comment (the appropriate place for this comment) as I don't have enough reputation, but the answer accepted as the best answer by the question owner misses the point. "If statistics is all about maximizing likelihood, then machine learning is all about minimizing loss." The likelihood is a loss function. Maximising likelihood is the same as minimising a loss function: the deviance, which is just -2 times the log-likelihood function. Similarly finding a least squares solution is about minimising the loss function describing the residual sum of squares. Both ML and stats use algorithms to optimise the fit of some function (in the broadest terms) to data. Optimisation necessarily involves minimising some loss function.
What is the 'fundamental' idea of machine learning for estimating parameters? I can't post a comment (the appropriate place for this comment) as I don't have enough reputation, but the answer accepted as the best answer by the question owner misses the point. "If statistics is
13,670
What is the 'fundamental' idea of machine learning for estimating parameters?
There is a trivial answer -- there is no parameter estimation in machine learning! We don't assume that our models are equivalent to some hidden background models; we treat both reality and the model as black boxes and we try to shake the model box (train in official terminology) so that its output will be similar to that of the reality box. The concept of not only likelihood but the whole model selection based on the training data is replaced by optimizing the accuracy (whatever defined; in principle the goodness in desired use) on the unseen data; this allows to optimize both precision and recall in a coupled manner. This leads to the concept of an ability to generalize, which is achieved in different ways depending on the learner type. The answer to the question two depends highly on definitions; still I think that the nonparametric statistics is something that connects the two.
What is the 'fundamental' idea of machine learning for estimating parameters?
There is a trivial answer -- there is no parameter estimation in machine learning! We don't assume that our models are equivalent to some hidden background models; we treat both reality and the model
What is the 'fundamental' idea of machine learning for estimating parameters? There is a trivial answer -- there is no parameter estimation in machine learning! We don't assume that our models are equivalent to some hidden background models; we treat both reality and the model as black boxes and we try to shake the model box (train in official terminology) so that its output will be similar to that of the reality box. The concept of not only likelihood but the whole model selection based on the training data is replaced by optimizing the accuracy (whatever defined; in principle the goodness in desired use) on the unseen data; this allows to optimize both precision and recall in a coupled manner. This leads to the concept of an ability to generalize, which is achieved in different ways depending on the learner type. The answer to the question two depends highly on definitions; still I think that the nonparametric statistics is something that connects the two.
What is the 'fundamental' idea of machine learning for estimating parameters? There is a trivial answer -- there is no parameter estimation in machine learning! We don't assume that our models are equivalent to some hidden background models; we treat both reality and the model
13,671
What is the 'fundamental' idea of machine learning for estimating parameters?
I don't think there is a fundamental idea around parameter estimation in Machine Learning. The ML crowd will happily maximize the likelihood or the posterior, as long as the algorithms are efficient and predict "accurately". The focus is on computation, and results from statistics are widely used. If you're looking for fundamental ideas in general, then in computational learning theory, PAC is central; in statistical learning theory, structural risk miniminization; and there are other areas (for example, see the Prediction Science post by John Langford). On bridging statistics/ML, the divide seems exagerrated. I liked gappy's answer to the "Two Cultures" question.
What is the 'fundamental' idea of machine learning for estimating parameters?
I don't think there is a fundamental idea around parameter estimation in Machine Learning. The ML crowd will happily maximize the likelihood or the posterior, as long as the algorithms are efficient
What is the 'fundamental' idea of machine learning for estimating parameters? I don't think there is a fundamental idea around parameter estimation in Machine Learning. The ML crowd will happily maximize the likelihood or the posterior, as long as the algorithms are efficient and predict "accurately". The focus is on computation, and results from statistics are widely used. If you're looking for fundamental ideas in general, then in computational learning theory, PAC is central; in statistical learning theory, structural risk miniminization; and there are other areas (for example, see the Prediction Science post by John Langford). On bridging statistics/ML, the divide seems exagerrated. I liked gappy's answer to the "Two Cultures" question.
What is the 'fundamental' idea of machine learning for estimating parameters? I don't think there is a fundamental idea around parameter estimation in Machine Learning. The ML crowd will happily maximize the likelihood or the posterior, as long as the algorithms are efficient
13,672
What is the 'fundamental' idea of machine learning for estimating parameters?
You can rewrite a likelihood-maximization problem as a loss-minimization problem by defining the loss as the negative log likelihood. If the likelihood is a product of independent probabilities or probability densities, the loss will be a sum of independent terms, which can be computed efficiently. Furthermore, if the stochastic variables are normally distributed, the corresponding loss-minimization problem will be a least squares problem. If it is possible to create a loss-minimization problem by rewriting a likelihood-maximization, this should be to prefer to creating a loss-minimization problem from scratch, since it will give rise to a loss-minimization problem that is (hopefully) more theoretically founded and less ad hoc. For example, weights, such as in weighted least squares, which you usually have to guesstimate values for, will simply emerge from the process of rewriting the original likelihood-maximization problem and already have (hopefully) optimal values.
What is the 'fundamental' idea of machine learning for estimating parameters?
You can rewrite a likelihood-maximization problem as a loss-minimization problem by defining the loss as the negative log likelihood. If the likelihood is a product of independent probabilities or pro
What is the 'fundamental' idea of machine learning for estimating parameters? You can rewrite a likelihood-maximization problem as a loss-minimization problem by defining the loss as the negative log likelihood. If the likelihood is a product of independent probabilities or probability densities, the loss will be a sum of independent terms, which can be computed efficiently. Furthermore, if the stochastic variables are normally distributed, the corresponding loss-minimization problem will be a least squares problem. If it is possible to create a loss-minimization problem by rewriting a likelihood-maximization, this should be to prefer to creating a loss-minimization problem from scratch, since it will give rise to a loss-minimization problem that is (hopefully) more theoretically founded and less ad hoc. For example, weights, such as in weighted least squares, which you usually have to guesstimate values for, will simply emerge from the process of rewriting the original likelihood-maximization problem and already have (hopefully) optimal values.
What is the 'fundamental' idea of machine learning for estimating parameters? You can rewrite a likelihood-maximization problem as a loss-minimization problem by defining the loss as the negative log likelihood. If the likelihood is a product of independent probabilities or pro
13,673
Why is XOR not linearly separable?
Draw a picture. The question asks you to show it is not possible to find a half-plane and its complement that separate the blue points where XOR is zero from the red points where XOR is one (in the sense that the former lie in the half-plane and the latter lie in its complement). One (flawed) attempt is shown here, where the half-plane is shaded in contrast to its complement. This particular example doesn't work because both the half-plane and its complement each contain one blue point and one red point. After pondering this a little, you might be inspired to attempt a proof by contradiction: suppose there were numbers $(a,b,c)$ for which the sign of $ax_1 + bx_2 +c$ agreed with the posted values of XOR. Plugging in all four possibilities for $(x_1,x_2)$ leads to this table. $$\begin{array}{lcccr} \text{Location} & x_1 & x_2 & \operatorname{XOR}(x_1,x_2) & a x_1 + b x_2 + c \lt 0? \\ \hline \text{Bottom left} & 0 & 0 & \color{blue}0 & c \ge 0 \\ \text{Top left} &0 & 1 & \color{red}1 & b + c \lt 0\\ \text{Bottom right} &1 & 0 & \color{red}1 & a + c \lt 0\\ \text{Top right} &1 & 1 & \color{blue}0 & a + b + c \ge 0 \end{array}$$ The stated values of XOR determine what the inequalities in the right hand column must be. If we were to sum the first three inequalities, after rewriting the first as $-c \le 0,$ we would obtain $$a + b + c = (-c) + (b+c) + (a+c) \lt 0,$$ exactly the opposite of the last inequality: there's the contradiction. It's a simple algebraic way of showing that if the bottom left point were separated from the upper left and bottom right points, then it would also have to be separated from the top right point--but that's exactly the opposite of what we need to separate the values of XOR. The second question is a simple (and mathematically unrelated) counting problem. The possible values of $(x_1,x_2)$ designate four points, each of which may take on one of the two values $0$ or $1,$ giving $2^4=16$ possibilities. If this isn't completely obvious, then it's a worthwhile exercise to write down all sixteen functions. You can do it with a table of four rows and 18 columns: one column for $x_1,$ another for $x_2,$ and the remaining 16 for the distinct functions. If you do this systematically, you will notice that those 16 columns correspond to the 16 four-digit binary numbers 0000, 0001, ..., 1111. You can also depict all 16 functions in the manner of the figure above: take out your crayons; choose two of them; and color the four points in as many distinct ways as possible. The titles in this figure give some standard names for the functions. The background shading depicts separating half-planes wherever they exist.
Why is XOR not linearly separable?
Draw a picture. The question asks you to show it is not possible to find a half-plane and its complement that separate the blue points where XOR is zero from the red points where XOR is one (in the s
Why is XOR not linearly separable? Draw a picture. The question asks you to show it is not possible to find a half-plane and its complement that separate the blue points where XOR is zero from the red points where XOR is one (in the sense that the former lie in the half-plane and the latter lie in its complement). One (flawed) attempt is shown here, where the half-plane is shaded in contrast to its complement. This particular example doesn't work because both the half-plane and its complement each contain one blue point and one red point. After pondering this a little, you might be inspired to attempt a proof by contradiction: suppose there were numbers $(a,b,c)$ for which the sign of $ax_1 + bx_2 +c$ agreed with the posted values of XOR. Plugging in all four possibilities for $(x_1,x_2)$ leads to this table. $$\begin{array}{lcccr} \text{Location} & x_1 & x_2 & \operatorname{XOR}(x_1,x_2) & a x_1 + b x_2 + c \lt 0? \\ \hline \text{Bottom left} & 0 & 0 & \color{blue}0 & c \ge 0 \\ \text{Top left} &0 & 1 & \color{red}1 & b + c \lt 0\\ \text{Bottom right} &1 & 0 & \color{red}1 & a + c \lt 0\\ \text{Top right} &1 & 1 & \color{blue}0 & a + b + c \ge 0 \end{array}$$ The stated values of XOR determine what the inequalities in the right hand column must be. If we were to sum the first three inequalities, after rewriting the first as $-c \le 0,$ we would obtain $$a + b + c = (-c) + (b+c) + (a+c) \lt 0,$$ exactly the opposite of the last inequality: there's the contradiction. It's a simple algebraic way of showing that if the bottom left point were separated from the upper left and bottom right points, then it would also have to be separated from the top right point--but that's exactly the opposite of what we need to separate the values of XOR. The second question is a simple (and mathematically unrelated) counting problem. The possible values of $(x_1,x_2)$ designate four points, each of which may take on one of the two values $0$ or $1,$ giving $2^4=16$ possibilities. If this isn't completely obvious, then it's a worthwhile exercise to write down all sixteen functions. You can do it with a table of four rows and 18 columns: one column for $x_1,$ another for $x_2,$ and the remaining 16 for the distinct functions. If you do this systematically, you will notice that those 16 columns correspond to the 16 four-digit binary numbers 0000, 0001, ..., 1111. You can also depict all 16 functions in the manner of the figure above: take out your crayons; choose two of them; and color the four points in as many distinct ways as possible. The titles in this figure give some standard names for the functions. The background shading depicts separating half-planes wherever they exist.
Why is XOR not linearly separable? Draw a picture. The question asks you to show it is not possible to find a half-plane and its complement that separate the blue points where XOR is zero from the red points where XOR is one (in the s
13,674
Why is XOR not linearly separable?
Xor(0,0) == 0 implies c >= 0 Xor(1,1) == 0 implies a+b+c >=0 Adding these implies that a+b+2c >=0 Xor(0,1) == 1 implies a + c < 0 Xor(1,0) == 1 implies b + c < 0 Adding these implies that a+b+2c <0 So it both has to be >=0 and <0 which is not possible. PS. The same argument is stated in the accepted answer.
Why is XOR not linearly separable?
Xor(0,0) == 0 implies c >= 0 Xor(1,1) == 0 implies a+b+c >=0 Adding these implies that a+b+2c >=0 Xor(0,1) == 1 implies a + c < 0 Xor(1,0) == 1 implies b + c < 0 Adding these implies that a+b+2c
Why is XOR not linearly separable? Xor(0,0) == 0 implies c >= 0 Xor(1,1) == 0 implies a+b+c >=0 Adding these implies that a+b+2c >=0 Xor(0,1) == 1 implies a + c < 0 Xor(1,0) == 1 implies b + c < 0 Adding these implies that a+b+2c <0 So it both has to be >=0 and <0 which is not possible. PS. The same argument is stated in the accepted answer.
Why is XOR not linearly separable? Xor(0,0) == 0 implies c >= 0 Xor(1,1) == 0 implies a+b+c >=0 Adding these implies that a+b+2c >=0 Xor(0,1) == 1 implies a + c < 0 Xor(1,0) == 1 implies b + c < 0 Adding these implies that a+b+2c
13,675
For linear classifiers, do larger coefficients imply more important features?
Not at all. The magnitude of the coefficients depends directly on the scales selected for the variables, which is a somewhat arbitrary modeling decision. To see this, consider a linear regression model predicting the petal width of an iris (in centimeters) given its petal length (in centimeters): summary(lm(Petal.Width~Petal.Length, data=iris)) # Call: # lm(formula = Petal.Width ~ Petal.Length, data = iris) # # Residuals: # Min 1Q Median 3Q Max # -0.56515 -0.12358 -0.01898 0.13288 0.64272 # # Coefficients: # Estimate Std. Error t value Pr(>|t|) # (Intercept) -0.363076 0.039762 -9.131 4.7e-16 *** # Petal.Length 0.415755 0.009582 43.387 < 2e-16 *** # --- # Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1 # # Residual standard error: 0.2065 on 148 degrees of freedom # Multiple R-squared: 0.9271, Adjusted R-squared: 0.9266 # F-statistic: 1882 on 1 and 148 DF, p-value: < 2.2e-16 Our model achieves an adjusted R^2 value of 0.9266 and assigns coefficient value 0.415755 to the Petal.Length variable. However, the choice to define Petal.Length in centimeters was quite arbitrary, and we could have instead defined the variable in meters: iris$Petal.Length.Meters <- iris$Petal.Length / 100 summary(lm(Petal.Width~Petal.Length.Meters, data=iris)) # Call: # lm(formula = Petal.Width ~ Petal.Length.Meters, data = iris) # # Residuals: # Min 1Q Median 3Q Max # -0.56515 -0.12358 -0.01898 0.13288 0.64272 # # Coefficients: # Estimate Std. Error t value Pr(>|t|) # (Intercept) -0.36308 0.03976 -9.131 4.7e-16 *** # Petal.Length.Meters 41.57554 0.95824 43.387 < 2e-16 *** # --- # Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1 # # Residual standard error: 0.2065 on 148 degrees of freedom # Multiple R-squared: 0.9271, Adjusted R-squared: 0.9266 # F-statistic: 1882 on 1 and 148 DF, p-value: < 2.2e-16 Of course, this doesn't really affect the fitted model in any way -- we simply assigned a 100x larger coefficient to Petal.Length.Meters (41.57554) than we did to Petal.Length (0.415755). All other properties of the model (adjusted R^2, t-statistics, p-values, etc.) are identical. Generally when fitting regularized linear models one will first normalize variables (for instance, to have mean 0 and unit variance) to avoid favoring some variables over others based on the selected scales. Assuming Normalized Data Even if you had normalized all variables, variables with higher coefficients may still not be as useful in predictions because the independent variables are rarely set (have low variance). As an example, consider a dataset with dependent variable Z and independent variables X and Y taking binary values set.seed(144) dat <- data.frame(X=rep(c(0, 1), each=50000), Y=rep(c(0, 1), c(1000, 99000))) dat$Z <- dat$X + 2*dat$Y + rnorm(100000) By construction, the coefficient for Y is roughly twice as large as the coefficient for X when both are used to predict Z via linear regression: summary(lm(Z~X+Y, data=dat)) # Call: # lm(formula = Z ~ X + Y, data = dat) # # Residuals: # Min 1Q Median 3Q Max # -4.4991 -0.6749 -0.0056 0.6723 4.7342 # # Coefficients: # Estimate Std. Error t value Pr(>|t|) # (Intercept) -0.094793 0.031598 -3.00 0.0027 ** # X 0.999435 0.006352 157.35 <2e-16 *** # Y 2.099410 0.031919 65.77 <2e-16 *** # --- # Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1 # # Residual standard error: 0.9992 on 99997 degrees of freedom # Multiple R-squared: 0.2394, Adjusted R-squared: 0.2394 # F-statistic: 1.574e+04 on 2 and 99997 DF, p-value: < 2.2e-16 Still, X explains more of the variance in Z than Y (the linear regression model predicting Z with X has R^2 value 0.2065, while the linear regression model predicting Z with Y has R^2 value 0.0511): summary(lm(Z~X, data=dat)) # Call: # lm(formula = Z ~ X, data = dat) # # Residuals: # Min 1Q Median 3Q Max # -5.2587 -0.6759 0.0038 0.6842 4.7342 # # Coefficients: # Estimate Std. Error t value Pr(>|t|) # (Intercept) 1.962629 0.004564 430.0 <2e-16 *** # X 1.041424 0.006455 161.3 <2e-16 *** # --- # Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1 # # Residual standard error: 1.021 on 99998 degrees of freedom # Multiple R-squared: 0.2065, Adjusted R-squared: 0.2065 # F-statistic: 2.603e+04 on 1 and 99998 DF, p-value: < 2.2e-16 versus: summary(lm(Z~Y, data=dat)) # Call: # lm(formula = Z ~ Y, data = dat) # # Residuals: # Min 1Q Median 3Q Max # -5.0038 -0.7638 -0.0007 0.7610 5.2288 # # Coefficients: # Estimate Std. Error t value Pr(>|t|) # (Intercept) -0.09479 0.03529 -2.686 0.00724 ** # Y 2.60418 0.03547 73.416 < 2e-16 *** # --- # Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1 # # Residual standard error: 1.116 on 99998 degrees of freedom # Multiple R-squared: 0.05114, Adjusted R-squared: 0.05113 # F-statistic: 5390 on 1 and 99998 DF, p-value: < 2.2e-16 The Case of Multi-Collinearity A third case where large coefficient values may be deceiving would be in the case of significant multi-collinearity between variables. As an example, consider a dataset where X and Y are highly correlated but W is not highly correlated to the other two; we are trying to predict Z: set.seed(144) dat <- data.frame(W=rnorm(100000), X=rnorm(100000)) dat$Y <- dat$X + rnorm(100000, 0, 0.001) dat$Z <- 2*dat$W+10*dat$X-11*dat$Y + rnorm(100000) cor(dat) # W X Y Z # W 1.000000e+00 5.191809e-05 5.200434e-05 0.8161636 # X 5.191809e-05 1.000000e+00 9.999995e-01 -0.4079183 # Y 5.200434e-05 9.999995e-01 1.000000e+00 -0.4079246 # Z 8.161636e-01 -4.079183e-01 -4.079246e-01 1.0000000 These variables pretty much have the same mean (0) and variance (~1), and linear regression assigns much higher coefficient values (in absolute value) to X (roughly 15) and Y (roughly -16) than it does to W (roughly 2): summary(lm(Z~W+X+Y, data=dat)) # Call: # lm(formula = Z ~ W + X + Y, data = dat) # # Residuals: # Min 1Q Median 3Q Max # -4.1886 -0.6760 0.0026 0.6679 4.2232 # # Coefficients: # Estimate Std. Error t value Pr(>|t|) # (Intercept) 1.831e-04 3.170e-03 0.058 0.954 # W 2.001e+00 3.172e-03 630.811 < 2e-16 *** # X 1.509e+01 3.177e+00 4.748 2.05e-06 *** # Y -1.609e+01 3.177e+00 -5.063 4.13e-07 *** # --- # Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1 # # Residual standard error: 1.002 on 99996 degrees of freedom # Multiple R-squared: 0.8326, Adjusted R-squared: 0.8326 # F-statistic: 1.658e+05 on 3 and 99996 DF, p-value: < 2.2e-16 Still, among the three variables in the model W is the most important: If you remove W from the full model, the R^2 drops from 0.833 to 0.166, while if you drop X or Y the R^2 is virtually unchanged.
For linear classifiers, do larger coefficients imply more important features?
Not at all. The magnitude of the coefficients depends directly on the scales selected for the variables, which is a somewhat arbitrary modeling decision. To see this, consider a linear regression mode
For linear classifiers, do larger coefficients imply more important features? Not at all. The magnitude of the coefficients depends directly on the scales selected for the variables, which is a somewhat arbitrary modeling decision. To see this, consider a linear regression model predicting the petal width of an iris (in centimeters) given its petal length (in centimeters): summary(lm(Petal.Width~Petal.Length, data=iris)) # Call: # lm(formula = Petal.Width ~ Petal.Length, data = iris) # # Residuals: # Min 1Q Median 3Q Max # -0.56515 -0.12358 -0.01898 0.13288 0.64272 # # Coefficients: # Estimate Std. Error t value Pr(>|t|) # (Intercept) -0.363076 0.039762 -9.131 4.7e-16 *** # Petal.Length 0.415755 0.009582 43.387 < 2e-16 *** # --- # Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1 # # Residual standard error: 0.2065 on 148 degrees of freedom # Multiple R-squared: 0.9271, Adjusted R-squared: 0.9266 # F-statistic: 1882 on 1 and 148 DF, p-value: < 2.2e-16 Our model achieves an adjusted R^2 value of 0.9266 and assigns coefficient value 0.415755 to the Petal.Length variable. However, the choice to define Petal.Length in centimeters was quite arbitrary, and we could have instead defined the variable in meters: iris$Petal.Length.Meters <- iris$Petal.Length / 100 summary(lm(Petal.Width~Petal.Length.Meters, data=iris)) # Call: # lm(formula = Petal.Width ~ Petal.Length.Meters, data = iris) # # Residuals: # Min 1Q Median 3Q Max # -0.56515 -0.12358 -0.01898 0.13288 0.64272 # # Coefficients: # Estimate Std. Error t value Pr(>|t|) # (Intercept) -0.36308 0.03976 -9.131 4.7e-16 *** # Petal.Length.Meters 41.57554 0.95824 43.387 < 2e-16 *** # --- # Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1 # # Residual standard error: 0.2065 on 148 degrees of freedom # Multiple R-squared: 0.9271, Adjusted R-squared: 0.9266 # F-statistic: 1882 on 1 and 148 DF, p-value: < 2.2e-16 Of course, this doesn't really affect the fitted model in any way -- we simply assigned a 100x larger coefficient to Petal.Length.Meters (41.57554) than we did to Petal.Length (0.415755). All other properties of the model (adjusted R^2, t-statistics, p-values, etc.) are identical. Generally when fitting regularized linear models one will first normalize variables (for instance, to have mean 0 and unit variance) to avoid favoring some variables over others based on the selected scales. Assuming Normalized Data Even if you had normalized all variables, variables with higher coefficients may still not be as useful in predictions because the independent variables are rarely set (have low variance). As an example, consider a dataset with dependent variable Z and independent variables X and Y taking binary values set.seed(144) dat <- data.frame(X=rep(c(0, 1), each=50000), Y=rep(c(0, 1), c(1000, 99000))) dat$Z <- dat$X + 2*dat$Y + rnorm(100000) By construction, the coefficient for Y is roughly twice as large as the coefficient for X when both are used to predict Z via linear regression: summary(lm(Z~X+Y, data=dat)) # Call: # lm(formula = Z ~ X + Y, data = dat) # # Residuals: # Min 1Q Median 3Q Max # -4.4991 -0.6749 -0.0056 0.6723 4.7342 # # Coefficients: # Estimate Std. Error t value Pr(>|t|) # (Intercept) -0.094793 0.031598 -3.00 0.0027 ** # X 0.999435 0.006352 157.35 <2e-16 *** # Y 2.099410 0.031919 65.77 <2e-16 *** # --- # Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1 # # Residual standard error: 0.9992 on 99997 degrees of freedom # Multiple R-squared: 0.2394, Adjusted R-squared: 0.2394 # F-statistic: 1.574e+04 on 2 and 99997 DF, p-value: < 2.2e-16 Still, X explains more of the variance in Z than Y (the linear regression model predicting Z with X has R^2 value 0.2065, while the linear regression model predicting Z with Y has R^2 value 0.0511): summary(lm(Z~X, data=dat)) # Call: # lm(formula = Z ~ X, data = dat) # # Residuals: # Min 1Q Median 3Q Max # -5.2587 -0.6759 0.0038 0.6842 4.7342 # # Coefficients: # Estimate Std. Error t value Pr(>|t|) # (Intercept) 1.962629 0.004564 430.0 <2e-16 *** # X 1.041424 0.006455 161.3 <2e-16 *** # --- # Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1 # # Residual standard error: 1.021 on 99998 degrees of freedom # Multiple R-squared: 0.2065, Adjusted R-squared: 0.2065 # F-statistic: 2.603e+04 on 1 and 99998 DF, p-value: < 2.2e-16 versus: summary(lm(Z~Y, data=dat)) # Call: # lm(formula = Z ~ Y, data = dat) # # Residuals: # Min 1Q Median 3Q Max # -5.0038 -0.7638 -0.0007 0.7610 5.2288 # # Coefficients: # Estimate Std. Error t value Pr(>|t|) # (Intercept) -0.09479 0.03529 -2.686 0.00724 ** # Y 2.60418 0.03547 73.416 < 2e-16 *** # --- # Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1 # # Residual standard error: 1.116 on 99998 degrees of freedom # Multiple R-squared: 0.05114, Adjusted R-squared: 0.05113 # F-statistic: 5390 on 1 and 99998 DF, p-value: < 2.2e-16 The Case of Multi-Collinearity A third case where large coefficient values may be deceiving would be in the case of significant multi-collinearity between variables. As an example, consider a dataset where X and Y are highly correlated but W is not highly correlated to the other two; we are trying to predict Z: set.seed(144) dat <- data.frame(W=rnorm(100000), X=rnorm(100000)) dat$Y <- dat$X + rnorm(100000, 0, 0.001) dat$Z <- 2*dat$W+10*dat$X-11*dat$Y + rnorm(100000) cor(dat) # W X Y Z # W 1.000000e+00 5.191809e-05 5.200434e-05 0.8161636 # X 5.191809e-05 1.000000e+00 9.999995e-01 -0.4079183 # Y 5.200434e-05 9.999995e-01 1.000000e+00 -0.4079246 # Z 8.161636e-01 -4.079183e-01 -4.079246e-01 1.0000000 These variables pretty much have the same mean (0) and variance (~1), and linear regression assigns much higher coefficient values (in absolute value) to X (roughly 15) and Y (roughly -16) than it does to W (roughly 2): summary(lm(Z~W+X+Y, data=dat)) # Call: # lm(formula = Z ~ W + X + Y, data = dat) # # Residuals: # Min 1Q Median 3Q Max # -4.1886 -0.6760 0.0026 0.6679 4.2232 # # Coefficients: # Estimate Std. Error t value Pr(>|t|) # (Intercept) 1.831e-04 3.170e-03 0.058 0.954 # W 2.001e+00 3.172e-03 630.811 < 2e-16 *** # X 1.509e+01 3.177e+00 4.748 2.05e-06 *** # Y -1.609e+01 3.177e+00 -5.063 4.13e-07 *** # --- # Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1 # # Residual standard error: 1.002 on 99996 degrees of freedom # Multiple R-squared: 0.8326, Adjusted R-squared: 0.8326 # F-statistic: 1.658e+05 on 3 and 99996 DF, p-value: < 2.2e-16 Still, among the three variables in the model W is the most important: If you remove W from the full model, the R^2 drops from 0.833 to 0.166, while if you drop X or Y the R^2 is virtually unchanged.
For linear classifiers, do larger coefficients imply more important features? Not at all. The magnitude of the coefficients depends directly on the scales selected for the variables, which is a somewhat arbitrary modeling decision. To see this, consider a linear regression mode
13,676
For linear classifiers, do larger coefficients imply more important features?
"Feature importance" is a very slippery concept even when all predictors have been adjusted to a common scale (which in itself is a non-trivial problem in many practical applications involving categorical variables or skewed distributions). So if you avoid the scaling problems indicated in the answer by @josliber or the low-predictor-variance issue raised by @dsaxton, you still have additional problems. For example, a more useful measure of feature importance may be the ratio of its coefficient to the estimated error of its coefficient. A high coefficient with a large estimated error would not necessarily be helpful in predictions. So coefficient magnitude alone, even in the pre-scaled situation, is not a good guide to "importance." Nevertheless, a predictor may be important even if its coefficient's ratio of magnitude to error is low (i.e., it is not "statistically significant"). Linear models provide the ability to take multiple predictor variables into account simultaneously, so including a "non-significant" predictor in a model can improve the overall performance provided by the combined collection of predictors. Furthermore, attempts to select "important" predictor variables tend to be highly dependent on the particular data sample and often do not extend well to further samples, particularly if the variables are correlated. You can see this for yourself by repeating feature selection on multiple bootstrap samples of the same data set. Frank Harrell, in this answer shows how to use his rms package in R for ranking feature importance, and notes in this answer how to use the bootstrap to get confidence intervals for the ranks. Bootstrapping can serve as a caution to those who put too much importance in "feature importance." This question from nearly 3 years ago, pointed out by @amoeba, also goes into extensive detail about difficulties with feature importance in multiple regression models.
For linear classifiers, do larger coefficients imply more important features?
"Feature importance" is a very slippery concept even when all predictors have been adjusted to a common scale (which in itself is a non-trivial problem in many practical applications involving categor
For linear classifiers, do larger coefficients imply more important features? "Feature importance" is a very slippery concept even when all predictors have been adjusted to a common scale (which in itself is a non-trivial problem in many practical applications involving categorical variables or skewed distributions). So if you avoid the scaling problems indicated in the answer by @josliber or the low-predictor-variance issue raised by @dsaxton, you still have additional problems. For example, a more useful measure of feature importance may be the ratio of its coefficient to the estimated error of its coefficient. A high coefficient with a large estimated error would not necessarily be helpful in predictions. So coefficient magnitude alone, even in the pre-scaled situation, is not a good guide to "importance." Nevertheless, a predictor may be important even if its coefficient's ratio of magnitude to error is low (i.e., it is not "statistically significant"). Linear models provide the ability to take multiple predictor variables into account simultaneously, so including a "non-significant" predictor in a model can improve the overall performance provided by the combined collection of predictors. Furthermore, attempts to select "important" predictor variables tend to be highly dependent on the particular data sample and often do not extend well to further samples, particularly if the variables are correlated. You can see this for yourself by repeating feature selection on multiple bootstrap samples of the same data set. Frank Harrell, in this answer shows how to use his rms package in R for ranking feature importance, and notes in this answer how to use the bootstrap to get confidence intervals for the ranks. Bootstrapping can serve as a caution to those who put too much importance in "feature importance." This question from nearly 3 years ago, pointed out by @amoeba, also goes into extensive detail about difficulties with feature importance in multiple regression models.
For linear classifiers, do larger coefficients imply more important features? "Feature importance" is a very slippery concept even when all predictors have been adjusted to a common scale (which in itself is a non-trivial problem in many practical applications involving categor
13,677
For linear classifiers, do larger coefficients imply more important features?
Just to add to the previous answer, the coefficient itself also fails to capture how much variability a predictor exhibits, which has a large effect on how useful it is in making predictions. Consider the simple model $$ \text{E}(Y_i) = \alpha + \beta X_i $$ where $X_i$ is a Bernoulli$(p)$ random variable. By taking $p \to 0$ we can send the usefulness of this predictor to zero as well, but the coefficient will always be $\beta$.
For linear classifiers, do larger coefficients imply more important features?
Just to add to the previous answer, the coefficient itself also fails to capture how much variability a predictor exhibits, which has a large effect on how useful it is in making predictions. Conside
For linear classifiers, do larger coefficients imply more important features? Just to add to the previous answer, the coefficient itself also fails to capture how much variability a predictor exhibits, which has a large effect on how useful it is in making predictions. Consider the simple model $$ \text{E}(Y_i) = \alpha + \beta X_i $$ where $X_i$ is a Bernoulli$(p)$ random variable. By taking $p \to 0$ we can send the usefulness of this predictor to zero as well, but the coefficient will always be $\beta$.
For linear classifiers, do larger coefficients imply more important features? Just to add to the previous answer, the coefficient itself also fails to capture how much variability a predictor exhibits, which has a large effect on how useful it is in making predictions. Conside
13,678
MLE vs MAP estimation, when to use which?
If a prior probability is given as part of the problem setup, then use that information (i.e. use MAP). If no such prior information is given or assumed, then MAP is not possible, and MLE is a reasonable approach.
MLE vs MAP estimation, when to use which?
If a prior probability is given as part of the problem setup, then use that information (i.e. use MAP). If no such prior information is given or assumed, then MAP is not possible, and MLE is a reasona
MLE vs MAP estimation, when to use which? If a prior probability is given as part of the problem setup, then use that information (i.e. use MAP). If no such prior information is given or assumed, then MAP is not possible, and MLE is a reasonable approach.
MLE vs MAP estimation, when to use which? If a prior probability is given as part of the problem setup, then use that information (i.e. use MAP). If no such prior information is given or assumed, then MAP is not possible, and MLE is a reasona
13,679
MLE vs MAP estimation, when to use which?
A Bayesian would agree with you, a frequentist would not. This is a matter of opinion, perspective, and philosophy. I think that it does a lot of harm to the statistics community to attempt to argue that one method is always better than the other. Many problems will have Bayesian and frequentist solutions that are similar so long as the Bayesian does not have too strong of a prior.
MLE vs MAP estimation, when to use which?
A Bayesian would agree with you, a frequentist would not. This is a matter of opinion, perspective, and philosophy. I think that it does a lot of harm to the statistics community to attempt to argue
MLE vs MAP estimation, when to use which? A Bayesian would agree with you, a frequentist would not. This is a matter of opinion, perspective, and philosophy. I think that it does a lot of harm to the statistics community to attempt to argue that one method is always better than the other. Many problems will have Bayesian and frequentist solutions that are similar so long as the Bayesian does not have too strong of a prior.
MLE vs MAP estimation, when to use which? A Bayesian would agree with you, a frequentist would not. This is a matter of opinion, perspective, and philosophy. I think that it does a lot of harm to the statistics community to attempt to argue
13,680
MLE vs MAP estimation, when to use which?
Assuming you have accurate prior information, MAP is better if the problem has a zero-one loss function on the estimate. If the loss is not zero-one (and in many real-world problems it is not), then it can happen that the MLE achieves lower expected loss. In these cases, it would be better not to limit yourself to MAP and MLE as the only two options, since they are both suboptimal.
MLE vs MAP estimation, when to use which?
Assuming you have accurate prior information, MAP is better if the problem has a zero-one loss function on the estimate. If the loss is not zero-one (and in many real-world problems it is not), then
MLE vs MAP estimation, when to use which? Assuming you have accurate prior information, MAP is better if the problem has a zero-one loss function on the estimate. If the loss is not zero-one (and in many real-world problems it is not), then it can happen that the MLE achieves lower expected loss. In these cases, it would be better not to limit yourself to MAP and MLE as the only two options, since they are both suboptimal.
MLE vs MAP estimation, when to use which? Assuming you have accurate prior information, MAP is better if the problem has a zero-one loss function on the estimate. If the loss is not zero-one (and in many real-world problems it is not), then
13,681
MLE vs MAP estimation, when to use which?
Short answer by @bean explains it very well. However, I would like to point to the section 1.1 of the paper Gibbs Sampling for the uninitiated by Resnik and Hardisty which takes the matter to more depth. I am writing few lines from this paper with very slight modifications (This answers repeats few of things which OP knows for sake of completeness) MLE Formally MLE produces the choice (of model parameter) most likely to generated the observed data. MAP A MAP estimated is the choice that is most likely given the observed data. In contrast to MLE, MAP estimation applies Bayes's Rule, so that our estimate can take into account prior knowledge about what we expect our parameters to be in the form of a prior probability distribution. Catch MLE and MAP estimates are both giving us the best estimate, according to their respective de nitions of "best". But notice that using a single estimate -- whether it's MLE or MAP -- throws away information. In principle, parameter could have any value (from the domain); might we not get better estimates if we took the whole distribution into account, rather than just a single estimated value for parameter? If we do that, we're making use of all the information about parameter that we can wring from the observed data, X. So with this catch, we might want to use none of them. Also, as already mentioned by bean and Tim, if you have to use one of them, use MAP if you got prior. If you do not have priors, MAP reduces to MLE. Conjugate priors will help to solve the problem analytically, otherwise use Gibbs Sampling.
MLE vs MAP estimation, when to use which?
Short answer by @bean explains it very well. However, I would like to point to the section 1.1 of the paper Gibbs Sampling for the uninitiated by Resnik and Hardisty which takes the matter to more dep
MLE vs MAP estimation, when to use which? Short answer by @bean explains it very well. However, I would like to point to the section 1.1 of the paper Gibbs Sampling for the uninitiated by Resnik and Hardisty which takes the matter to more depth. I am writing few lines from this paper with very slight modifications (This answers repeats few of things which OP knows for sake of completeness) MLE Formally MLE produces the choice (of model parameter) most likely to generated the observed data. MAP A MAP estimated is the choice that is most likely given the observed data. In contrast to MLE, MAP estimation applies Bayes's Rule, so that our estimate can take into account prior knowledge about what we expect our parameters to be in the form of a prior probability distribution. Catch MLE and MAP estimates are both giving us the best estimate, according to their respective de nitions of "best". But notice that using a single estimate -- whether it's MLE or MAP -- throws away information. In principle, parameter could have any value (from the domain); might we not get better estimates if we took the whole distribution into account, rather than just a single estimated value for parameter? If we do that, we're making use of all the information about parameter that we can wring from the observed data, X. So with this catch, we might want to use none of them. Also, as already mentioned by bean and Tim, if you have to use one of them, use MAP if you got prior. If you do not have priors, MAP reduces to MLE. Conjugate priors will help to solve the problem analytically, otherwise use Gibbs Sampling.
MLE vs MAP estimation, when to use which? Short answer by @bean explains it very well. However, I would like to point to the section 1.1 of the paper Gibbs Sampling for the uninitiated by Resnik and Hardisty which takes the matter to more dep
13,682
MLE vs MAP estimation, when to use which?
Theoretically, if you have the information about the prior probability, use MAP; otherwise MLE. However, as the amount of data increases, the leading role of prior assumptions (which used by MAP) on model parameters will gradually weaken, while the data samples will greatly occupy a favorable position. In extreme cases, MLE is exactly same to MAP even if you remove the information about prior probability, i.e., assume the prior probability is uniformly distributed. So: If dataset is large (like in machine learning): there is no difference between MLE and MAP; always use MLE. If dataset is small: MAP is much better than MLE; use MAP if you have information about prior probability.
MLE vs MAP estimation, when to use which?
Theoretically, if you have the information about the prior probability, use MAP; otherwise MLE. However, as the amount of data increases, the leading role of prior assumptions (which used by MAP) on m
MLE vs MAP estimation, when to use which? Theoretically, if you have the information about the prior probability, use MAP; otherwise MLE. However, as the amount of data increases, the leading role of prior assumptions (which used by MAP) on model parameters will gradually weaken, while the data samples will greatly occupy a favorable position. In extreme cases, MLE is exactly same to MAP even if you remove the information about prior probability, i.e., assume the prior probability is uniformly distributed. So: If dataset is large (like in machine learning): there is no difference between MLE and MAP; always use MLE. If dataset is small: MAP is much better than MLE; use MAP if you have information about prior probability.
MLE vs MAP estimation, when to use which? Theoretically, if you have the information about the prior probability, use MAP; otherwise MLE. However, as the amount of data increases, the leading role of prior assumptions (which used by MAP) on m
13,683
MLE vs MAP estimation, when to use which?
As we know that $$\begin{equation}\begin{aligned} \hat\theta^{MAP}&=\arg \max\limits_{\substack{\theta}} \log P(\theta|\mathcal{D})\\ &= \arg \max\limits_{\substack{\theta}} \log \frac{P(\mathcal{D}|\theta)P(\theta)}{P(\mathcal{D})}\\ &=\arg \max\limits_{\substack{\theta}} \log P(\mathcal{D}|\theta)P(\theta) \\ &=\arg \max\limits_{\substack{\theta}} \underbrace{\log P(\mathcal{D}|\theta)}_{\text{log-likelihood}}+ \underbrace{\log P(\theta)}_{\text{regularizer}} \end{aligned}\end{equation}$$ The prior is treated as a regularizer and if you know the prior distribution, for example, Gaussin ($\exp(-\frac{\lambda}{2}\theta^T\theta)$) in linear regression, and it's better to add that regularization for better performance. I think MAP is much better. MAP is better compared to MLE, but here are some of its minuses: It only provides a point estimate but no measure of uncertainty It predicts overconfidently Hard to summarize the posterior distribution, and the mode is sometimes untypical Reparameterization invariance The posterior cannot be used as the prior in the next step Can’t compute credible intervals
MLE vs MAP estimation, when to use which?
As we know that $$\begin{equation}\begin{aligned} \hat\theta^{MAP}&=\arg \max\limits_{\substack{\theta}} \log P(\theta|\mathcal{D})\\ &= \arg \max\limits_{\substack{\theta}} \log \frac{P(\mathcal{D}|\
MLE vs MAP estimation, when to use which? As we know that $$\begin{equation}\begin{aligned} \hat\theta^{MAP}&=\arg \max\limits_{\substack{\theta}} \log P(\theta|\mathcal{D})\\ &= \arg \max\limits_{\substack{\theta}} \log \frac{P(\mathcal{D}|\theta)P(\theta)}{P(\mathcal{D})}\\ &=\arg \max\limits_{\substack{\theta}} \log P(\mathcal{D}|\theta)P(\theta) \\ &=\arg \max\limits_{\substack{\theta}} \underbrace{\log P(\mathcal{D}|\theta)}_{\text{log-likelihood}}+ \underbrace{\log P(\theta)}_{\text{regularizer}} \end{aligned}\end{equation}$$ The prior is treated as a regularizer and if you know the prior distribution, for example, Gaussin ($\exp(-\frac{\lambda}{2}\theta^T\theta)$) in linear regression, and it's better to add that regularization for better performance. I think MAP is much better. MAP is better compared to MLE, but here are some of its minuses: It only provides a point estimate but no measure of uncertainty It predicts overconfidently Hard to summarize the posterior distribution, and the mode is sometimes untypical Reparameterization invariance The posterior cannot be used as the prior in the next step Can’t compute credible intervals
MLE vs MAP estimation, when to use which? As we know that $$\begin{equation}\begin{aligned} \hat\theta^{MAP}&=\arg \max\limits_{\substack{\theta}} \log P(\theta|\mathcal{D})\\ &= \arg \max\limits_{\substack{\theta}} \log \frac{P(\mathcal{D}|\
13,684
MLE vs MAP estimation, when to use which?
If the data is less and you have priors available - "GO FOR MAP". If you have a lot data, the MAP will converge to MLE. Thus in case of lot of data scenario it's always better to do MLE rather than MAP.
MLE vs MAP estimation, when to use which?
If the data is less and you have priors available - "GO FOR MAP". If you have a lot data, the MAP will converge to MLE. Thus in case of lot of data scenario it's always better to do MLE rather than MA
MLE vs MAP estimation, when to use which? If the data is less and you have priors available - "GO FOR MAP". If you have a lot data, the MAP will converge to MLE. Thus in case of lot of data scenario it's always better to do MLE rather than MAP.
MLE vs MAP estimation, when to use which? If the data is less and you have priors available - "GO FOR MAP". If you have a lot data, the MAP will converge to MLE. Thus in case of lot of data scenario it's always better to do MLE rather than MA
13,685
Collinear variables in Multiclass LDA training
Multicollinearity means that your predictors are correlated. Why is this bad? Because LDA, like regression techniques involves computing a matrix inversion, which is inaccurate if the determinant is close to 0 (i.e. two or more variables are almost a linear combination of each other). More importantly, it makes the estimated coefficients impossible to interpret. If an increase in $X_1$, say, is associated with an decrease in $X_2$ and they both increase variable $Y$, every change in $X_1$ will be compensated by a change in $X_2$ and you will underestimate the effect of $X_1$ on $Y$. In LDA, you would underestimate the effect of $X_1$ on the classification. If all you care for is the classification per se, and that after training your model on half of the data and testing it on the other half you get 85-95% accuracy I'd say it is fine.
Collinear variables in Multiclass LDA training
Multicollinearity means that your predictors are correlated. Why is this bad? Because LDA, like regression techniques involves computing a matrix inversion, which is inaccurate if the determinant is c
Collinear variables in Multiclass LDA training Multicollinearity means that your predictors are correlated. Why is this bad? Because LDA, like regression techniques involves computing a matrix inversion, which is inaccurate if the determinant is close to 0 (i.e. two or more variables are almost a linear combination of each other). More importantly, it makes the estimated coefficients impossible to interpret. If an increase in $X_1$, say, is associated with an decrease in $X_2$ and they both increase variable $Y$, every change in $X_1$ will be compensated by a change in $X_2$ and you will underestimate the effect of $X_1$ on $Y$. In LDA, you would underestimate the effect of $X_1$ on the classification. If all you care for is the classification per se, and that after training your model on half of the data and testing it on the other half you get 85-95% accuracy I'd say it is fine.
Collinear variables in Multiclass LDA training Multicollinearity means that your predictors are correlated. Why is this bad? Because LDA, like regression techniques involves computing a matrix inversion, which is inaccurate if the determinant is c
13,686
Collinear variables in Multiclass LDA training
As I seem to think gui11aume has given you a great answer, I want to give an example from a slightly different angle that might be illuminating. Consider that a covariate in your discriminant function looks as follows: $X_1= 5X_2 +3X_3 -X_4$. Suppose the best LDA has the following linear boundary: $X_1+2X_2+X_3-2X_4 =5$ Then we can substitute $5X_2+3X_3-X_4$ for $X_1$ n the LDA boundary equation, so: $5X_2+3X_3-X_4+2X_2+X_3-2X_4=5$ or $7X_2+4X_3-3X_4=5$. These two boundaries are identical but the first one has coefficients $1, 2, 1,-2$ for $X_1$, $X_2$, $X_3$, and $X_4$ respectively, while the other has coefficients $0, 7, 3, -1$. So the coefficient are quite different but the two equations give the same boundary and identical prediction rule. If one form is good the other is also. But now you can see why gui11ame says the coefficients are uninterpretable. There are several other ways to express this boundary as well by substituting for $X_2$ to give it the $0$ coefficient and the same could be done for $X_3$ or $X_4$. But in practice the collinearity is approximate. This makes things worse because the noise allows for a unique answer. Very slight perturbations of the data will cause the coefficients to change drastically. But for prediction you are okay because each equation defines almost the same boundary and so LDA will result in nearly identical predictions.
Collinear variables in Multiclass LDA training
As I seem to think gui11aume has given you a great answer, I want to give an example from a slightly different angle that might be illuminating. Consider that a covariate in your discriminant functio
Collinear variables in Multiclass LDA training As I seem to think gui11aume has given you a great answer, I want to give an example from a slightly different angle that might be illuminating. Consider that a covariate in your discriminant function looks as follows: $X_1= 5X_2 +3X_3 -X_4$. Suppose the best LDA has the following linear boundary: $X_1+2X_2+X_3-2X_4 =5$ Then we can substitute $5X_2+3X_3-X_4$ for $X_1$ n the LDA boundary equation, so: $5X_2+3X_3-X_4+2X_2+X_3-2X_4=5$ or $7X_2+4X_3-3X_4=5$. These two boundaries are identical but the first one has coefficients $1, 2, 1,-2$ for $X_1$, $X_2$, $X_3$, and $X_4$ respectively, while the other has coefficients $0, 7, 3, -1$. So the coefficient are quite different but the two equations give the same boundary and identical prediction rule. If one form is good the other is also. But now you can see why gui11ame says the coefficients are uninterpretable. There are several other ways to express this boundary as well by substituting for $X_2$ to give it the $0$ coefficient and the same could be done for $X_3$ or $X_4$. But in practice the collinearity is approximate. This makes things worse because the noise allows for a unique answer. Very slight perturbations of the data will cause the coefficients to change drastically. But for prediction you are okay because each equation defines almost the same boundary and so LDA will result in nearly identical predictions.
Collinear variables in Multiclass LDA training As I seem to think gui11aume has given you a great answer, I want to give an example from a slightly different angle that might be illuminating. Consider that a covariate in your discriminant functio
13,687
Collinear variables in Multiclass LDA training
While the answer that was marked here is correct, I think you were looking for a different explanation to find out what happened in your code. I had the exact same issue running through a model. Here's whats going on: You're training your model with the predicted variable as part of your data set. Here's an example of what was occurring to me without even noticing it: df = pd.read_csv('file.csv') df.columns = ['COL1','COL2','COL3','COL4'] train_Y = train['COL3'] train_X = train[train.columns[:-1]] In this code, I want to predict the value of 'COL3'... but, if you look at train_X, I'm telling it to retrieve every column except the last one, so its inputting COL1 COL2 and COL3, not COL4, and trying to predict COL3 which is part of train_X. I corrected this by just moving the columns, manually moved COL3 in Excel to be the last column in my data set (now taking place of COL4), and then: df = pd.read_csv('file.csv') df.columns = ['COL1','COL2','COL3','COL4'] train_Y = train['COL4'] train_X = train[train.columns[:-1]] If you don't want to move it in Excel, and want to just do it by code then: df = pd.read_csv('file.csv') df.columns = ['COL1','COL2','COL3','COL4'] train_Y = train['COL3'] train_X = train[train.columns['COL1','COL2','COL4']] Note now how I declared train_X, to include all columns except COL3, which is part of train_Y. I hope that helps.
Collinear variables in Multiclass LDA training
While the answer that was marked here is correct, I think you were looking for a different explanation to find out what happened in your code. I had the exact same issue running through a model. Here'
Collinear variables in Multiclass LDA training While the answer that was marked here is correct, I think you were looking for a different explanation to find out what happened in your code. I had the exact same issue running through a model. Here's whats going on: You're training your model with the predicted variable as part of your data set. Here's an example of what was occurring to me without even noticing it: df = pd.read_csv('file.csv') df.columns = ['COL1','COL2','COL3','COL4'] train_Y = train['COL3'] train_X = train[train.columns[:-1]] In this code, I want to predict the value of 'COL3'... but, if you look at train_X, I'm telling it to retrieve every column except the last one, so its inputting COL1 COL2 and COL3, not COL4, and trying to predict COL3 which is part of train_X. I corrected this by just moving the columns, manually moved COL3 in Excel to be the last column in my data set (now taking place of COL4), and then: df = pd.read_csv('file.csv') df.columns = ['COL1','COL2','COL3','COL4'] train_Y = train['COL4'] train_X = train[train.columns[:-1]] If you don't want to move it in Excel, and want to just do it by code then: df = pd.read_csv('file.csv') df.columns = ['COL1','COL2','COL3','COL4'] train_Y = train['COL3'] train_X = train[train.columns['COL1','COL2','COL4']] Note now how I declared train_X, to include all columns except COL3, which is part of train_Y. I hope that helps.
Collinear variables in Multiclass LDA training While the answer that was marked here is correct, I think you were looking for a different explanation to find out what happened in your code. I had the exact same issue running through a model. Here'
13,688
"Least Squares" and "Linear Regression", are they synonyms?
Linear regression assumes a linear relationship between the independent and dependent variable. It doesn't tell you how the model is fitted. Least square fitting is simply one of the possibilities. Other methods for training a linear model is in the comment. Non-linear least squares is common (https://en.wikipedia.org/wiki/Non-linear_least_squares). For example, the popular Levenberg–Marquardt algorithm solves something like: $$\hat\beta=\mathop{\textrm{argmin}}_\beta S(\beta)\equiv \mathop{\textrm{argmin}}_\beta\sum_{i=1}^{m}\left[ y_i-f(x_i,\beta) \right]^2$$ It is a least squares optimization but the model is not linear. They are not the same thing.
"Least Squares" and "Linear Regression", are they synonyms?
Linear regression assumes a linear relationship between the independent and dependent variable. It doesn't tell you how the model is fitted. Least square fitting is simply one of the possibilities. O
"Least Squares" and "Linear Regression", are they synonyms? Linear regression assumes a linear relationship between the independent and dependent variable. It doesn't tell you how the model is fitted. Least square fitting is simply one of the possibilities. Other methods for training a linear model is in the comment. Non-linear least squares is common (https://en.wikipedia.org/wiki/Non-linear_least_squares). For example, the popular Levenberg–Marquardt algorithm solves something like: $$\hat\beta=\mathop{\textrm{argmin}}_\beta S(\beta)\equiv \mathop{\textrm{argmin}}_\beta\sum_{i=1}^{m}\left[ y_i-f(x_i,\beta) \right]^2$$ It is a least squares optimization but the model is not linear. They are not the same thing.
"Least Squares" and "Linear Regression", are they synonyms? Linear regression assumes a linear relationship between the independent and dependent variable. It doesn't tell you how the model is fitted. Least square fitting is simply one of the possibilities. O
13,689
"Least Squares" and "Linear Regression", are they synonyms?
In addition to the correct answer of @Student T, I want to emphasize that least squares is a potential loss function for an optimization problem, whereas linear regression is an optimization problem. Given a certain dataset, linear regression is used to find the best possible linear function, which is explaining the connection between the variables. In this case the "best" possible is determined by a loss function, comparing the predicted values of a linear function with the actual values in the dataset. Least Squares is a possible loss function. The wikipedia article of least-squares also shows pictures on the right side which show using least squares for other problems than linear regression such as: conic-fitting fitting quadratic function The following gif from the wikipedia article shows several different polynomial functions fitted to a dataset using least squares. Only one of them is linear (polynom of 1). This is taken from the german wikipedia article to the topic.
"Least Squares" and "Linear Regression", are they synonyms?
In addition to the correct answer of @Student T, I want to emphasize that least squares is a potential loss function for an optimization problem, whereas linear regression is an optimization problem.
"Least Squares" and "Linear Regression", are they synonyms? In addition to the correct answer of @Student T, I want to emphasize that least squares is a potential loss function for an optimization problem, whereas linear regression is an optimization problem. Given a certain dataset, linear regression is used to find the best possible linear function, which is explaining the connection between the variables. In this case the "best" possible is determined by a loss function, comparing the predicted values of a linear function with the actual values in the dataset. Least Squares is a possible loss function. The wikipedia article of least-squares also shows pictures on the right side which show using least squares for other problems than linear regression such as: conic-fitting fitting quadratic function The following gif from the wikipedia article shows several different polynomial functions fitted to a dataset using least squares. Only one of them is linear (polynom of 1). This is taken from the german wikipedia article to the topic.
"Least Squares" and "Linear Regression", are they synonyms? In addition to the correct answer of @Student T, I want to emphasize that least squares is a potential loss function for an optimization problem, whereas linear regression is an optimization problem.
13,690
How to use SVD for dimensionality reduction to reduce the number of columns (features) of the data matrix? [duplicate]
What @davidhigh wrote is correct: if you multiply reduced versions of $\mathbf U_\mathrm{r}$, $\mathbf S_\mathrm{r}$, and $\mathbf V_\mathrm{r}$, as you describe in your question, then you will obtain a matrix $$\tilde{ \mathbf A}=\mathbf U_\mathrm{r}\mathbf S_\mathrm{r}\mathbf V_\mathrm{r}^\top$$ that has exactly the same dimensions as before, but has a reduced rank. However, what @davidhigh did not add is that you can get what you want by multiplying reduced versions of $\mathbf U_\mathrm{r}$ and $\mathbf S_\mathrm{r}$ only, i.e. computing $$\mathbf B=\mathbf U_\mathrm{r}\mathbf S_\mathrm{r}.$$ This matrix has (in your example) only $100$ columns, but the same number of rows as $\mathbf A$. Matrix $\mathbf V$ is used only to map the data from this reduced 100-dimensional space to your original $p$-dimensional space. If you don't need to map it back, just leave $\mathbf V$ out, and done you are. By the way, the columns of matrix $\mathbf B$ will contain what is called principal components of your data.
How to use SVD for dimensionality reduction to reduce the number of columns (features) of the data m
What @davidhigh wrote is correct: if you multiply reduced versions of $\mathbf U_\mathrm{r}$, $\mathbf S_\mathrm{r}$, and $\mathbf V_\mathrm{r}$, as you describe in your question, then you will obtain
How to use SVD for dimensionality reduction to reduce the number of columns (features) of the data matrix? [duplicate] What @davidhigh wrote is correct: if you multiply reduced versions of $\mathbf U_\mathrm{r}$, $\mathbf S_\mathrm{r}$, and $\mathbf V_\mathrm{r}$, as you describe in your question, then you will obtain a matrix $$\tilde{ \mathbf A}=\mathbf U_\mathrm{r}\mathbf S_\mathrm{r}\mathbf V_\mathrm{r}^\top$$ that has exactly the same dimensions as before, but has a reduced rank. However, what @davidhigh did not add is that you can get what you want by multiplying reduced versions of $\mathbf U_\mathrm{r}$ and $\mathbf S_\mathrm{r}$ only, i.e. computing $$\mathbf B=\mathbf U_\mathrm{r}\mathbf S_\mathrm{r}.$$ This matrix has (in your example) only $100$ columns, but the same number of rows as $\mathbf A$. Matrix $\mathbf V$ is used only to map the data from this reduced 100-dimensional space to your original $p$-dimensional space. If you don't need to map it back, just leave $\mathbf V$ out, and done you are. By the way, the columns of matrix $\mathbf B$ will contain what is called principal components of your data.
How to use SVD for dimensionality reduction to reduce the number of columns (features) of the data m What @davidhigh wrote is correct: if you multiply reduced versions of $\mathbf U_\mathrm{r}$, $\mathbf S_\mathrm{r}$, and $\mathbf V_\mathrm{r}$, as you describe in your question, then you will obtain
13,691
How to use SVD for dimensionality reduction to reduce the number of columns (features) of the data matrix? [duplicate]
It seems that you are not completely aware of what an SVD does. As you wrote, it decomposes a matrix $\mathbf A$ according to $$\mathbf A = \mathbf U \mathbf S \mathbf V^T,$$ Read the details on the involved matrix dimensions and properties for example here. Now, dimensionality reduction is done by neglecting small singular values in the diagonal matrix $\mathbf S$. Regardless of how many singular values you approximately set to zero, the resulting matrix $\mathbf A$ always retains its original dimension. In particular, you don't drop any rows or columns. Consequently, the feature of dimensionality reduction is only exploited in the decomposed version. Consider for example a very large matrix with rank 1, that is, the column/row-vectors span only a one-dimensional subspace. For this matrix, you will obtain only one non-zero singular value. Now, instead of storing this large matrix one can also store two vectors and one real number, which corresponds to a reduction by one order of magnitude.
How to use SVD for dimensionality reduction to reduce the number of columns (features) of the data m
It seems that you are not completely aware of what an SVD does. As you wrote, it decomposes a matrix $\mathbf A$ according to $$\mathbf A = \mathbf U \mathbf S \mathbf V^T,$$ Read the details on the i
How to use SVD for dimensionality reduction to reduce the number of columns (features) of the data matrix? [duplicate] It seems that you are not completely aware of what an SVD does. As you wrote, it decomposes a matrix $\mathbf A$ according to $$\mathbf A = \mathbf U \mathbf S \mathbf V^T,$$ Read the details on the involved matrix dimensions and properties for example here. Now, dimensionality reduction is done by neglecting small singular values in the diagonal matrix $\mathbf S$. Regardless of how many singular values you approximately set to zero, the resulting matrix $\mathbf A$ always retains its original dimension. In particular, you don't drop any rows or columns. Consequently, the feature of dimensionality reduction is only exploited in the decomposed version. Consider for example a very large matrix with rank 1, that is, the column/row-vectors span only a one-dimensional subspace. For this matrix, you will obtain only one non-zero singular value. Now, instead of storing this large matrix one can also store two vectors and one real number, which corresponds to a reduction by one order of magnitude.
How to use SVD for dimensionality reduction to reduce the number of columns (features) of the data m It seems that you are not completely aware of what an SVD does. As you wrote, it decomposes a matrix $\mathbf A$ according to $$\mathbf A = \mathbf U \mathbf S \mathbf V^T,$$ Read the details on the i
13,692
Prove the equivalence of the following two formulas for Spearman correlation
$ \rho = \frac{\sum_i(x_i-\bar{x})(y_i-\bar{y})}{\sqrt{\sum_i (x_i-\bar{x})^2 \sum_i(y_i-\bar{y})^2}}$ Since there are no ties, the $x$'s and $y$'s both consist of the integers from $1$ to $n$ inclusive. Hence we can rewrite the denominator: $\frac{\sum_i(x_i-\bar{x})(y_i-\bar{y})}{\sum_i (x_i-\bar{x})^2}$ But the denominator is just a function of $n$: $\sum_i (x_i-\bar{x})^2 = \sum_i x_i^2 - n\bar{x}^2 \\ \quad= \frac{n(n + 1)(2n + 1)}{6} - n(\frac{(n + 1)}{2})^2\\ \quad= n(n + 1)(\frac{(2n + 1)}{6} - \frac{(n + 1)}{4})\\ \quad= n(n + 1)(\frac{(8n + 4-6n-6)}{24})\\ \quad= n(n + 1)(\frac{(n -1)}{12})\\ \quad= \frac{n(n^2 - 1)}{12}$ Now let's look at the numerator: $\sum_i(x_i-\bar{x})(y_i-\bar{y})\\ \quad=\sum_i x_i(y_i-\bar{y})-\sum_i\bar{x}(y_i-\bar{y}) \\ \quad=\sum_i x_i y_i-\bar{y}\sum_i x_i-\bar{x}\sum_iy_i+n\bar{x}\bar{y} \\ \quad=\sum_i x_i y_i-n\bar{x}\bar{y} \\ \quad= \sum_i x_i y_i-n(\frac{n+1}{2})^2 \\ \quad= \sum_i x_i y_i- \frac{n(n+1)}{12}3(n +1) \\ \quad= \frac{n(n+1)}{12}.(-3(n +1))+\sum_i x_i y_i \\ \quad= \frac{n(n+1)}{12}.[(n-1) - (4n+2)] + \sum_i x_i y_i \\ \quad= \frac{n(n+1)(n-1)}{12} - n(n+1)(2n+1)/6 + \sum_i x_i y_i \\ \quad= \frac{n(n+1)(n-1)}{12} -\sum_i x_i^2+ \sum_i x_i y_i \\ \quad= \frac{n(n+1)(n-1)}{12} -\sum_i (x_i^2+ y_i^2)/2+ \sum_i x_i y_i \\ \quad= \frac{n(n+1)(n-1)}{12} - \sum_i (x_i^2 - 2x_i y_i + y_i^2) /2\\ \quad= \frac{n(n+1)(n-1)}{12} - \sum_i(x_i - y_i)^2/2\\ \quad= \frac{n(n^2-1)}{12} - \sum d_i^2/2$ Numerator/Denominator $= \frac{n(n+1)(n-1)/12 - \sum d_i^2/2}{n(n^2 - 1)/12}\\ \quad= {\frac {n(n^2 - 1)/12 -\sum d_i^2/2}{n(n^2 - 1)/12}}\\ \quad= 1- {\frac {6 \sum d_i^2}{n(n^2 - 1)}}\,$. Hence $ \rho = 1- {\frac {6 \sum d_i^2}{n(n^2 - 1)}}.$
Prove the equivalence of the following two formulas for Spearman correlation
$ \rho = \frac{\sum_i(x_i-\bar{x})(y_i-\bar{y})}{\sqrt{\sum_i (x_i-\bar{x})^2 \sum_i(y_i-\bar{y})^2}}$ Since there are no ties, the $x$'s and $y$'s both consist of the integers from $1$ to $n$ inclusi
Prove the equivalence of the following two formulas for Spearman correlation $ \rho = \frac{\sum_i(x_i-\bar{x})(y_i-\bar{y})}{\sqrt{\sum_i (x_i-\bar{x})^2 \sum_i(y_i-\bar{y})^2}}$ Since there are no ties, the $x$'s and $y$'s both consist of the integers from $1$ to $n$ inclusive. Hence we can rewrite the denominator: $\frac{\sum_i(x_i-\bar{x})(y_i-\bar{y})}{\sum_i (x_i-\bar{x})^2}$ But the denominator is just a function of $n$: $\sum_i (x_i-\bar{x})^2 = \sum_i x_i^2 - n\bar{x}^2 \\ \quad= \frac{n(n + 1)(2n + 1)}{6} - n(\frac{(n + 1)}{2})^2\\ \quad= n(n + 1)(\frac{(2n + 1)}{6} - \frac{(n + 1)}{4})\\ \quad= n(n + 1)(\frac{(8n + 4-6n-6)}{24})\\ \quad= n(n + 1)(\frac{(n -1)}{12})\\ \quad= \frac{n(n^2 - 1)}{12}$ Now let's look at the numerator: $\sum_i(x_i-\bar{x})(y_i-\bar{y})\\ \quad=\sum_i x_i(y_i-\bar{y})-\sum_i\bar{x}(y_i-\bar{y}) \\ \quad=\sum_i x_i y_i-\bar{y}\sum_i x_i-\bar{x}\sum_iy_i+n\bar{x}\bar{y} \\ \quad=\sum_i x_i y_i-n\bar{x}\bar{y} \\ \quad= \sum_i x_i y_i-n(\frac{n+1}{2})^2 \\ \quad= \sum_i x_i y_i- \frac{n(n+1)}{12}3(n +1) \\ \quad= \frac{n(n+1)}{12}.(-3(n +1))+\sum_i x_i y_i \\ \quad= \frac{n(n+1)}{12}.[(n-1) - (4n+2)] + \sum_i x_i y_i \\ \quad= \frac{n(n+1)(n-1)}{12} - n(n+1)(2n+1)/6 + \sum_i x_i y_i \\ \quad= \frac{n(n+1)(n-1)}{12} -\sum_i x_i^2+ \sum_i x_i y_i \\ \quad= \frac{n(n+1)(n-1)}{12} -\sum_i (x_i^2+ y_i^2)/2+ \sum_i x_i y_i \\ \quad= \frac{n(n+1)(n-1)}{12} - \sum_i (x_i^2 - 2x_i y_i + y_i^2) /2\\ \quad= \frac{n(n+1)(n-1)}{12} - \sum_i(x_i - y_i)^2/2\\ \quad= \frac{n(n^2-1)}{12} - \sum d_i^2/2$ Numerator/Denominator $= \frac{n(n+1)(n-1)/12 - \sum d_i^2/2}{n(n^2 - 1)/12}\\ \quad= {\frac {n(n^2 - 1)/12 -\sum d_i^2/2}{n(n^2 - 1)/12}}\\ \quad= 1- {\frac {6 \sum d_i^2}{n(n^2 - 1)}}\,$. Hence $ \rho = 1- {\frac {6 \sum d_i^2}{n(n^2 - 1)}}.$
Prove the equivalence of the following two formulas for Spearman correlation $ \rho = \frac{\sum_i(x_i-\bar{x})(y_i-\bar{y})}{\sqrt{\sum_i (x_i-\bar{x})^2 \sum_i(y_i-\bar{y})^2}}$ Since there are no ties, the $x$'s and $y$'s both consist of the integers from $1$ to $n$ inclusi
13,693
Prove the equivalence of the following two formulas for Spearman correlation
We see that in the second formula there appears the squared Euclidean distance between the two (ranked) variables: $D^2= \Sigma d_i^2$. The decisive intuition at the start will be how $D^2$ might be related to $r$. It is clearly related via the cosine theorem. If we have the two variables centered, then the cosine in the linked theorem's formula is equal to $r$ (it can be easily proved, we'll take here as granted). And $h^2$ (the squared Euclidean norm) is $N \sigma^2$, sum-of-squares in a centered variable. So the theorem's formula looks like this: $D_{xy}^2 = N\sigma_x^2+N\sigma_y^2-2\sqrt N\sigma_x \sqrt N \sigma_yr$. Please note also another important thing (which might have to be proved separately): When data are ranks, $D^2$ is the same for centered and not centered data. Further, since the two variables were ranked, their variances are the same, $\sigma_x=\sigma_y=\sigma$, so $D^2 = 2N\sigma^2-2N\sigma^2r$. $r= 1-\frac{D^2}{2N\sigma^2}$. Recall that ranked data are from a discrete uniform distribution having variance $(N^2-1)/12$. Substituting it into the formula leaves $r= 1-\frac{6D^2}{N(N^2-1)}$.
Prove the equivalence of the following two formulas for Spearman correlation
We see that in the second formula there appears the squared Euclidean distance between the two (ranked) variables: $D^2= \Sigma d_i^2$. The decisive intuition at the start will be how $D^2$ might be r
Prove the equivalence of the following two formulas for Spearman correlation We see that in the second formula there appears the squared Euclidean distance between the two (ranked) variables: $D^2= \Sigma d_i^2$. The decisive intuition at the start will be how $D^2$ might be related to $r$. It is clearly related via the cosine theorem. If we have the two variables centered, then the cosine in the linked theorem's formula is equal to $r$ (it can be easily proved, we'll take here as granted). And $h^2$ (the squared Euclidean norm) is $N \sigma^2$, sum-of-squares in a centered variable. So the theorem's formula looks like this: $D_{xy}^2 = N\sigma_x^2+N\sigma_y^2-2\sqrt N\sigma_x \sqrt N \sigma_yr$. Please note also another important thing (which might have to be proved separately): When data are ranks, $D^2$ is the same for centered and not centered data. Further, since the two variables were ranked, their variances are the same, $\sigma_x=\sigma_y=\sigma$, so $D^2 = 2N\sigma^2-2N\sigma^2r$. $r= 1-\frac{D^2}{2N\sigma^2}$. Recall that ranked data are from a discrete uniform distribution having variance $(N^2-1)/12$. Substituting it into the formula leaves $r= 1-\frac{6D^2}{N(N^2-1)}$.
Prove the equivalence of the following two formulas for Spearman correlation We see that in the second formula there appears the squared Euclidean distance between the two (ranked) variables: $D^2= \Sigma d_i^2$. The decisive intuition at the start will be how $D^2$ might be r
13,694
Prove the equivalence of the following two formulas for Spearman correlation
The algebra is simpler than it might first appear. IMHO, there is little profit or insight achieved by belaboring the algebraic manipulations. Instead, a truly simple identity shows why squared differences can be used to express (the usual Pearson) correlation coefficient. Applying this to the special case where the data are ranks produces the result. It exhibits the heretofore mysterious coefficient $$\frac{6}{n(n^2-1)}$$ as being half the reciprocal of the variance of the ranks $1, 2, \ldots, n$. (When ties are present, this coefficient acquires a more complicated formula, but will still be one-half the reciprocal of the variance of the ranks assigned to the data.) Once you have seen and understood this, the formula becomes memorable. Comparable (but more complex) formulas that handle ties, show up in nonparametric statistical tests like the Wilcoxon rank sum test, or appear in spatial statistics (like Moran's I, Geary's C, and others) become instantly understandable. Consider any set of paired data $(X_i,Y_i)$ with means $\bar X$ and $\bar Y$ and variances $s_X^2$ and $s_Y^2$. By recentering the variables at their means $\bar X$ and $\bar Y$ and using their standard deviations $s_X$ and $s_Y$ as units of measurement, the data will be re-expressed in terms of the standardized values $$(x_i, y_i) = \left(\frac{X_i-\bar X}{s_X}, \frac{Y_i-\bar Y}{s_Y}\right).$$ By definition, the Pearson correlation coefficient of the original data is the average product of the standardized values, $$\rho = \frac{1}{n}\sum_{i=1}^n x_i y_i.$$ The Polarization Identity relates products to squares. For two numbers $x$ and $y$ it asserts $$xy = \frac{1}{2}\left(x^2 + y^2 - (x-y)^2\right),$$ which is easily verified. Applying this to each term in the sum gives $$\rho = \frac{1}{n}\sum_{i=1}^n \frac{1}{2}\left(x_i^2 + y_i^2 - (x_i-y_i)^2\right).$$ Because the $x_i$ and $y_i$ have been standardized, their average squares are both unity, whence $$\rho = \frac{1}{2}\left(1 + 1 - \frac{1}{n}\sum_{i=1}^n (x_i-y_i)^2\right) = 1 - \frac{1}{2}\left(\frac{1}{n}\sum_{i=1}^n (x_i-y_i)^2\right).\tag{1}$$ The correlation coefficient differs from its maximum possible value, $1$, by one-half the mean squared difference of the standardized data. This is a universal formula for correlation, valid no matter what the original data were (provided only that both variables have nonzero standard deviations). (Faithful readers of this site will recognize this as being closely related to the geometric characterization of covariance described and illustrated at How would you explain covariance to someone who understands only the mean?.) In the special case where the $X_i$ and $Y_i$ are distinct ranks, each is a permutation of the same sequence of numbers $1,2 , \ldots, n$. Thus $\bar X = \bar Y = (n+1)/2$ and, with a tiny bit of calculation we find $$s_X^2 = s_Y^2 = \frac{1}{n} \sum_{i=1}^n (i - (n+1)/2)^2 = \frac{n^2 - 1}{12}$$ (which, happily, is nonzero whenever $n\gt 1$). Therefore $$(x_i - y_i)^2 = \frac{\left((X_i - (n+1)/2)- (Y_i - (n+1)/2)\right)^2}{(n^2-1)/12} = \frac{12(X_i-Y_i)^2}{n^2-1}.$$ This nice simplification occurred because the $X_i$ and $Y_i$ have the same means and standard deviations: the difference of their means therefore disappeared and the product $s_X s_Y$ became $s_X^2$ which involves no square roots. Plugging this into the formula $(1)$ for $\rho$ gives $$\rho = 1 - \frac{6}{n(n^2-1)}\sum_{i=1}^n (X_i - Y_i)^2.$$
Prove the equivalence of the following two formulas for Spearman correlation
The algebra is simpler than it might first appear. IMHO, there is little profit or insight achieved by belaboring the algebraic manipulations. Instead, a truly simple identity shows why squared diffe
Prove the equivalence of the following two formulas for Spearman correlation The algebra is simpler than it might first appear. IMHO, there is little profit or insight achieved by belaboring the algebraic manipulations. Instead, a truly simple identity shows why squared differences can be used to express (the usual Pearson) correlation coefficient. Applying this to the special case where the data are ranks produces the result. It exhibits the heretofore mysterious coefficient $$\frac{6}{n(n^2-1)}$$ as being half the reciprocal of the variance of the ranks $1, 2, \ldots, n$. (When ties are present, this coefficient acquires a more complicated formula, but will still be one-half the reciprocal of the variance of the ranks assigned to the data.) Once you have seen and understood this, the formula becomes memorable. Comparable (but more complex) formulas that handle ties, show up in nonparametric statistical tests like the Wilcoxon rank sum test, or appear in spatial statistics (like Moran's I, Geary's C, and others) become instantly understandable. Consider any set of paired data $(X_i,Y_i)$ with means $\bar X$ and $\bar Y$ and variances $s_X^2$ and $s_Y^2$. By recentering the variables at their means $\bar X$ and $\bar Y$ and using their standard deviations $s_X$ and $s_Y$ as units of measurement, the data will be re-expressed in terms of the standardized values $$(x_i, y_i) = \left(\frac{X_i-\bar X}{s_X}, \frac{Y_i-\bar Y}{s_Y}\right).$$ By definition, the Pearson correlation coefficient of the original data is the average product of the standardized values, $$\rho = \frac{1}{n}\sum_{i=1}^n x_i y_i.$$ The Polarization Identity relates products to squares. For two numbers $x$ and $y$ it asserts $$xy = \frac{1}{2}\left(x^2 + y^2 - (x-y)^2\right),$$ which is easily verified. Applying this to each term in the sum gives $$\rho = \frac{1}{n}\sum_{i=1}^n \frac{1}{2}\left(x_i^2 + y_i^2 - (x_i-y_i)^2\right).$$ Because the $x_i$ and $y_i$ have been standardized, their average squares are both unity, whence $$\rho = \frac{1}{2}\left(1 + 1 - \frac{1}{n}\sum_{i=1}^n (x_i-y_i)^2\right) = 1 - \frac{1}{2}\left(\frac{1}{n}\sum_{i=1}^n (x_i-y_i)^2\right).\tag{1}$$ The correlation coefficient differs from its maximum possible value, $1$, by one-half the mean squared difference of the standardized data. This is a universal formula for correlation, valid no matter what the original data were (provided only that both variables have nonzero standard deviations). (Faithful readers of this site will recognize this as being closely related to the geometric characterization of covariance described and illustrated at How would you explain covariance to someone who understands only the mean?.) In the special case where the $X_i$ and $Y_i$ are distinct ranks, each is a permutation of the same sequence of numbers $1,2 , \ldots, n$. Thus $\bar X = \bar Y = (n+1)/2$ and, with a tiny bit of calculation we find $$s_X^2 = s_Y^2 = \frac{1}{n} \sum_{i=1}^n (i - (n+1)/2)^2 = \frac{n^2 - 1}{12}$$ (which, happily, is nonzero whenever $n\gt 1$). Therefore $$(x_i - y_i)^2 = \frac{\left((X_i - (n+1)/2)- (Y_i - (n+1)/2)\right)^2}{(n^2-1)/12} = \frac{12(X_i-Y_i)^2}{n^2-1}.$$ This nice simplification occurred because the $X_i$ and $Y_i$ have the same means and standard deviations: the difference of their means therefore disappeared and the product $s_X s_Y$ became $s_X^2$ which involves no square roots. Plugging this into the formula $(1)$ for $\rho$ gives $$\rho = 1 - \frac{6}{n(n^2-1)}\sum_{i=1}^n (X_i - Y_i)^2.$$
Prove the equivalence of the following two formulas for Spearman correlation The algebra is simpler than it might first appear. IMHO, there is little profit or insight achieved by belaboring the algebraic manipulations. Instead, a truly simple identity shows why squared diffe
13,695
Prove the equivalence of the following two formulas for Spearman correlation
High school students may see the PMCC and Spearman correlation formulae years before they have the algebra skills to manipulate sigma notation, though they may well know the method of finite differences for deducing the polynomial equation for a sequence. So I have tried to write a "high school proof" for the equivalence: finding the denominator using finite differences, and minimising the algebraic manipulation of sums in the numerator. Depending on the students the proof is presented to, you may prefer this approach to the numerator, but combine it with a more conventional method for the denominator. Denominator, $\sqrt{\sum_i (x_i-\bar{x})^2 \sum_i(y_i-\bar{y})^2}$ With no ties, the data are the ranks $\{1, 2,\dots, n\}$ in some order, so it is easy to show $\bar{x}=\frac{n + 1}{2}$. We can reorder the sum $S_{xx}=\sum_{i=1}^{n} (x_i-\bar{x})^2 = \sum_{k=1}^{n} (k-\frac{n + 1}{2})^2$, though with lower grade students I'd likely write this sum out explicitly rather than in sigma notation. The sum of a quadratic in $k$ will be cubic in $n$, a fact that students familiar with the finite difference method may grasp intuitively: differencing a cubic produces a quadratic, so summing a quadratic produces a cubic. Determining the coefficients of the cubic $f(n)$ is straightforward if students are comfortable manipulating $\Sigma$ notation and know (and remember!) the formulae for $\sum_{k=1}^{n} {k}$ and $\sum_{k=1}^{n} {k^2}$. But they can also be deduced using finite differences, as follows. When $n=1$, the data set is just $\{1\}$, $\bar{x}=1$, so $f(1)=(1-1)^2 = 0$. For $n=2$, the data are $\{1, 2\}$, $\bar{x}=1.5$, so $f(2)=(1-1.5)^2 + (2-1.5)^2 = 0.5$. For $n=3$, the data are $\{1, 2, 3\}$, $\bar{x}=2$, so $f(3)=(1-2)^2 + (2-2)^2 + (3-2)^2 = 2$. These computations are fairly brief, and help reinforce what the notation $\sum_{i=1}^{n} (x_i-\bar{x})^2$ means, and in short order we produce the finite difference table. We can obtain the coefficients of $f(n)$ by cranking out the finite difference method as outlined in the links above. For instance, the constant third differences indicate our polynomial is indeed cubic, with leading coefficient $\frac{0.5}{3!} = \frac{1}{12}$. There are a few tricks to minimise drudgery: a well-known one is to use the common differences to extend the sequence back to $n=0$, as knowing $f(0)$ immediately gives away the constant coefficient. Another is to try extending the sequence to see if $f(n)$ is zero for an integer $n$ - e.g. if the sequence had been positive but decreasing, it would be worth extending rightwards to see if we could "catch a root", as this makes factorisation easier later. In our case, the function seems to hover around low values when $n$ is small, so let's extend even further leftwards. Aha! It turns out we have caught all three roots: $f(-1) = f(0) = f(1) = 0$. So the polynomial has factors of $(n+1)$, $n$, and $(n-1)$. Since it was cubic it must be of the form: $$f(n) = an(n+1)(n-1)$$ We can see that $a$ must be the coefficient of $n^3$ which we already determined to be $\frac{1}{12}$. Alternatively, since $f(2) = 0.5$ we have $a(2)(3)(1)=0.5$ which leads to the same conclusion. Expanding the difference of two squares gives: $$S_{xx} = \frac{n(n^2-1)}{12}$$ Since the same argument applies to $S_{yy}$, the denominator is $\sqrt{S_{xx} S_{yy}} = \sqrt{S_{xx}^2} = S_{xx}$ and we are done. Ignoring my exposition, this method is surprisingly short. If one can spot that the polynomial is cubic, it is necessary only to calculate $S_{xx}$ for the cases $n \in \{1,2,3,4\}$ to establish the third difference is 0.5. Root-hunters need only extend the sequence leftwards to $n=0$ and $n=-1$, by when all three roots are found. It took me a couple of minutes to find $S_{xx}$ this way. Numerator, $\sum_i(x_i-\bar{x})(y_i-\bar{y})$ I note the identity $(b-a)^2 \equiv b^2 - 2ab + a^2$ which can be rearranged to: $$ab \equiv \frac{1}{2}\left(a^2 + b^2 - (b-a)^2 \right)$$ If we let $a = x_i - \bar{x} = x_i - \frac{n+1}{2}$ and $b = y_i - \bar{y} = y_i - \frac{n+1}{2}$ we have the useful result that $b-a = y_i - x_i = d_i$ because the means, being identical, cancel out. That was my intuition for writing the identity in the first place; I wanted to switch from working with the product of the moments to the square of their differences. We now have: $$(x_i - \bar{x})(y_i - \bar{y}) = \frac{1}{2}\left((x_i - \bar{x})^2 + (y_i - \bar{y})^2 - d_i^2 \right)$$ Hopefully even students unsure how to manipulate $\Sigma$ notation can see how summing over the data set yields: $$S_{xy} = \frac{1}{2}\left(S_{xx} + S_{yy} - \sum_{i=1}^n{d_i^2}\right)$$ We have already established, by reordering the sums, that $S_{yy} = S_{xx}$, leaving us with: $$S_{xy}=S_{xx} - \frac{1}{2} \sum_{i=1}^n{d_i^2}$$ The formula for Spearman's correlation coefficient is within our grasp! $$r_S = \frac{S_{xy}}{\sqrt{S_{xx}S_{yy}}} = \frac{S_{xx}-\frac{1}{2}\sum_i{d_i^2}}{S_{xx}} = 1 - \frac{\sum_i{d_i^2}}{2S_{xx}}$$ Substituting the earlier result that $S_{xx}=\frac{1}{12}n(n^2-1)$ will finish the job. $$r_S = 1 - \frac{\sum_i{d_i^2}}{\frac{2}{12}n(n^2-1)} = 1 - \frac{6\sum_i{d_i^2}}{n(n^2-1)}$$
Prove the equivalence of the following two formulas for Spearman correlation
High school students may see the PMCC and Spearman correlation formulae years before they have the algebra skills to manipulate sigma notation, though they may well know the method of finite differenc
Prove the equivalence of the following two formulas for Spearman correlation High school students may see the PMCC and Spearman correlation formulae years before they have the algebra skills to manipulate sigma notation, though they may well know the method of finite differences for deducing the polynomial equation for a sequence. So I have tried to write a "high school proof" for the equivalence: finding the denominator using finite differences, and minimising the algebraic manipulation of sums in the numerator. Depending on the students the proof is presented to, you may prefer this approach to the numerator, but combine it with a more conventional method for the denominator. Denominator, $\sqrt{\sum_i (x_i-\bar{x})^2 \sum_i(y_i-\bar{y})^2}$ With no ties, the data are the ranks $\{1, 2,\dots, n\}$ in some order, so it is easy to show $\bar{x}=\frac{n + 1}{2}$. We can reorder the sum $S_{xx}=\sum_{i=1}^{n} (x_i-\bar{x})^2 = \sum_{k=1}^{n} (k-\frac{n + 1}{2})^2$, though with lower grade students I'd likely write this sum out explicitly rather than in sigma notation. The sum of a quadratic in $k$ will be cubic in $n$, a fact that students familiar with the finite difference method may grasp intuitively: differencing a cubic produces a quadratic, so summing a quadratic produces a cubic. Determining the coefficients of the cubic $f(n)$ is straightforward if students are comfortable manipulating $\Sigma$ notation and know (and remember!) the formulae for $\sum_{k=1}^{n} {k}$ and $\sum_{k=1}^{n} {k^2}$. But they can also be deduced using finite differences, as follows. When $n=1$, the data set is just $\{1\}$, $\bar{x}=1$, so $f(1)=(1-1)^2 = 0$. For $n=2$, the data are $\{1, 2\}$, $\bar{x}=1.5$, so $f(2)=(1-1.5)^2 + (2-1.5)^2 = 0.5$. For $n=3$, the data are $\{1, 2, 3\}$, $\bar{x}=2$, so $f(3)=(1-2)^2 + (2-2)^2 + (3-2)^2 = 2$. These computations are fairly brief, and help reinforce what the notation $\sum_{i=1}^{n} (x_i-\bar{x})^2$ means, and in short order we produce the finite difference table. We can obtain the coefficients of $f(n)$ by cranking out the finite difference method as outlined in the links above. For instance, the constant third differences indicate our polynomial is indeed cubic, with leading coefficient $\frac{0.5}{3!} = \frac{1}{12}$. There are a few tricks to minimise drudgery: a well-known one is to use the common differences to extend the sequence back to $n=0$, as knowing $f(0)$ immediately gives away the constant coefficient. Another is to try extending the sequence to see if $f(n)$ is zero for an integer $n$ - e.g. if the sequence had been positive but decreasing, it would be worth extending rightwards to see if we could "catch a root", as this makes factorisation easier later. In our case, the function seems to hover around low values when $n$ is small, so let's extend even further leftwards. Aha! It turns out we have caught all three roots: $f(-1) = f(0) = f(1) = 0$. So the polynomial has factors of $(n+1)$, $n$, and $(n-1)$. Since it was cubic it must be of the form: $$f(n) = an(n+1)(n-1)$$ We can see that $a$ must be the coefficient of $n^3$ which we already determined to be $\frac{1}{12}$. Alternatively, since $f(2) = 0.5$ we have $a(2)(3)(1)=0.5$ which leads to the same conclusion. Expanding the difference of two squares gives: $$S_{xx} = \frac{n(n^2-1)}{12}$$ Since the same argument applies to $S_{yy}$, the denominator is $\sqrt{S_{xx} S_{yy}} = \sqrt{S_{xx}^2} = S_{xx}$ and we are done. Ignoring my exposition, this method is surprisingly short. If one can spot that the polynomial is cubic, it is necessary only to calculate $S_{xx}$ for the cases $n \in \{1,2,3,4\}$ to establish the third difference is 0.5. Root-hunters need only extend the sequence leftwards to $n=0$ and $n=-1$, by when all three roots are found. It took me a couple of minutes to find $S_{xx}$ this way. Numerator, $\sum_i(x_i-\bar{x})(y_i-\bar{y})$ I note the identity $(b-a)^2 \equiv b^2 - 2ab + a^2$ which can be rearranged to: $$ab \equiv \frac{1}{2}\left(a^2 + b^2 - (b-a)^2 \right)$$ If we let $a = x_i - \bar{x} = x_i - \frac{n+1}{2}$ and $b = y_i - \bar{y} = y_i - \frac{n+1}{2}$ we have the useful result that $b-a = y_i - x_i = d_i$ because the means, being identical, cancel out. That was my intuition for writing the identity in the first place; I wanted to switch from working with the product of the moments to the square of their differences. We now have: $$(x_i - \bar{x})(y_i - \bar{y}) = \frac{1}{2}\left((x_i - \bar{x})^2 + (y_i - \bar{y})^2 - d_i^2 \right)$$ Hopefully even students unsure how to manipulate $\Sigma$ notation can see how summing over the data set yields: $$S_{xy} = \frac{1}{2}\left(S_{xx} + S_{yy} - \sum_{i=1}^n{d_i^2}\right)$$ We have already established, by reordering the sums, that $S_{yy} = S_{xx}$, leaving us with: $$S_{xy}=S_{xx} - \frac{1}{2} \sum_{i=1}^n{d_i^2}$$ The formula for Spearman's correlation coefficient is within our grasp! $$r_S = \frac{S_{xy}}{\sqrt{S_{xx}S_{yy}}} = \frac{S_{xx}-\frac{1}{2}\sum_i{d_i^2}}{S_{xx}} = 1 - \frac{\sum_i{d_i^2}}{2S_{xx}}$$ Substituting the earlier result that $S_{xx}=\frac{1}{12}n(n^2-1)$ will finish the job. $$r_S = 1 - \frac{\sum_i{d_i^2}}{\frac{2}{12}n(n^2-1)} = 1 - \frac{6\sum_i{d_i^2}}{n(n^2-1)}$$
Prove the equivalence of the following two formulas for Spearman correlation High school students may see the PMCC and Spearman correlation formulae years before they have the algebra skills to manipulate sigma notation, though they may well know the method of finite differenc
13,696
What formula is used for standard deviation in R?
As pointed out by @Gschneider, it computes the sample standard deviation $$\sqrt{\frac{\sum\limits_{i=1}^{n} (x_i - \bar{x})^2}{n-1}}$$ which you can easily check as follows: > #generate a random vector > x <- rnorm(n=5, mean=3, sd=1.5) > n <- length(x) > > #sd in R > sd1 <- sd(x) > > #self-written sd > sd2 <- sqrt(sum((x - mean(x))^2) / (n - 1)) > > #comparison > c(sd1, sd2) #:-) [1] 0.6054196 0.6054196
What formula is used for standard deviation in R?
As pointed out by @Gschneider, it computes the sample standard deviation $$\sqrt{\frac{\sum\limits_{i=1}^{n} (x_i - \bar{x})^2}{n-1}}$$ which you can easily check as follows: > #generate a random vect
What formula is used for standard deviation in R? As pointed out by @Gschneider, it computes the sample standard deviation $$\sqrt{\frac{\sum\limits_{i=1}^{n} (x_i - \bar{x})^2}{n-1}}$$ which you can easily check as follows: > #generate a random vector > x <- rnorm(n=5, mean=3, sd=1.5) > n <- length(x) > > #sd in R > sd1 <- sd(x) > > #self-written sd > sd2 <- sqrt(sum((x - mean(x))^2) / (n - 1)) > > #comparison > c(sd1, sd2) #:-) [1] 0.6054196 0.6054196
What formula is used for standard deviation in R? As pointed out by @Gschneider, it computes the sample standard deviation $$\sqrt{\frac{\sum\limits_{i=1}^{n} (x_i - \bar{x})^2}{n-1}}$$ which you can easily check as follows: > #generate a random vect
13,697
What formula is used for standard deviation in R?
Yes. Technically, it computes the sample variance, and then takes the square root: > sd function (x, na.rm = FALSE) { if (is.matrix(x)) apply(x, 2, sd, na.rm = na.rm) else if (is.vector(x)) sqrt(var(x, na.rm = na.rm)) else if (is.data.frame(x)) sapply(x, sd, na.rm = na.rm) else sqrt(var(as.vector(x), na.rm = na.rm)) }
What formula is used for standard deviation in R?
Yes. Technically, it computes the sample variance, and then takes the square root: > sd function (x, na.rm = FALSE) { if (is.matrix(x)) apply(x, 2, sd, na.rm = na.rm) else if (is.vector(x))
What formula is used for standard deviation in R? Yes. Technically, it computes the sample variance, and then takes the square root: > sd function (x, na.rm = FALSE) { if (is.matrix(x)) apply(x, 2, sd, na.rm = na.rm) else if (is.vector(x)) sqrt(var(x, na.rm = na.rm)) else if (is.data.frame(x)) sapply(x, sd, na.rm = na.rm) else sqrt(var(as.vector(x), na.rm = na.rm)) }
What formula is used for standard deviation in R? Yes. Technically, it computes the sample variance, and then takes the square root: > sd function (x, na.rm = FALSE) { if (is.matrix(x)) apply(x, 2, sd, na.rm = na.rm) else if (is.vector(x))
13,698
Visualizing Likert responses using R or SPSS
If you really want to use stacked barcharts with such a large number of items, here are two possible solutions. Using irutils I came across this package some months ago. As of commit 0573195c07 on Github, the code won't work with a grouping= argument. Let's go for Friday's debugging session. Start by downloading a zipped version from Github. You'll need to hack the R/likert.R file, specifically the likert and plot.likert functions. First, in likert, cast() is used but the reshape package is never loaded (although there's an import(reshape) instruction in the NAMESPACE file). You can load this yourself beforehand. Second, there's an incorrect instruction to fetch items labels, where a i is dangling around line 175. This has to be fixed as well, e.g. by replacing all occurrences of likert$items[,i] with likert$items[,1]. Then you can install the package the way you are used to do on your machine. On my Mac, I did % tar -czf irutils.tar.gz jbryer-irutils-0573195 % R CMD INSTALL irutils.tar.gz Then, with R, try the following: library(irutils) library(reshape) # Simulate some data (82 respondents x 66 items) resp <- data.frame(replicate(66, sample(1:5, 82, replace=TRUE))) resp <- data.frame(lapply(resp, factor, ordered=TRUE, levels=1:5, labels=c("Strongly disagree","Disagree", "Neutral","Agree","Strongly Agree"))) grp <- gl(2, 82/2, labels=LETTERS[1:2]) # say equal group size for simplicity # Summarize responses by group resp.likert <- likert(resp, grouping=grp) That should just work, but the visual rendering will be awful because of the high number of items. It works without grouping (e.g., plot(likert(resp))), though. I would thus suggest to reduce your dataset to smaller subsets of items. E.g., using 12 items, plot(likert(resp[,1:12], grouping=grp)) I get a 'readable' stacked barchart. You can probably process them afterwards. (Those are ggplot2 objects, but you won't be able to arrange them on a single page with gridExtra::grid.arrange() because of readability issue!) Alternative solution I would like to draw your attention on another package, HH, that allows to plot Likert scales as diverging stacked barcharts. We could reuse the above code as shown below: resp.likert <- likert(resp) detach(package:irutils) library(HH) plot.likert(resp.likert$results[,-6]*82/100, main="") but that will complicate things a bit because we need to convert frequencies to counts, subset the likert object produced by irutils, detach package, etc. So let's start again with fresh (counts) statistics: plot.likert(t(apply(resp, 2, table)), main="", as.percent=TRUE, rightAxisLabels=NULL, rightAxis=NULL, ylab.right="", positive.order=TRUE) To use a grouping variable, you'll need to work with an array of numerical values. # compute responses frequencies separately by grp resp.array <- array(NA, dim=c(66, 5, 2)) resp.array[,,1] <- t(apply(subset(resp, grp=="A"), 2, table)) resp.array[,,2] <- t(apply(subset(resp, grp=="B"), 2, table)) dimnames(resp.array) <- list(NULL, NULL, group=levels(grp)) plot.likert(resp.array, layout=c(2,1), main="") This will produce two separate panels, but it fits on a single page. Edit 2016-6-3 As of now likert is available as separate package. You do not need reshape library or detach both irutils and reshape
Visualizing Likert responses using R or SPSS
If you really want to use stacked barcharts with such a large number of items, here are two possible solutions. Using irutils I came across this package some months ago. As of commit 0573195c07 on Git
Visualizing Likert responses using R or SPSS If you really want to use stacked barcharts with such a large number of items, here are two possible solutions. Using irutils I came across this package some months ago. As of commit 0573195c07 on Github, the code won't work with a grouping= argument. Let's go for Friday's debugging session. Start by downloading a zipped version from Github. You'll need to hack the R/likert.R file, specifically the likert and plot.likert functions. First, in likert, cast() is used but the reshape package is never loaded (although there's an import(reshape) instruction in the NAMESPACE file). You can load this yourself beforehand. Second, there's an incorrect instruction to fetch items labels, where a i is dangling around line 175. This has to be fixed as well, e.g. by replacing all occurrences of likert$items[,i] with likert$items[,1]. Then you can install the package the way you are used to do on your machine. On my Mac, I did % tar -czf irutils.tar.gz jbryer-irutils-0573195 % R CMD INSTALL irutils.tar.gz Then, with R, try the following: library(irutils) library(reshape) # Simulate some data (82 respondents x 66 items) resp <- data.frame(replicate(66, sample(1:5, 82, replace=TRUE))) resp <- data.frame(lapply(resp, factor, ordered=TRUE, levels=1:5, labels=c("Strongly disagree","Disagree", "Neutral","Agree","Strongly Agree"))) grp <- gl(2, 82/2, labels=LETTERS[1:2]) # say equal group size for simplicity # Summarize responses by group resp.likert <- likert(resp, grouping=grp) That should just work, but the visual rendering will be awful because of the high number of items. It works without grouping (e.g., plot(likert(resp))), though. I would thus suggest to reduce your dataset to smaller subsets of items. E.g., using 12 items, plot(likert(resp[,1:12], grouping=grp)) I get a 'readable' stacked barchart. You can probably process them afterwards. (Those are ggplot2 objects, but you won't be able to arrange them on a single page with gridExtra::grid.arrange() because of readability issue!) Alternative solution I would like to draw your attention on another package, HH, that allows to plot Likert scales as diverging stacked barcharts. We could reuse the above code as shown below: resp.likert <- likert(resp) detach(package:irutils) library(HH) plot.likert(resp.likert$results[,-6]*82/100, main="") but that will complicate things a bit because we need to convert frequencies to counts, subset the likert object produced by irutils, detach package, etc. So let's start again with fresh (counts) statistics: plot.likert(t(apply(resp, 2, table)), main="", as.percent=TRUE, rightAxisLabels=NULL, rightAxis=NULL, ylab.right="", positive.order=TRUE) To use a grouping variable, you'll need to work with an array of numerical values. # compute responses frequencies separately by grp resp.array <- array(NA, dim=c(66, 5, 2)) resp.array[,,1] <- t(apply(subset(resp, grp=="A"), 2, table)) resp.array[,,2] <- t(apply(subset(resp, grp=="B"), 2, table)) dimnames(resp.array) <- list(NULL, NULL, group=levels(grp)) plot.likert(resp.array, layout=c(2,1), main="") This will produce two separate panels, but it fits on a single page. Edit 2016-6-3 As of now likert is available as separate package. You do not need reshape library or detach both irutils and reshape
Visualizing Likert responses using R or SPSS If you really want to use stacked barcharts with such a large number of items, here are two possible solutions. Using irutils I came across this package some months ago. As of commit 0573195c07 on Git
13,699
Visualizing Likert responses using R or SPSS
I started to write a blog post about recreating many of the charts in the post you mention (Visualizing Likert Item Response Data) in SPSS so I suppose this will be good motivation for finishing it. As Michelle notes, the fact that you have groups is a new twist compared to the previous questions. And while groups can be taken into account using the stacked bar graphs, IMO they are much more easily incorporated into the dot plot example in chl's original post. I've included the SPSS code to generate this at the end of the post, essentially it entails knowing how to reshape your data in the appropriate format to generate said plot (annotation provided in the code to hopefully clear some of that up). Here I used some redundant encoding (color and shape) to distinguish points coming from the two groups, and made the points semi-transparent so you can tell when they overlap (another option would be to dodge the points when they overlap). Why is this better than the stacked bar charts? The stacked bar charts encode information in the length of the bars. When you try to make comparisons between lengths of bars, either within the same axis category or between panels, the stacking precludes the bars from having a common scale. For an example, I have provided an image in Figure 2 in which two bars are placed in a plot in which their beginning location is different, which bar is the wider one (along the horizontal axis)? Compare that to the plot in Figure 3 below, in which the two bars (of the same length) are plotted from the same beginning point. I've intentionally made the task difficult, but you should be able to tell which one is longer. Stacked bar charts are essentially doing what is displayed in Figure 2. Dot plots can be considered more similar to what is displayed in Figure 3, just replace the bar with a dot at the end of the bar. I'm not going to say don't generate any particular chart for exploratory data analysis, but I would suggest avoiding the stacked bar charts when using so many categories. The dot plots aren't a panacea either, but I believe making comparisons between panels with the dot plots is much easier than with the stacked bar charts. Consider some of the advice I provide on my blog post here for tables as well, try to order and/or seperate the charts into meaningful categories, and make sure that items you would want to look at in tandem are closer together in the charts. While some of the plotting methods may scale well to many questions (the categorical heat maps are an example), without sorting it will still be difficult to identify any meaningul patterns (besides obvious outliers). A note on using SPSS. SPSS can generate any of the previous linked to charts, although it frequently entails knowing how to shape your data (the same is true of ggplot, but people have been developing packages to essentially do the reshaping for you). To understand how SPSS's GPL language works better I would actually suggest reading Hadley Wickham's book on ggplot2 in the Use R! series. It lays out the grammar necessary to understand how SPSS's GPL work, and is a much easier read than the GPL programming manual that comes with SPSS! If you have any questions about generating specific charts in SPSS it would be best to ask one question for one chart (I've talked enough here as is!) I will update this answer with a link though if I ever get around to making my blog post replicating some of the other charts. For a proof of concept of the heat maps or fluctuation plots you can see another blog post of mine, Some example Corrgrams in SPSS. SPSS code used to generate Figure 1 ****************************************. input program. */making fake data similar to yours. loop #i = 1 to 82. compute case_num = #i. end case. end loop. end file. end input program. execute. dataset name likert. *making number in groups. compute group = 1. if case_num > 43 group = 2. value labels group 1 'A' 2 'B'. *this makes 5 variables with categories between 0 and 5 (similar to Likert data with 5 categories plus missing data). vector V(5). do repeat V = V1 to V5. compute V = TRUNC(RV.UNIFORM(0,6)). end repeat. execute. value labels V1 to V5 0 'missing' 1 'very disagree' 2 'disagree' 3 'neutral' 4 'agree' 5 'very agree'. formats case_num group V1 to V5 (F1.0). *****************************************. *Because I want to panel by variable, I am going to reshape my data so all of the "V" variables are in one column (stacking them in long format). varstocases /make V from V1 to V5 /index orig (V). *I am going to plot the points, so I aggregate that information (you could aggregate total counts as well if you wanted to plot percentages. DATASET DECLARE agg_lik. AGGREGATE /OUTFILE='agg_lik' /BREAK=orig V group /count_lik=N. dataset activate agg_lik. *now the fun part, generating the chart. *The X axis, dim(1) is the count of likert responses within each category for each original question. *The Y axis, dim(2) is the likert responses, and the third axis is used to panel the observations by the original questions, dim(4) here beacause I want to panel by rows instead of columns. DATASET ACTIVATE agg_lik. * Chart Builder. GGRAPH /GRAPHDATASET NAME="graphdataset" VARIABLES=count_lik V group orig MISSING=LISTWISE REPORTMISSING=NO /GRAPHSPEC SOURCE=INLINE. BEGIN GPL SOURCE: s=userSource(id("graphdataset")) DATA: count_lik=col(source(s), name("count_lik")) DATA: V=col(source(s), name("V"), unit.category()) DATA: group=col(source(s), name("group"), unit.category()) DATA: orig=col(source(s), name("orig"), unit.category()) GUIDE: axis(dim(1), label("Count")) GUIDE: axis(dim(2)) GUIDE: axis(dim(4)) GUIDE: legend(aesthetic(aesthetic.color.exterior), label("group")) GUIDE: text.title(label("Figure 1: Dot Plots by Group")) SCALE: cat(aesthetic(aesthetic.color.exterior), include("1", "2")) SCALE: cat(aesthetic(aesthetic.shape), map(("1", shape.circle), ("2", shape.square))) ELEMENT: point(position(count_lik*V*1*orig), color.exterior(group), color.interior(group), transparency.interior(transparency."0.7"), size(size."8px"), shape(group)) END GPL. *The "SCALE: cat" statements map different shapes which I use to assign to the two groups in the plot, and I plot the interior of the points as partially transparent. *With some post hoc editing you should be able to make the chart look like what I have in the stats post. ****************************************.
Visualizing Likert responses using R or SPSS
I started to write a blog post about recreating many of the charts in the post you mention (Visualizing Likert Item Response Data) in SPSS so I suppose this will be good motivation for finishing it. A
Visualizing Likert responses using R or SPSS I started to write a blog post about recreating many of the charts in the post you mention (Visualizing Likert Item Response Data) in SPSS so I suppose this will be good motivation for finishing it. As Michelle notes, the fact that you have groups is a new twist compared to the previous questions. And while groups can be taken into account using the stacked bar graphs, IMO they are much more easily incorporated into the dot plot example in chl's original post. I've included the SPSS code to generate this at the end of the post, essentially it entails knowing how to reshape your data in the appropriate format to generate said plot (annotation provided in the code to hopefully clear some of that up). Here I used some redundant encoding (color and shape) to distinguish points coming from the two groups, and made the points semi-transparent so you can tell when they overlap (another option would be to dodge the points when they overlap). Why is this better than the stacked bar charts? The stacked bar charts encode information in the length of the bars. When you try to make comparisons between lengths of bars, either within the same axis category or between panels, the stacking precludes the bars from having a common scale. For an example, I have provided an image in Figure 2 in which two bars are placed in a plot in which their beginning location is different, which bar is the wider one (along the horizontal axis)? Compare that to the plot in Figure 3 below, in which the two bars (of the same length) are plotted from the same beginning point. I've intentionally made the task difficult, but you should be able to tell which one is longer. Stacked bar charts are essentially doing what is displayed in Figure 2. Dot plots can be considered more similar to what is displayed in Figure 3, just replace the bar with a dot at the end of the bar. I'm not going to say don't generate any particular chart for exploratory data analysis, but I would suggest avoiding the stacked bar charts when using so many categories. The dot plots aren't a panacea either, but I believe making comparisons between panels with the dot plots is much easier than with the stacked bar charts. Consider some of the advice I provide on my blog post here for tables as well, try to order and/or seperate the charts into meaningful categories, and make sure that items you would want to look at in tandem are closer together in the charts. While some of the plotting methods may scale well to many questions (the categorical heat maps are an example), without sorting it will still be difficult to identify any meaningul patterns (besides obvious outliers). A note on using SPSS. SPSS can generate any of the previous linked to charts, although it frequently entails knowing how to shape your data (the same is true of ggplot, but people have been developing packages to essentially do the reshaping for you). To understand how SPSS's GPL language works better I would actually suggest reading Hadley Wickham's book on ggplot2 in the Use R! series. It lays out the grammar necessary to understand how SPSS's GPL work, and is a much easier read than the GPL programming manual that comes with SPSS! If you have any questions about generating specific charts in SPSS it would be best to ask one question for one chart (I've talked enough here as is!) I will update this answer with a link though if I ever get around to making my blog post replicating some of the other charts. For a proof of concept of the heat maps or fluctuation plots you can see another blog post of mine, Some example Corrgrams in SPSS. SPSS code used to generate Figure 1 ****************************************. input program. */making fake data similar to yours. loop #i = 1 to 82. compute case_num = #i. end case. end loop. end file. end input program. execute. dataset name likert. *making number in groups. compute group = 1. if case_num > 43 group = 2. value labels group 1 'A' 2 'B'. *this makes 5 variables with categories between 0 and 5 (similar to Likert data with 5 categories plus missing data). vector V(5). do repeat V = V1 to V5. compute V = TRUNC(RV.UNIFORM(0,6)). end repeat. execute. value labels V1 to V5 0 'missing' 1 'very disagree' 2 'disagree' 3 'neutral' 4 'agree' 5 'very agree'. formats case_num group V1 to V5 (F1.0). *****************************************. *Because I want to panel by variable, I am going to reshape my data so all of the "V" variables are in one column (stacking them in long format). varstocases /make V from V1 to V5 /index orig (V). *I am going to plot the points, so I aggregate that information (you could aggregate total counts as well if you wanted to plot percentages. DATASET DECLARE agg_lik. AGGREGATE /OUTFILE='agg_lik' /BREAK=orig V group /count_lik=N. dataset activate agg_lik. *now the fun part, generating the chart. *The X axis, dim(1) is the count of likert responses within each category for each original question. *The Y axis, dim(2) is the likert responses, and the third axis is used to panel the observations by the original questions, dim(4) here beacause I want to panel by rows instead of columns. DATASET ACTIVATE agg_lik. * Chart Builder. GGRAPH /GRAPHDATASET NAME="graphdataset" VARIABLES=count_lik V group orig MISSING=LISTWISE REPORTMISSING=NO /GRAPHSPEC SOURCE=INLINE. BEGIN GPL SOURCE: s=userSource(id("graphdataset")) DATA: count_lik=col(source(s), name("count_lik")) DATA: V=col(source(s), name("V"), unit.category()) DATA: group=col(source(s), name("group"), unit.category()) DATA: orig=col(source(s), name("orig"), unit.category()) GUIDE: axis(dim(1), label("Count")) GUIDE: axis(dim(2)) GUIDE: axis(dim(4)) GUIDE: legend(aesthetic(aesthetic.color.exterior), label("group")) GUIDE: text.title(label("Figure 1: Dot Plots by Group")) SCALE: cat(aesthetic(aesthetic.color.exterior), include("1", "2")) SCALE: cat(aesthetic(aesthetic.shape), map(("1", shape.circle), ("2", shape.square))) ELEMENT: point(position(count_lik*V*1*orig), color.exterior(group), color.interior(group), transparency.interior(transparency."0.7"), size(size."8px"), shape(group)) END GPL. *The "SCALE: cat" statements map different shapes which I use to assign to the two groups in the plot, and I plot the interior of the points as partially transparent. *With some post hoc editing you should be able to make the chart look like what I have in the stats post. ****************************************.
Visualizing Likert responses using R or SPSS I started to write a blog post about recreating many of the charts in the post you mention (Visualizing Likert Item Response Data) in SPSS so I suppose this will be good motivation for finishing it. A
13,700
Visualizing Likert responses using R or SPSS
Oh well, I came up with the code before you clarified. Should have waited but thought I should post it up so that anyone who comes here can reuse this code. Dummy data for visualizing # Response for http://stats.stackexchange.com/questions/25109/visualizing-likert-responses-using-r-or-spss # Load libraries library(reshape2) library(ggplot2) # Functions CreateRowsColumns <- function(noofrows, noofcolumns) { createcolumnnames <- paste("Q", 1:noofcolumns, sep ="") df <- sapply(1:noofcolumns, function(i) assign(createcolumnnames[i], matrix(sample(1:5, noofrows, replace = TRUE)))) df <- sapply(1:noofcolumns, function(i) df[,i] <- as.factor(df[,i])) colnames(df) <- createcolumnnames return(df)} # Generate dummy dataframe LikertResponse <- CreateRowsColumns(82, 65) LikertResponse[LikertResponse == 1] <- "Strongly agree" LikertResponse[LikertResponse == 2] <- "Agree" LikertResponse[LikertResponse == 3] <- "Neutral" LikertResponse[LikertResponse == 4] <- "Disagree" LikertResponse[LikertResponse == 5] <- "Strongly disagree" Code for heatmap # Prepare data LikertResponseSummary <- do.call(rbind, lapply(data.frame(LikertResponse), table)) LikertResponseSummaryPercent <- prop.table(LikertResponseSummary,1) # Melt data LikertResponseSummary <- melt(LikertResponseSummary) LikertResponseSummaryPercent <- melt(LikertResponseSummaryPercent) # Merge counts with proportions LikertResponsePlotData <- merge(LikertResponseSummary, LikertResponseSummaryPercent, by = c("Var1","Var2")) # Plot heatmap! # Use the "geom_tile(aes(fill = value.y*100), colour = "white")" to control how you want the heatmap colours to map to. ggplot(LikertResponsePlotData, aes(x = Var2, y = Var1)) + geom_tile(aes(fill = value.y*100), colour = "white") + scale_fill_gradient(low = "white", high = "steelblue", name = "% of Respondents") + scale_x_discrete(name = 'Response') + scale_y_discrete(name = 'Questions') + geom_text(aes(label = paste(format(round(value.y*100), width = 3), '% (', format(round(value.x), width = 3), ')')), size = 3) This is basically a template to the visualising Likert items on a heatmap from Jason Bryon's website.
Visualizing Likert responses using R or SPSS
Oh well, I came up with the code before you clarified. Should have waited but thought I should post it up so that anyone who comes here can reuse this code. Dummy data for visualizing # Response for h
Visualizing Likert responses using R or SPSS Oh well, I came up with the code before you clarified. Should have waited but thought I should post it up so that anyone who comes here can reuse this code. Dummy data for visualizing # Response for http://stats.stackexchange.com/questions/25109/visualizing-likert-responses-using-r-or-spss # Load libraries library(reshape2) library(ggplot2) # Functions CreateRowsColumns <- function(noofrows, noofcolumns) { createcolumnnames <- paste("Q", 1:noofcolumns, sep ="") df <- sapply(1:noofcolumns, function(i) assign(createcolumnnames[i], matrix(sample(1:5, noofrows, replace = TRUE)))) df <- sapply(1:noofcolumns, function(i) df[,i] <- as.factor(df[,i])) colnames(df) <- createcolumnnames return(df)} # Generate dummy dataframe LikertResponse <- CreateRowsColumns(82, 65) LikertResponse[LikertResponse == 1] <- "Strongly agree" LikertResponse[LikertResponse == 2] <- "Agree" LikertResponse[LikertResponse == 3] <- "Neutral" LikertResponse[LikertResponse == 4] <- "Disagree" LikertResponse[LikertResponse == 5] <- "Strongly disagree" Code for heatmap # Prepare data LikertResponseSummary <- do.call(rbind, lapply(data.frame(LikertResponse), table)) LikertResponseSummaryPercent <- prop.table(LikertResponseSummary,1) # Melt data LikertResponseSummary <- melt(LikertResponseSummary) LikertResponseSummaryPercent <- melt(LikertResponseSummaryPercent) # Merge counts with proportions LikertResponsePlotData <- merge(LikertResponseSummary, LikertResponseSummaryPercent, by = c("Var1","Var2")) # Plot heatmap! # Use the "geom_tile(aes(fill = value.y*100), colour = "white")" to control how you want the heatmap colours to map to. ggplot(LikertResponsePlotData, aes(x = Var2, y = Var1)) + geom_tile(aes(fill = value.y*100), colour = "white") + scale_fill_gradient(low = "white", high = "steelblue", name = "% of Respondents") + scale_x_discrete(name = 'Response') + scale_y_discrete(name = 'Questions') + geom_text(aes(label = paste(format(round(value.y*100), width = 3), '% (', format(round(value.x), width = 3), ')')), size = 3) This is basically a template to the visualising Likert items on a heatmap from Jason Bryon's website.
Visualizing Likert responses using R or SPSS Oh well, I came up with the code before you clarified. Should have waited but thought I should post it up so that anyone who comes here can reuse this code. Dummy data for visualizing # Response for h