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 |
|---|---|---|---|---|---|---|
27,001 | In an experiment, why can you select your own alpha level for significance testing? | The premise of your question is not quite right. Alpha is the fraction of the time you'll have a false positive only if:
The null hypothesis is assumed to be true. Usually, this means assuming (for the sake of argument while interpreting alpha or p) that the two populations have the same mean (or proportion, or survival curves...).
All the assumptions of the analysis are correct. Often this means assuming the population follows a normal distribution and the deviation of each value from the mean is due to independent random reasons.
Your overall question needs clarifying. Alpha is a cutoff for making a conclusion, so it has to be set to a value. If not chosen by the experimenter, then by who?
Addendum Feb. 25, 2023: Maybe this will help. If you choose a large value for alpha, you'll have a larger chance of obtaining a false positive but a smaller chance of a false negative. If you choose a small value for alpha, you'll have a smaller chance of obtaining a false positive but a larger chance of false negative. It's a tradeoff. That is why there is a choice. | In an experiment, why can you select your own alpha level for significance testing? | The premise of your question is not quite right. Alpha is the fraction of the time you'll have a false positive only if:
The null hypothesis is assumed to be true. Usually, this means assuming (for t | In an experiment, why can you select your own alpha level for significance testing?
The premise of your question is not quite right. Alpha is the fraction of the time you'll have a false positive only if:
The null hypothesis is assumed to be true. Usually, this means assuming (for the sake of argument while interpreting alpha or p) that the two populations have the same mean (or proportion, or survival curves...).
All the assumptions of the analysis are correct. Often this means assuming the population follows a normal distribution and the deviation of each value from the mean is due to independent random reasons.
Your overall question needs clarifying. Alpha is a cutoff for making a conclusion, so it has to be set to a value. If not chosen by the experimenter, then by who?
Addendum Feb. 25, 2023: Maybe this will help. If you choose a large value for alpha, you'll have a larger chance of obtaining a false positive but a smaller chance of a false negative. If you choose a small value for alpha, you'll have a smaller chance of obtaining a false positive but a larger chance of false negative. It's a tradeoff. That is why there is a choice. | In an experiment, why can you select your own alpha level for significance testing?
The premise of your question is not quite right. Alpha is the fraction of the time you'll have a false positive only if:
The null hypothesis is assumed to be true. Usually, this means assuming (for t |
27,002 | In an experiment, why can you select your own alpha level for significance testing? | UNDER THE NULL HYPOTHESIS, THE P-VALUE HAS A UNIFORM(0,1) DISTRIBUTION.
That's really all there is to it, but I believe that a simulation and a picture can help unpack that sentence.
UNDER THE NULL HYPOTHESIS means when the null hypothesis is totally, 100% true, along with all other assumptions (such as normality for a t-test). Consequently, what ever p-values we simulate should happen for tests of true null hypothesis. In this case, we will use a one-sample t-test to test if the mean is zero, simulating independent draws from a $N(0,1)$ distribution. Thus, all standard assumptions of the t-test are satisfied: independence, equal variance, and normality. The simulation repeats this $10000$ times to get an entire distribution of p-values.
library(ggplot2)
set.seed(2023)
N <- 1000
R <- 10000
p <- rep(NA, R)
for (i in 1:R){
x <- rnorm(N) # Simulate the distribution
p[i] <- t.test(x, mu = 0)$p.value # Calculate the t-test p-value
}
d0 <- data.frame(
p_value = p,
CDF = ecdf(p)(p),
Distribution = "p-value Distribution"
)
d1 <- data.frame(
p_value = p,
CDF = qunif(p, 0, 1),
Distribution = "U(0,1) Distribution"
)
d <- rbind(d0, d1)
ggplot(d, aes(x = p_value, y = CDF, col = Distribution)) +
geom_line() +
theme(legend.position="bottom")
As you can see from the lines overlapping so nicely, when the null hypothesis is true and the other test assumptions are met, the p-values generated by a t-test do generate a $U(0,1)$ distribution.
What this means is that, if you reject the null hypothesis when $p\le0.05$, you will reject in $5\%$ of these cases where the null hypothesis and other test assumptions are true, since $P(p\le0.05)=0.05$. If you reject the null hypothesis when $p=0.5$, as is suggested in the OP, you will reject in $50\%$ of these cases where the null hypothesis and other test assumptions are true, since $P(p\le0.5)=0.5$.
In general, for a $U(0,1)$ distribution, if $0\le\alpha\le 1$, $P(p\le\alpha)=\alpha$. That's really the defining characteristic of the $U(0,1)$ distribution. In that sense, by picking the $\alpha$-level for the test, you pick your tolerance for rejecting when the null hypothesis is true.
However, note that rejecting in this case is a mistake. By the simulation, the null hypothesis is correct, and rejecting the null hypothesis is a so-called type I error. Errors are bad, and we like to minimize them. Consequently, it is typical to set $\alpha$ low, often around $0.05$ or lower, in order to keep from having a bunch of false positives.
You can take it it to the extreme to see why we don't want a high $\alpha$-level: if you set $\alpha = 1$, your test always rejects. Is a rejection by a statistical hypothesis test that always rejects, no matter what, any kind of evidence of a discovery? I say it is not. That is equivalent to the function below that makes absolutely no use of the data.
worthless.test <- function(input_data){
print("Reject the null hypothesis!")
} | In an experiment, why can you select your own alpha level for significance testing? | UNDER THE NULL HYPOTHESIS, THE P-VALUE HAS A UNIFORM(0,1) DISTRIBUTION.
That's really all there is to it, but I believe that a simulation and a picture can help unpack that sentence.
UNDER THE NULL HY | In an experiment, why can you select your own alpha level for significance testing?
UNDER THE NULL HYPOTHESIS, THE P-VALUE HAS A UNIFORM(0,1) DISTRIBUTION.
That's really all there is to it, but I believe that a simulation and a picture can help unpack that sentence.
UNDER THE NULL HYPOTHESIS means when the null hypothesis is totally, 100% true, along with all other assumptions (such as normality for a t-test). Consequently, what ever p-values we simulate should happen for tests of true null hypothesis. In this case, we will use a one-sample t-test to test if the mean is zero, simulating independent draws from a $N(0,1)$ distribution. Thus, all standard assumptions of the t-test are satisfied: independence, equal variance, and normality. The simulation repeats this $10000$ times to get an entire distribution of p-values.
library(ggplot2)
set.seed(2023)
N <- 1000
R <- 10000
p <- rep(NA, R)
for (i in 1:R){
x <- rnorm(N) # Simulate the distribution
p[i] <- t.test(x, mu = 0)$p.value # Calculate the t-test p-value
}
d0 <- data.frame(
p_value = p,
CDF = ecdf(p)(p),
Distribution = "p-value Distribution"
)
d1 <- data.frame(
p_value = p,
CDF = qunif(p, 0, 1),
Distribution = "U(0,1) Distribution"
)
d <- rbind(d0, d1)
ggplot(d, aes(x = p_value, y = CDF, col = Distribution)) +
geom_line() +
theme(legend.position="bottom")
As you can see from the lines overlapping so nicely, when the null hypothesis is true and the other test assumptions are met, the p-values generated by a t-test do generate a $U(0,1)$ distribution.
What this means is that, if you reject the null hypothesis when $p\le0.05$, you will reject in $5\%$ of these cases where the null hypothesis and other test assumptions are true, since $P(p\le0.05)=0.05$. If you reject the null hypothesis when $p=0.5$, as is suggested in the OP, you will reject in $50\%$ of these cases where the null hypothesis and other test assumptions are true, since $P(p\le0.5)=0.5$.
In general, for a $U(0,1)$ distribution, if $0\le\alpha\le 1$, $P(p\le\alpha)=\alpha$. That's really the defining characteristic of the $U(0,1)$ distribution. In that sense, by picking the $\alpha$-level for the test, you pick your tolerance for rejecting when the null hypothesis is true.
However, note that rejecting in this case is a mistake. By the simulation, the null hypothesis is correct, and rejecting the null hypothesis is a so-called type I error. Errors are bad, and we like to minimize them. Consequently, it is typical to set $\alpha$ low, often around $0.05$ or lower, in order to keep from having a bunch of false positives.
You can take it it to the extreme to see why we don't want a high $\alpha$-level: if you set $\alpha = 1$, your test always rejects. Is a rejection by a statistical hypothesis test that always rejects, no matter what, any kind of evidence of a discovery? I say it is not. That is equivalent to the function below that makes absolutely no use of the data.
worthless.test <- function(input_data){
print("Reject the null hypothesis!")
} | In an experiment, why can you select your own alpha level for significance testing?
UNDER THE NULL HYPOTHESIS, THE P-VALUE HAS A UNIFORM(0,1) DISTRIBUTION.
That's really all there is to it, but I believe that a simulation and a picture can help unpack that sentence.
UNDER THE NULL HY |
27,003 | In an experiment, why can you select your own alpha level for significance testing? | Alpha is a decision threshold of how "sure" you need to be that an observed result is incompatible with the null before you conclude that the null is indeed false. For a typical alpha like 0.05, only 5% of the time will you reject the null when it's actually true - you'll get very few false positives, since you require pretty strong evidence to reject the null. For an uncommonly permissive alpha like 0.5, you'll incorrectly reject the null 50% of the time - you'll make many mistakes by rejecting the null since little evidence is required at that threshold.
Alpha = 0.05 is a typical threshold where most people agree that "statistically significant" is generally useful and not a meaningless statistical fluctuation. But each researcher is free to choose their alpha, which in a way represents how much evidence they require to be convinced - in other words, how skeptical they are. A high-alpha individual will spuriously reject many nulls but will rarely miss a true effect, while a low-alpha individual will find fewer true effects overall, but at a higher rate.
Imagine the Bigfoot enthusiast who accepts a grainy photo as sufficient proof of cryptozoology. He has a high alpha threshold, willing to reject the null with little evidence. He will not, however, ever be proven wrong by claiming that cryptids do not exist when they actually do. In contrast, a scientifically rigorous biologist may have a much lower alpha threshold, requiring more evidence to reject the default state of knowledge that there is no Bigfoot. The scientist's skepticism may lead him to disregard evidence of cryptids that truly do exist, but when the scientist claims that one exists, he's more often correct.
There is not one "optimal" alpha that is universally agreed upon for all scenarios. At the one end, a person who uses a very high alpha threshold regularly makes false findings based on little evidence, but at the other end, a person who uses a very low alpha regularly fails to acknowledge real effects because they deem even strong evidence insufficient. What alpha to use depends on your goals and how you perceive the relative costs of false positives versus false negatives.
Alpha represents a decision threshold for whether you deem an observation to be a result of random chance or a true effect. The question could be rephrased as, why am I allowed to decide for myself how much evidence will be convincing? Although there are common standards, it's a personal choice. | In an experiment, why can you select your own alpha level for significance testing? | Alpha is a decision threshold of how "sure" you need to be that an observed result is incompatible with the null before you conclude that the null is indeed false. For a typical alpha like 0.05, only | In an experiment, why can you select your own alpha level for significance testing?
Alpha is a decision threshold of how "sure" you need to be that an observed result is incompatible with the null before you conclude that the null is indeed false. For a typical alpha like 0.05, only 5% of the time will you reject the null when it's actually true - you'll get very few false positives, since you require pretty strong evidence to reject the null. For an uncommonly permissive alpha like 0.5, you'll incorrectly reject the null 50% of the time - you'll make many mistakes by rejecting the null since little evidence is required at that threshold.
Alpha = 0.05 is a typical threshold where most people agree that "statistically significant" is generally useful and not a meaningless statistical fluctuation. But each researcher is free to choose their alpha, which in a way represents how much evidence they require to be convinced - in other words, how skeptical they are. A high-alpha individual will spuriously reject many nulls but will rarely miss a true effect, while a low-alpha individual will find fewer true effects overall, but at a higher rate.
Imagine the Bigfoot enthusiast who accepts a grainy photo as sufficient proof of cryptozoology. He has a high alpha threshold, willing to reject the null with little evidence. He will not, however, ever be proven wrong by claiming that cryptids do not exist when they actually do. In contrast, a scientifically rigorous biologist may have a much lower alpha threshold, requiring more evidence to reject the default state of knowledge that there is no Bigfoot. The scientist's skepticism may lead him to disregard evidence of cryptids that truly do exist, but when the scientist claims that one exists, he's more often correct.
There is not one "optimal" alpha that is universally agreed upon for all scenarios. At the one end, a person who uses a very high alpha threshold regularly makes false findings based on little evidence, but at the other end, a person who uses a very low alpha regularly fails to acknowledge real effects because they deem even strong evidence insufficient. What alpha to use depends on your goals and how you perceive the relative costs of false positives versus false negatives.
Alpha represents a decision threshold for whether you deem an observation to be a result of random chance or a true effect. The question could be rephrased as, why am I allowed to decide for myself how much evidence will be convincing? Although there are common standards, it's a personal choice. | In an experiment, why can you select your own alpha level for significance testing?
Alpha is a decision threshold of how "sure" you need to be that an observed result is incompatible with the null before you conclude that the null is indeed false. For a typical alpha like 0.05, only |
27,004 | In an experiment, why can you select your own alpha level for significance testing? | The optimal alpha value depends on many factors of the specific research area. It can't be fixed a priori by mathematics alone, and there's no universal consensus on what the "best" value is, nor can there be. Here's a recent paper in PLoS One that tries to grapple with this issue:
Miller J, Ulrich R. The quest for an optimal alpha. PLoS One. 2019 Jan
2;14(1):e0208631. doi: 10.1371/journal.pone.0208631. PMID: 30601826;
PMCID: PMC6314595.
The abstract:
Researchers who analyze data within the framework of null hypothesis
significance testing must choose a critical “alpha” level, α, to use
as a cutoff for deciding whether a given set of data demonstrates the
presence of a particular effect. In most fields, α = 0.05 has
traditionally been used as the standard cutoff. Many researchers have
recently argued for a change to a more stringent evidence cutoff such
as α = 0.01, 0.005, or 0.001, noting that this change would tend to
reduce the rate of false positives, which are of growing concern in
many research areas. Other researchers oppose this proposed change,
however, because it would correspondingly tend to increase the rate of
false negatives. We show how a simple statistical model can be used to
explore the quantitative tradeoff between reducing false positives and
increasing false negatives. In particular, the model shows how the
optimal α level depends on numerous characteristics of the research
area, and it reveals that although α = 0.05 would indeed be
approximately the optimal value in some realistic situations, the
optimal α could actually be substantially larger or smaller in other
situations. The importance of the model lies in making it clear what
characteristics of the research area have to be specified to make a
principled argument for using one α level rather than another, and the
model thereby provides a blueprint for researchers seeking to justify
a particular α level.
Link to the article. | In an experiment, why can you select your own alpha level for significance testing? | The optimal alpha value depends on many factors of the specific research area. It can't be fixed a priori by mathematics alone, and there's no universal consensus on what the "best" value is, nor can | In an experiment, why can you select your own alpha level for significance testing?
The optimal alpha value depends on many factors of the specific research area. It can't be fixed a priori by mathematics alone, and there's no universal consensus on what the "best" value is, nor can there be. Here's a recent paper in PLoS One that tries to grapple with this issue:
Miller J, Ulrich R. The quest for an optimal alpha. PLoS One. 2019 Jan
2;14(1):e0208631. doi: 10.1371/journal.pone.0208631. PMID: 30601826;
PMCID: PMC6314595.
The abstract:
Researchers who analyze data within the framework of null hypothesis
significance testing must choose a critical “alpha” level, α, to use
as a cutoff for deciding whether a given set of data demonstrates the
presence of a particular effect. In most fields, α = 0.05 has
traditionally been used as the standard cutoff. Many researchers have
recently argued for a change to a more stringent evidence cutoff such
as α = 0.01, 0.005, or 0.001, noting that this change would tend to
reduce the rate of false positives, which are of growing concern in
many research areas. Other researchers oppose this proposed change,
however, because it would correspondingly tend to increase the rate of
false negatives. We show how a simple statistical model can be used to
explore the quantitative tradeoff between reducing false positives and
increasing false negatives. In particular, the model shows how the
optimal α level depends on numerous characteristics of the research
area, and it reveals that although α = 0.05 would indeed be
approximately the optimal value in some realistic situations, the
optimal α could actually be substantially larger or smaller in other
situations. The importance of the model lies in making it clear what
characteristics of the research area have to be specified to make a
principled argument for using one α level rather than another, and the
model thereby provides a blueprint for researchers seeking to justify
a particular α level.
Link to the article. | In an experiment, why can you select your own alpha level for significance testing?
The optimal alpha value depends on many factors of the specific research area. It can't be fixed a priori by mathematics alone, and there's no universal consensus on what the "best" value is, nor can |
27,005 | In an experiment, why can you select your own alpha level for significance testing? | There are some excellent answers, but none discuss risk.
Often, stats are used for practical reasons. We can talk about the probability that two people in a particular group weigh within a kilogram of each other, or we can talk about the probability that a vaccine has a potentially deadly side effect. We may use similar tools, but it should be apparent that making a poor decision concerning the latter has ramifications above and beyond messing up on the former. If you tell the FDA that you tested the RSV vaccine for the side effect of Guillan Barre Syndrome at $\alpha=0.05$, the FDA may well turn your application down (as soon as they finish laughing).
Thus, we can choose alpha based upon how certain we need to be. In fact, when you present a reviewer with the results of your test and the alpha you used, you tell the reviewer what they need to know to make a decision about whether your statistical methods have an appropriate level of conservatism for a given situation. | In an experiment, why can you select your own alpha level for significance testing? | There are some excellent answers, but none discuss risk.
Often, stats are used for practical reasons. We can talk about the probability that two people in a particular group weigh within a kilogram o | In an experiment, why can you select your own alpha level for significance testing?
There are some excellent answers, but none discuss risk.
Often, stats are used for practical reasons. We can talk about the probability that two people in a particular group weigh within a kilogram of each other, or we can talk about the probability that a vaccine has a potentially deadly side effect. We may use similar tools, but it should be apparent that making a poor decision concerning the latter has ramifications above and beyond messing up on the former. If you tell the FDA that you tested the RSV vaccine for the side effect of Guillan Barre Syndrome at $\alpha=0.05$, the FDA may well turn your application down (as soon as they finish laughing).
Thus, we can choose alpha based upon how certain we need to be. In fact, when you present a reviewer with the results of your test and the alpha you used, you tell the reviewer what they need to know to make a decision about whether your statistical methods have an appropriate level of conservatism for a given situation. | In an experiment, why can you select your own alpha level for significance testing?
There are some excellent answers, but none discuss risk.
Often, stats are used for practical reasons. We can talk about the probability that two people in a particular group weigh within a kilogram o |
27,006 | In an experiment, why can you select your own alpha level for significance testing? | When you do a statistical test (any kind of yes/no test, really), you can have two kinds of errors (wrong results): false positives (test says yes but real answer is no), and false negatives (test says no but real answer is yes).
The catch is that it's very easy to skew (non-technical term) your test one way or the other simply by making the test more likely to give one or the other answer - make a "yes" answer more likely, and then you get less false negatives, but more false positives, or make a "no" answer more likely, and then you get more false negatives, but less false positives.
So, how do you know that your test has a good yes/no balance? There's no "default" or "neutral" setting - there's nothing we can look at and definitively say "this is a fair test". Setting alpha=0.05 is setting your test's skew so that if the real answer is no, your test gives a false positive result 5% of the time. That seems fairly reasonable, so they do it. I don't think there's any reason why 5% is so common, rather than say 2% or 10%, other than gut feelings.
You only get to set one knob - all the other "skew parameters" are determined based on the one you control, and the quality of your data. You can't say you want 1% false positives and also 1% false negatives. If you want very few false positives, and your data is crap, you're going to get very few true positives as well.
Why do we choose to set the percentage of the time we get a false positive when the real answer is no, and not some other statistic, like the percentage of the time we get a false negative when the real answer is yes? Well that just happens to be something that's easy to control. | In an experiment, why can you select your own alpha level for significance testing? | When you do a statistical test (any kind of yes/no test, really), you can have two kinds of errors (wrong results): false positives (test says yes but real answer is no), and false negatives (test say | In an experiment, why can you select your own alpha level for significance testing?
When you do a statistical test (any kind of yes/no test, really), you can have two kinds of errors (wrong results): false positives (test says yes but real answer is no), and false negatives (test says no but real answer is yes).
The catch is that it's very easy to skew (non-technical term) your test one way or the other simply by making the test more likely to give one or the other answer - make a "yes" answer more likely, and then you get less false negatives, but more false positives, or make a "no" answer more likely, and then you get more false negatives, but less false positives.
So, how do you know that your test has a good yes/no balance? There's no "default" or "neutral" setting - there's nothing we can look at and definitively say "this is a fair test". Setting alpha=0.05 is setting your test's skew so that if the real answer is no, your test gives a false positive result 5% of the time. That seems fairly reasonable, so they do it. I don't think there's any reason why 5% is so common, rather than say 2% or 10%, other than gut feelings.
You only get to set one knob - all the other "skew parameters" are determined based on the one you control, and the quality of your data. You can't say you want 1% false positives and also 1% false negatives. If you want very few false positives, and your data is crap, you're going to get very few true positives as well.
Why do we choose to set the percentage of the time we get a false positive when the real answer is no, and not some other statistic, like the percentage of the time we get a false negative when the real answer is yes? Well that just happens to be something that's easy to control. | In an experiment, why can you select your own alpha level for significance testing?
When you do a statistical test (any kind of yes/no test, really), you can have two kinds of errors (wrong results): false positives (test says yes but real answer is no), and false negatives (test say |
27,007 | Why not log-transform all variables that are not of main interest? | Now, I understand that this depends on distributions and normality in predictors
log transforming does make data more uniform
As a general claim, this is false --- but even if it were the case, why would uniformity be important?
Consider, for example,
i) a binary predictor taking only the values 1 and 2. Taking logs would leave it as a binary predictor taking only the values 0 and log 2. It doesn't really affect anything except the intercept and scaling of terms involving this predictor. Even the p-value of the predictor would be unchanged, as would the fitted values.
ii) consider a left-skew predictor. Now take logs. It typically becomes more left skew.
iii) uniform data becomes left skew
(it's often not always so extreme a change, though)
less affected by outliers
As a general claim, this is false. Consider low outliers in a predictor.
I thought about log transforming all my continuous variables which are not of main interest
To what end? If originally the relationships were linear, they would not longer be.
And if they were already curved, doing this automatically might make them worse (more curved), not better.
--
Taking logs of a predictor (whether of primary interest or not) might sometimes be suitable, but it's not always so. | Why not log-transform all variables that are not of main interest? | Now, I understand that this depends on distributions and normality in predictors
log transforming does make data more uniform
As a general claim, this is false --- but even if it were the case, why w | Why not log-transform all variables that are not of main interest?
Now, I understand that this depends on distributions and normality in predictors
log transforming does make data more uniform
As a general claim, this is false --- but even if it were the case, why would uniformity be important?
Consider, for example,
i) a binary predictor taking only the values 1 and 2. Taking logs would leave it as a binary predictor taking only the values 0 and log 2. It doesn't really affect anything except the intercept and scaling of terms involving this predictor. Even the p-value of the predictor would be unchanged, as would the fitted values.
ii) consider a left-skew predictor. Now take logs. It typically becomes more left skew.
iii) uniform data becomes left skew
(it's often not always so extreme a change, though)
less affected by outliers
As a general claim, this is false. Consider low outliers in a predictor.
I thought about log transforming all my continuous variables which are not of main interest
To what end? If originally the relationships were linear, they would not longer be.
And if they were already curved, doing this automatically might make them worse (more curved), not better.
--
Taking logs of a predictor (whether of primary interest or not) might sometimes be suitable, but it's not always so. | Why not log-transform all variables that are not of main interest?
Now, I understand that this depends on distributions and normality in predictors
log transforming does make data more uniform
As a general claim, this is false --- but even if it were the case, why w |
27,008 | Why not log-transform all variables that are not of main interest? | In my opinion, it doesn't make sense to perform log transformation (and any data transformation, for that matter) just for the sake of it. As previous answers mentioned, depending on data, some transformations would be either invalid, or useless. I highly recommend you to read the following IMHO excellent introductory material on data transformation: http://fmwww.bc.edu/repec/bocode/t/transint.html. Please note that code examples in this document are written in Stata language, but otherwise the document is generic enough and, thus, useful to non-Stata users as well.
Some simple techniques and tools for dealing with common data-related problems, such as lack of normality, outliers and mixture distributions can be found in this article (note, that stratification as an approach to dealing with mixture distribution is most likely the simplest one - a more general and complex approach to this is mixture analysis, also known as finite mixture models, a description of which is beyond the scope of this answer). Box-Cox transformation, briefly mentioned in the two references above, is a rather important data transformation, especially for non-normal data (with some caveats). For more details on Box-Cox transformation, please see this introductory article. | Why not log-transform all variables that are not of main interest? | In my opinion, it doesn't make sense to perform log transformation (and any data transformation, for that matter) just for the sake of it. As previous answers mentioned, depending on data, some transf | Why not log-transform all variables that are not of main interest?
In my opinion, it doesn't make sense to perform log transformation (and any data transformation, for that matter) just for the sake of it. As previous answers mentioned, depending on data, some transformations would be either invalid, or useless. I highly recommend you to read the following IMHO excellent introductory material on data transformation: http://fmwww.bc.edu/repec/bocode/t/transint.html. Please note that code examples in this document are written in Stata language, but otherwise the document is generic enough and, thus, useful to non-Stata users as well.
Some simple techniques and tools for dealing with common data-related problems, such as lack of normality, outliers and mixture distributions can be found in this article (note, that stratification as an approach to dealing with mixture distribution is most likely the simplest one - a more general and complex approach to this is mixture analysis, also known as finite mixture models, a description of which is beyond the scope of this answer). Box-Cox transformation, briefly mentioned in the two references above, is a rather important data transformation, especially for non-normal data (with some caveats). For more details on Box-Cox transformation, please see this introductory article. | Why not log-transform all variables that are not of main interest?
In my opinion, it doesn't make sense to perform log transformation (and any data transformation, for that matter) just for the sake of it. As previous answers mentioned, depending on data, some transf |
27,009 | Why not log-transform all variables that are not of main interest? | Log transforming does not ALWAYS make things better. Obviously, you can't log-transform variables that achieve zero or negative values, and even positive ones that hug zero could come out with negative outliers if log-transformed.
You should not just routinely log everything, but it is a good practice to THINK about transforming selected positive predictors (suitably, often a log but maybe something else) before fitting a model. The same goes for the response variable. Subject-matter knowledge is important too. Some theory from physics or sociology or whatever might naturally lead to certain transformations. Generally, if you see variables that are positively skewed, that's where a log (or maybe a square root or a reciprocal) might help.
Some regression texts seem to suggest that you have to look at diagnostic plots before considering any transformations, but I disagree. I think it's better to do the best job you can at making these choices before fitting any models, so that you have the best starting point possible; then look at diagnostics to see if you need to adjust from there. | Why not log-transform all variables that are not of main interest? | Log transforming does not ALWAYS make things better. Obviously, you can't log-transform variables that achieve zero or negative values, and even positive ones that hug zero could come out with negativ | Why not log-transform all variables that are not of main interest?
Log transforming does not ALWAYS make things better. Obviously, you can't log-transform variables that achieve zero or negative values, and even positive ones that hug zero could come out with negative outliers if log-transformed.
You should not just routinely log everything, but it is a good practice to THINK about transforming selected positive predictors (suitably, often a log but maybe something else) before fitting a model. The same goes for the response variable. Subject-matter knowledge is important too. Some theory from physics or sociology or whatever might naturally lead to certain transformations. Generally, if you see variables that are positively skewed, that's where a log (or maybe a square root or a reciprocal) might help.
Some regression texts seem to suggest that you have to look at diagnostic plots before considering any transformations, but I disagree. I think it's better to do the best job you can at making these choices before fitting any models, so that you have the best starting point possible; then look at diagnostics to see if you need to adjust from there. | Why not log-transform all variables that are not of main interest?
Log transforming does not ALWAYS make things better. Obviously, you can't log-transform variables that achieve zero or negative values, and even positive ones that hug zero could come out with negativ |
27,010 | Determine how good an AUC is (Area under the Curve of ROC) | From the comments:
Calimo: If you are a trader and you can get an AUC of 0.501 in predicting future financial transactions, you're the richest man in the world. If you are a CPU engineer and your design gets an AUC of 0.999 at telling if a bit is 0 or 1, you have a useless piece of silicon. | Determine how good an AUC is (Area under the Curve of ROC) | From the comments:
Calimo: If you are a trader and you can get an AUC of 0.501 in predicting future financial transactions, you're the richest man in the world. If you are a CPU engineer and your des | Determine how good an AUC is (Area under the Curve of ROC)
From the comments:
Calimo: If you are a trader and you can get an AUC of 0.501 in predicting future financial transactions, you're the richest man in the world. If you are a CPU engineer and your design gets an AUC of 0.999 at telling if a bit is 0 or 1, you have a useless piece of silicon. | Determine how good an AUC is (Area under the Curve of ROC)
From the comments:
Calimo: If you are a trader and you can get an AUC of 0.501 in predicting future financial transactions, you're the richest man in the world. If you are a CPU engineer and your des |
27,011 | Determine how good an AUC is (Area under the Curve of ROC) | This is a complementary to Andrey's answer (+1).
When looking for a generally accepted reference on AUC-ROC values, I came across Hosmer's "Applied Logistic Regression". In Chapt. 5 "Assessing the Fit of the Model", it emphasised that "there is no “magic” number, only general guidelines". Therein, the following values are given:
ROC = 0.5 This suggests no discrimination, (...).
0.5 < ROC < 0.7 We consider this poor discrimination, (...).
0.7 $\leq$ ROC < 0.8 We consider this acceptable discrimination.
0.8 $\leq$ ROC < 0.9 We consider this excellent discrimination.
ROC $\geq$ 0.9 We consider this outstanding discrimination.
These values are by no means set-to-stone and they are given without any context. As Star Trek teaches us: "Universal law is for lackeys, context is for kings", i.e. (and more seriously) we need to understand what we are making a particular decision and what our metrics reflect. My guidelines would be:
For any new task we should actively look at existing literature to see what is considered competitive performance. (e.g. detection of lung cancer from X-ray images) This is practically a literature review.
If our tasks is not present in literature, we should aim to provide an improvement over a reasonable baseline model. That baseline model might be some simple rules of thumb, other existing solutions and/or predictions provided by human rater(s).
If we have a task with no existing literature and no simple baseline model available, we should stop trying to make a "better/worse" model performance comparison. At this point, saying "AUC-R0C 0.75 is bad" or "AUC-ROC 0.75 is good" is a matter of opinion. | Determine how good an AUC is (Area under the Curve of ROC) | This is a complementary to Andrey's answer (+1).
When looking for a generally accepted reference on AUC-ROC values, I came across Hosmer's "Applied Logistic Regression". In Chapt. 5 "Assessing the Fit | Determine how good an AUC is (Area under the Curve of ROC)
This is a complementary to Andrey's answer (+1).
When looking for a generally accepted reference on AUC-ROC values, I came across Hosmer's "Applied Logistic Regression". In Chapt. 5 "Assessing the Fit of the Model", it emphasised that "there is no “magic” number, only general guidelines". Therein, the following values are given:
ROC = 0.5 This suggests no discrimination, (...).
0.5 < ROC < 0.7 We consider this poor discrimination, (...).
0.7 $\leq$ ROC < 0.8 We consider this acceptable discrimination.
0.8 $\leq$ ROC < 0.9 We consider this excellent discrimination.
ROC $\geq$ 0.9 We consider this outstanding discrimination.
These values are by no means set-to-stone and they are given without any context. As Star Trek teaches us: "Universal law is for lackeys, context is for kings", i.e. (and more seriously) we need to understand what we are making a particular decision and what our metrics reflect. My guidelines would be:
For any new task we should actively look at existing literature to see what is considered competitive performance. (e.g. detection of lung cancer from X-ray images) This is practically a literature review.
If our tasks is not present in literature, we should aim to provide an improvement over a reasonable baseline model. That baseline model might be some simple rules of thumb, other existing solutions and/or predictions provided by human rater(s).
If we have a task with no existing literature and no simple baseline model available, we should stop trying to make a "better/worse" model performance comparison. At this point, saying "AUC-R0C 0.75 is bad" or "AUC-ROC 0.75 is good" is a matter of opinion. | Determine how good an AUC is (Area under the Curve of ROC)
This is a complementary to Andrey's answer (+1).
When looking for a generally accepted reference on AUC-ROC values, I came across Hosmer's "Applied Logistic Regression". In Chapt. 5 "Assessing the Fit |
27,012 | Determine how good an AUC is (Area under the Curve of ROC) | It isn't possible to say because it really depends on the task and the data. For some simple tasks AUC can be 90+, for others ~0.5-0.6. | Determine how good an AUC is (Area under the Curve of ROC) | It isn't possible to say because it really depends on the task and the data. For some simple tasks AUC can be 90+, for others ~0.5-0.6. | Determine how good an AUC is (Area under the Curve of ROC)
It isn't possible to say because it really depends on the task and the data. For some simple tasks AUC can be 90+, for others ~0.5-0.6. | Determine how good an AUC is (Area under the Curve of ROC)
It isn't possible to say because it really depends on the task and the data. For some simple tasks AUC can be 90+, for others ~0.5-0.6. |
27,013 | Determine how good an AUC is (Area under the Curve of ROC) | Generally, I would not say so. It all depends on the task, your data set, and objectives. There is no rule of thumb that an AUC value of x.x is defined as a good predicting model.
That being said, you want to achieve as high an AUC value as possible. In cases where you get an AUC of 1, your model is essentially a perfect predictor for your outcome. In cases of 0.5, your model is not really valuable. An AUC of 0.5 just means the model is just randomly predicting the outcome no better than a monkey would do (in theory). I can only recommend you to read more about it if you have not so. This is realtively straightforward. And, here. | Determine how good an AUC is (Area under the Curve of ROC) | Generally, I would not say so. It all depends on the task, your data set, and objectives. There is no rule of thumb that an AUC value of x.x is defined as a good predicting model.
That being said, you | Determine how good an AUC is (Area under the Curve of ROC)
Generally, I would not say so. It all depends on the task, your data set, and objectives. There is no rule of thumb that an AUC value of x.x is defined as a good predicting model.
That being said, you want to achieve as high an AUC value as possible. In cases where you get an AUC of 1, your model is essentially a perfect predictor for your outcome. In cases of 0.5, your model is not really valuable. An AUC of 0.5 just means the model is just randomly predicting the outcome no better than a monkey would do (in theory). I can only recommend you to read more about it if you have not so. This is realtively straightforward. And, here. | Determine how good an AUC is (Area under the Curve of ROC)
Generally, I would not say so. It all depends on the task, your data set, and objectives. There is no rule of thumb that an AUC value of x.x is defined as a good predicting model.
That being said, you |
27,014 | Analytical solution to linear-regression coefficient estimates | We have
$\frac{d}{d\beta} (y - X \beta)' (y - X\beta) = -2 X' (y - X \beta)$.
It can be shown by writing the equation explicitly with components. For example, write $(\beta_{1}, \ldots, \beta_{p})'$ instead of $\beta$. Then take derivatives with respect to $\beta_{1}$, $\beta_{2}$, ..., $\beta_{p}$ and stack everything to get the answer. For a quick and easy illustration, you can start with $p = 2$.
With experience one develops general rules, some of which are given, e.g., in that document.
Edit to guide for the added part of the question
With $p = 2$, we have
$(y - X \beta)'(y - X \beta) = (y_1 - x_{11} \beta_1 - x_{12} \beta_2)^2 +
(y_2 - x_{21}\beta_1 - x_{22} \beta_2)^2$
The derivative with respect to $\beta_1$ is
$-2x_{11}(y_1 - x_{11} \beta_1 - x_{12} \beta_2)-2x_{21}(y_2 - x_{21}\beta_1 - x_{22} \beta_2)$
Similarly, the derivative with respect to $\beta_2$ is
$-2x_{12}(y_1 - x_{11} \beta_1 - x_{12} \beta_2)-2x_{22}(y_2 - x_{21}\beta_1 - x_{22} \beta_2)$
Hence, the derivative with respect to $\beta = (\beta_1, \beta_2)'$ is
$
\left(
\begin{array}{c}
-2x_{11}(y_1 - x_{11} \beta_1 - x_{12} \beta_2)-2x_{21}(y_2 - x_{21}\beta_1 - x_{22} \beta_2) \\
-2x_{12}(y_1 - x_{11} \beta_1 - x_{12} \beta_2)-2x_{22}(y_2 - x_{21}\beta_1 - x_{22} \beta_2)
\end{array}
\right)
$
Now, observe you can rewrite the last expression as
$-2\left(
\begin{array}{cc}
x_{11} & x_{21} \\
x_{12} & x_{22}
\end{array}
\right)\left(
\begin{array}{c}
y_{1} - x_{11}\beta_{1} - x_{12}\beta_2 \\
y_{2} - x_{21}\beta_{1} - x_{22}\beta_2
\end{array}
\right) = -2 X' (y - X \beta)$
Of course, everything is done in the same way for a larger $p$. | Analytical solution to linear-regression coefficient estimates | We have
$\frac{d}{d\beta} (y - X \beta)' (y - X\beta) = -2 X' (y - X \beta)$.
It can be shown by writing the equation explicitly with components. For example, write $(\beta_{1}, \ldots, \beta_{p})'$ i | Analytical solution to linear-regression coefficient estimates
We have
$\frac{d}{d\beta} (y - X \beta)' (y - X\beta) = -2 X' (y - X \beta)$.
It can be shown by writing the equation explicitly with components. For example, write $(\beta_{1}, \ldots, \beta_{p})'$ instead of $\beta$. Then take derivatives with respect to $\beta_{1}$, $\beta_{2}$, ..., $\beta_{p}$ and stack everything to get the answer. For a quick and easy illustration, you can start with $p = 2$.
With experience one develops general rules, some of which are given, e.g., in that document.
Edit to guide for the added part of the question
With $p = 2$, we have
$(y - X \beta)'(y - X \beta) = (y_1 - x_{11} \beta_1 - x_{12} \beta_2)^2 +
(y_2 - x_{21}\beta_1 - x_{22} \beta_2)^2$
The derivative with respect to $\beta_1$ is
$-2x_{11}(y_1 - x_{11} \beta_1 - x_{12} \beta_2)-2x_{21}(y_2 - x_{21}\beta_1 - x_{22} \beta_2)$
Similarly, the derivative with respect to $\beta_2$ is
$-2x_{12}(y_1 - x_{11} \beta_1 - x_{12} \beta_2)-2x_{22}(y_2 - x_{21}\beta_1 - x_{22} \beta_2)$
Hence, the derivative with respect to $\beta = (\beta_1, \beta_2)'$ is
$
\left(
\begin{array}{c}
-2x_{11}(y_1 - x_{11} \beta_1 - x_{12} \beta_2)-2x_{21}(y_2 - x_{21}\beta_1 - x_{22} \beta_2) \\
-2x_{12}(y_1 - x_{11} \beta_1 - x_{12} \beta_2)-2x_{22}(y_2 - x_{21}\beta_1 - x_{22} \beta_2)
\end{array}
\right)
$
Now, observe you can rewrite the last expression as
$-2\left(
\begin{array}{cc}
x_{11} & x_{21} \\
x_{12} & x_{22}
\end{array}
\right)\left(
\begin{array}{c}
y_{1} - x_{11}\beta_{1} - x_{12}\beta_2 \\
y_{2} - x_{21}\beta_{1} - x_{22}\beta_2
\end{array}
\right) = -2 X' (y - X \beta)$
Of course, everything is done in the same way for a larger $p$. | Analytical solution to linear-regression coefficient estimates
We have
$\frac{d}{d\beta} (y - X \beta)' (y - X\beta) = -2 X' (y - X \beta)$.
It can be shown by writing the equation explicitly with components. For example, write $(\beta_{1}, \ldots, \beta_{p})'$ i |
27,015 | Analytical solution to linear-regression coefficient estimates | You can also use formulas from Matrix cookbook. We have
$$(y-X\beta)'(y-X\beta)=y'y-\beta'X'y-y'X\beta+\beta'X'X\beta$$
Now take derivatives of each term. You might want to notice that $\beta'X'y=y'X\beta$. The derivative of term $y'y$ with respect to $\beta$ is zero. The remaining term
$$\beta'X'X\beta-2y'X\beta$$
is of form of function
$$f(x)=x'Ax+b'x,$$
in formula (88) in the book in page 11, with $x=\beta$, $A=X'X$ and $b=-2X'y$. The derivative is given in the formula (89):
$$\frac{\partial f}{\partial x}=(A+A')x+b$$
so
$$\frac{\partial}{\partial \beta}(y-X\beta)'(y-X\beta)=(X'X+(X'X)')\beta-2X'y$$
Now since $(X'X)'=X'X$ we get the desired solution:
$$X'X\beta=X'y$$ | Analytical solution to linear-regression coefficient estimates | You can also use formulas from Matrix cookbook. We have
$$(y-X\beta)'(y-X\beta)=y'y-\beta'X'y-y'X\beta+\beta'X'X\beta$$
Now take derivatives of each term. You might want to notice that $\beta'X'y=y'X\ | Analytical solution to linear-regression coefficient estimates
You can also use formulas from Matrix cookbook. We have
$$(y-X\beta)'(y-X\beta)=y'y-\beta'X'y-y'X\beta+\beta'X'X\beta$$
Now take derivatives of each term. You might want to notice that $\beta'X'y=y'X\beta$. The derivative of term $y'y$ with respect to $\beta$ is zero. The remaining term
$$\beta'X'X\beta-2y'X\beta$$
is of form of function
$$f(x)=x'Ax+b'x,$$
in formula (88) in the book in page 11, with $x=\beta$, $A=X'X$ and $b=-2X'y$. The derivative is given in the formula (89):
$$\frac{\partial f}{\partial x}=(A+A')x+b$$
so
$$\frac{\partial}{\partial \beta}(y-X\beta)'(y-X\beta)=(X'X+(X'X)')\beta-2X'y$$
Now since $(X'X)'=X'X$ we get the desired solution:
$$X'X\beta=X'y$$ | Analytical solution to linear-regression coefficient estimates
You can also use formulas from Matrix cookbook. We have
$$(y-X\beta)'(y-X\beta)=y'y-\beta'X'y-y'X\beta+\beta'X'X\beta$$
Now take derivatives of each term. You might want to notice that $\beta'X'y=y'X\ |
27,016 | Analytical solution to linear-regression coefficient estimates | Here is a technique for minimizing the sum of squares in regression that actually has applications to more general settings and which I find useful.
Let's try to avoid vector-matrix calculus altogether.
Suppose we are interested in minimizing
$$
\newcommand{\err}{\mathcal{E}}\newcommand{\my}{\mathbf{y}}\newcommand{\mX}{\mathbf{X}}\newcommand{\bhat}{\hat{\beta}}\newcommand{\reals}{\mathbb{R}}
\err = (\my - \mX \beta)^T (\my - \mX \beta) = \|\my - \mX \beta\|_2^2 \> ,
$$
where $\my \in \reals^n$, $\mX \in \reals^{n\times p}$ and $\beta \in \reals^p$. We assume for simplicity that $p \leq n$ and $\mathrm{rank}(\mX) = p$.
For any $\bhat \in \reals^p$, we get
$$
\err = \|\my - \mX \bhat + \mX \bhat - \mX \beta\|_2^2 = \|\my - \mX \bhat\|_2^2 + \|\mX(\beta-\bhat)\|_2^2 - 2(\beta - \bhat)^T \mX^T (\my - \mX \bhat) \>.
$$
If we can choose (find!) a vector $\bhat$ such that the last term on the right-hand side is zero for every $\beta$, then we would be done, since that would imply that $\min_\beta \err \geq \|\my - \mX \bhat\|_2^2$.
But, $(\beta - \bhat)^T \mX^T (\my - \mX \bhat) = 0$ for all $\beta$ if and only if $\mX^T (\my - \mX \bhat) = 0$ and this last equation is true if and only if $\mX^T \mX \bhat = \mX^T \my$. So $\err$ is minimized by taking $\bhat = (\mX^T \mX)^{-1} \mX^T \my$.
While this may seem like a "trick" to avoid calculus, it actually has wider application and there is some interesting geometry at play.
One example where this technique makes a derivation much simpler than any matrix-vector calculus approach is when we generalize to the matrix case. Let $\newcommand{\mY}{\mathbf{Y}}\newcommand{\mB}{\mathbf{B}}\mY \in \reals^{n \times p}$, $\mX \in \reals^{n \times q}$ and $\mB \in \reals^{q \times p}$. Suppose we wish to minimize
$$
\err = \mathrm{tr}( (\mY - \mX \mB) \Sigma^{-1} (\mY - \mX \mB)^T )
$$
over the entire matrix $\mB$ of parameters. Here $\Sigma$ is a covariance matrix.
An entirely analogous approach to the above quickly establishes that the minimum of $\err$ is attained by taking
$$
\hat{\mB} = (\mX^T \mX)^{-1} \mX^T \mY \>.
$$
That is, in a regression setting where the response is a vector with covariance $\Sigma$ and the observations are independent, then the OLS estimate is attained by doing $p$ separate linear regressions on the components of the response. | Analytical solution to linear-regression coefficient estimates | Here is a technique for minimizing the sum of squares in regression that actually has applications to more general settings and which I find useful.
Let's try to avoid vector-matrix calculus altogeth | Analytical solution to linear-regression coefficient estimates
Here is a technique for minimizing the sum of squares in regression that actually has applications to more general settings and which I find useful.
Let's try to avoid vector-matrix calculus altogether.
Suppose we are interested in minimizing
$$
\newcommand{\err}{\mathcal{E}}\newcommand{\my}{\mathbf{y}}\newcommand{\mX}{\mathbf{X}}\newcommand{\bhat}{\hat{\beta}}\newcommand{\reals}{\mathbb{R}}
\err = (\my - \mX \beta)^T (\my - \mX \beta) = \|\my - \mX \beta\|_2^2 \> ,
$$
where $\my \in \reals^n$, $\mX \in \reals^{n\times p}$ and $\beta \in \reals^p$. We assume for simplicity that $p \leq n$ and $\mathrm{rank}(\mX) = p$.
For any $\bhat \in \reals^p$, we get
$$
\err = \|\my - \mX \bhat + \mX \bhat - \mX \beta\|_2^2 = \|\my - \mX \bhat\|_2^2 + \|\mX(\beta-\bhat)\|_2^2 - 2(\beta - \bhat)^T \mX^T (\my - \mX \bhat) \>.
$$
If we can choose (find!) a vector $\bhat$ such that the last term on the right-hand side is zero for every $\beta$, then we would be done, since that would imply that $\min_\beta \err \geq \|\my - \mX \bhat\|_2^2$.
But, $(\beta - \bhat)^T \mX^T (\my - \mX \bhat) = 0$ for all $\beta$ if and only if $\mX^T (\my - \mX \bhat) = 0$ and this last equation is true if and only if $\mX^T \mX \bhat = \mX^T \my$. So $\err$ is minimized by taking $\bhat = (\mX^T \mX)^{-1} \mX^T \my$.
While this may seem like a "trick" to avoid calculus, it actually has wider application and there is some interesting geometry at play.
One example where this technique makes a derivation much simpler than any matrix-vector calculus approach is when we generalize to the matrix case. Let $\newcommand{\mY}{\mathbf{Y}}\newcommand{\mB}{\mathbf{B}}\mY \in \reals^{n \times p}$, $\mX \in \reals^{n \times q}$ and $\mB \in \reals^{q \times p}$. Suppose we wish to minimize
$$
\err = \mathrm{tr}( (\mY - \mX \mB) \Sigma^{-1} (\mY - \mX \mB)^T )
$$
over the entire matrix $\mB$ of parameters. Here $\Sigma$ is a covariance matrix.
An entirely analogous approach to the above quickly establishes that the minimum of $\err$ is attained by taking
$$
\hat{\mB} = (\mX^T \mX)^{-1} \mX^T \mY \>.
$$
That is, in a regression setting where the response is a vector with covariance $\Sigma$ and the observations are independent, then the OLS estimate is attained by doing $p$ separate linear regressions on the components of the response. | Analytical solution to linear-regression coefficient estimates
Here is a technique for minimizing the sum of squares in regression that actually has applications to more general settings and which I find useful.
Let's try to avoid vector-matrix calculus altogeth |
27,017 | Analytical solution to linear-regression coefficient estimates | One way which may help you understand is to not use matrix algebra, and differentiate with each respect to each component, and then "store" the results in a column vector. So we have:
$$\frac{\partial}{\partial \beta_{k}}\sum_{i=1}^{N}\left(Y_{i}-\sum_{j=1}^{p}X_{ij}\beta_{j}\right)^{2}=0$$
Now you have $p$ of these equations, one for each beta. This is a simple application of the chain rule:
$$\sum_{i=1}^{N}2\left(Y_{i}-\sum_{j=1}^{p}X_{ij}\beta_{j}\right)^{1}\left(\frac{\partial}{\partial \beta_{k}}\left[Y_{i}-\sum_{j=1}^{p}X_{ij}\beta_{j}\right]\right)=0$$
$$-2\sum_{i=1}^{N}X_{ik}\left(Y_{i}-\sum_{j=1}^{p}X_{ij}\beta_{j}\right)=0$$
Now we can re-write the sum inside the bracket as $\sum_{j=1}^{p}X_{ij}\beta_{j}=\bf{x}_{i}^{T}\boldsymbol{\beta}$ So you get:
$$\sum_{i=1}^{N}X_{ik}Y_{i}-\sum_{i=1}^{N}X_{ik}\bf{x}_{i}^{T}\boldsymbol{\beta}=0$$
Now we have $p$ of these equations, and we will "stack them" in a column vector. Notice how $X_{ik}$ is the only term which depends on $k$, so we can stack this into the vector $\bf{x}_{i}$ and we get:
$$\sum_{i=1}^{N}\bf{x}_{i}\rm{Y}_{i}=\sum_{i=1}^{N}\bf{x}_{i}\bf{x}_{i}^{T}\boldsymbol{\beta}$$
Now we can take the beta outside the sum (but must stay on RHS of sum), and then take the invervse:
$$\left(\sum_{i=1}^{N}\bf{x}_{i}\bf{x}_{i}^{T}\right)^{-1}\sum_{i=1}^{N}\bf{x}_{i}\rm{Y}_{i}=\boldsymbol{\beta}$$ | Analytical solution to linear-regression coefficient estimates | One way which may help you understand is to not use matrix algebra, and differentiate with each respect to each component, and then "store" the results in a column vector. So we have:
$$\frac{\partia | Analytical solution to linear-regression coefficient estimates
One way which may help you understand is to not use matrix algebra, and differentiate with each respect to each component, and then "store" the results in a column vector. So we have:
$$\frac{\partial}{\partial \beta_{k}}\sum_{i=1}^{N}\left(Y_{i}-\sum_{j=1}^{p}X_{ij}\beta_{j}\right)^{2}=0$$
Now you have $p$ of these equations, one for each beta. This is a simple application of the chain rule:
$$\sum_{i=1}^{N}2\left(Y_{i}-\sum_{j=1}^{p}X_{ij}\beta_{j}\right)^{1}\left(\frac{\partial}{\partial \beta_{k}}\left[Y_{i}-\sum_{j=1}^{p}X_{ij}\beta_{j}\right]\right)=0$$
$$-2\sum_{i=1}^{N}X_{ik}\left(Y_{i}-\sum_{j=1}^{p}X_{ij}\beta_{j}\right)=0$$
Now we can re-write the sum inside the bracket as $\sum_{j=1}^{p}X_{ij}\beta_{j}=\bf{x}_{i}^{T}\boldsymbol{\beta}$ So you get:
$$\sum_{i=1}^{N}X_{ik}Y_{i}-\sum_{i=1}^{N}X_{ik}\bf{x}_{i}^{T}\boldsymbol{\beta}=0$$
Now we have $p$ of these equations, and we will "stack them" in a column vector. Notice how $X_{ik}$ is the only term which depends on $k$, so we can stack this into the vector $\bf{x}_{i}$ and we get:
$$\sum_{i=1}^{N}\bf{x}_{i}\rm{Y}_{i}=\sum_{i=1}^{N}\bf{x}_{i}\bf{x}_{i}^{T}\boldsymbol{\beta}$$
Now we can take the beta outside the sum (but must stay on RHS of sum), and then take the invervse:
$$\left(\sum_{i=1}^{N}\bf{x}_{i}\bf{x}_{i}^{T}\right)^{-1}\sum_{i=1}^{N}\bf{x}_{i}\rm{Y}_{i}=\boldsymbol{\beta}$$ | Analytical solution to linear-regression coefficient estimates
One way which may help you understand is to not use matrix algebra, and differentiate with each respect to each component, and then "store" the results in a column vector. So we have:
$$\frac{\partia |
27,018 | Can RMSE and MAE have the same value? | Yes, in theory. The simplest case I can imagine is a dataset where all the prediction errors (i.e. residuals) are exactly $\pm$1. RMSE and MAE will return identical values of 1. One can construct other scenarios too, but none seem very likely.
EDIT: Thanks to @DilipSarwate for pointing out (further elaborated upon by @user20160 in their excellent answer) that this result is possible if and only if the absolute values of all prediction errors are identical. There is nothing special about the value $\pm$1 in my example, in other words; any other number would work instead of 1. | Can RMSE and MAE have the same value? | Yes, in theory. The simplest case I can imagine is a dataset where all the prediction errors (i.e. residuals) are exactly $\pm$1. RMSE and MAE will return identical values of 1. One can construct othe | Can RMSE and MAE have the same value?
Yes, in theory. The simplest case I can imagine is a dataset where all the prediction errors (i.e. residuals) are exactly $\pm$1. RMSE and MAE will return identical values of 1. One can construct other scenarios too, but none seem very likely.
EDIT: Thanks to @DilipSarwate for pointing out (further elaborated upon by @user20160 in their excellent answer) that this result is possible if and only if the absolute values of all prediction errors are identical. There is nothing special about the value $\pm$1 in my example, in other words; any other number would work instead of 1. | Can RMSE and MAE have the same value?
Yes, in theory. The simplest case I can imagine is a dataset where all the prediction errors (i.e. residuals) are exactly $\pm$1. RMSE and MAE will return identical values of 1. One can construct othe |
27,019 | Can RMSE and MAE have the same value? | The mean absolute error (MAE) can equal the mean squared error (MSE) or root mean squared error (RMSE) under certain conditions, which I'll show below. These conditions are unlikely to occur in practice.
Preliminaries
Let $r_i = |y_i - \hat{y}_i|$ denote the absolute value of the residual for the $i$th data point, and let $r = [r_i, \dots, r_n]^T$ be a vector containing absolute residuals for all $n$ points in the dataset. Letting $\vec{1}$ denote a $n \times 1$ vector of ones, the MAE, MSE, and RMSE can be written as:
$$MAE = \frac{1}{n} \vec{1}^T r \quad
MSE = \frac{1}{n} r^T r \quad
RMSE = \sqrt{\frac{1}{n} r^T r}
\tag{1}$$
MSE
Setting the MSE equal to the MAE and rearranging gives:
$$(r - \vec{1})^T r = 0 \tag{2}$$
The MSE and MAE are equal for all datasets where the absolute residuals solve the above equation. Two obvious solutions are: $r = \vec{0}$ (there's zero error) and $r = \vec{1}$ (the residuals are all $\pm 1$, as mkt mentioned). But, there are infinitely many solutions.
We can interpret equation $(2)$ geometrically as follows: The LHS is the dot product of $r-\vec{1}$ and $r$. Zero dot product implies orthogonality. So, the MSE and MAE are equal if subtracting 1 from each absolute residual gives a vector that's orthogonal to the original absolute residuals.
Furthermore, by completing the square, equation $(2)$ can be rewritten as:
$$\Big( r-\frac{1}{2} \vec{1} \Big)^T \Big( r-\frac{1}{2} \vec{1} \Big)
= \frac{n}{4} \tag{3}$$
This equation describes an $n$-dimensional sphere centered at $[\frac{1}{2}, \dots, \frac{1}{2}]^T$ with radius $\frac{1}{2} \sqrt{n}$. The MSE and MAE are equal if and only if the absolute residuals lie on the surface of this hypersphere.
RMSE
Setting the RMSE equal to the MAE and rearranging gives:
$$r^T A r = 0 \tag{4}$$
$$A = (n I - \vec{1} \vec{1}^T)$$
where $I$ is the identity matrix. The solution set is the null space of $A$; that is, the set of all $r$ such that $A r = \vec{0}$. To find the null space, note that $A$ is a $n \times n$ matrix with diagonal elements equal to $n-1$ and all other elements equal to $-1$. The statement $A r = \vec{0}$ corresponds to the system of equations:
$$(n-1) r_i - \sum_{j \ne i} r_j = 0 \quad \forall i \tag{5}$$
Or, rearranging things:
$$r_i = \frac{1}{n-1}\sum_{j \ne i} r_j \quad \forall i \tag{6}$$
That is, every element $r_i$ must equal the mean of the other elements. The only way to satisfy this requirement is for all elements to be equal (this result can also be obtained by considering the eigendecomposition of $A$). Therefore, the solution set consists of all nonnegative vectors with identical entries:
$$\{r \mid r = c \vec{1} \enspace \forall c \ge 0\}$$
So, the RMSE and MAE are equal if and only if the absolute values of the residuals are equal for all data points. | Can RMSE and MAE have the same value? | The mean absolute error (MAE) can equal the mean squared error (MSE) or root mean squared error (RMSE) under certain conditions, which I'll show below. These conditions are unlikely to occur in practi | Can RMSE and MAE have the same value?
The mean absolute error (MAE) can equal the mean squared error (MSE) or root mean squared error (RMSE) under certain conditions, which I'll show below. These conditions are unlikely to occur in practice.
Preliminaries
Let $r_i = |y_i - \hat{y}_i|$ denote the absolute value of the residual for the $i$th data point, and let $r = [r_i, \dots, r_n]^T$ be a vector containing absolute residuals for all $n$ points in the dataset. Letting $\vec{1}$ denote a $n \times 1$ vector of ones, the MAE, MSE, and RMSE can be written as:
$$MAE = \frac{1}{n} \vec{1}^T r \quad
MSE = \frac{1}{n} r^T r \quad
RMSE = \sqrt{\frac{1}{n} r^T r}
\tag{1}$$
MSE
Setting the MSE equal to the MAE and rearranging gives:
$$(r - \vec{1})^T r = 0 \tag{2}$$
The MSE and MAE are equal for all datasets where the absolute residuals solve the above equation. Two obvious solutions are: $r = \vec{0}$ (there's zero error) and $r = \vec{1}$ (the residuals are all $\pm 1$, as mkt mentioned). But, there are infinitely many solutions.
We can interpret equation $(2)$ geometrically as follows: The LHS is the dot product of $r-\vec{1}$ and $r$. Zero dot product implies orthogonality. So, the MSE and MAE are equal if subtracting 1 from each absolute residual gives a vector that's orthogonal to the original absolute residuals.
Furthermore, by completing the square, equation $(2)$ can be rewritten as:
$$\Big( r-\frac{1}{2} \vec{1} \Big)^T \Big( r-\frac{1}{2} \vec{1} \Big)
= \frac{n}{4} \tag{3}$$
This equation describes an $n$-dimensional sphere centered at $[\frac{1}{2}, \dots, \frac{1}{2}]^T$ with radius $\frac{1}{2} \sqrt{n}$. The MSE and MAE are equal if and only if the absolute residuals lie on the surface of this hypersphere.
RMSE
Setting the RMSE equal to the MAE and rearranging gives:
$$r^T A r = 0 \tag{4}$$
$$A = (n I - \vec{1} \vec{1}^T)$$
where $I$ is the identity matrix. The solution set is the null space of $A$; that is, the set of all $r$ such that $A r = \vec{0}$. To find the null space, note that $A$ is a $n \times n$ matrix with diagonal elements equal to $n-1$ and all other elements equal to $-1$. The statement $A r = \vec{0}$ corresponds to the system of equations:
$$(n-1) r_i - \sum_{j \ne i} r_j = 0 \quad \forall i \tag{5}$$
Or, rearranging things:
$$r_i = \frac{1}{n-1}\sum_{j \ne i} r_j \quad \forall i \tag{6}$$
That is, every element $r_i$ must equal the mean of the other elements. The only way to satisfy this requirement is for all elements to be equal (this result can also be obtained by considering the eigendecomposition of $A$). Therefore, the solution set consists of all nonnegative vectors with identical entries:
$$\{r \mid r = c \vec{1} \enspace \forall c \ge 0\}$$
So, the RMSE and MAE are equal if and only if the absolute values of the residuals are equal for all data points. | Can RMSE and MAE have the same value?
The mean absolute error (MAE) can equal the mean squared error (MSE) or root mean squared error (RMSE) under certain conditions, which I'll show below. These conditions are unlikely to occur in practi |
27,020 | What is the interpretation of interquartile range? | From definition, this defines the range witch holds 75-25=50 per cent of all measured values.
: (median-24/2,median+24/2). Median should be written somewhere near this IQR.
The above was false of course, it seems I was still sleeping when writing this; sorry for confusion. It is true that IQR is width of a range which holds 50% of data, but it is not centered in median -- one needs to know both Q1 and Q3 to localize this range.
In general IQR can be seen as a nonparametric (=when we don't assume that the distribution is Gaussian) equivalent to standard deviation -- both measure spread of the data. (Equivalent not equal, for SD, (mean-$\sigma$,mean+$\sigma$) holds 68.2% of perfectly normally distributed data).
EDIT: As for example, this is how it looks on normal data; red lines show $\pm 1\sigma$, the range showed by the box on box plot shows IQR, the histogram shows the data itself:
you can see both show spread pretty good; $\pm 1\sigma$ range holds 68.3% of data (as expected). Now for non-normal data
the SD spread is widened due to long, asymmetric tail and $\pm 1\sigma$ holds 90.5% of data! (IQR holds 50% in both cases by definition) | What is the interpretation of interquartile range? | From definition, this defines the range witch holds 75-25=50 per cent of all measured values.
: (median-24/2,median+24/2). Median should be written somewhere near this IQR.
The above was false of cour | What is the interpretation of interquartile range?
From definition, this defines the range witch holds 75-25=50 per cent of all measured values.
: (median-24/2,median+24/2). Median should be written somewhere near this IQR.
The above was false of course, it seems I was still sleeping when writing this; sorry for confusion. It is true that IQR is width of a range which holds 50% of data, but it is not centered in median -- one needs to know both Q1 and Q3 to localize this range.
In general IQR can be seen as a nonparametric (=when we don't assume that the distribution is Gaussian) equivalent to standard deviation -- both measure spread of the data. (Equivalent not equal, for SD, (mean-$\sigma$,mean+$\sigma$) holds 68.2% of perfectly normally distributed data).
EDIT: As for example, this is how it looks on normal data; red lines show $\pm 1\sigma$, the range showed by the box on box plot shows IQR, the histogram shows the data itself:
you can see both show spread pretty good; $\pm 1\sigma$ range holds 68.3% of data (as expected). Now for non-normal data
the SD spread is widened due to long, asymmetric tail and $\pm 1\sigma$ holds 90.5% of data! (IQR holds 50% in both cases by definition) | What is the interpretation of interquartile range?
From definition, this defines the range witch holds 75-25=50 per cent of all measured values.
: (median-24/2,median+24/2). Median should be written somewhere near this IQR.
The above was false of cour |
27,021 | What is the interpretation of interquartile range? | This is a simple question asking for a simple answer. Here is a list of statements, starting with the most basic, and proceeding with more precise qualifications.
The IQR is the spread of the middle half of the data.
Without making assumptions about how the data are distributed, the IQR quantifies the amount by which individual values typically vary.
The IQR is related to the well-known "standard deviation" (SD): when the data follow a "bell curve," the IQR is about 35% greater than the SD. (Equivalently, the SD is about three-quarters of the IQR.)
As a rule of thumb, data values that deviate from the middle value by more than twice the IQR deserve individual attention. They are called "outliers." Data values that deviate from the middle value by more than 3.5 times the IQR are usually scrutinized closely. They are sometimes called "far outliers." | What is the interpretation of interquartile range? | This is a simple question asking for a simple answer. Here is a list of statements, starting with the most basic, and proceeding with more precise qualifications.
The IQR is the spread of the middle | What is the interpretation of interquartile range?
This is a simple question asking for a simple answer. Here is a list of statements, starting with the most basic, and proceeding with more precise qualifications.
The IQR is the spread of the middle half of the data.
Without making assumptions about how the data are distributed, the IQR quantifies the amount by which individual values typically vary.
The IQR is related to the well-known "standard deviation" (SD): when the data follow a "bell curve," the IQR is about 35% greater than the SD. (Equivalently, the SD is about three-quarters of the IQR.)
As a rule of thumb, data values that deviate from the middle value by more than twice the IQR deserve individual attention. They are called "outliers." Data values that deviate from the middle value by more than 3.5 times the IQR are usually scrutinized closely. They are sometimes called "far outliers." | What is the interpretation of interquartile range?
This is a simple question asking for a simple answer. Here is a list of statements, starting with the most basic, and proceeding with more precise qualifications.
The IQR is the spread of the middle |
27,022 | What is the interpretation of interquartile range? | The interquartile range is an interval, not a scalar. You should always report both numbers, not just the difference between them. You can then explain it by saying that half the sample readings were between these two values, a quarter were smaller than the lower quartile, and a quarter higher than the upper quartile. | What is the interpretation of interquartile range? | The interquartile range is an interval, not a scalar. You should always report both numbers, not just the difference between them. You can then explain it by saying that half the sample readings were | What is the interpretation of interquartile range?
The interquartile range is an interval, not a scalar. You should always report both numbers, not just the difference between them. You can then explain it by saying that half the sample readings were between these two values, a quarter were smaller than the lower quartile, and a quarter higher than the upper quartile. | What is the interpretation of interquartile range?
The interquartile range is an interval, not a scalar. You should always report both numbers, not just the difference between them. You can then explain it by saying that half the sample readings were |
27,023 | What is the interpretation of interquartile range? | Roughly speaking, I would say to a journalist that I could declare the daily level of nitrogen dioxide being sure, after discarding the highest values and the lowest values, that in each one of one-half of the days in that year the observed value is not beyond a distance of IQR/2 from the declared level.
For example, if your first quartile and third quartile are 100 and 124, you could say that daily level is 112 (average of 100 and 124) and assure your interlocutor that in half of the days the error you make isn't greater than 12. | What is the interpretation of interquartile range? | Roughly speaking, I would say to a journalist that I could declare the daily level of nitrogen dioxide being sure, after discarding the highest values and the lowest values, that in each one of one-ha | What is the interpretation of interquartile range?
Roughly speaking, I would say to a journalist that I could declare the daily level of nitrogen dioxide being sure, after discarding the highest values and the lowest values, that in each one of one-half of the days in that year the observed value is not beyond a distance of IQR/2 from the declared level.
For example, if your first quartile and third quartile are 100 and 124, you could say that daily level is 112 (average of 100 and 124) and assure your interlocutor that in half of the days the error you make isn't greater than 12. | What is the interpretation of interquartile range?
Roughly speaking, I would say to a journalist that I could declare the daily level of nitrogen dioxide being sure, after discarding the highest values and the lowest values, that in each one of one-ha |
27,024 | Why is the denominator in a conditional probability the probability of the conditioning event? | In your tree diagram, if you want to know the probability $P(B+|A+)$ Then you completely ignore the $A-$ section, since you know that that does not occur. So the probability of $B+$ given that $A+$ occurred is the count of the ways $A+B+$ can occur divided by the total number of ways that $A+$ can occur, that is the combination of $A+B+$ and $A+B-$, which together is $A+$, so you would need to divide by the count (or probability) of $A+$ happening.
It might be easier to think of actual events that you can count the ways it happens.
One example:
Roll a fair die (possible outcomes are 1, 2, 3, 4, 5, 6)
A is the event that the roll is greater than 3 (4, 5, 6)
B is the event that an odd number was rolled (1, 3, 5)
So the probability of A and B is $\frac16$ since 5 is the only number that matches,
but if we know that A happened, then $P(B|A) = \frac13$ since we know that the outcome was 4, 5, or 6. We can get there by counting (1 out of 3 possibilities) or by the math with probabilities $\frac16$ divided by $\frac12$. If you do not divide by what you are conditioning on, then you are looking at the joint probability, not the conditional probability. Also think about the Venn diagram. You need to divide by the area of the circle that you are conditioning on so that the total area of the sum of the conditional probabilities is 1. | Why is the denominator in a conditional probability the probability of the conditioning event? | In your tree diagram, if you want to know the probability $P(B+|A+)$ Then you completely ignore the $A-$ section, since you know that that does not occur. So the probability of $B+$ given that $A+$ | Why is the denominator in a conditional probability the probability of the conditioning event?
In your tree diagram, if you want to know the probability $P(B+|A+)$ Then you completely ignore the $A-$ section, since you know that that does not occur. So the probability of $B+$ given that $A+$ occurred is the count of the ways $A+B+$ can occur divided by the total number of ways that $A+$ can occur, that is the combination of $A+B+$ and $A+B-$, which together is $A+$, so you would need to divide by the count (or probability) of $A+$ happening.
It might be easier to think of actual events that you can count the ways it happens.
One example:
Roll a fair die (possible outcomes are 1, 2, 3, 4, 5, 6)
A is the event that the roll is greater than 3 (4, 5, 6)
B is the event that an odd number was rolled (1, 3, 5)
So the probability of A and B is $\frac16$ since 5 is the only number that matches,
but if we know that A happened, then $P(B|A) = \frac13$ since we know that the outcome was 4, 5, or 6. We can get there by counting (1 out of 3 possibilities) or by the math with probabilities $\frac16$ divided by $\frac12$. If you do not divide by what you are conditioning on, then you are looking at the joint probability, not the conditional probability. Also think about the Venn diagram. You need to divide by the area of the circle that you are conditioning on so that the total area of the sum of the conditional probabilities is 1. | Why is the denominator in a conditional probability the probability of the conditioning event?
In your tree diagram, if you want to know the probability $P(B+|A+)$ Then you completely ignore the $A-$ section, since you know that that does not occur. So the probability of $B+$ given that $A+$ |
27,025 | Why is the denominator in a conditional probability the probability of the conditioning event? | The tickets-in-a-box model provides a helpful picture. It makes the formula for conditional probability immediate and obvious.
Let $\mathcal{A}$ and $\mathcal{B}$ designate events: collections of types of tickets. (That is, whenever a ticket for a particular outcome is in an event, all the tickets for that outcome must be in the event.) Recall that the probability of $\mathcal A$ is defined as the proportion of tickets of type $\mathcal A$ in the box. It is a ratio of that ticket count to the count of all tickets in the box $\Omega.$ (Some people insist all probabilities are conditional and to emphasize this would write the probability as $\Pr(\mathcal A\mid \Omega).$)
If we were to remove all tickets not of type $\mathcal{B},$ we would still have a box with tickets -- all of type $\mathcal B,$ obviously. Assuming some tickets remain (that is, $\mathcal{B}$ is not empty), this is still a tickets-in-a-box model.
The selective removal can alter the relative proportions of $\mathcal A$ among the remaining tickets. The new proportion of tickets of type $\mathcal{A}$ is their probability when $\mathcal B$ is viewed as the "box" -- the sample space. It is called the conditional probability of $\mathcal{A},$ conditional on $\mathcal{B},$ and is written $\Pr{\left(\mathcal{A}\mid\mathcal{B}\right)}.$
In this Venn diagram, areas (relative to the total area of the rectangle $\Omega$ representing the whole probability space) represent probabilities. It looks like both the events $\mathcal{A}$ and $\mathcal{B}$ have probabilities around $1/3$ each. But when all non-$\mathcal{B}$ points are removed, the new sample space is $\mathcal{B}$ itself and the portion of $\mathcal{A}$ within it is tiny – just the sliver of space where the circles intersect, as a proportion of the area of the circle representing $\mathcal{B}.$ In this example $\Pr{\left(\mathcal{A}\right)}\approx1/3$ but $\Pr{\left(\mathcal{A}\mid\mathcal{B}\right)}\approx1/100,$ exemplifying how dramatically the conditioning on $\mathcal B$ can change the probabilities.
It should be apparent that (a) this construction works provided $\mathcal{B}$ does not have zero probability and (b) in that case, the new relative area of $\mathcal A$ is
$$Pr{\left(\mathcal{A}\mid\mathcal{B}\right)=}\frac{\Pr{\left(\mathcal{A}\cap\mathcal{B}\right\}}}{\Pr{\left(\mathcal{B}\right)}}.$$
The tree diagram is merely another way to (partially) represent the Venn diagram. Branching at $\mathcal A$ corresponds to slicing everything in $\Omega$ into outcomes in $\mathcal A$ and outcomes not in $\mathcal A;$ likewise, branching at $\mathcal B$ slices everything by $\mathcal B.$
In your diagram you condition on $\mathcal A.$ This means removing everything from the tree that is outside $\mathcal A.$ Afterwards, only two leaves remain: everything in $\mathcal A$ and in $\mathcal B$ ($\mathcal A \cap \mathcal B$) and everything in $\mathcal A$ and not in $\mathcal B$ ($\mathcal A \cap (\Omega \setminus \mathcal B)$). Those leaves represent all the tickets remaining in the box. Trees are usually decorated with probabilities permitting you to compute the relative proportions of those leaves.
Translating between different ways of visualizing the same thing is a useful skill because some visualizations support specific concepts or calculations especially well, and others shine in other areas. | Why is the denominator in a conditional probability the probability of the conditioning event? | The tickets-in-a-box model provides a helpful picture. It makes the formula for conditional probability immediate and obvious.
Let $\mathcal{A}$ and $\mathcal{B}$ designate events: collections of typ | Why is the denominator in a conditional probability the probability of the conditioning event?
The tickets-in-a-box model provides a helpful picture. It makes the formula for conditional probability immediate and obvious.
Let $\mathcal{A}$ and $\mathcal{B}$ designate events: collections of types of tickets. (That is, whenever a ticket for a particular outcome is in an event, all the tickets for that outcome must be in the event.) Recall that the probability of $\mathcal A$ is defined as the proportion of tickets of type $\mathcal A$ in the box. It is a ratio of that ticket count to the count of all tickets in the box $\Omega.$ (Some people insist all probabilities are conditional and to emphasize this would write the probability as $\Pr(\mathcal A\mid \Omega).$)
If we were to remove all tickets not of type $\mathcal{B},$ we would still have a box with tickets -- all of type $\mathcal B,$ obviously. Assuming some tickets remain (that is, $\mathcal{B}$ is not empty), this is still a tickets-in-a-box model.
The selective removal can alter the relative proportions of $\mathcal A$ among the remaining tickets. The new proportion of tickets of type $\mathcal{A}$ is their probability when $\mathcal B$ is viewed as the "box" -- the sample space. It is called the conditional probability of $\mathcal{A},$ conditional on $\mathcal{B},$ and is written $\Pr{\left(\mathcal{A}\mid\mathcal{B}\right)}.$
In this Venn diagram, areas (relative to the total area of the rectangle $\Omega$ representing the whole probability space) represent probabilities. It looks like both the events $\mathcal{A}$ and $\mathcal{B}$ have probabilities around $1/3$ each. But when all non-$\mathcal{B}$ points are removed, the new sample space is $\mathcal{B}$ itself and the portion of $\mathcal{A}$ within it is tiny – just the sliver of space where the circles intersect, as a proportion of the area of the circle representing $\mathcal{B}.$ In this example $\Pr{\left(\mathcal{A}\right)}\approx1/3$ but $\Pr{\left(\mathcal{A}\mid\mathcal{B}\right)}\approx1/100,$ exemplifying how dramatically the conditioning on $\mathcal B$ can change the probabilities.
It should be apparent that (a) this construction works provided $\mathcal{B}$ does not have zero probability and (b) in that case, the new relative area of $\mathcal A$ is
$$Pr{\left(\mathcal{A}\mid\mathcal{B}\right)=}\frac{\Pr{\left(\mathcal{A}\cap\mathcal{B}\right\}}}{\Pr{\left(\mathcal{B}\right)}}.$$
The tree diagram is merely another way to (partially) represent the Venn diagram. Branching at $\mathcal A$ corresponds to slicing everything in $\Omega$ into outcomes in $\mathcal A$ and outcomes not in $\mathcal A;$ likewise, branching at $\mathcal B$ slices everything by $\mathcal B.$
In your diagram you condition on $\mathcal A.$ This means removing everything from the tree that is outside $\mathcal A.$ Afterwards, only two leaves remain: everything in $\mathcal A$ and in $\mathcal B$ ($\mathcal A \cap \mathcal B$) and everything in $\mathcal A$ and not in $\mathcal B$ ($\mathcal A \cap (\Omega \setminus \mathcal B)$). Those leaves represent all the tickets remaining in the box. Trees are usually decorated with probabilities permitting you to compute the relative proportions of those leaves.
Translating between different ways of visualizing the same thing is a useful skill because some visualizations support specific concepts or calculations especially well, and others shine in other areas. | Why is the denominator in a conditional probability the probability of the conditioning event?
The tickets-in-a-box model provides a helpful picture. It makes the formula for conditional probability immediate and obvious.
Let $\mathcal{A}$ and $\mathcal{B}$ designate events: collections of typ |
27,026 | Why is the denominator in a conditional probability the probability of the conditioning event? | $$
P(A \cap B) = P(A \cap B) \\
P(A | B) P(B) = P(A \cap B) \\
P(A|B) = \frac{P(A \cap B)}{P(B)}
$$ | Why is the denominator in a conditional probability the probability of the conditioning event? | $$
P(A \cap B) = P(A \cap B) \\
P(A | B) P(B) = P(A \cap B) \\
P(A|B) = \frac{P(A \cap B)}{P(B)}
$$ | Why is the denominator in a conditional probability the probability of the conditioning event?
$$
P(A \cap B) = P(A \cap B) \\
P(A | B) P(B) = P(A \cap B) \\
P(A|B) = \frac{P(A \cap B)}{P(B)}
$$ | Why is the denominator in a conditional probability the probability of the conditioning event?
$$
P(A \cap B) = P(A \cap B) \\
P(A | B) P(B) = P(A \cap B) \\
P(A|B) = \frac{P(A \cap B)}{P(B)}
$$ |
27,027 | Why is the denominator in a conditional probability the probability of the conditioning event? | Sycorax has answered it nicely. But let me leave behind an intuitive set up that articulates the genesis of the concept.
Start with the very familiar experiment: throwing a die. Let $A:=\{\text{odd number appears}\}, ~ B:=\{\text{a digit smaller than or equal three appears}\}.$ One might wonder what the probability would be of $A$ had it already been assured that $B $ was realised.
Construct the probability space $(\Omega, \mathcal A, \mathbb P) ,$ with $\Omega= \{1, 2,3,4,5,6\}, ~\mathcal A= 2^\Omega$ and $\mathbb P$ being the discrete uniform distribution on $\Omega.$ Naturally $A=\{1, 3,5\}, ~B=\{1, 2,3\}.$ If $B$ has indeed occurred, then it is plausible to assume the uniform distribution on the remaining possible outcomes, i.e. $\{1,2,3\}.$ For assessing the new situation, define a new probability measure $\mathbb P_B$ on $(B, 2^B) $ by
$$ \mathbb P_B[C]:= \frac{\#C}{\#B}, ~C\subset B;$$ natural extension would be to assign probability $0$ on $\Omega\setminus B$ as
$$\mathbb P[C|B]:= \mathbb P_B[C\cap B]:= \frac{\#(C\cap B) }{\#B}, ~C\subset \Omega.$$
In that case $\mathbb P[A|B] =\frac{\# \{1,3\}}{\#\{1,2,3\}} = \frac23.$ This is different from $\mathbb P[A]=\frac12.$
This prompts us to define the conditional probability for any $B\in \mathcal A$ as a new probability measure $\mathbb P[\cdot|B]$ on the space $(\Omega, \mathcal A)$ for $\mathbb P[B] > 0$ as
$$ \mathbb P[A|B] =\begin{cases}\frac{\mathbb P[A\cap B]}{\mathbb P[B]},~~ \mathbb P[B] > 0\\ 0 ,~~~~~~~~~~~\textrm{otherwise}\end{cases}.$$
Reference
Probability Theory: A Comprehensive Course, Achim Klenke, Springer, 2014.
After edit of OP:
As the definition developed above, that $A^+$ has occured provides new information has been incorporated by dividing by $\mathbb P[A^+].$ | Why is the denominator in a conditional probability the probability of the conditioning event? | Sycorax has answered it nicely. But let me leave behind an intuitive set up that articulates the genesis of the concept.
Start with the very familiar experiment: throwing a die. Let $A:=\{\text{odd n | Why is the denominator in a conditional probability the probability of the conditioning event?
Sycorax has answered it nicely. But let me leave behind an intuitive set up that articulates the genesis of the concept.
Start with the very familiar experiment: throwing a die. Let $A:=\{\text{odd number appears}\}, ~ B:=\{\text{a digit smaller than or equal three appears}\}.$ One might wonder what the probability would be of $A$ had it already been assured that $B $ was realised.
Construct the probability space $(\Omega, \mathcal A, \mathbb P) ,$ with $\Omega= \{1, 2,3,4,5,6\}, ~\mathcal A= 2^\Omega$ and $\mathbb P$ being the discrete uniform distribution on $\Omega.$ Naturally $A=\{1, 3,5\}, ~B=\{1, 2,3\}.$ If $B$ has indeed occurred, then it is plausible to assume the uniform distribution on the remaining possible outcomes, i.e. $\{1,2,3\}.$ For assessing the new situation, define a new probability measure $\mathbb P_B$ on $(B, 2^B) $ by
$$ \mathbb P_B[C]:= \frac{\#C}{\#B}, ~C\subset B;$$ natural extension would be to assign probability $0$ on $\Omega\setminus B$ as
$$\mathbb P[C|B]:= \mathbb P_B[C\cap B]:= \frac{\#(C\cap B) }{\#B}, ~C\subset \Omega.$$
In that case $\mathbb P[A|B] =\frac{\# \{1,3\}}{\#\{1,2,3\}} = \frac23.$ This is different from $\mathbb P[A]=\frac12.$
This prompts us to define the conditional probability for any $B\in \mathcal A$ as a new probability measure $\mathbb P[\cdot|B]$ on the space $(\Omega, \mathcal A)$ for $\mathbb P[B] > 0$ as
$$ \mathbb P[A|B] =\begin{cases}\frac{\mathbb P[A\cap B]}{\mathbb P[B]},~~ \mathbb P[B] > 0\\ 0 ,~~~~~~~~~~~\textrm{otherwise}\end{cases}.$$
Reference
Probability Theory: A Comprehensive Course, Achim Klenke, Springer, 2014.
After edit of OP:
As the definition developed above, that $A^+$ has occured provides new information has been incorporated by dividing by $\mathbb P[A^+].$ | Why is the denominator in a conditional probability the probability of the conditioning event?
Sycorax has answered it nicely. But let me leave behind an intuitive set up that articulates the genesis of the concept.
Start with the very familiar experiment: throwing a die. Let $A:=\{\text{odd n |
27,028 | Why is the denominator in a conditional probability the probability of the conditioning event? | A more intuitive way to understand is to know that conditioning on an event with strictly positive probability defines a new probability measure.
So instead of looking at the bigger picture (the original sample space, say $X$), we are now restricting to a possibly much smaller sample space (which is $B$ in your case). The intersection $A \cap B$ will be smaller in probability with $X$ being the sample space, but larger when we take the $B$ to be the whole sample space. So we adjust for restricting to a smaller sample space by enlarging the probability of the intersection $A\cap B$. This normalizing process is done by dividing by $\mathbb{P}(B)$. Which is easy to understand, we are thus calculating the relative area of $A\cap B$ with respect to $B$, instead of $X$.
You can also view $\mathbb{P}(A)$ as a conditional probability by noting that $$ \mathbb{P}(A)=\mathbb{P}(A\cap X) = \dfrac{\mathbb{P}(A\cap X)}{\mathbb{P}(X)},$$ where $\mathbb{P}(X)=1$. | Why is the denominator in a conditional probability the probability of the conditioning event? | A more intuitive way to understand is to know that conditioning on an event with strictly positive probability defines a new probability measure.
So instead of looking at the bigger picture (the origi | Why is the denominator in a conditional probability the probability of the conditioning event?
A more intuitive way to understand is to know that conditioning on an event with strictly positive probability defines a new probability measure.
So instead of looking at the bigger picture (the original sample space, say $X$), we are now restricting to a possibly much smaller sample space (which is $B$ in your case). The intersection $A \cap B$ will be smaller in probability with $X$ being the sample space, but larger when we take the $B$ to be the whole sample space. So we adjust for restricting to a smaller sample space by enlarging the probability of the intersection $A\cap B$. This normalizing process is done by dividing by $\mathbb{P}(B)$. Which is easy to understand, we are thus calculating the relative area of $A\cap B$ with respect to $B$, instead of $X$.
You can also view $\mathbb{P}(A)$ as a conditional probability by noting that $$ \mathbb{P}(A)=\mathbb{P}(A\cap X) = \dfrac{\mathbb{P}(A\cap X)}{\mathbb{P}(X)},$$ where $\mathbb{P}(X)=1$. | Why is the denominator in a conditional probability the probability of the conditioning event?
A more intuitive way to understand is to know that conditioning on an event with strictly positive probability defines a new probability measure.
So instead of looking at the bigger picture (the origi |
27,029 | Why is the denominator in a conditional probability the probability of the conditioning event? | First of all, I disagree with the picture. Blue set does not refer to $P(A)$ but $P(A\cap B')$. Green set refers to $P(B\cap A')$.
Back to the question: Why
$$
P(B^+|A^+)=\frac{P(B^+\cap A^+)}{P(A^+)}?
$$
We can understand it by saying $P(B^+|A^+)$ as the probability that event $B^+$ happening given that event $A^+$ happened.
It means that, if I you have information that $A^+$ has happened,
you must make sure that both events happened at the same time. Hence, you have $P(B^+\cap A^+)$.
your answers must be with respect to the event $A^+$. Your answers are constrained to event $A^+$. Hence, you have a ratio to $P(A^+)$.
As an example, let $A^+$ be the event someone goes outside to play and $B^+$ be the event that someone will come home after 6pm. If you know that someone has already went outside to play, what is their probability to come home after 6pm? You already know that $A^+$ happened, so you will have
that person went outside to play AND that person will come home after 6pm.
that the probability above happened with respect to that person will come home after 6pm. | Why is the denominator in a conditional probability the probability of the conditioning event? | First of all, I disagree with the picture. Blue set does not refer to $P(A)$ but $P(A\cap B')$. Green set refers to $P(B\cap A')$.
Back to the question: Why
$$
P(B^+|A^+)=\frac{P(B^+\cap A^+)}{P(A^+)} | Why is the denominator in a conditional probability the probability of the conditioning event?
First of all, I disagree with the picture. Blue set does not refer to $P(A)$ but $P(A\cap B')$. Green set refers to $P(B\cap A')$.
Back to the question: Why
$$
P(B^+|A^+)=\frac{P(B^+\cap A^+)}{P(A^+)}?
$$
We can understand it by saying $P(B^+|A^+)$ as the probability that event $B^+$ happening given that event $A^+$ happened.
It means that, if I you have information that $A^+$ has happened,
you must make sure that both events happened at the same time. Hence, you have $P(B^+\cap A^+)$.
your answers must be with respect to the event $A^+$. Your answers are constrained to event $A^+$. Hence, you have a ratio to $P(A^+)$.
As an example, let $A^+$ be the event someone goes outside to play and $B^+$ be the event that someone will come home after 6pm. If you know that someone has already went outside to play, what is their probability to come home after 6pm? You already know that $A^+$ happened, so you will have
that person went outside to play AND that person will come home after 6pm.
that the probability above happened with respect to that person will come home after 6pm. | Why is the denominator in a conditional probability the probability of the conditioning event?
First of all, I disagree with the picture. Blue set does not refer to $P(A)$ but $P(A\cap B')$. Green set refers to $P(B\cap A')$.
Back to the question: Why
$$
P(B^+|A^+)=\frac{P(B^+\cap A^+)}{P(A^+)} |
27,030 | Why is the denominator in a conditional probability the probability of the conditioning event? | Intuitive, hand-wavey explanation that I feel is lacking here. (This argument works 100% fine in the case of uniform probability with a finite number of outcomes, such throwing a fair die, or picking cards from a well-shuffled deck, but to work more generally it would need some rephrasing.)
The first probability formula you learn is
$$
P(\text{Something}) = \frac{\text{Number of outcomes where Something happens}}{\text{Total number of relevant outcomes}}
$$
We are going to use this three times.
First off, the probability $P(B^+\mid A^+)$ is given by
$$
P(B^+\mid A^+) = \frac{\text{Number of outcomes where }B^+\text{ and } A^+\text{ happen}}{\text{Number of outcomes where }A^+\text{ happens}}
$$
Now we divide numerator and denominator by the total number of outcomes. This does not change the value of the fraction:
$$
= \frac{\text{Number of outcomes where }B^+\text{ and } A^+\text{ happen}/\text{Total number of outcomes}}{\text{Number of outcomes where }A^+\text{ happens}/\text{Total number of outcomes}}
$$
Applying our basic probability formula again, to numerator and denominator separately, we do indeed get
$$
= \frac{P(A^+\cap B^+)}{P(A^+)}
$$ | Why is the denominator in a conditional probability the probability of the conditioning event? | Intuitive, hand-wavey explanation that I feel is lacking here. (This argument works 100% fine in the case of uniform probability with a finite number of outcomes, such throwing a fair die, or picking | Why is the denominator in a conditional probability the probability of the conditioning event?
Intuitive, hand-wavey explanation that I feel is lacking here. (This argument works 100% fine in the case of uniform probability with a finite number of outcomes, such throwing a fair die, or picking cards from a well-shuffled deck, but to work more generally it would need some rephrasing.)
The first probability formula you learn is
$$
P(\text{Something}) = \frac{\text{Number of outcomes where Something happens}}{\text{Total number of relevant outcomes}}
$$
We are going to use this three times.
First off, the probability $P(B^+\mid A^+)$ is given by
$$
P(B^+\mid A^+) = \frac{\text{Number of outcomes where }B^+\text{ and } A^+\text{ happen}}{\text{Number of outcomes where }A^+\text{ happens}}
$$
Now we divide numerator and denominator by the total number of outcomes. This does not change the value of the fraction:
$$
= \frac{\text{Number of outcomes where }B^+\text{ and } A^+\text{ happen}/\text{Total number of outcomes}}{\text{Number of outcomes where }A^+\text{ happens}/\text{Total number of outcomes}}
$$
Applying our basic probability formula again, to numerator and denominator separately, we do indeed get
$$
= \frac{P(A^+\cap B^+)}{P(A^+)}
$$ | Why is the denominator in a conditional probability the probability of the conditioning event?
Intuitive, hand-wavey explanation that I feel is lacking here. (This argument works 100% fine in the case of uniform probability with a finite number of outcomes, such throwing a fair die, or picking |
27,031 | Expectation of random sum of non-random numbers | The expectation
$$
\mathbb E\left[\sum_{i=1}^{\lfloor\tau\rfloor} Y_i\right]=\mathbb E\left[\sum_{i=1}^{\infty} \mathbb I_{\tau\ge i} Y_i\right]$$simplifies into
$$Y_1\underbrace{\mathbb P(\tau\ge 1)}_{=1}+Y_2\mathbb P(\tau\ge 2)+\cdots+Y_N\underbrace{\mathbb P(\tau=N)}_{=0}$$
and since the $Y_i$'s are known, only the cdf of $\tau$ need be approximated by Monte Carlo, if I understand correctly, resulting in
$$Y_1+Y_2\hat{\mathbb P}(\tau\ge 2)+\cdots+Y_{N-1}\hat{\mathbb P}(\tau\ge N-1)$$
where $\hat{\mathbb P}$ denotes the empirical distribution. The magnitude / dimension of the $Y_i$'s thus does not impact the Monte Carlo effort. | Expectation of random sum of non-random numbers | The expectation
$$
\mathbb E\left[\sum_{i=1}^{\lfloor\tau\rfloor} Y_i\right]=\mathbb E\left[\sum_{i=1}^{\infty} \mathbb I_{\tau\ge i} Y_i\right]$$simplifies into
$$Y_1\underbrace{\mathbb P(\tau\ge 1)} | Expectation of random sum of non-random numbers
The expectation
$$
\mathbb E\left[\sum_{i=1}^{\lfloor\tau\rfloor} Y_i\right]=\mathbb E\left[\sum_{i=1}^{\infty} \mathbb I_{\tau\ge i} Y_i\right]$$simplifies into
$$Y_1\underbrace{\mathbb P(\tau\ge 1)}_{=1}+Y_2\mathbb P(\tau\ge 2)+\cdots+Y_N\underbrace{\mathbb P(\tau=N)}_{=0}$$
and since the $Y_i$'s are known, only the cdf of $\tau$ need be approximated by Monte Carlo, if I understand correctly, resulting in
$$Y_1+Y_2\hat{\mathbb P}(\tau\ge 2)+\cdots+Y_{N-1}\hat{\mathbb P}(\tau\ge N-1)$$
where $\hat{\mathbb P}$ denotes the empirical distribution. The magnitude / dimension of the $Y_i$'s thus does not impact the Monte Carlo effort. | Expectation of random sum of non-random numbers
The expectation
$$
\mathbb E\left[\sum_{i=1}^{\lfloor\tau\rfloor} Y_i\right]=\mathbb E\left[\sum_{i=1}^{\infty} \mathbb I_{\tau\ge i} Y_i\right]$$simplifies into
$$Y_1\underbrace{\mathbb P(\tau\ge 1)} |
27,032 | Expectation of random sum of non-random numbers | This approximation will definitely not work in general. Consider a $\tau$ with support on $(1,3)$ and $E(\lfloor\tau\rfloor)\in [1,2)$. Then
$$
\sum_{i=1}^{E(\lfloor \tau \rfloor)} Y_i = Y_1,
$$
but if $Y_2\to\infty$ and $\tau$ has any mass at all on $[2,3)$,
$$
E\left(\sum_{i=1}^{\lfloor \tau \rfloor} Y_i\right)\to\infty.
$$
You will need to include more information on the distribution of $\lfloor\tau\rfloor$ and the whole vector $Y$. | Expectation of random sum of non-random numbers | This approximation will definitely not work in general. Consider a $\tau$ with support on $(1,3)$ and $E(\lfloor\tau\rfloor)\in [1,2)$. Then
$$
\sum_{i=1}^{E(\lfloor \tau \rfloor)} Y_i = Y_1,
$$
but i | Expectation of random sum of non-random numbers
This approximation will definitely not work in general. Consider a $\tau$ with support on $(1,3)$ and $E(\lfloor\tau\rfloor)\in [1,2)$. Then
$$
\sum_{i=1}^{E(\lfloor \tau \rfloor)} Y_i = Y_1,
$$
but if $Y_2\to\infty$ and $\tau$ has any mass at all on $[2,3)$,
$$
E\left(\sum_{i=1}^{\lfloor \tau \rfloor} Y_i\right)\to\infty.
$$
You will need to include more information on the distribution of $\lfloor\tau\rfloor$ and the whole vector $Y$. | Expectation of random sum of non-random numbers
This approximation will definitely not work in general. Consider a $\tau$ with support on $(1,3)$ and $E(\lfloor\tau\rfloor)\in [1,2)$. Then
$$
\sum_{i=1}^{E(\lfloor \tau \rfloor)} Y_i = Y_1,
$$
but i |
27,033 | Expectation of random sum of non-random numbers | Answer: Part 1 (Expectation of the $E(\tau)$ will not work)
To add to the previous answers about why the expectation will not work.
Consider the following, let us assume:
$\tau$ uniformly distributed ~ Unif([1,3]) (i.e. p($\tau$=1)=p($\tau$=2)=p($\tau$=3)=$\frac{1}{3}$) [I.e. you will have to redefine your continuous distribution as a discrete one]
$Y_1=1$, $Y_2=5$, $Y_3=100$
Then,
$E(\tau)=2$
$\Sigma_i^{E(\tau)} Y_i$ = 1+5 = 6
However, the real expectation is:
$\frac{1}{3}(1) + \frac{1}{3}(1+5) + \frac{1}{3}(1+5+100)$ = 38
Answer: Part 2 (Explicit Formula for the expectation)
Starting with $E(\Sigma_{i=1}^{\lfloor\tau\rfloor}Y_i)$, we have:
$E(\Sigma_{i=1}^{\lfloor\tau\rfloor}Y_i)$ = $\Sigma_{i=1}^N p(\tau \geq i) Y_i$ = $\Sigma_{i=1}^N (1-p(\tau < i)) Y_i$ = $\Sigma_{i=1}^N (Y_i) - \Sigma_{i=1}^N p(\tau < i) Y_i$ = $\Sigma_{i=1}^N (Y_i) - \Sigma_{i=1}^N CDF_{\tau}(i) Y_i$
Where CDF is the Cumulatative Distribution Function.
I apologise for any mistakes I have made as this is my first post. Hope this helps. | Expectation of random sum of non-random numbers | Answer: Part 1 (Expectation of the $E(\tau)$ will not work)
To add to the previous answers about why the expectation will not work.
Consider the following, let us assume:
$\tau$ uniformly distributed | Expectation of random sum of non-random numbers
Answer: Part 1 (Expectation of the $E(\tau)$ will not work)
To add to the previous answers about why the expectation will not work.
Consider the following, let us assume:
$\tau$ uniformly distributed ~ Unif([1,3]) (i.e. p($\tau$=1)=p($\tau$=2)=p($\tau$=3)=$\frac{1}{3}$) [I.e. you will have to redefine your continuous distribution as a discrete one]
$Y_1=1$, $Y_2=5$, $Y_3=100$
Then,
$E(\tau)=2$
$\Sigma_i^{E(\tau)} Y_i$ = 1+5 = 6
However, the real expectation is:
$\frac{1}{3}(1) + \frac{1}{3}(1+5) + \frac{1}{3}(1+5+100)$ = 38
Answer: Part 2 (Explicit Formula for the expectation)
Starting with $E(\Sigma_{i=1}^{\lfloor\tau\rfloor}Y_i)$, we have:
$E(\Sigma_{i=1}^{\lfloor\tau\rfloor}Y_i)$ = $\Sigma_{i=1}^N p(\tau \geq i) Y_i$ = $\Sigma_{i=1}^N (1-p(\tau < i)) Y_i$ = $\Sigma_{i=1}^N (Y_i) - \Sigma_{i=1}^N p(\tau < i) Y_i$ = $\Sigma_{i=1}^N (Y_i) - \Sigma_{i=1}^N CDF_{\tau}(i) Y_i$
Where CDF is the Cumulatative Distribution Function.
I apologise for any mistakes I have made as this is my first post. Hope this helps. | Expectation of random sum of non-random numbers
Answer: Part 1 (Expectation of the $E(\tau)$ will not work)
To add to the previous answers about why the expectation will not work.
Consider the following, let us assume:
$\tau$ uniformly distributed |
27,034 | Expectation of random sum of non-random numbers | Let me change a little notation (so we use uppercase for random variables)
We want $E[Z]$ where
$$Z = \sum_{i=0}^{\lfloor T \rfloor} a_i = \sum_{i=0}^\infty a_i h(T-i) \tag 1$$
where $h()$ is the Heaviside step function. We assume $T$ is continuous, non-negative, with density $f_T$ and CDF $F_T$. Let $G(t)=P(T>t)=1-F_T(t)$
Then
$$E[h(T-i)]=P(T > i) = G(i) \tag 2$$
and
$$E[Z] = \sum_{i=0}^{\infty} a_i G(i) \tag 3$$
We know $E[T]=\int_0^{\infty} g(t) dt $. This suggests that your approximation is fair only when the $a_i$ are (almost?) constant and $f_T$ is quite smooth.
Edit: alternatively, using summation by parts
$$E[Z] = \sum_{i=0}^{\infty} g_i A(i) \tag 4$$
where $g_i = P( i \le T < i+1)$ (probability mass function of $\lfloor T \rfloor$ ) and $A_i=a_i + a_{i+1}$ | Expectation of random sum of non-random numbers | Let me change a little notation (so we use uppercase for random variables)
We want $E[Z]$ where
$$Z = \sum_{i=0}^{\lfloor T \rfloor} a_i = \sum_{i=0}^\infty a_i h(T-i) \tag 1$$
where $h()$ is the Heav | Expectation of random sum of non-random numbers
Let me change a little notation (so we use uppercase for random variables)
We want $E[Z]$ where
$$Z = \sum_{i=0}^{\lfloor T \rfloor} a_i = \sum_{i=0}^\infty a_i h(T-i) \tag 1$$
where $h()$ is the Heaviside step function. We assume $T$ is continuous, non-negative, with density $f_T$ and CDF $F_T$. Let $G(t)=P(T>t)=1-F_T(t)$
Then
$$E[h(T-i)]=P(T > i) = G(i) \tag 2$$
and
$$E[Z] = \sum_{i=0}^{\infty} a_i G(i) \tag 3$$
We know $E[T]=\int_0^{\infty} g(t) dt $. This suggests that your approximation is fair only when the $a_i$ are (almost?) constant and $f_T$ is quite smooth.
Edit: alternatively, using summation by parts
$$E[Z] = \sum_{i=0}^{\infty} g_i A(i) \tag 4$$
where $g_i = P( i \le T < i+1)$ (probability mass function of $\lfloor T \rfloor$ ) and $A_i=a_i + a_{i+1}$ | Expectation of random sum of non-random numbers
Let me change a little notation (so we use uppercase for random variables)
We want $E[Z]$ where
$$Z = \sum_{i=0}^{\lfloor T \rfloor} a_i = \sum_{i=0}^\infty a_i h(T-i) \tag 1$$
where $h()$ is the Heav |
27,035 | Expectation of random sum of non-random numbers | Set $S_t = \sum_{i=1}^t Y_i$. Then
$$
E[S_\tau\mid \tau \leq T] = \sum_{t=1}^T S_t P(\tau = t) \triangleq H_T
=H_{T-1} + S_T\cdot P(\tau = T)
$$
Y = getY()
p = simulatep()
H = 0
T = -1
S = 0
while not converged:
T += 1
S = S + Y[T]
H = H + S * p[T] | Expectation of random sum of non-random numbers | Set $S_t = \sum_{i=1}^t Y_i$. Then
$$
E[S_\tau\mid \tau \leq T] = \sum_{t=1}^T S_t P(\tau = t) \triangleq H_T
=H_{T-1} + S_T\cdot P(\tau = T)
$$
Y = getY()
p = simulatep()
H = 0
T = -1
S = 0
while not | Expectation of random sum of non-random numbers
Set $S_t = \sum_{i=1}^t Y_i$. Then
$$
E[S_\tau\mid \tau \leq T] = \sum_{t=1}^T S_t P(\tau = t) \triangleq H_T
=H_{T-1} + S_T\cdot P(\tau = T)
$$
Y = getY()
p = simulatep()
H = 0
T = -1
S = 0
while not converged:
T += 1
S = S + Y[T]
H = H + S * p[T] | Expectation of random sum of non-random numbers
Set $S_t = \sum_{i=1}^t Y_i$. Then
$$
E[S_\tau\mid \tau \leq T] = \sum_{t=1}^T S_t P(\tau = t) \triangleq H_T
=H_{T-1} + S_T\cdot P(\tau = T)
$$
Y = getY()
p = simulatep()
H = 0
T = -1
S = 0
while not |
27,036 | Can a neural network work with negative and zero inputs? | (this has been said already by other answers) ReLu activation function has a gradient equal to 0 (hence it stops learning) when the linear combination of the inputs is less than 0, not when the input themselves are 0
(this also has been said already by other answers) the inputs of NNs are often normalised around 0, so it's totally normal that some values are 0, also the weights of each neuron are usually (randomly) initialised around 0, meaning that when it comes the time to compute the linear combination, some random input values will switch sign, this is expected
ReLu function is actually designed to result in a null gradient for values below 0, don't stress out about this, the problem of dead neurons comes up when all inputs for that neuron result in a null gradient. It's not a trivial problem to discuss so I will slide upon it, but it has nothing to do with simply having some negative values in the inputs. As HitLuca has pointed in his comment, having the neuron parameters go to zero during the learning process will cause the neuron to die.
Of course other activation functions that never result in a null gradient (like leaky ReLu) will avoid dead neurons entirely. | Can a neural network work with negative and zero inputs? | (this has been said already by other answers) ReLu activation function has a gradient equal to 0 (hence it stops learning) when the linear combination of the inputs is less than 0, not when the input | Can a neural network work with negative and zero inputs?
(this has been said already by other answers) ReLu activation function has a gradient equal to 0 (hence it stops learning) when the linear combination of the inputs is less than 0, not when the input themselves are 0
(this also has been said already by other answers) the inputs of NNs are often normalised around 0, so it's totally normal that some values are 0, also the weights of each neuron are usually (randomly) initialised around 0, meaning that when it comes the time to compute the linear combination, some random input values will switch sign, this is expected
ReLu function is actually designed to result in a null gradient for values below 0, don't stress out about this, the problem of dead neurons comes up when all inputs for that neuron result in a null gradient. It's not a trivial problem to discuss so I will slide upon it, but it has nothing to do with simply having some negative values in the inputs. As HitLuca has pointed in his comment, having the neuron parameters go to zero during the learning process will cause the neuron to die.
Of course other activation functions that never result in a null gradient (like leaky ReLu) will avoid dead neurons entirely. | Can a neural network work with negative and zero inputs?
(this has been said already by other answers) ReLu activation function has a gradient equal to 0 (hence it stops learning) when the linear combination of the inputs is less than 0, not when the input |
27,037 | Can a neural network work with negative and zero inputs? | It's not your inputs which are passed to the activation function (ReLu in your case), your inputs are first transformed using a linear (affine) transformation, and these transformed values are then passed to the activation function. So negative values are not an issue, it is entirely possible that negative values will be transformed to positive values. | Can a neural network work with negative and zero inputs? | It's not your inputs which are passed to the activation function (ReLu in your case), your inputs are first transformed using a linear (affine) transformation, and these transformed values are then pa | Can a neural network work with negative and zero inputs?
It's not your inputs which are passed to the activation function (ReLu in your case), your inputs are first transformed using a linear (affine) transformation, and these transformed values are then passed to the activation function. So negative values are not an issue, it is entirely possible that negative values will be transformed to positive values. | Can a neural network work with negative and zero inputs?
It's not your inputs which are passed to the activation function (ReLu in your case), your inputs are first transformed using a linear (affine) transformation, and these transformed values are then pa |
27,038 | Can a neural network work with negative and zero inputs? | LeakyRelu is a good option for remedying dead neurons, so it's reasonable to use. But, having negative inputs doesn't cause this because your weight initialization can also have negative weights and turn the positive inputs into negative when multiplied. This is hardly a problem. It's usually preferred that your inputs have zero-mean, so very natural to have negative inputs as well. | Can a neural network work with negative and zero inputs? | LeakyRelu is a good option for remedying dead neurons, so it's reasonable to use. But, having negative inputs doesn't cause this because your weight initialization can also have negative weights and t | Can a neural network work with negative and zero inputs?
LeakyRelu is a good option for remedying dead neurons, so it's reasonable to use. But, having negative inputs doesn't cause this because your weight initialization can also have negative weights and turn the positive inputs into negative when multiplied. This is hardly a problem. It's usually preferred that your inputs have zero-mean, so very natural to have negative inputs as well. | Can a neural network work with negative and zero inputs?
LeakyRelu is a good option for remedying dead neurons, so it's reasonable to use. But, having negative inputs doesn't cause this because your weight initialization can also have negative weights and t |
27,039 | Can a neural network work with negative and zero inputs? | Dead neurons refer to the fact that the network comes to a state where the back-propagation step (which is used to update the internal network's weights and biases) isn't effective enough, as the changes in values are zero or close to zero. One way to get a dead neuron situation is to initialize your network with weight and bias values of zero, with ReLU activations: this will produce an input value to the activation function of zero, which has a derivative of zero in that point. When updating the weights, the gradient will be zero so no changes are made.
The same issue can arise when a neuron received negative values to its ReLU activation function: since for x<=0 f(x)=0, the output will always be zero, with again zero gradient.
To remedy this, we have activation functions like LeakyReLU, which has nonzero activation for negative values, and thus nonzero gradient. A zero-initialized network will still have the same issue, as LeakyReLUs still have outputs of zero for any input, but manage to solve the problems with negative values. | Can a neural network work with negative and zero inputs? | Dead neurons refer to the fact that the network comes to a state where the back-propagation step (which is used to update the internal network's weights and biases) isn't effective enough, as the chan | Can a neural network work with negative and zero inputs?
Dead neurons refer to the fact that the network comes to a state where the back-propagation step (which is used to update the internal network's weights and biases) isn't effective enough, as the changes in values are zero or close to zero. One way to get a dead neuron situation is to initialize your network with weight and bias values of zero, with ReLU activations: this will produce an input value to the activation function of zero, which has a derivative of zero in that point. When updating the weights, the gradient will be zero so no changes are made.
The same issue can arise when a neuron received negative values to its ReLU activation function: since for x<=0 f(x)=0, the output will always be zero, with again zero gradient.
To remedy this, we have activation functions like LeakyReLU, which has nonzero activation for negative values, and thus nonzero gradient. A zero-initialized network will still have the same issue, as LeakyReLUs still have outputs of zero for any input, but manage to solve the problems with negative values. | Can a neural network work with negative and zero inputs?
Dead neurons refer to the fact that the network comes to a state where the back-propagation step (which is used to update the internal network's weights and biases) isn't effective enough, as the chan |
27,040 | Can a neural network work with negative and zero inputs? | ReLu neurons can indeed effectively ignore some input values. This is a good thing. The neurons are coupled to the inputs via trained weights, so some inputs are ignored by some neurons and other inputs are ignored by other neurons. It allows weights in the subsequent layers to focus on interesting subsets of your input space | Can a neural network work with negative and zero inputs? | ReLu neurons can indeed effectively ignore some input values. This is a good thing. The neurons are coupled to the inputs via trained weights, so some inputs are ignored by some neurons and other inpu | Can a neural network work with negative and zero inputs?
ReLu neurons can indeed effectively ignore some input values. This is a good thing. The neurons are coupled to the inputs via trained weights, so some inputs are ignored by some neurons and other inputs are ignored by other neurons. It allows weights in the subsequent layers to focus on interesting subsets of your input space | Can a neural network work with negative and zero inputs?
ReLu neurons can indeed effectively ignore some input values. This is a good thing. The neurons are coupled to the inputs via trained weights, so some inputs are ignored by some neurons and other inpu |
27,041 | The prestige magician paradox | This mistake was put in evidence in written conversations among Fermat, Pascal, and eminent French mathematicians in 1654 when the former two were considering the "problem of points." A simple example is this:
Two people gamble on the outcome of two flips of a fair coin. Player A wins if either flip is heads; otherwise, Player B wins. What are player B's chances of winning?
The false argument begins by examining the set of possible outcomes, which we can enumerate:
H: The first flip is heads. Player A wins.
TH: Only the second flip is heads. Player A wins.
TT: No flip is heads. Player B wins.
Because Player A has two chances of winning and B has only one chance, the odds in favor of B are (according to this argument) 1:2; that is, B's chances are 1/3. Among those defending this argument were Gilles Personne de Roberval, a founding member of the French Academy of Sciences.
The mistake is plain to us today, because we have been educated by people who learned from this discussion. Fermat argued (correctly, but not very convincingly) that case (1) really has to be considered two cases, as if the game had been played out through both flips no matter what. Invoking a hypothetical sequence of flips that wasn't actually played out makes many people uneasy. Nowadays we might find it more convincing just to work out the probabilities of the individual cases: the chance of (1) is 1/2 and the chances of (2) and (3) are each 1/4, whence the chance that A wins equals 1/2 + 1/4 = 3/4 and the chance that B wins is 1/4. These calculations rely on axioms of probability, which were finally settled early in the 20th century, but were essentially established by the fall of 1654 by Pascal and Fermat and popularized throughout Europe three years later by Christian Huyghens in his brief treatise on probability (the first ever published), De ratiociniis in ludo aleae (calculating in games of chance).
The present question can be modeled as 100 coin flips, with heads representing death and tails representing survival. The argument for "1 in 100" (which really should be 1/101, by the way) has exactly the same flaw. | The prestige magician paradox | This mistake was put in evidence in written conversations among Fermat, Pascal, and eminent French mathematicians in 1654 when the former two were considering the "problem of points." A simple exampl | The prestige magician paradox
This mistake was put in evidence in written conversations among Fermat, Pascal, and eminent French mathematicians in 1654 when the former two were considering the "problem of points." A simple example is this:
Two people gamble on the outcome of two flips of a fair coin. Player A wins if either flip is heads; otherwise, Player B wins. What are player B's chances of winning?
The false argument begins by examining the set of possible outcomes, which we can enumerate:
H: The first flip is heads. Player A wins.
TH: Only the second flip is heads. Player A wins.
TT: No flip is heads. Player B wins.
Because Player A has two chances of winning and B has only one chance, the odds in favor of B are (according to this argument) 1:2; that is, B's chances are 1/3. Among those defending this argument were Gilles Personne de Roberval, a founding member of the French Academy of Sciences.
The mistake is plain to us today, because we have been educated by people who learned from this discussion. Fermat argued (correctly, but not very convincingly) that case (1) really has to be considered two cases, as if the game had been played out through both flips no matter what. Invoking a hypothetical sequence of flips that wasn't actually played out makes many people uneasy. Nowadays we might find it more convincing just to work out the probabilities of the individual cases: the chance of (1) is 1/2 and the chances of (2) and (3) are each 1/4, whence the chance that A wins equals 1/2 + 1/4 = 3/4 and the chance that B wins is 1/4. These calculations rely on axioms of probability, which were finally settled early in the 20th century, but were essentially established by the fall of 1654 by Pascal and Fermat and popularized throughout Europe three years later by Christian Huyghens in his brief treatise on probability (the first ever published), De ratiociniis in ludo aleae (calculating in games of chance).
The present question can be modeled as 100 coin flips, with heads representing death and tails representing survival. The argument for "1 in 100" (which really should be 1/101, by the way) has exactly the same flaw. | The prestige magician paradox
This mistake was put in evidence in written conversations among Fermat, Pascal, and eminent French mathematicians in 1654 when the former two were considering the "problem of points." A simple exampl |
27,042 | The prestige magician paradox | One one hand, there is one magician alive, and 100 drowned magicians, so his chances are 1 out of 100.
That reasoning implicitly assumes that every magician is equally likely to be the one surviving at the end of the process. However, only the original would have to endure all 100 trials, and he would have the worst odds. Contrast the original with the last clone that gets created; he only needs to survive once and he has a 1 in 2 chance of being the lone survivor.
Pretend that instead of clones we are dealing with a single-elimination tournament (like the famous NCAA basketball tournament every March). The original has to last 100 rounds whereas the last clone only has to play in the tourney finals. Not all clones are equally likely to last until the end, and the original has the worst chances of $\frac{1}{2^{100}}$. | The prestige magician paradox | One one hand, there is one magician alive, and 100 drowned magicians, so his chances are 1 out of 100.
That reasoning implicitly assumes that every magician is equally likely to be the one surviving | The prestige magician paradox
One one hand, there is one magician alive, and 100 drowned magicians, so his chances are 1 out of 100.
That reasoning implicitly assumes that every magician is equally likely to be the one surviving at the end of the process. However, only the original would have to endure all 100 trials, and he would have the worst odds. Contrast the original with the last clone that gets created; he only needs to survive once and he has a 1 in 2 chance of being the lone survivor.
Pretend that instead of clones we are dealing with a single-elimination tournament (like the famous NCAA basketball tournament every March). The original has to last 100 rounds whereas the last clone only has to play in the tourney finals. Not all clones are equally likely to last until the end, and the original has the worst chances of $\frac{1}{2^{100}}$. | The prestige magician paradox
One one hand, there is one magician alive, and 100 drowned magicians, so his chances are 1 out of 100.
That reasoning implicitly assumes that every magician is equally likely to be the one surviving |
27,043 | The prestige magician paradox | The probability he survives is 1 on every trial, and the probability is 1 that he dies on every trial (notwithstanding water tank failure). After duplicating, there is no "him" anymore; there are "hims". | The prestige magician paradox | The probability he survives is 1 on every trial, and the probability is 1 that he dies on every trial (notwithstanding water tank failure). After duplicating, there is no "him" anymore; there are "hi | The prestige magician paradox
The probability he survives is 1 on every trial, and the probability is 1 that he dies on every trial (notwithstanding water tank failure). After duplicating, there is no "him" anymore; there are "hims". | The prestige magician paradox
The probability he survives is 1 on every trial, and the probability is 1 that he dies on every trial (notwithstanding water tank failure). After duplicating, there is no "him" anymore; there are "hi |
27,044 | How to test random effects in a multilevel model in R | First point:
You need to be careful if you want to test whether the variance of a random effect is 0:
The standard $\chi^2$-asymptotics for the LR that are used in anova() do not apply for LRTs or restricted likelihood ratio tests on variance components since the null hypothesis is on the edge of the parameter space. Using this wrong reference distribution will yield ridiculously conservative tests.
Sources: Self & Liang (1987), Crainiceanu & Ruppert (2003), Greven, Crainiceanu, Küchenhoff (2008).
For exact LR tests on variances in linear mixed models with uncorrelated random effects you can use my package RLRsim.
For generalized linear mixed models or models with correlated random effects, I would strongly recommend a parametric bootstrap to approximate the correct p-value if the LRT or RLRT (the latter has more power, see sources above) are somewhere in the vicinity of the critical value for the (wrong) standard reference distribution. Code for lme4 at the end of the post.
Second point:
It may be dangerous to use standard confidence intervals for variance parameter estimates, since their distribution is usually very skewed and so using a symmetric interval is a little simplistic- Douglas Bates has some material on this here.
Parametric bootstrap code for lme4-models:
#m0 is the lmer model under the null hypothesis (i.e. the smaller model)
#mA is the lmer model under the alternative
bootstrapAnova <- function(mA, m0, B=1000){
oneBootstrap <- function(m0, mA){
d <- drop(simulate(m0))
m2 <-refit(mA, newresp=d)
m1 <-refit(m0, newresp=d)
return(anova(m2,m1)$Chisq[2])
}
nulldist <- if(!require(multicore)){
replicate(B, oneBootstrap(m0, mA))
} else {
unlist(mclapply(1:B, function(x) oneBootstrap(m0, mA)))
}
ret <- anova(mA, m0)
ret$"Pr(>Chisq)"[2] <- mean(ret$Chisq[2] < nulldist)
names(ret)[7] <- "Pr_boot(>Chisq)"
attr(ret, "heading") <- c(attr(ret, "heading")[1],
paste("Parametric bootstrap with", B,"samples."),
attr(ret, "heading")[-1])
attr(ret, "nulldist") <- nulldist
return(ret)
}
#use like this (and increase B if you want reviewers to believe you):
(bRLRT <- bootstrapAnova(mA=<BIG MODEL>, m0=<SMALLER MODEL>)) | How to test random effects in a multilevel model in R | First point:
You need to be careful if you want to test whether the variance of a random effect is 0:
The standard $\chi^2$-asymptotics for the LR that are used in anova() do not apply for LRTs or re | How to test random effects in a multilevel model in R
First point:
You need to be careful if you want to test whether the variance of a random effect is 0:
The standard $\chi^2$-asymptotics for the LR that are used in anova() do not apply for LRTs or restricted likelihood ratio tests on variance components since the null hypothesis is on the edge of the parameter space. Using this wrong reference distribution will yield ridiculously conservative tests.
Sources: Self & Liang (1987), Crainiceanu & Ruppert (2003), Greven, Crainiceanu, Küchenhoff (2008).
For exact LR tests on variances in linear mixed models with uncorrelated random effects you can use my package RLRsim.
For generalized linear mixed models or models with correlated random effects, I would strongly recommend a parametric bootstrap to approximate the correct p-value if the LRT or RLRT (the latter has more power, see sources above) are somewhere in the vicinity of the critical value for the (wrong) standard reference distribution. Code for lme4 at the end of the post.
Second point:
It may be dangerous to use standard confidence intervals for variance parameter estimates, since their distribution is usually very skewed and so using a symmetric interval is a little simplistic- Douglas Bates has some material on this here.
Parametric bootstrap code for lme4-models:
#m0 is the lmer model under the null hypothesis (i.e. the smaller model)
#mA is the lmer model under the alternative
bootstrapAnova <- function(mA, m0, B=1000){
oneBootstrap <- function(m0, mA){
d <- drop(simulate(m0))
m2 <-refit(mA, newresp=d)
m1 <-refit(m0, newresp=d)
return(anova(m2,m1)$Chisq[2])
}
nulldist <- if(!require(multicore)){
replicate(B, oneBootstrap(m0, mA))
} else {
unlist(mclapply(1:B, function(x) oneBootstrap(m0, mA)))
}
ret <- anova(mA, m0)
ret$"Pr(>Chisq)"[2] <- mean(ret$Chisq[2] < nulldist)
names(ret)[7] <- "Pr_boot(>Chisq)"
attr(ret, "heading") <- c(attr(ret, "heading")[1],
paste("Parametric bootstrap with", B,"samples."),
attr(ret, "heading")[-1])
attr(ret, "nulldist") <- nulldist
return(ret)
}
#use like this (and increase B if you want reviewers to believe you):
(bRLRT <- bootstrapAnova(mA=<BIG MODEL>, m0=<SMALLER MODEL>)) | How to test random effects in a multilevel model in R
First point:
You need to be careful if you want to test whether the variance of a random effect is 0:
The standard $\chi^2$-asymptotics for the LR that are used in anova() do not apply for LRTs or re |
27,045 | How to test random effects in a multilevel model in R | (I would post this as a comment to the previous answer by 'chi', but don't see that that is possible here.)
Be very careful with intervals() and anova() from the nlme package, these have exactly the flaws that @fabians points out above -- they rely on the standard chi-squared distribution applied to a quadratic approximation of the shape of the likelihood profile for the variances. The newer lme4a package (on r-forge) allows the creation of likelihood profiles for the variance parameters, which takes care of the quadratic approximation part (although not the distributional part).
Also, it is fairly hotly debated whether dropping non-significant variance components is a good idea or not (don't have an immediate reference, but this has been discussed on r-sig-mixed-models). | How to test random effects in a multilevel model in R | (I would post this as a comment to the previous answer by 'chi', but don't see that that is possible here.)
Be very careful with intervals() and anova() from the nlme package, these have exactly the f | How to test random effects in a multilevel model in R
(I would post this as a comment to the previous answer by 'chi', but don't see that that is possible here.)
Be very careful with intervals() and anova() from the nlme package, these have exactly the flaws that @fabians points out above -- they rely on the standard chi-squared distribution applied to a quadratic approximation of the shape of the likelihood profile for the variances. The newer lme4a package (on r-forge) allows the creation of likelihood profiles for the variance parameters, which takes care of the quadratic approximation part (although not the distributional part).
Also, it is fairly hotly debated whether dropping non-significant variance components is a good idea or not (don't have an immediate reference, but this has been discussed on r-sig-mixed-models). | How to test random effects in a multilevel model in R
(I would post this as a comment to the previous answer by 'chi', but don't see that that is possible here.)
Be very careful with intervals() and anova() from the nlme package, these have exactly the f |
27,046 | How to test random effects in a multilevel model in R | The intervals() function should provide you with $100(1-\alpha)$ confidence intervals for the random effects in your model, see help(intervals.lme) for more information.
You can also test if any of the variance components can be droped from the model by using anova() (which amounts to do an LRT between two nested models). | How to test random effects in a multilevel model in R | The intervals() function should provide you with $100(1-\alpha)$ confidence intervals for the random effects in your model, see help(intervals.lme) for more information.
You can also test if any of th | How to test random effects in a multilevel model in R
The intervals() function should provide you with $100(1-\alpha)$ confidence intervals for the random effects in your model, see help(intervals.lme) for more information.
You can also test if any of the variance components can be droped from the model by using anova() (which amounts to do an LRT between two nested models). | How to test random effects in a multilevel model in R
The intervals() function should provide you with $100(1-\alpha)$ confidence intervals for the random effects in your model, see help(intervals.lme) for more information.
You can also test if any of th |
27,047 | How to test random effects in a multilevel model in R | One of the best resources on multilevel analysis in R is John Fox's web appendix to the text "An R and S-PLUS Companion to Applied Regression". It provides a great overview of the method and means to calculate some of the more familiar measures from the R NLME output. The appendix is available on CRAN.
Here is the link:
http://cran.r-project.org/doc/contrib/Fox-Companion/appendix-mixed-models.pdf | How to test random effects in a multilevel model in R | One of the best resources on multilevel analysis in R is John Fox's web appendix to the text "An R and S-PLUS Companion to Applied Regression". It provides a great overview of the method and means to | How to test random effects in a multilevel model in R
One of the best resources on multilevel analysis in R is John Fox's web appendix to the text "An R and S-PLUS Companion to Applied Regression". It provides a great overview of the method and means to calculate some of the more familiar measures from the R NLME output. The appendix is available on CRAN.
Here is the link:
http://cran.r-project.org/doc/contrib/Fox-Companion/appendix-mixed-models.pdf | How to test random effects in a multilevel model in R
One of the best resources on multilevel analysis in R is John Fox's web appendix to the text "An R and S-PLUS Companion to Applied Regression". It provides a great overview of the method and means to |
27,048 | Confidence intervals around functions of estimated parameters | Two common approaches for this problem are to calculate the non-linear combination of the coefficients directly from the regression or to bootstrap it.
The variance in the former is based on the "delta method", an approximation appropriate in large samples. This was suggested in the other answer, but statistics software can make the calculation a whole lot easier.
The variance for the latter comes from resampling the data in memory with replacement, fitting the model, calculating the coefficient combination, and then using the sampled distribution to get the confidence interval.
Here's an example of both using Stata:
. sysuse auto, clear
(1978 automobile data)
. set seed 11082021
. regress price mpg foreign
Source | SS df MS Number of obs = 74
-------------+---------------------------------- F(2, 71) = 14.07
Model | 180261702 2 90130850.8 Prob > F = 0.0000
Residual | 454803695 71 6405685.84 R-squared = 0.2838
-------------+---------------------------------- Adj R-squared = 0.2637
Total | 635065396 73 8699525.97 Root MSE = 2530.9
------------------------------------------------------------------------------
price | Coefficient Std. err. t P>|t| [95% conf. interval]
-------------+----------------------------------------------------------------
mpg | -294.1955 55.69172 -5.28 0.000 -405.2417 -183.1494
foreign | 1767.292 700.158 2.52 0.014 371.2169 3163.368
_cons | 11905.42 1158.634 10.28 0.000 9595.164 14215.67
------------------------------------------------------------------------------
. nlcom (gamma_dm:sqrt(_b[_cons] - 4*_b[mpg]*_b[foreign]))
gamma_dm: sqrt(_b[_cons] - 4*_b[mpg]*_b[foreign])
------------------------------------------------------------------------------
price | Coefficient Std. err. z P>|z| [95% conf. interval]
-------------+----------------------------------------------------------------
gamma_dm | 1446.245 361.0078 4.01 0.000 738.6823 2153.807
------------------------------------------------------------------------------
The 95% CI using the delta method is [738.6823, 2153.807].
Boostrapping yields [740.5149, 2151.974], which is fairly similar:
. bootstrap (gamma_bs:sqrt(_b[_cons] - 4*_b[mpg]*_b[foreign])), reps(500) nodots: regress price mpg foreign
Linear regression Number of obs = 74
Replications = 499
Command: regress price mpg foreign
[gamma_bs]_bs_1: sqrt(_b[_cons] - 4*_b[mpg]*_b[foreign])
------------------------------------------------------------------------------
| Observed Bootstrap Normal-based
| coefficient std. err. z P>|z| [95% conf. interval]
-------------+----------------------------------------------------------------
gamma_bs |
_bs_1 | 1446.245 360.0728 4.02 0.000 740.5149 2151.974
------------------------------------------------------------------------------
Note: One or more parameters could not be estimated in 1 bootstrap replicate;
standard-error estimates include only complete replications.
Your Solution
Your proposed solution would work if you have lots of data, but here it does not do so well with only 74 observations:
. quietly regress price mpg foreign
. corr2data b_mpg b_foreign b_cons, n(500) means(e(b)) cov(e(V)) clear
(obs 500)
. gen gamma_sim = sqrt(b_cons - 4*b_mpg*b_foreign)
(3 missing values generated)
. sum gamma_sim
Variable | Obs Mean Std. dev. Min Max
-------------+---------------------------------------------------------
gamma_sim | 497 1426.183 366.6408 197.5594 2397.263
. display "[" %-9.4f r(mean) + invttail(r(N)-1,.975)*r(sd) ", " r(mean) + invttail(r(N)-1,.025)*r(sd) "]"
[705.8224 , 2146.5434]
The CI here is [705.8224 , 2146.5434], which is noticeably different from the two CIs above.
My thought is that if you are going to simulate, you might as well bootstrap and not rely on the normal approximation that is only valid asymptotically. If you have lots of data, the difference between bootstrapping and sampling from MVN parameterized by estimated coefficients and variance should not be noticeable. | Confidence intervals around functions of estimated parameters | Two common approaches for this problem are to calculate the non-linear combination of the coefficients directly from the regression or to bootstrap it.
The variance in the former is based on the "delt | Confidence intervals around functions of estimated parameters
Two common approaches for this problem are to calculate the non-linear combination of the coefficients directly from the regression or to bootstrap it.
The variance in the former is based on the "delta method", an approximation appropriate in large samples. This was suggested in the other answer, but statistics software can make the calculation a whole lot easier.
The variance for the latter comes from resampling the data in memory with replacement, fitting the model, calculating the coefficient combination, and then using the sampled distribution to get the confidence interval.
Here's an example of both using Stata:
. sysuse auto, clear
(1978 automobile data)
. set seed 11082021
. regress price mpg foreign
Source | SS df MS Number of obs = 74
-------------+---------------------------------- F(2, 71) = 14.07
Model | 180261702 2 90130850.8 Prob > F = 0.0000
Residual | 454803695 71 6405685.84 R-squared = 0.2838
-------------+---------------------------------- Adj R-squared = 0.2637
Total | 635065396 73 8699525.97 Root MSE = 2530.9
------------------------------------------------------------------------------
price | Coefficient Std. err. t P>|t| [95% conf. interval]
-------------+----------------------------------------------------------------
mpg | -294.1955 55.69172 -5.28 0.000 -405.2417 -183.1494
foreign | 1767.292 700.158 2.52 0.014 371.2169 3163.368
_cons | 11905.42 1158.634 10.28 0.000 9595.164 14215.67
------------------------------------------------------------------------------
. nlcom (gamma_dm:sqrt(_b[_cons] - 4*_b[mpg]*_b[foreign]))
gamma_dm: sqrt(_b[_cons] - 4*_b[mpg]*_b[foreign])
------------------------------------------------------------------------------
price | Coefficient Std. err. z P>|z| [95% conf. interval]
-------------+----------------------------------------------------------------
gamma_dm | 1446.245 361.0078 4.01 0.000 738.6823 2153.807
------------------------------------------------------------------------------
The 95% CI using the delta method is [738.6823, 2153.807].
Boostrapping yields [740.5149, 2151.974], which is fairly similar:
. bootstrap (gamma_bs:sqrt(_b[_cons] - 4*_b[mpg]*_b[foreign])), reps(500) nodots: regress price mpg foreign
Linear regression Number of obs = 74
Replications = 499
Command: regress price mpg foreign
[gamma_bs]_bs_1: sqrt(_b[_cons] - 4*_b[mpg]*_b[foreign])
------------------------------------------------------------------------------
| Observed Bootstrap Normal-based
| coefficient std. err. z P>|z| [95% conf. interval]
-------------+----------------------------------------------------------------
gamma_bs |
_bs_1 | 1446.245 360.0728 4.02 0.000 740.5149 2151.974
------------------------------------------------------------------------------
Note: One or more parameters could not be estimated in 1 bootstrap replicate;
standard-error estimates include only complete replications.
Your Solution
Your proposed solution would work if you have lots of data, but here it does not do so well with only 74 observations:
. quietly regress price mpg foreign
. corr2data b_mpg b_foreign b_cons, n(500) means(e(b)) cov(e(V)) clear
(obs 500)
. gen gamma_sim = sqrt(b_cons - 4*b_mpg*b_foreign)
(3 missing values generated)
. sum gamma_sim
Variable | Obs Mean Std. dev. Min Max
-------------+---------------------------------------------------------
gamma_sim | 497 1426.183 366.6408 197.5594 2397.263
. display "[" %-9.4f r(mean) + invttail(r(N)-1,.975)*r(sd) ", " r(mean) + invttail(r(N)-1,.025)*r(sd) "]"
[705.8224 , 2146.5434]
The CI here is [705.8224 , 2146.5434], which is noticeably different from the two CIs above.
My thought is that if you are going to simulate, you might as well bootstrap and not rely on the normal approximation that is only valid asymptotically. If you have lots of data, the difference between bootstrapping and sampling from MVN parameterized by estimated coefficients and variance should not be noticeable. | Confidence intervals around functions of estimated parameters
Two common approaches for this problem are to calculate the non-linear combination of the coefficients directly from the regression or to bootstrap it.
The variance in the former is based on the "delt |
27,049 | Confidence intervals around functions of estimated parameters | Usually we take normality assumption for linear regression models. That is, $y_i\sim N(\beta^Tx_i,\sigma^2)$. From this assumption we derive the asymptotic distribution of $\hat{\beta}$, which is also normal: $\hat{\beta}\overset{.}{\sim}N(\beta,\sigma^2(X^TX)^{-1})$. Let us denote the covariance matrix of $\hat{\beta}$ as $Var(\hat{\beta})=V=\sigma^2(X^TX)^{-1}$.
Next, we take $\gamma=g(\beta)=\sqrt{\beta_0^2-4\beta_1\beta_2}$ so $\hat{\gamma}=g(\hat{\beta})$. The function $g$ is differentiable and let us assume it is non-zero. Equipped with these, we can apply the delta method to get the following estimator:
$$\hat{\gamma}\sim N\left(\gamma,\nabla g(\hat{\beta})^T\cdot V\cdot \nabla g(\hat{\beta})\right)$$
Where $\nabla g(\hat{\beta})$ is the gradient vector of $g$ :
$$\nabla g(\beta)=\begin{pmatrix} \frac{\beta_0}{\sqrt{\beta_0^2-4\beta_1\beta_2}} \\ \frac{-2\beta_2}{\sqrt{\beta_0^2-4\beta_1\beta_2}} \\ \frac{-2\beta_1}{\sqrt{\beta_0^2-4\beta_1\beta_2}}
\end{pmatrix}$$
Now, you can easily write the value of $\nabla g$ at $\hat{\beta}$ and then substitute $\hat{\beta}=(X^TX)^{-1}X^Ty$ and obtain a nicer form for the variance of $\hat{\gamma}$ (this does require some linear algebra work). Finally, you can write down your CI. | Confidence intervals around functions of estimated parameters | Usually we take normality assumption for linear regression models. That is, $y_i\sim N(\beta^Tx_i,\sigma^2)$. From this assumption we derive the asymptotic distribution of $\hat{\beta}$, which is also | Confidence intervals around functions of estimated parameters
Usually we take normality assumption for linear regression models. That is, $y_i\sim N(\beta^Tx_i,\sigma^2)$. From this assumption we derive the asymptotic distribution of $\hat{\beta}$, which is also normal: $\hat{\beta}\overset{.}{\sim}N(\beta,\sigma^2(X^TX)^{-1})$. Let us denote the covariance matrix of $\hat{\beta}$ as $Var(\hat{\beta})=V=\sigma^2(X^TX)^{-1}$.
Next, we take $\gamma=g(\beta)=\sqrt{\beta_0^2-4\beta_1\beta_2}$ so $\hat{\gamma}=g(\hat{\beta})$. The function $g$ is differentiable and let us assume it is non-zero. Equipped with these, we can apply the delta method to get the following estimator:
$$\hat{\gamma}\sim N\left(\gamma,\nabla g(\hat{\beta})^T\cdot V\cdot \nabla g(\hat{\beta})\right)$$
Where $\nabla g(\hat{\beta})$ is the gradient vector of $g$ :
$$\nabla g(\beta)=\begin{pmatrix} \frac{\beta_0}{\sqrt{\beta_0^2-4\beta_1\beta_2}} \\ \frac{-2\beta_2}{\sqrt{\beta_0^2-4\beta_1\beta_2}} \\ \frac{-2\beta_1}{\sqrt{\beta_0^2-4\beta_1\beta_2}}
\end{pmatrix}$$
Now, you can easily write the value of $\nabla g$ at $\hat{\beta}$ and then substitute $\hat{\beta}=(X^TX)^{-1}X^Ty$ and obtain a nicer form for the variance of $\hat{\gamma}$ (this does require some linear algebra work). Finally, you can write down your CI. | Confidence intervals around functions of estimated parameters
Usually we take normality assumption for linear regression models. That is, $y_i\sim N(\beta^Tx_i,\sigma^2)$. From this assumption we derive the asymptotic distribution of $\hat{\beta}$, which is also |
27,050 | Confidence intervals around functions of estimated parameters | It seems like you are estimating the discriminant of a quadratic function, ie. your function is
$$y = \hat{\beta_0} + \hat{\beta_1} X_1 + \hat{\beta_2} X_2 =
\hat{\beta_0} + \hat{\beta_1} X + \hat{\beta_2} X^2$$
We can rewrite this in terms of the roots
$$y = \hat{\beta_2} (X-r_1)(X-r_2)$$
And now we have $$\gamma = \beta_2 (r_2-r_1)$$
If you estimate $\beta_2$, $r_1$, and $r_2$ with a non-linear estimation method and obtain an estimate for the approximate multivariate normal distribution of the estimates (based on an estimate of the Fisher information matrix), then you can describe an estimate distribution for $\gamma$ as a product of two correlated non central normal distributions. | Confidence intervals around functions of estimated parameters | It seems like you are estimating the discriminant of a quadratic function, ie. your function is
$$y = \hat{\beta_0} + \hat{\beta_1} X_1 + \hat{\beta_2} X_2 =
\hat{\beta_0} + \hat{\beta_1} X + \hat{\b | Confidence intervals around functions of estimated parameters
It seems like you are estimating the discriminant of a quadratic function, ie. your function is
$$y = \hat{\beta_0} + \hat{\beta_1} X_1 + \hat{\beta_2} X_2 =
\hat{\beta_0} + \hat{\beta_1} X + \hat{\beta_2} X^2$$
We can rewrite this in terms of the roots
$$y = \hat{\beta_2} (X-r_1)(X-r_2)$$
And now we have $$\gamma = \beta_2 (r_2-r_1)$$
If you estimate $\beta_2$, $r_1$, and $r_2$ with a non-linear estimation method and obtain an estimate for the approximate multivariate normal distribution of the estimates (based on an estimate of the Fisher information matrix), then you can describe an estimate distribution for $\gamma$ as a product of two correlated non central normal distributions. | Confidence intervals around functions of estimated parameters
It seems like you are estimating the discriminant of a quadratic function, ie. your function is
$$y = \hat{\beta_0} + \hat{\beta_1} X_1 + \hat{\beta_2} X_2 =
\hat{\beta_0} + \hat{\beta_1} X + \hat{\b |
27,051 | Confidence intervals around functions of estimated parameters | There's one big problem with your proposed method, although it can be fairly easily remedied. In particular, you compute the estimate of variance of $\gamma$ as $\frac{V(\gamma_i)}{n}$ (where $V(\gamma_i)$ is variance of your samples generated by first sampling from the multi variance normal and then pushing through your function), when the standard error should really just be $V(\gamma_i)$.
But furthermore, I would suggest you use the simulated percentiles to create the CI rather than using the mean + se formula.
And one final note, we note that the sqrt function is not defined for negative values. This means if a random draw gives you $4\beta_1 \beta_2 > \beta_0^2$, your estimate is not real valued. Assuming that this is not what you want to do, I would say you should consider simply dropping the simulated values when this is true. That may seem adhoc, but it perfectly aligns with defining a restricted parameter space where $4\beta_1 \beta_2 \le \beta_0^2$. | Confidence intervals around functions of estimated parameters | There's one big problem with your proposed method, although it can be fairly easily remedied. In particular, you compute the estimate of variance of $\gamma$ as $\frac{V(\gamma_i)}{n}$ (where $V(\gamm | Confidence intervals around functions of estimated parameters
There's one big problem with your proposed method, although it can be fairly easily remedied. In particular, you compute the estimate of variance of $\gamma$ as $\frac{V(\gamma_i)}{n}$ (where $V(\gamma_i)$ is variance of your samples generated by first sampling from the multi variance normal and then pushing through your function), when the standard error should really just be $V(\gamma_i)$.
But furthermore, I would suggest you use the simulated percentiles to create the CI rather than using the mean + se formula.
And one final note, we note that the sqrt function is not defined for negative values. This means if a random draw gives you $4\beta_1 \beta_2 > \beta_0^2$, your estimate is not real valued. Assuming that this is not what you want to do, I would say you should consider simply dropping the simulated values when this is true. That may seem adhoc, but it perfectly aligns with defining a restricted parameter space where $4\beta_1 \beta_2 \le \beta_0^2$. | Confidence intervals around functions of estimated parameters
There's one big problem with your proposed method, although it can be fairly easily remedied. In particular, you compute the estimate of variance of $\gamma$ as $\frac{V(\gamma_i)}{n}$ (where $V(\gamm |
27,052 | How should variables in statistics be understood? | Units are often understood to be part of a random variable. If someone writes that "$h_i$ is the height of the $i$th patient ", you're meant to assume that every $i$ uses the same unit and it's a sensible one given the context (say, meters if $i$ indexes over adult humans). This is often omitted for clarity, but it would better if people explicitly wrote it out, as " $h_i$ is the height of the $i$th patient in meters."
This restricts how you can manipulate these variables. You can only directly add or subtract variables with the same units, which yields a result with the same units as the original (but see below). Variables with different units can be multiplied or divided, with the result having compound units. If $X$ is in meters and $Y$ in seconds, $\frac{X}{Y}$ has units of $\frac{\text{m}}{\text{s}}$ and $XY$ has units of $\text{m}\cdot \text{s}$. You can also multiply and divide by unitless values, like the number of data points. This doesn't affect the units. Thus, the mean has the same units as the data from which is calculated, as does the standard deviation. Variance, however, has squared units: if $X$ is in meters, $V(X)$ has units of $\text{m}^2$.
Some statistical operations remove the units. Suppose you have a set of heights $h_i$ measured in meters. If you plug these into into the formula for $Z$-scores
$$z_i = \frac{h_i - \bar{h}}{\sigma_h}$$
you'll notice that the units cancel:
$\frac{\left(\text{meter} - \text{meter}\right) \overset{\Delta}{=} \text{meter}}{\text{meter}} = 1$, so $z_i$ is unitless. In a sense, this is the whole point: the $Z$ score is used to make variables, potentially measured with on different scales and with different units, comparable. Covariance and correlation also make a useful pair of examples. If you grind though the formula, you'll find the the covariance of $X$ and $Y$ has units of $x \cdot y$ and a scale that depends on the original variable. Correlation includes a "normalization" term that rescales this to between -1 and +1, while removing the units. This too is intentional: it lets you use correlation to compare relationships between disparate quantities.
Others find conversions between units. You can interpret regression as finding the "best" way to convert between the dependent and independent variables. Suppose you want to crudely predict people's heights. Using a set of heights (in meters), weights (in kilograms), and sex, you might fit a model like:
$$ \text{height} = \beta_0 + \beta_1 \text{weight} + \beta_2 \text{sex}$$
The coefficient $\beta_1$ needs to have units of $\frac{\text{m}}{\text{kg}}$ for the equation to balance, and that's exactly how you should interpret it. Holding everything else at its baseline level, a $1 \text{ kg}$ increase in weight corresponds to a $\beta_1 \text{ m}$ increase in predicted height! Categorical variables are conceptually similar. We usually encode them as (unitless) numbers, such as male=0, female=1. $\beta_2$ is therefore in units of meters. You can also imagine that it's in the fictitious units of meters per sex-code or something if you want to move the units through the encoding process instead.
This holds for linear models, but you can apply similar logic to other families. A logistic regression, for example, predicts probabilities and finds coefficients that can be interpreted as mapping between the predictors and changes in log odds.
Want to learn more? If you're familiar with dimensional analysis from a natural science class, you may enjoy this article Nick Cox found.
Finney, D. J. (1977). Dimensions of Statistics. Journal of the Royal Statistical Society. Series C (Applied Statistics), 26(3), 285–289. https://doi.org/10.2307/2346969
If you want more practice with dimensional analysis, check out the first chapter of Sanjoy Mahajan's Street Fighting Mathematics, available with open-access here. | How should variables in statistics be understood? | Units are often understood to be part of a random variable. If someone writes that "$h_i$ is the height of the $i$th patient ", you're meant to assume that every $i$ uses the same unit and it's a sens | How should variables in statistics be understood?
Units are often understood to be part of a random variable. If someone writes that "$h_i$ is the height of the $i$th patient ", you're meant to assume that every $i$ uses the same unit and it's a sensible one given the context (say, meters if $i$ indexes over adult humans). This is often omitted for clarity, but it would better if people explicitly wrote it out, as " $h_i$ is the height of the $i$th patient in meters."
This restricts how you can manipulate these variables. You can only directly add or subtract variables with the same units, which yields a result with the same units as the original (but see below). Variables with different units can be multiplied or divided, with the result having compound units. If $X$ is in meters and $Y$ in seconds, $\frac{X}{Y}$ has units of $\frac{\text{m}}{\text{s}}$ and $XY$ has units of $\text{m}\cdot \text{s}$. You can also multiply and divide by unitless values, like the number of data points. This doesn't affect the units. Thus, the mean has the same units as the data from which is calculated, as does the standard deviation. Variance, however, has squared units: if $X$ is in meters, $V(X)$ has units of $\text{m}^2$.
Some statistical operations remove the units. Suppose you have a set of heights $h_i$ measured in meters. If you plug these into into the formula for $Z$-scores
$$z_i = \frac{h_i - \bar{h}}{\sigma_h}$$
you'll notice that the units cancel:
$\frac{\left(\text{meter} - \text{meter}\right) \overset{\Delta}{=} \text{meter}}{\text{meter}} = 1$, so $z_i$ is unitless. In a sense, this is the whole point: the $Z$ score is used to make variables, potentially measured with on different scales and with different units, comparable. Covariance and correlation also make a useful pair of examples. If you grind though the formula, you'll find the the covariance of $X$ and $Y$ has units of $x \cdot y$ and a scale that depends on the original variable. Correlation includes a "normalization" term that rescales this to between -1 and +1, while removing the units. This too is intentional: it lets you use correlation to compare relationships between disparate quantities.
Others find conversions between units. You can interpret regression as finding the "best" way to convert between the dependent and independent variables. Suppose you want to crudely predict people's heights. Using a set of heights (in meters), weights (in kilograms), and sex, you might fit a model like:
$$ \text{height} = \beta_0 + \beta_1 \text{weight} + \beta_2 \text{sex}$$
The coefficient $\beta_1$ needs to have units of $\frac{\text{m}}{\text{kg}}$ for the equation to balance, and that's exactly how you should interpret it. Holding everything else at its baseline level, a $1 \text{ kg}$ increase in weight corresponds to a $\beta_1 \text{ m}$ increase in predicted height! Categorical variables are conceptually similar. We usually encode them as (unitless) numbers, such as male=0, female=1. $\beta_2$ is therefore in units of meters. You can also imagine that it's in the fictitious units of meters per sex-code or something if you want to move the units through the encoding process instead.
This holds for linear models, but you can apply similar logic to other families. A logistic regression, for example, predicts probabilities and finds coefficients that can be interpreted as mapping between the predictors and changes in log odds.
Want to learn more? If you're familiar with dimensional analysis from a natural science class, you may enjoy this article Nick Cox found.
Finney, D. J. (1977). Dimensions of Statistics. Journal of the Royal Statistical Society. Series C (Applied Statistics), 26(3), 285–289. https://doi.org/10.2307/2346969
If you want more practice with dimensional analysis, check out the first chapter of Sanjoy Mahajan's Street Fighting Mathematics, available with open-access here. | How should variables in statistics be understood?
Units are often understood to be part of a random variable. If someone writes that "$h_i$ is the height of the $i$th patient ", you're meant to assume that every $i$ uses the same unit and it's a sens |
27,053 | How should variables in statistics be understood? | You have to be careful here, because this depends on what exactly you're doing. For example, if you consider just a single variable and you compare two groups, methods such as a two-sample t-test or Wilcoxon test are scale invariant, meaning that their outcome will not depend on the measurement unit, and will be the same if you apply a linear (t-test) or even monotonic (Wilcoxon) transformation to the data, as is a change of measurement units.
Note that in most cases changes of measurement unit are linear, but they may not necessarily be, for example fuel consumption of cars can be measured by "gallons per mile" and "miles per gallon"; and you may get different results even in a t-test (as this is only invariant to linear transformation), depending on which measurement unit you choose, but not in a Wilcoxon.
If you want to test, in a single sample, for example "true mean=5", obviously this needs to use the same measurement unit as your data.
Furthermore, there are methods in statistics that are not scale invariant. Particularly when you're working with more than one variable, multivariate methods that bring information from several variables with potentially different measurement units together may be sensitive to the measurement scales. For example Principal Component Analysis and k-means clustering will implicitly give higher weight to variables that have a larger variance. This means that if one variable is weight in kg and the other one is height, the weight/impact of the height variable for the overall result will be higher if height is in cm than if the same heights are given in m, as this will yield smaller numbers and a smaller variance. In such cases it is normally recommended to standardise the data (standardising removes the effect from linear changes of the measurement units), whereas this is not recommended in some cases if the measurement units for all variables are the same, namely if for some reason in the given situation a larger variance implies that a variable is in fact more informative than the others. | How should variables in statistics be understood? | You have to be careful here, because this depends on what exactly you're doing. For example, if you consider just a single variable and you compare two groups, methods such as a two-sample t-test or W | How should variables in statistics be understood?
You have to be careful here, because this depends on what exactly you're doing. For example, if you consider just a single variable and you compare two groups, methods such as a two-sample t-test or Wilcoxon test are scale invariant, meaning that their outcome will not depend on the measurement unit, and will be the same if you apply a linear (t-test) or even monotonic (Wilcoxon) transformation to the data, as is a change of measurement units.
Note that in most cases changes of measurement unit are linear, but they may not necessarily be, for example fuel consumption of cars can be measured by "gallons per mile" and "miles per gallon"; and you may get different results even in a t-test (as this is only invariant to linear transformation), depending on which measurement unit you choose, but not in a Wilcoxon.
If you want to test, in a single sample, for example "true mean=5", obviously this needs to use the same measurement unit as your data.
Furthermore, there are methods in statistics that are not scale invariant. Particularly when you're working with more than one variable, multivariate methods that bring information from several variables with potentially different measurement units together may be sensitive to the measurement scales. For example Principal Component Analysis and k-means clustering will implicitly give higher weight to variables that have a larger variance. This means that if one variable is weight in kg and the other one is height, the weight/impact of the height variable for the overall result will be higher if height is in cm than if the same heights are given in m, as this will yield smaller numbers and a smaller variance. In such cases it is normally recommended to standardise the data (standardising removes the effect from linear changes of the measurement units), whereas this is not recommended in some cases if the measurement units for all variables are the same, namely if for some reason in the given situation a larger variance implies that a variable is in fact more informative than the others. | How should variables in statistics be understood?
You have to be careful here, because this depends on what exactly you're doing. For example, if you consider just a single variable and you compare two groups, methods such as a two-sample t-test or W |
27,054 | How should variables in statistics be understood? | Implicitly, there is a unit-conversion factor in front of the height. Thus, the full way to write it is something like:
$$
\text{weight (lbs)} = \dfrac{1 \text{ lbs}}{1 \text{ ft}}\bigg(\text{Height (ft)}\bigg) + 4\text{ (lbs)}
$$
It is typical to ignore units, and statistics tends to work out fine, but you are correct that the units are there and do sometimes need to be considered. For instance, if you wanted to calculate the weight for a subject who has their height measured in meters, you cannot just plug that number of meters into the equation. You would first have to convert the height in meters to a height in feet. | How should variables in statistics be understood? | Implicitly, there is a unit-conversion factor in front of the height. Thus, the full way to write it is something like:
$$
\text{weight (lbs)} = \dfrac{1 \text{ lbs}}{1 \text{ ft}}\bigg(\text{Height ( | How should variables in statistics be understood?
Implicitly, there is a unit-conversion factor in front of the height. Thus, the full way to write it is something like:
$$
\text{weight (lbs)} = \dfrac{1 \text{ lbs}}{1 \text{ ft}}\bigg(\text{Height (ft)}\bigg) + 4\text{ (lbs)}
$$
It is typical to ignore units, and statistics tends to work out fine, but you are correct that the units are there and do sometimes need to be considered. For instance, if you wanted to calculate the weight for a subject who has their height measured in meters, you cannot just plug that number of meters into the equation. You would first have to convert the height in meters to a height in feet. | How should variables in statistics be understood?
Implicitly, there is a unit-conversion factor in front of the height. Thus, the full way to write it is something like:
$$
\text{weight (lbs)} = \dfrac{1 \text{ lbs}}{1 \text{ ft}}\bigg(\text{Height ( |
27,055 | How should variables in statistics be understood? | Largely ignorable--the regression won't care if you measure height in inches or feet. However very small or very large numbers (millions or millionths) can cause issues due to software limitations. So when dealing with a large number such as count of population, or count of road miles, you might divide the total (e.g. 12345678) by a thousand to get 1234.5678. Likewise, if you are dealing with a very small number (e.g. pediatric cancer rate per million of .001234), you might change units to get 1.234. | How should variables in statistics be understood? | Largely ignorable--the regression won't care if you measure height in inches or feet. However very small or very large numbers (millions or millionths) can cause issues due to software limitations. So | How should variables in statistics be understood?
Largely ignorable--the regression won't care if you measure height in inches or feet. However very small or very large numbers (millions or millionths) can cause issues due to software limitations. So when dealing with a large number such as count of population, or count of road miles, you might divide the total (e.g. 12345678) by a thousand to get 1234.5678. Likewise, if you are dealing with a very small number (e.g. pediatric cancer rate per million of .001234), you might change units to get 1.234. | How should variables in statistics be understood?
Largely ignorable--the regression won't care if you measure height in inches or feet. However very small or very large numbers (millions or millionths) can cause issues due to software limitations. So |
27,056 | Loss function in machine learning - how to constrain? | This isn't exactly what you've asked for, but it's a very easy solution to implement in neural network libraries like keras, tensorflow and pytorch.
The main idea is to penalize the loss whenever the inequality $L_1 > L_2$ is violated. This inequality is violated whenever $L_2 \ge L_1$;on the other hand, we don't want to penalize the loss at all when $L_1 > L_2$. This describes a ReLU function in $L_1, L_2$:
$$
\min L_1 + L_2 + \lambda\text{ReLU}(L_2 - L_1)
$$
The hyper-parameter $\lambda>0$ controls how steep the penalty should be for violating the inequality.
This loss doesn't guarantee that the inequality is satisfied, but it is an improvement over minimizing $L_1 + L_2$ alone.
This loss is just a composition of functions readily available in modern neural network libraries, so it's simple to implement.
In comments, jkpate makes the following suggestion:
Notice that if you incorporate a maximization over $\lambda$, then we do get exactly what the poster asked for because we now have a two-player formulation of the Lagrange dual to the original constrained optimization problem. Essentially, rather than setting $\lambda$ be fixed, we allow the penalty for a violation to grow. See Cotter et al. "Two-Player Games for Efficient Non-Convex Constrained Optimization" (2019) for the theory and https://github.com/google-research/tensorflow_constrained_optimization for a Tensorflow implementation.
If I understand correctly, this allows the estimation procedure to select a good value of $\lambda$, rather than the user fixing a particular value ahead of time and worrying about whether that fixed value is a good choice. | Loss function in machine learning - how to constrain? | This isn't exactly what you've asked for, but it's a very easy solution to implement in neural network libraries like keras, tensorflow and pytorch.
The main idea is to penalize the loss whenever the | Loss function in machine learning - how to constrain?
This isn't exactly what you've asked for, but it's a very easy solution to implement in neural network libraries like keras, tensorflow and pytorch.
The main idea is to penalize the loss whenever the inequality $L_1 > L_2$ is violated. This inequality is violated whenever $L_2 \ge L_1$;on the other hand, we don't want to penalize the loss at all when $L_1 > L_2$. This describes a ReLU function in $L_1, L_2$:
$$
\min L_1 + L_2 + \lambda\text{ReLU}(L_2 - L_1)
$$
The hyper-parameter $\lambda>0$ controls how steep the penalty should be for violating the inequality.
This loss doesn't guarantee that the inequality is satisfied, but it is an improvement over minimizing $L_1 + L_2$ alone.
This loss is just a composition of functions readily available in modern neural network libraries, so it's simple to implement.
In comments, jkpate makes the following suggestion:
Notice that if you incorporate a maximization over $\lambda$, then we do get exactly what the poster asked for because we now have a two-player formulation of the Lagrange dual to the original constrained optimization problem. Essentially, rather than setting $\lambda$ be fixed, we allow the penalty for a violation to grow. See Cotter et al. "Two-Player Games for Efficient Non-Convex Constrained Optimization" (2019) for the theory and https://github.com/google-research/tensorflow_constrained_optimization for a Tensorflow implementation.
If I understand correctly, this allows the estimation procedure to select a good value of $\lambda$, rather than the user fixing a particular value ahead of time and worrying about whether that fixed value is a good choice. | Loss function in machine learning - how to constrain?
This isn't exactly what you've asked for, but it's a very easy solution to implement in neural network libraries like keras, tensorflow and pytorch.
The main idea is to penalize the loss whenever the |
27,057 | Loss function in machine learning - how to constrain? | That will likely give you unexpected results. Minimizing your loss will incentivize your algorithm to minimize L2, but to maximize L1. There is no incentive to minimize L1.
It sounds like you have a constraint minimization problem: minimize L1+L2, subject to L1>L2. This is very common in optimization software, but less so in ML fitting software. You will likely need to feed this into your modeler in some tool-specific way, if such a constraint can be modeled at all. | Loss function in machine learning - how to constrain? | That will likely give you unexpected results. Minimizing your loss will incentivize your algorithm to minimize L2, but to maximize L1. There is no incentive to minimize L1.
It sounds like you have a c | Loss function in machine learning - how to constrain?
That will likely give you unexpected results. Minimizing your loss will incentivize your algorithm to minimize L2, but to maximize L1. There is no incentive to minimize L1.
It sounds like you have a constraint minimization problem: minimize L1+L2, subject to L1>L2. This is very common in optimization software, but less so in ML fitting software. You will likely need to feed this into your modeler in some tool-specific way, if such a constraint can be modeled at all. | Loss function in machine learning - how to constrain?
That will likely give you unexpected results. Minimizing your loss will incentivize your algorithm to minimize L2, but to maximize L1. There is no incentive to minimize L1.
It sounds like you have a c |
27,058 | Loss function in machine learning - how to constrain? | No, that is not correct. If you want to minimize both, definitely you should write L1+L2, but not L2-L1.
This is because in L2-L1, we can always make L1 to be huge (maximize L1) to make the final loss small.
The problem can be formulated to
$$\text{minimze} ~~L_1+L_2$$
$$\text{st.}~ L_2 -L_1 >0$$
And in many case, if we want to emphasize one loss than another we can use a weighted sum where
$$\text{minimze} ~~\alpha L_1+ (1-\alpha)L_2$$ | Loss function in machine learning - how to constrain? | No, that is not correct. If you want to minimize both, definitely you should write L1+L2, but not L2-L1.
This is because in L2-L1, we can always make L1 to be huge (maximize L1) to make the final loss | Loss function in machine learning - how to constrain?
No, that is not correct. If you want to minimize both, definitely you should write L1+L2, but not L2-L1.
This is because in L2-L1, we can always make L1 to be huge (maximize L1) to make the final loss small.
The problem can be formulated to
$$\text{minimze} ~~L_1+L_2$$
$$\text{st.}~ L_2 -L_1 >0$$
And in many case, if we want to emphasize one loss than another we can use a weighted sum where
$$\text{minimze} ~~\alpha L_1+ (1-\alpha)L_2$$ | Loss function in machine learning - how to constrain?
No, that is not correct. If you want to minimize both, definitely you should write L1+L2, but not L2-L1.
This is because in L2-L1, we can always make L1 to be huge (maximize L1) to make the final loss |
27,059 | Loss function in machine learning - how to constrain? | I would try to follow the Kuhn-Tucker problem setup for inequality constrained optimization. Here's how its objective is set as a Lagrangian:
$$L(x,\lambda)=L_1(x)+L_2(x)+\lambda(L_2(x)-L_1(x))$$
You need to find a saddle point where $\nabla L=0$, then $x$ will be the optimum. Normally, in optimization we don't like saddle points though, because they're not optima. However, in this case we're optimizing both $x$ and $\lambda$, not just $x$, so the saddle point is what we need.
Maybe experiment with Newton's method optimizer in your Neural Net. Unlike some other optimizers, such as SGD, this one is attracted to saddle points. I like @Sycorax answer where he uses ReLU. However, I believe than Kuhn-Tucker lagrangian will be more efficient if you manage to convine your NN that saddle points are Ok. The reason being is that ReLU will have a flat gradient everywhere where $L_1>L_2$, so the speed convergence must be relatively lower. At the same type ReLU is obviously a no brainer to setup in any NN. | Loss function in machine learning - how to constrain? | I would try to follow the Kuhn-Tucker problem setup for inequality constrained optimization. Here's how its objective is set as a Lagrangian:
$$L(x,\lambda)=L_1(x)+L_2(x)+\lambda(L_2(x)-L_1(x))$$
You | Loss function in machine learning - how to constrain?
I would try to follow the Kuhn-Tucker problem setup for inequality constrained optimization. Here's how its objective is set as a Lagrangian:
$$L(x,\lambda)=L_1(x)+L_2(x)+\lambda(L_2(x)-L_1(x))$$
You need to find a saddle point where $\nabla L=0$, then $x$ will be the optimum. Normally, in optimization we don't like saddle points though, because they're not optima. However, in this case we're optimizing both $x$ and $\lambda$, not just $x$, so the saddle point is what we need.
Maybe experiment with Newton's method optimizer in your Neural Net. Unlike some other optimizers, such as SGD, this one is attracted to saddle points. I like @Sycorax answer where he uses ReLU. However, I believe than Kuhn-Tucker lagrangian will be more efficient if you manage to convine your NN that saddle points are Ok. The reason being is that ReLU will have a flat gradient everywhere where $L_1>L_2$, so the speed convergence must be relatively lower. At the same type ReLU is obviously a no brainer to setup in any NN. | Loss function in machine learning - how to constrain?
I would try to follow the Kuhn-Tucker problem setup for inequality constrained optimization. Here's how its objective is set as a Lagrangian:
$$L(x,\lambda)=L_1(x)+L_2(x)+\lambda(L_2(x)-L_1(x))$$
You |
27,060 | Why is the sum of probabilities in a continuous uniform distribution not infinity? | $f(x)$ describes the probability density rather than a probability mass in your example. In general, for continuous distributions the events—the things we get probabilities for—are ranges of values, such as for the area under the curve from $a$ to $a+.1$, or from $a$ to $b$ (although such ranges need not be contiguous). For continuous distributions, the probability of any single value occurring is generally 0. | Why is the sum of probabilities in a continuous uniform distribution not infinity? | $f(x)$ describes the probability density rather than a probability mass in your example. In general, for continuous distributions the events—the things we get probabilities for—are ranges of values, s | Why is the sum of probabilities in a continuous uniform distribution not infinity?
$f(x)$ describes the probability density rather than a probability mass in your example. In general, for continuous distributions the events—the things we get probabilities for—are ranges of values, such as for the area under the curve from $a$ to $a+.1$, or from $a$ to $b$ (although such ranges need not be contiguous). For continuous distributions, the probability of any single value occurring is generally 0. | Why is the sum of probabilities in a continuous uniform distribution not infinity?
$f(x)$ describes the probability density rather than a probability mass in your example. In general, for continuous distributions the events—the things we get probabilities for—are ranges of values, s |
27,061 | Why is the sum of probabilities in a continuous uniform distribution not infinity? | Because each term in the summation is weighted by the infinitesimal d$x$. The importance of this is probably most easily understood by carefully walking through a very basic example.
Consider using Riemann summation to compute the area under the following rectangular region (a rectangle was chosen to remove the approximation aspect of Riemann summation, which is not the focus here):
]
We can compute the area using 2 subregions, or by using 4 subregions. In the case of the 2 subregions (denoted $A_i$), the areas are given by $$A_1=A_2=5\times 2 = 10$$ whereas in the case of 4 subregions (denoted $B_i$), the areas are given by $$B_1=B_2=B_3=B_4=5\times 1 = 5$$ The total area in both cases correspond to $$\sum_{i=1}^2 A_i = \sum_{i=1}^4B_i = 20$$
Now, this is all fairly obvious, but it raises a subtly important question which is: why do these two answers agree? Intuitively it should be clear that it works because we've reduced the width of the second set of subregions. We could consider doing the same thing with 8 subregions each with a width of $0.5$, and again with 16... and we could continue this process until we have an infinite number of subregions, each with a tiny width of d$x$. As long as everything is always correctly weighted, the answers should always agree. Without the correct weighting, the summation would indeed simply be $\infty$.
This is why I always make sure to point out to students that an integral is not simply the symbol $\int$, but the pair of symbols $\int \text dx$. | Why is the sum of probabilities in a continuous uniform distribution not infinity? | Because each term in the summation is weighted by the infinitesimal d$x$. The importance of this is probably most easily understood by carefully walking through a very basic example.
Consider using R | Why is the sum of probabilities in a continuous uniform distribution not infinity?
Because each term in the summation is weighted by the infinitesimal d$x$. The importance of this is probably most easily understood by carefully walking through a very basic example.
Consider using Riemann summation to compute the area under the following rectangular region (a rectangle was chosen to remove the approximation aspect of Riemann summation, which is not the focus here):
]
We can compute the area using 2 subregions, or by using 4 subregions. In the case of the 2 subregions (denoted $A_i$), the areas are given by $$A_1=A_2=5\times 2 = 10$$ whereas in the case of 4 subregions (denoted $B_i$), the areas are given by $$B_1=B_2=B_3=B_4=5\times 1 = 5$$ The total area in both cases correspond to $$\sum_{i=1}^2 A_i = \sum_{i=1}^4B_i = 20$$
Now, this is all fairly obvious, but it raises a subtly important question which is: why do these two answers agree? Intuitively it should be clear that it works because we've reduced the width of the second set of subregions. We could consider doing the same thing with 8 subregions each with a width of $0.5$, and again with 16... and we could continue this process until we have an infinite number of subregions, each with a tiny width of d$x$. As long as everything is always correctly weighted, the answers should always agree. Without the correct weighting, the summation would indeed simply be $\infty$.
This is why I always make sure to point out to students that an integral is not simply the symbol $\int$, but the pair of symbols $\int \text dx$. | Why is the sum of probabilities in a continuous uniform distribution not infinity?
Because each term in the summation is weighted by the infinitesimal d$x$. The importance of this is probably most easily understood by carefully walking through a very basic example.
Consider using R |
27,062 | Why is the sum of probabilities in a continuous uniform distribution not infinity? | You're interpreting the probability distribution the wrong way - it is an infinite number of infinitely divided probabilities, so you can't say that "the probability of drawing the value 0.5 from a (0, 1) uniform distribution" because that probability is zero - there are an infinite number of possible values you could get, and all of them are equally likely, so clearly the probability of any individual outcome is $\frac{1}{\infty} = 0$[1].
Instead, you can look at the probability for a range of outcomes, and measure that using areas (and hence integrals). For example, if you draw from the (0, 1) uniform distribution (with pdf $f(x) = 1$ for $x \in \left[0, 1\right]$ and $f(x) = 0$ otherwise), then the probability that your result lies between $0.2$ and $0.3$ is
$\int_{0.2}^{0.3} f(x)\ dx = \int_{0.2}^{0.3} 1\ dx = \left[x \right]_{0.2}^{0.3} = 0.3 - 0.2 = 0.1$
i.e. you have a 10% chance of getting a result in that range.
[1]Sorry for all the people having heart attacks at my over-simplification of the calculation. | Why is the sum of probabilities in a continuous uniform distribution not infinity? | You're interpreting the probability distribution the wrong way - it is an infinite number of infinitely divided probabilities, so you can't say that "the probability of drawing the value 0.5 from a (0 | Why is the sum of probabilities in a continuous uniform distribution not infinity?
You're interpreting the probability distribution the wrong way - it is an infinite number of infinitely divided probabilities, so you can't say that "the probability of drawing the value 0.5 from a (0, 1) uniform distribution" because that probability is zero - there are an infinite number of possible values you could get, and all of them are equally likely, so clearly the probability of any individual outcome is $\frac{1}{\infty} = 0$[1].
Instead, you can look at the probability for a range of outcomes, and measure that using areas (and hence integrals). For example, if you draw from the (0, 1) uniform distribution (with pdf $f(x) = 1$ for $x \in \left[0, 1\right]$ and $f(x) = 0$ otherwise), then the probability that your result lies between $0.2$ and $0.3$ is
$\int_{0.2}^{0.3} f(x)\ dx = \int_{0.2}^{0.3} 1\ dx = \left[x \right]_{0.2}^{0.3} = 0.3 - 0.2 = 0.1$
i.e. you have a 10% chance of getting a result in that range.
[1]Sorry for all the people having heart attacks at my over-simplification of the calculation. | Why is the sum of probabilities in a continuous uniform distribution not infinity?
You're interpreting the probability distribution the wrong way - it is an infinite number of infinitely divided probabilities, so you can't say that "the probability of drawing the value 0.5 from a (0 |
27,063 | Why is the sum of probabilities in a continuous uniform distribution not infinity? | $f(x)$ describes the probability density, and has the unit $\frac{p}{x}$. Hence for a given x you get $f(x) = \frac{1}{b-a}$ in $\frac{p}{x}$ units, and not p, as you are looking for. If you want p, you need the distribution function for a given range, that is the probability p of x being within a and b.
Hope this makes sense. | Why is the sum of probabilities in a continuous uniform distribution not infinity? | $f(x)$ describes the probability density, and has the unit $\frac{p}{x}$. Hence for a given x you get $f(x) = \frac{1}{b-a}$ in $\frac{p}{x}$ units, and not p, as you are looking for. If you want p, y | Why is the sum of probabilities in a continuous uniform distribution not infinity?
$f(x)$ describes the probability density, and has the unit $\frac{p}{x}$. Hence for a given x you get $f(x) = \frac{1}{b-a}$ in $\frac{p}{x}$ units, and not p, as you are looking for. If you want p, you need the distribution function for a given range, that is the probability p of x being within a and b.
Hope this makes sense. | Why is the sum of probabilities in a continuous uniform distribution not infinity?
$f(x)$ describes the probability density, and has the unit $\frac{p}{x}$. Hence for a given x you get $f(x) = \frac{1}{b-a}$ in $\frac{p}{x}$ units, and not p, as you are looking for. If you want p, y |
27,064 | Why is the sum of probabilities in a continuous uniform distribution not infinity? | In general your reasoning fails in this assumption:
However, since there are an infinite number of numbers in that interval, shouldn't the sum of all the probabilities sum up to infinity?
It's a mathematical problem, known since the Zeno of Elea Paradoxes.
Two of his claims were that
An arrow can never reach its target
Achilles will never overtake a turtle
Both of them were based on the claim that you can build an infinite sequence of positive numbers (in the former case by saying that an arrow has to fly infinitely times half of the remaining way to the target, in the latter by saying that Achilles has to reach position where the turtle was previously, and in the meantime the turtle moves to a new position that becomes our next reference base point).
Fast forward, this led to a discovery of infinite sums.
So in general sum of infinite many positive numbers does not necessarily have to be infinite; however, it may not be infinite only if (an extreme oversimplification, sorry about that) almost all of the numbers in the sequence are very close to 0, regardless how close to zero you request them to be.
Infinity plays even more tricks. The order in which you add elements of the sequence is important too and might lead to a situation that reordering gives different results!
Explore a bit more about paradoxes of infinity. You might be astonished. | Why is the sum of probabilities in a continuous uniform distribution not infinity? | In general your reasoning fails in this assumption:
However, since there are an infinite number of numbers in that interval, shouldn't the sum of all the probabilities sum up to infinity?
It's a mat | Why is the sum of probabilities in a continuous uniform distribution not infinity?
In general your reasoning fails in this assumption:
However, since there are an infinite number of numbers in that interval, shouldn't the sum of all the probabilities sum up to infinity?
It's a mathematical problem, known since the Zeno of Elea Paradoxes.
Two of his claims were that
An arrow can never reach its target
Achilles will never overtake a turtle
Both of them were based on the claim that you can build an infinite sequence of positive numbers (in the former case by saying that an arrow has to fly infinitely times half of the remaining way to the target, in the latter by saying that Achilles has to reach position where the turtle was previously, and in the meantime the turtle moves to a new position that becomes our next reference base point).
Fast forward, this led to a discovery of infinite sums.
So in general sum of infinite many positive numbers does not necessarily have to be infinite; however, it may not be infinite only if (an extreme oversimplification, sorry about that) almost all of the numbers in the sequence are very close to 0, regardless how close to zero you request them to be.
Infinity plays even more tricks. The order in which you add elements of the sequence is important too and might lead to a situation that reordering gives different results!
Explore a bit more about paradoxes of infinity. You might be astonished. | Why is the sum of probabilities in a continuous uniform distribution not infinity?
In general your reasoning fails in this assumption:
However, since there are an infinite number of numbers in that interval, shouldn't the sum of all the probabilities sum up to infinity?
It's a mat |
27,065 | Is a variable significant in a linear regression model? | Statistical significance is not usually a good basis for determining whether a variable should be included in a model. Statistical tests were designed to test hypotheses, not select variables. I know a lot of textbooks discuss variable selection using statistical tests, but this is generally a bad approach. See Harrell's book Regression Modelling Strategies for some of the reasons why. These days, variable selection based on the AIC (or something similar) is usually preferred. | Is a variable significant in a linear regression model? | Statistical significance is not usually a good basis for determining whether a variable should be included in a model. Statistical tests were designed to test hypotheses, not select variables. I know | Is a variable significant in a linear regression model?
Statistical significance is not usually a good basis for determining whether a variable should be included in a model. Statistical tests were designed to test hypotheses, not select variables. I know a lot of textbooks discuss variable selection using statistical tests, but this is generally a bad approach. See Harrell's book Regression Modelling Strategies for some of the reasons why. These days, variable selection based on the AIC (or something similar) is usually preferred. | Is a variable significant in a linear regression model?
Statistical significance is not usually a good basis for determining whether a variable should be included in a model. Statistical tests were designed to test hypotheses, not select variables. I know |
27,066 | Is a variable significant in a linear regression model? | I second Rob's comment. An increasingly prefered alternative is to include all your variables and shrink them towards 0. See Tibshirani, R. (1996). Regression shrinkage and selection via the lasso.
http://www-stat.stanford.edu/~tibs/lasso/lasso.pdf | Is a variable significant in a linear regression model? | I second Rob's comment. An increasingly prefered alternative is to include all your variables and shrink them towards 0. See Tibshirani, R. (1996). Regression shrinkage and selection via the lasso.
ht | Is a variable significant in a linear regression model?
I second Rob's comment. An increasingly prefered alternative is to include all your variables and shrink them towards 0. See Tibshirani, R. (1996). Regression shrinkage and selection via the lasso.
http://www-stat.stanford.edu/~tibs/lasso/lasso.pdf | Is a variable significant in a linear regression model?
I second Rob's comment. An increasingly prefered alternative is to include all your variables and shrink them towards 0. See Tibshirani, R. (1996). Regression shrinkage and selection via the lasso.
ht |
27,067 | Is a variable significant in a linear regression model? | For part 1, you're looking for the F-test. Calculate your residual sum of squares from each model fit and calculate an F-statistic, which you can use to find p-values from either an F-distribution or some other null distribution that you generate yourself. | Is a variable significant in a linear regression model? | For part 1, you're looking for the F-test. Calculate your residual sum of squares from each model fit and calculate an F-statistic, which you can use to find p-values from either an F-distribution or | Is a variable significant in a linear regression model?
For part 1, you're looking for the F-test. Calculate your residual sum of squares from each model fit and calculate an F-statistic, which you can use to find p-values from either an F-distribution or some other null distribution that you generate yourself. | Is a variable significant in a linear regression model?
For part 1, you're looking for the F-test. Calculate your residual sum of squares from each model fit and calculate an F-statistic, which you can use to find p-values from either an F-distribution or |
27,068 | Is a variable significant in a linear regression model? | Another vote for Rob's answer.
There are also some interesting ideas in the "relative importance" literature. This work develops methods that seek to determine how much importance is associated with each of a number of candidate predictors. There are Bayesian and Frequentist methods. Check the "relaimpo" package in R for citations and code. | Is a variable significant in a linear regression model? | Another vote for Rob's answer.
There are also some interesting ideas in the "relative importance" literature. This work develops methods that seek to determine how much importance is associated with | Is a variable significant in a linear regression model?
Another vote for Rob's answer.
There are also some interesting ideas in the "relative importance" literature. This work develops methods that seek to determine how much importance is associated with each of a number of candidate predictors. There are Bayesian and Frequentist methods. Check the "relaimpo" package in R for citations and code. | Is a variable significant in a linear regression model?
Another vote for Rob's answer.
There are also some interesting ideas in the "relative importance" literature. This work develops methods that seek to determine how much importance is associated with |
27,069 | Is a variable significant in a linear regression model? | I also like Rob's answer. And, if you happen to use SAS rather than R, you can use PROC GLMSELECT for models that would be done with PROC GLM, although it works well for some other models, as well. See
Flom and Cassell "Stopping Stepwise: Why Stepwise Selection Methods are Bad and What you Should Use" presented at various groups, most recently, NESUG 2009 | Is a variable significant in a linear regression model? | I also like Rob's answer. And, if you happen to use SAS rather than R, you can use PROC GLMSELECT for models that would be done with PROC GLM, although it works well for some other models, as well. | Is a variable significant in a linear regression model?
I also like Rob's answer. And, if you happen to use SAS rather than R, you can use PROC GLMSELECT for models that would be done with PROC GLM, although it works well for some other models, as well. See
Flom and Cassell "Stopping Stepwise: Why Stepwise Selection Methods are Bad and What you Should Use" presented at various groups, most recently, NESUG 2009 | Is a variable significant in a linear regression model?
I also like Rob's answer. And, if you happen to use SAS rather than R, you can use PROC GLMSELECT for models that would be done with PROC GLM, although it works well for some other models, as well. |
27,070 | Example of a parametric test with no normality assumptions? | Non-normal parametric tests occur often in practice and are widely used; e.g. generalized linear models, parametric survival models. If you need an example to give someone, I suggest (a) pointing to the definition of parametric statistics given in Wikipedia (to disabuse them of the terminological error) and then mentioning logistic regression as an explicit example of a model where parametric tests are used that do not make an assumption about normality of the data, which are 0/1 (again, logistic regression has a Wikipedia page). Both Wikipedia pages include references, if some are needed instead.
Hypothesis tests for many given distributional assumptions may be constructed essentially at will, as the situation might require.
You simply start with some specific distributional assumption, choose a suitable test statistic, and work out its distribution under $H_0$, in order to compute critical regions.
(Even if you can't do it algebraically, simulation can be used.)
Let's start with an extremely simple example:
Imagine our parametric assumption is that the waiting time to the next bus is exponential, with some unknown mean $\mu$.
My friend Casey has claimed that the average waiting time for a bus during morning peak hour at a certain bus stop is no more than 6 minutes. I doubt this claim. In this instance we have a one-tailed test. We will be measuring the wait time in seconds.
The hypotheses are:
$H_0: \mu \leq 360s$
$H_1: \mu > 360s$
If the hypothesis is not rejected I will agree that there's not sufficient evidence to dispute my friend's claim.
We decide to collect data in the following fashion: each week for 10 weeks, choose a random weekday and then we choose an instant at random (uniformly distributed) during an agreed peak hour (the 'arrival time' of a theoretical traveller at the bus stop) and measure the time from that instant until the next bus passes, agreeing that this corresponds to the intent of the claim for our purposes. We agree that it is reasonable to treat this as if it were a random sample from the process of interest and (from experience) that the distribution is consistent enough across days that we'll treat it as homogeneous.
(We appear not to have other demands on our time.)
What statistic to use? Let us choose the sample mean.
[It turns out that this is an excellent choice but let us not get distracted with considerations of most powerful tests just yet and content ourselves for the moment with statistics that work sufficiently well for our purposes.]
In this case we can compute the null distribution (the distribution of the test statistic when $H_0$ is true) exactly; the sample mean of an i.i.d. sample of size $n$ drawn from an exponential distribution with mean $\mu_0$ is has a gamma distribution with mean $\mu_0$ and shape parameter $n$ (shape-mean parameterization). In shape-scale parameterization, this has shape $\alpha=n$ and scale $\beta=\mu_0/n$. For our specific example, $\alpha=10$ and $\beta=36$ (note that $\beta$ is in units of seconds). In the shape-rate parameterization $\alpha=10$ and $\lambda=\frac{1}{36}$; we can use functions for whatever gamma-distribution parameterization we have available.
Given the small chosen sample size, let's assume we have agreed to test at $\alpha=0.10$.
The $0.9$ quantile of a gamma with shape $10$ and scale $36$ is $511.4...$ (in R: qgamma(0.9,shape=10,scale=36)). We agree to the rejection rule "Reject $H_0$ if the average waiting time across the sample of size 10 equals or exceeds 511 seconds."
That's a parametric hypothesis test (in the Neyman-Pearson framework) with an exponential distributional assumption.
If desired, a p-value could be obtained from that gamma distribution. e.g. imagine the average time in the sample was 498 seconds. The tail area beyond 498 seconds would be 0.1175, so our p-value is about 11.75% (pgamma(498,shape=10,scale=36,lower.tail=FALSE) if we're working in R).
This test could have been done in anything that allows us to compute gamma quantiles (which does not limit us to just stats packages), or indeed it could be done by hand via ordinary chi-squared tables.
I'm skipping a number of important considerations when constructing tests in the hope of giving the general concepts and some signposts; e.g. I'm almost completely ignoring dealing with nuisance parameters here. Consult books on mathematical statistics for a more complete coverage.
Simulating the null distribution of a test statistic, and simulation to obtain p-values
In the above example, it was possible to obtain an explicit null distribution of the test statistic algebraically. This is not always possible, and sometimes possible but nevertheless inconvenient.
We could obtain a critical value by simulating many samples where $H_0$ is true and finding the relevant quantiles to mark the boundary of a critical region.
We can similarly obtain p-values by finding where the sample statistic occurs in a large simulation from the null distribution of the test statistic.
Given this is extremely rapid to carry out, even with a modest laptop, I tend to use $10^5$ or $10^6$ (or indeed, sometimes more) samples for such purposes. I don't really need a critical value in a hundredth of a second -- what harm is there in waiting a few seconds? Or even a half a minute?
It's also simple to estimate a standard error on such simulated p-values, and to bound it (using calculations used in margin-of-error calculations). If my simulated p-value is 0.038 and the standard error is 0.002, I have no qualms about rejecting at the 5% level or not-rejecting at the 2.5% level.
A brief word on 'optimal' tests
Clearly we have a fair bit of freedom in our choice of statistic. Given that high power is usually regarded as a nice property to have, an obvious criterion would be to choose a test with the 'best' power, were one available.
This leads to the concept of uniformly most powerful tests.
I won't labor the point by going into details, but this line of thought leads to useful ways to choose your test statistics via tests based off the likelihood ratio, including explicit likelihood ratio tests themselves. There's also a convenient result related to the asymptotic null distribution of the likelihood ratio, meaning that in sufficiently large samples we don't necessarily have to worry about obtaining the distribution of the test statistic, as the asymptotic distribution will eventually be quite accurate
There's also the related score tests and Wald tests.
For example, I have (including in questions here on site) fitted Weibull models to data on wind speed or rainfall using parametric survival regression models (the program doesn't know that the wind-speeds aren't survival times, nor does it object if none of the values are censored), and it's possible to test a variety of hypotheses in these frameworks with little effort.
Powerful, small-sample, nonparametric 'exact' tests based on the same ideas:
In simple cases, we can use some parametric statistic as the basis for a permutation test. This is sometimes convenient in several ways; generally offering very good power when the distributional assumption is true, but avoiding the risk of a potentially higher significance level if it's not. Indeed, the likelihood ratio itself might be used quite directly, if desired.
[In more complicated cases there may often be tests that are approximately (/asymptotically) distribution free / nonparametric tests that attain the desired significance level in large samples, whether via the bootstrap or via a permutation test based on an asymptotically exchangeable quantity - like a residual in multiple regression, given some assumptions. These won't be small-sample exact, but their properties can be investigated, such as via simulation, so you're not left entirely in the dark as to how close you might be getting to a desired $\alpha$ in specific situations.] | Example of a parametric test with no normality assumptions? | Non-normal parametric tests occur often in practice and are widely used; e.g. generalized linear models, parametric survival models. If you need an example to give someone, I suggest (a) pointing to | Example of a parametric test with no normality assumptions?
Non-normal parametric tests occur often in practice and are widely used; e.g. generalized linear models, parametric survival models. If you need an example to give someone, I suggest (a) pointing to the definition of parametric statistics given in Wikipedia (to disabuse them of the terminological error) and then mentioning logistic regression as an explicit example of a model where parametric tests are used that do not make an assumption about normality of the data, which are 0/1 (again, logistic regression has a Wikipedia page). Both Wikipedia pages include references, if some are needed instead.
Hypothesis tests for many given distributional assumptions may be constructed essentially at will, as the situation might require.
You simply start with some specific distributional assumption, choose a suitable test statistic, and work out its distribution under $H_0$, in order to compute critical regions.
(Even if you can't do it algebraically, simulation can be used.)
Let's start with an extremely simple example:
Imagine our parametric assumption is that the waiting time to the next bus is exponential, with some unknown mean $\mu$.
My friend Casey has claimed that the average waiting time for a bus during morning peak hour at a certain bus stop is no more than 6 minutes. I doubt this claim. In this instance we have a one-tailed test. We will be measuring the wait time in seconds.
The hypotheses are:
$H_0: \mu \leq 360s$
$H_1: \mu > 360s$
If the hypothesis is not rejected I will agree that there's not sufficient evidence to dispute my friend's claim.
We decide to collect data in the following fashion: each week for 10 weeks, choose a random weekday and then we choose an instant at random (uniformly distributed) during an agreed peak hour (the 'arrival time' of a theoretical traveller at the bus stop) and measure the time from that instant until the next bus passes, agreeing that this corresponds to the intent of the claim for our purposes. We agree that it is reasonable to treat this as if it were a random sample from the process of interest and (from experience) that the distribution is consistent enough across days that we'll treat it as homogeneous.
(We appear not to have other demands on our time.)
What statistic to use? Let us choose the sample mean.
[It turns out that this is an excellent choice but let us not get distracted with considerations of most powerful tests just yet and content ourselves for the moment with statistics that work sufficiently well for our purposes.]
In this case we can compute the null distribution (the distribution of the test statistic when $H_0$ is true) exactly; the sample mean of an i.i.d. sample of size $n$ drawn from an exponential distribution with mean $\mu_0$ is has a gamma distribution with mean $\mu_0$ and shape parameter $n$ (shape-mean parameterization). In shape-scale parameterization, this has shape $\alpha=n$ and scale $\beta=\mu_0/n$. For our specific example, $\alpha=10$ and $\beta=36$ (note that $\beta$ is in units of seconds). In the shape-rate parameterization $\alpha=10$ and $\lambda=\frac{1}{36}$; we can use functions for whatever gamma-distribution parameterization we have available.
Given the small chosen sample size, let's assume we have agreed to test at $\alpha=0.10$.
The $0.9$ quantile of a gamma with shape $10$ and scale $36$ is $511.4...$ (in R: qgamma(0.9,shape=10,scale=36)). We agree to the rejection rule "Reject $H_0$ if the average waiting time across the sample of size 10 equals or exceeds 511 seconds."
That's a parametric hypothesis test (in the Neyman-Pearson framework) with an exponential distributional assumption.
If desired, a p-value could be obtained from that gamma distribution. e.g. imagine the average time in the sample was 498 seconds. The tail area beyond 498 seconds would be 0.1175, so our p-value is about 11.75% (pgamma(498,shape=10,scale=36,lower.tail=FALSE) if we're working in R).
This test could have been done in anything that allows us to compute gamma quantiles (which does not limit us to just stats packages), or indeed it could be done by hand via ordinary chi-squared tables.
I'm skipping a number of important considerations when constructing tests in the hope of giving the general concepts and some signposts; e.g. I'm almost completely ignoring dealing with nuisance parameters here. Consult books on mathematical statistics for a more complete coverage.
Simulating the null distribution of a test statistic, and simulation to obtain p-values
In the above example, it was possible to obtain an explicit null distribution of the test statistic algebraically. This is not always possible, and sometimes possible but nevertheless inconvenient.
We could obtain a critical value by simulating many samples where $H_0$ is true and finding the relevant quantiles to mark the boundary of a critical region.
We can similarly obtain p-values by finding where the sample statistic occurs in a large simulation from the null distribution of the test statistic.
Given this is extremely rapid to carry out, even with a modest laptop, I tend to use $10^5$ or $10^6$ (or indeed, sometimes more) samples for such purposes. I don't really need a critical value in a hundredth of a second -- what harm is there in waiting a few seconds? Or even a half a minute?
It's also simple to estimate a standard error on such simulated p-values, and to bound it (using calculations used in margin-of-error calculations). If my simulated p-value is 0.038 and the standard error is 0.002, I have no qualms about rejecting at the 5% level or not-rejecting at the 2.5% level.
A brief word on 'optimal' tests
Clearly we have a fair bit of freedom in our choice of statistic. Given that high power is usually regarded as a nice property to have, an obvious criterion would be to choose a test with the 'best' power, were one available.
This leads to the concept of uniformly most powerful tests.
I won't labor the point by going into details, but this line of thought leads to useful ways to choose your test statistics via tests based off the likelihood ratio, including explicit likelihood ratio tests themselves. There's also a convenient result related to the asymptotic null distribution of the likelihood ratio, meaning that in sufficiently large samples we don't necessarily have to worry about obtaining the distribution of the test statistic, as the asymptotic distribution will eventually be quite accurate
There's also the related score tests and Wald tests.
For example, I have (including in questions here on site) fitted Weibull models to data on wind speed or rainfall using parametric survival regression models (the program doesn't know that the wind-speeds aren't survival times, nor does it object if none of the values are censored), and it's possible to test a variety of hypotheses in these frameworks with little effort.
Powerful, small-sample, nonparametric 'exact' tests based on the same ideas:
In simple cases, we can use some parametric statistic as the basis for a permutation test. This is sometimes convenient in several ways; generally offering very good power when the distributional assumption is true, but avoiding the risk of a potentially higher significance level if it's not. Indeed, the likelihood ratio itself might be used quite directly, if desired.
[In more complicated cases there may often be tests that are approximately (/asymptotically) distribution free / nonparametric tests that attain the desired significance level in large samples, whether via the bootstrap or via a permutation test based on an asymptotically exchangeable quantity - like a residual in multiple regression, given some assumptions. These won't be small-sample exact, but their properties can be investigated, such as via simulation, so you're not left entirely in the dark as to how close you might be getting to a desired $\alpha$ in specific situations.] | Example of a parametric test with no normality assumptions?
Non-normal parametric tests occur often in practice and are widely used; e.g. generalized linear models, parametric survival models. If you need an example to give someone, I suggest (a) pointing to |
27,071 | Example of a parametric test with no normality assumptions? | There are numerous examples of parametric tests that have nothing to do with normality. In fact, the underpinning of the hypothesis testing theory: Neyman-Pearson lemma applies to testing any parametric probability density $\rho$. The backbone of the hypothesis testing theory is likelihood ratio, not normality.
On the other hand, you got this impression probably because with the normality assumption, the sampling distribution of the test statistic (under the null hypothesis) becomes mathematically tractable. This is why most of the classical hypothesis testings that you learned from class relied on the normality assumption. However, as stated above, this by no means rules out the possibility of doing hypothesis testing with other parametric distribution families. | Example of a parametric test with no normality assumptions? | There are numerous examples of parametric tests that have nothing to do with normality. In fact, the underpinning of the hypothesis testing theory: Neyman-Pearson lemma applies to testing any paramet | Example of a parametric test with no normality assumptions?
There are numerous examples of parametric tests that have nothing to do with normality. In fact, the underpinning of the hypothesis testing theory: Neyman-Pearson lemma applies to testing any parametric probability density $\rho$. The backbone of the hypothesis testing theory is likelihood ratio, not normality.
On the other hand, you got this impression probably because with the normality assumption, the sampling distribution of the test statistic (under the null hypothesis) becomes mathematically tractable. This is why most of the classical hypothesis testings that you learned from class relied on the normality assumption. However, as stated above, this by no means rules out the possibility of doing hypothesis testing with other parametric distribution families. | Example of a parametric test with no normality assumptions?
There are numerous examples of parametric tests that have nothing to do with normality. In fact, the underpinning of the hypothesis testing theory: Neyman-Pearson lemma applies to testing any paramet |
27,072 | Example of a parametric test with no normality assumptions? | PROPORTION TESTING
Testing a proportion implies use of a binomial variable, which is a particular parametric family with a parameter being tested. Consequently, the variable is not normal, yet the test is parametric.
(Be careful, however, as plenty of people think that parametric testing is synonymous with assuming a normal distribution since so many common parametric tests do make such an assumption. If that is how someone (incorrectly, in my opinion) defines a parametric test, then it is a tautology that a parametric test assumes a normal distribution (though, again, I find such a characterization to be a poor one).) | Example of a parametric test with no normality assumptions? | PROPORTION TESTING
Testing a proportion implies use of a binomial variable, which is a particular parametric family with a parameter being tested. Consequently, the variable is not normal, yet the tes | Example of a parametric test with no normality assumptions?
PROPORTION TESTING
Testing a proportion implies use of a binomial variable, which is a particular parametric family with a parameter being tested. Consequently, the variable is not normal, yet the test is parametric.
(Be careful, however, as plenty of people think that parametric testing is synonymous with assuming a normal distribution since so many common parametric tests do make such an assumption. If that is how someone (incorrectly, in my opinion) defines a parametric test, then it is a tautology that a parametric test assumes a normal distribution (though, again, I find such a characterization to be a poor one).) | Example of a parametric test with no normality assumptions?
PROPORTION TESTING
Testing a proportion implies use of a binomial variable, which is a particular parametric family with a parameter being tested. Consequently, the variable is not normal, yet the tes |
27,073 | Example of a parametric test with no normality assumptions? | Just to give a concrete example of a parametric test not assuming normality: the binomial test as implemented in binom.test function in R. It's just a test for one proportion that uses the binomial distribution instead of approximating it by a normal distribution (thus requiring normality) as it's usually done in elementary statistics courses.
You can see that the p-value given by binom.test is exactly the same we get using the binomial distribution:
> binom.test(5,20,.3, alternative = "less")
Exact binomial test
data: 5 and 20
number of successes = 5, number of trials = 20, p-value = 0.4164
alternative hypothesis: true probability of success is less than 0.3
95 percent confidence interval:
0.0000000 0.4555824
sample estimates:
probability of success
0.25
> pbinom(5, 20, .3)
[1] 0.4163708
The Poisson test (implemented in poisson.test in R) would be a similar example of parametric test that does not assume normality. | Example of a parametric test with no normality assumptions? | Just to give a concrete example of a parametric test not assuming normality: the binomial test as implemented in binom.test function in R. It's just a test for one proportion that uses the binomial di | Example of a parametric test with no normality assumptions?
Just to give a concrete example of a parametric test not assuming normality: the binomial test as implemented in binom.test function in R. It's just a test for one proportion that uses the binomial distribution instead of approximating it by a normal distribution (thus requiring normality) as it's usually done in elementary statistics courses.
You can see that the p-value given by binom.test is exactly the same we get using the binomial distribution:
> binom.test(5,20,.3, alternative = "less")
Exact binomial test
data: 5 and 20
number of successes = 5, number of trials = 20, p-value = 0.4164
alternative hypothesis: true probability of success is less than 0.3
95 percent confidence interval:
0.0000000 0.4555824
sample estimates:
probability of success
0.25
> pbinom(5, 20, .3)
[1] 0.4163708
The Poisson test (implemented in poisson.test in R) would be a similar example of parametric test that does not assume normality. | Example of a parametric test with no normality assumptions?
Just to give a concrete example of a parametric test not assuming normality: the binomial test as implemented in binom.test function in R. It's just a test for one proportion that uses the binomial di |
27,074 | Is this p-hacking? | If you are doing explorative analysis, then you don't care about p-values. What you do is search for any pattern. P-values are used to verify a hypothesis, but you have none.
However, if after your explorative analysis you are gonna perform some hypothesis tests with the same data then this gives the erroneous p-values if the hypothesis were created by the same data.
If you only have a single data set available then you can split the data into two subsets, one for analysis and another for follow-up research to verify whether the found patterns are much different from statistical variations in the sampling.
You seem to be doing a search for patterns by using hypothesis tests and p-values. That is not p-hacking if you regard the p-values only as an aid in pattern recognition (a search for anomalies) instead of a value to report in relation to an experiment to verify a certain effect.
You have to be careful though that you do not switch the meaning from a statistic used in pattern recognition to a value that expresses the statistical significance of an experiment to measure an effect. | Is this p-hacking? | If you are doing explorative analysis, then you don't care about p-values. What you do is search for any pattern. P-values are used to verify a hypothesis, but you have none.
However, if after your ex | Is this p-hacking?
If you are doing explorative analysis, then you don't care about p-values. What you do is search for any pattern. P-values are used to verify a hypothesis, but you have none.
However, if after your explorative analysis you are gonna perform some hypothesis tests with the same data then this gives the erroneous p-values if the hypothesis were created by the same data.
If you only have a single data set available then you can split the data into two subsets, one for analysis and another for follow-up research to verify whether the found patterns are much different from statistical variations in the sampling.
You seem to be doing a search for patterns by using hypothesis tests and p-values. That is not p-hacking if you regard the p-values only as an aid in pattern recognition (a search for anomalies) instead of a value to report in relation to an experiment to verify a certain effect.
You have to be careful though that you do not switch the meaning from a statistic used in pattern recognition to a value that expresses the statistical significance of an experiment to measure an effect. | Is this p-hacking?
If you are doing explorative analysis, then you don't care about p-values. What you do is search for any pattern. P-values are used to verify a hypothesis, but you have none.
However, if after your ex |
27,075 | Is this p-hacking? | It looks like p-hacking. Keep in mind that standard tests (e.g., t-test) are designed for testing a single hypothesis. In particular, if you get several p-values, such values are not independent of each other, especially if you look for effect heterogeneity across sub-groups. This usually leads to p-hacking (or data snooping).
Whenever you test multiple hypotheses, you should be careful, and take into account multiple hypotheses testing (e.g., Bonferroni correction) and False Discoveries. In alternative, rely on pre-analysis plans, where you specify ex-ante the (few) hypotheses you want to test.
If you want more details on p-hacking, I suggest an easy reading (about 40 minutes, not technical at all) from the last economics nobel laureate Guido Imbens: Imbens (2021). If you are interested in treament effect heterogeneity, a data-driven alternative to pre-analysis plans and data snooping is proposed in Athey and Imbens (2016).
Regarding the ANOVA, I agree with @Dave's comment in opening a different question. | Is this p-hacking? | It looks like p-hacking. Keep in mind that standard tests (e.g., t-test) are designed for testing a single hypothesis. In particular, if you get several p-values, such values are not independent of ea | Is this p-hacking?
It looks like p-hacking. Keep in mind that standard tests (e.g., t-test) are designed for testing a single hypothesis. In particular, if you get several p-values, such values are not independent of each other, especially if you look for effect heterogeneity across sub-groups. This usually leads to p-hacking (or data snooping).
Whenever you test multiple hypotheses, you should be careful, and take into account multiple hypotheses testing (e.g., Bonferroni correction) and False Discoveries. In alternative, rely on pre-analysis plans, where you specify ex-ante the (few) hypotheses you want to test.
If you want more details on p-hacking, I suggest an easy reading (about 40 minutes, not technical at all) from the last economics nobel laureate Guido Imbens: Imbens (2021). If you are interested in treament effect heterogeneity, a data-driven alternative to pre-analysis plans and data snooping is proposed in Athey and Imbens (2016).
Regarding the ANOVA, I agree with @Dave's comment in opening a different question. | Is this p-hacking?
It looks like p-hacking. Keep in mind that standard tests (e.g., t-test) are designed for testing a single hypothesis. In particular, if you get several p-values, such values are not independent of ea |
27,076 | Is this p-hacking? | P-hacking implies an agenda to prove a particular type of hypothesis, and in furtherance of that agenda, several related hypotheses are tested. Then if one of them is found to be "statistically significant", only that test is reported with only its p-value. For instance, if I'm claiming to be psychic, I might test the hypothesis that I can guess the color of a card better than chance, and the hypothesis that I can guess the card value, etc. Then if any of those tests is statistically significant, I ignore the others. This ignores the fact that the total probability of a false positive over any of the hypotheses is larger than the probability of a false positive for any particular one. I.e P(A or B) > P(A).
Here, you don't seem to have an agenda, and you're probably not publishing your results, so you shouldn't worry too much about p-hacking, other than the fact that the more hypotheses you check, the higher the probability of getting at least one false positive. If that concerns you, what you can do is choose an overall alpha value (how much of a probability you're willing to accept for any of the tests yielding a false positive), and then choosing smaller adjusted alphas for the individual tests to get the overall false positive probability sufficiently low. One method that is a bit overly conservative (that is, it's not quite correct, but it's erring on the side of avoiding false positives), but simple to implement, is to divide overall alpha by the number of tests (or multiply the p-values by the number). For instance, if you end up testing $100$ combinations, and one of them has a p-value of $0.001$, you can treat that as if its p-value is $0.1$ (if you're wondering "Wait, does that mean I can get a p-value greater than $1$?", well, that's part of what I was talking about of this being an approximation).
While ANOVA tests involve multiple comparisons, they ultimate output only one p-value. The term "p-hacking" is similar to "cherry-picking". You can't cherry-pick if you only have one cherry. | Is this p-hacking? | P-hacking implies an agenda to prove a particular type of hypothesis, and in furtherance of that agenda, several related hypotheses are tested. Then if one of them is found to be "statistically signif | Is this p-hacking?
P-hacking implies an agenda to prove a particular type of hypothesis, and in furtherance of that agenda, several related hypotheses are tested. Then if one of them is found to be "statistically significant", only that test is reported with only its p-value. For instance, if I'm claiming to be psychic, I might test the hypothesis that I can guess the color of a card better than chance, and the hypothesis that I can guess the card value, etc. Then if any of those tests is statistically significant, I ignore the others. This ignores the fact that the total probability of a false positive over any of the hypotheses is larger than the probability of a false positive for any particular one. I.e P(A or B) > P(A).
Here, you don't seem to have an agenda, and you're probably not publishing your results, so you shouldn't worry too much about p-hacking, other than the fact that the more hypotheses you check, the higher the probability of getting at least one false positive. If that concerns you, what you can do is choose an overall alpha value (how much of a probability you're willing to accept for any of the tests yielding a false positive), and then choosing smaller adjusted alphas for the individual tests to get the overall false positive probability sufficiently low. One method that is a bit overly conservative (that is, it's not quite correct, but it's erring on the side of avoiding false positives), but simple to implement, is to divide overall alpha by the number of tests (or multiply the p-values by the number). For instance, if you end up testing $100$ combinations, and one of them has a p-value of $0.001$, you can treat that as if its p-value is $0.1$ (if you're wondering "Wait, does that mean I can get a p-value greater than $1$?", well, that's part of what I was talking about of this being an approximation).
While ANOVA tests involve multiple comparisons, they ultimate output only one p-value. The term "p-hacking" is similar to "cherry-picking". You can't cherry-pick if you only have one cherry. | Is this p-hacking?
P-hacking implies an agenda to prove a particular type of hypothesis, and in furtherance of that agenda, several related hypotheses are tested. Then if one of them is found to be "statistically signif |
27,077 | Can you add polynomial terms to multiple linear regression? | In addition to @mkt's excellent answer, I thought I would provide a specific example for you to see so that you can develop some intuition.
Generate Data for Example
For this example, I generated some data using R as follows:
set.seed(124)
n <- 200
x1 <- rnorm(n, mean=0, sd=0.2)
x2 <- rnorm(n, mean=0, sd=0.5)
eps <- rnorm(n, mean=0, sd=1)
y = 1 + 10*x1 + 0.4*x2 + 0.8*x2^2 + eps
As you can see from the above, the data come from the model $y = \beta_0 + \beta_1*x_1 + \beta_2*x_2 + \beta_3*x_2^2 + \epsilon$, where $\epsilon$ is a normally distributed random error term with mean $0$ and unknown variance $\sigma^2$. Furthermore, $\beta_0 = 1$, $\beta_1 = 10$, $\beta_2 = 0.4$ and $\beta_3 = 0.8$, while $\sigma = 1$.
Visualize the Generated Data via Coplots
Given the simulated data on the outcome variable y and the predictor variables x1 and x2, we can visualize these data using coplots:
library(lattice)
coplot(y ~ x1 | x2,
number = 4, rows = 1,
panel = panel.smooth)
coplot(y ~ x2 | x1,
number = 4, rows = 1,
panel = panel.smooth)
The resulting coplots are shown below.
The first coplot shows scatterplots of y versus x1 when x2 belongs to four different ranges of observed values (which are overlapping) and enhances each of these scatterplots with a smooth, possibly non-linear fit whose shape is estimated from the data.
The second coplot shows scatterplots of y versus x2 when x1 belongs to four different ranges of observed values (which are overlapping) and enhances each of these scatterplots with a smooth fit.
The first coplot suggests that it is reasonable to assume that x1 has a linear effect on y when controlling for x2 and that this effect does not depend on x2.
The second coplot suggests that it is reasonable to assume that x2 has a quadratic effect on y when controlling for x1 and that this effect does not depend on x1.
Fit a Correctly Specified Model
The coplots suggest fitting the following model to the data, which allows for a linear effect of x1 and a quadratic effect of x2:
m <- lm(y ~ x1 + x2 + I(x2^2))
Construct Component Plus Residual Plots for the Correctly Specified Model
Once the correctly specified model is fitted to the data, we can examine component plus residual plots for each predictor included in the model:
library(car)
crPlots(m)
These component plus residual plots are shown below and suggest that the model was correctly specified since they display no evidence of nonlinearity, etc. Indeed, in each of these plots, there is no obvious discrepancy between the dotted blue line suggestive of a linear effect of the corresponding predictor, and the solid magenta line suggestive of a non-linear effect of that predictor in the model.
Fit an Incorrectly Specified Model
Let's play the devil's advocate and say that our lm() model was in fact incorrectly specified (i.e., misspecified), in the sense that it omitted the quadratic term I(x2^2):
m.mis <- lm(y ~ x1 + x2)
Construct Component Plus Residual Plots for the Incorrectly Specified Model
If we were to construct component plus residual plots for the misspecified model, we would immediately see a suggestion of non-linearity of the effect of x2 in the misspecified model:
crPlots(m.mis)
In other words, as seen below, the misspecified model failed to capture the quadratic effect of x2 and this effect shows up in the component plus residual plot corresponding to the predictor x2 in the misspecified model.
The misspecification of the effect of x2 in the model m.mis would also be apparent when examining plots of the residuals associated with this model against each of the predictors x1 and x2:
par(mfrow=c(1,2))
plot(residuals(m.mis) ~ x1, pch=20, col="darkred")
abline(h=0, lty=2, col="blue", lwd=2)
plot(residuals(m.mis) ~ x2, pch=20, col="darkred")
abline(h=0, lty=2, col="blue", lwd=2)
As seen below, the plot of residuals associated with m.mis versus x2 exhibits a clear quadratic pattern, suggesting that the model m.mis failed to capture this systematic pattern.
Augment the Incorrectly Specified Model
To correctly specify the model m.mis, we would need to augment it so that it also includes the term I(x2^2):
m <- lm(y ~ x1 + x2 + I(x2^2))
Here are the plots of the residuals versus x1 and x2 for this correctly specified model:
par(mfrow=c(1,2))
plot(residuals(m) ~ x1, pch=20, col="darkred")
abline(h=0, lty=2, col="blue", lwd=2)
plot(residuals(m) ~ x2, pch=20, col="darkred")
abline(h=0, lty=2, col="blue", lwd=2)
Notice that the quadratic pattern previously seen in the plot of residuals versus x2 for the misspecified model m.mis has now disappeared from the plot of residuals versus x2 for the correctly specified model m.
Note that the vertical axis of all the plots of residuals versus x1 and x2 shown here should be labelled as "Residual". For some reason, R Studio cuts that label off. | Can you add polynomial terms to multiple linear regression? | In addition to @mkt's excellent answer, I thought I would provide a specific example for you to see so that you can develop some intuition.
Generate Data for Example
For this example, I generated so | Can you add polynomial terms to multiple linear regression?
In addition to @mkt's excellent answer, I thought I would provide a specific example for you to see so that you can develop some intuition.
Generate Data for Example
For this example, I generated some data using R as follows:
set.seed(124)
n <- 200
x1 <- rnorm(n, mean=0, sd=0.2)
x2 <- rnorm(n, mean=0, sd=0.5)
eps <- rnorm(n, mean=0, sd=1)
y = 1 + 10*x1 + 0.4*x2 + 0.8*x2^2 + eps
As you can see from the above, the data come from the model $y = \beta_0 + \beta_1*x_1 + \beta_2*x_2 + \beta_3*x_2^2 + \epsilon$, where $\epsilon$ is a normally distributed random error term with mean $0$ and unknown variance $\sigma^2$. Furthermore, $\beta_0 = 1$, $\beta_1 = 10$, $\beta_2 = 0.4$ and $\beta_3 = 0.8$, while $\sigma = 1$.
Visualize the Generated Data via Coplots
Given the simulated data on the outcome variable y and the predictor variables x1 and x2, we can visualize these data using coplots:
library(lattice)
coplot(y ~ x1 | x2,
number = 4, rows = 1,
panel = panel.smooth)
coplot(y ~ x2 | x1,
number = 4, rows = 1,
panel = panel.smooth)
The resulting coplots are shown below.
The first coplot shows scatterplots of y versus x1 when x2 belongs to four different ranges of observed values (which are overlapping) and enhances each of these scatterplots with a smooth, possibly non-linear fit whose shape is estimated from the data.
The second coplot shows scatterplots of y versus x2 when x1 belongs to four different ranges of observed values (which are overlapping) and enhances each of these scatterplots with a smooth fit.
The first coplot suggests that it is reasonable to assume that x1 has a linear effect on y when controlling for x2 and that this effect does not depend on x2.
The second coplot suggests that it is reasonable to assume that x2 has a quadratic effect on y when controlling for x1 and that this effect does not depend on x1.
Fit a Correctly Specified Model
The coplots suggest fitting the following model to the data, which allows for a linear effect of x1 and a quadratic effect of x2:
m <- lm(y ~ x1 + x2 + I(x2^2))
Construct Component Plus Residual Plots for the Correctly Specified Model
Once the correctly specified model is fitted to the data, we can examine component plus residual plots for each predictor included in the model:
library(car)
crPlots(m)
These component plus residual plots are shown below and suggest that the model was correctly specified since they display no evidence of nonlinearity, etc. Indeed, in each of these plots, there is no obvious discrepancy between the dotted blue line suggestive of a linear effect of the corresponding predictor, and the solid magenta line suggestive of a non-linear effect of that predictor in the model.
Fit an Incorrectly Specified Model
Let's play the devil's advocate and say that our lm() model was in fact incorrectly specified (i.e., misspecified), in the sense that it omitted the quadratic term I(x2^2):
m.mis <- lm(y ~ x1 + x2)
Construct Component Plus Residual Plots for the Incorrectly Specified Model
If we were to construct component plus residual plots for the misspecified model, we would immediately see a suggestion of non-linearity of the effect of x2 in the misspecified model:
crPlots(m.mis)
In other words, as seen below, the misspecified model failed to capture the quadratic effect of x2 and this effect shows up in the component plus residual plot corresponding to the predictor x2 in the misspecified model.
The misspecification of the effect of x2 in the model m.mis would also be apparent when examining plots of the residuals associated with this model against each of the predictors x1 and x2:
par(mfrow=c(1,2))
plot(residuals(m.mis) ~ x1, pch=20, col="darkred")
abline(h=0, lty=2, col="blue", lwd=2)
plot(residuals(m.mis) ~ x2, pch=20, col="darkred")
abline(h=0, lty=2, col="blue", lwd=2)
As seen below, the plot of residuals associated with m.mis versus x2 exhibits a clear quadratic pattern, suggesting that the model m.mis failed to capture this systematic pattern.
Augment the Incorrectly Specified Model
To correctly specify the model m.mis, we would need to augment it so that it also includes the term I(x2^2):
m <- lm(y ~ x1 + x2 + I(x2^2))
Here are the plots of the residuals versus x1 and x2 for this correctly specified model:
par(mfrow=c(1,2))
plot(residuals(m) ~ x1, pch=20, col="darkred")
abline(h=0, lty=2, col="blue", lwd=2)
plot(residuals(m) ~ x2, pch=20, col="darkred")
abline(h=0, lty=2, col="blue", lwd=2)
Notice that the quadratic pattern previously seen in the plot of residuals versus x2 for the misspecified model m.mis has now disappeared from the plot of residuals versus x2 for the correctly specified model m.
Note that the vertical axis of all the plots of residuals versus x1 and x2 shown here should be labelled as "Residual". For some reason, R Studio cuts that label off. | Can you add polynomial terms to multiple linear regression?
In addition to @mkt's excellent answer, I thought I would provide a specific example for you to see so that you can develop some intuition.
Generate Data for Example
For this example, I generated so |
27,078 | Can you add polynomial terms to multiple linear regression? | Yes, what you're suggesting is fine. It's perfectly valid in a model to treat the response to one predictor as linear and a different one as being polynomial. It's also completely fine to assume no interactions between the predictors. | Can you add polynomial terms to multiple linear regression? | Yes, what you're suggesting is fine. It's perfectly valid in a model to treat the response to one predictor as linear and a different one as being polynomial. It's also completely fine to assume no in | Can you add polynomial terms to multiple linear regression?
Yes, what you're suggesting is fine. It's perfectly valid in a model to treat the response to one predictor as linear and a different one as being polynomial. It's also completely fine to assume no interactions between the predictors. | Can you add polynomial terms to multiple linear regression?
Yes, what you're suggesting is fine. It's perfectly valid in a model to treat the response to one predictor as linear and a different one as being polynomial. It's also completely fine to assume no in |
27,079 | Can you add polynomial terms to multiple linear regression? | You should take care to use Orthogonal polynomials if you're going to add polynomial terms.
Why? Without them you have a problem resembling colinearity. In certain regions, $x^2$ will look quite similar to $x$, and a parabola will do a decent job of fitting a straight line.
Observe:
These are polynomials of $x,x^2,x^3$.
Between 0 and 1.5 all three curves increase monotonically and while they curve differently from each other, they will give similar quality fits when x is positively correlated with y. By using all three in your code
y ~ x + x^2 + x^3
you are essentially using redundant shapes to fit your data with.
Orthogonal polynomials essentially give you added wiggle room when fitting, and each polynomial is essentially independent of the others.
Three polynomials of degree 1,2 and 3 generated by the poly() function in R.
Perhaps instead of explicitly thinking of them as polynomials, you instead think of them as 'trend components' or something:
$x$ represents 'more is always better' (or worse if the coefficient is negative). If you were doing a regression on music quality vs cowbell, you'd need this component.
$x^2$ represents a kind of goldilocks zone. If you were doing a regression on food tastiness vs amount of salt, this component would be salient.
$x^3$ is probably unlikely to be a dominant component on its own (the only example I could think of is How Much People Know vs How Much They Think They Know), but its presence will influence the shape and symmetry of the $x$ and $x^2$ terms.
There is a lot of hardout maths involved in orthogonal polynomials, but thankfully you only really need to know two things:
Orthogonal polynomials are only orthogonal over a certain region. The example I gave involves polynomials that are only orthogonal between 0 and 1.5.
If you're using R, use the poly() function to make your polynomials. poly(x,n) where n is the degree of the highest polynomial. It will make them orthogonal for you over the domain of your data $x$. | Can you add polynomial terms to multiple linear regression? | You should take care to use Orthogonal polynomials if you're going to add polynomial terms.
Why? Without them you have a problem resembling colinearity. In certain regions, $x^2$ will look quite simil | Can you add polynomial terms to multiple linear regression?
You should take care to use Orthogonal polynomials if you're going to add polynomial terms.
Why? Without them you have a problem resembling colinearity. In certain regions, $x^2$ will look quite similar to $x$, and a parabola will do a decent job of fitting a straight line.
Observe:
These are polynomials of $x,x^2,x^3$.
Between 0 and 1.5 all three curves increase monotonically and while they curve differently from each other, they will give similar quality fits when x is positively correlated with y. By using all three in your code
y ~ x + x^2 + x^3
you are essentially using redundant shapes to fit your data with.
Orthogonal polynomials essentially give you added wiggle room when fitting, and each polynomial is essentially independent of the others.
Three polynomials of degree 1,2 and 3 generated by the poly() function in R.
Perhaps instead of explicitly thinking of them as polynomials, you instead think of them as 'trend components' or something:
$x$ represents 'more is always better' (or worse if the coefficient is negative). If you were doing a regression on music quality vs cowbell, you'd need this component.
$x^2$ represents a kind of goldilocks zone. If you were doing a regression on food tastiness vs amount of salt, this component would be salient.
$x^3$ is probably unlikely to be a dominant component on its own (the only example I could think of is How Much People Know vs How Much They Think They Know), but its presence will influence the shape and symmetry of the $x$ and $x^2$ terms.
There is a lot of hardout maths involved in orthogonal polynomials, but thankfully you only really need to know two things:
Orthogonal polynomials are only orthogonal over a certain region. The example I gave involves polynomials that are only orthogonal between 0 and 1.5.
If you're using R, use the poly() function to make your polynomials. poly(x,n) where n is the degree of the highest polynomial. It will make them orthogonal for you over the domain of your data $x$. | Can you add polynomial terms to multiple linear regression?
You should take care to use Orthogonal polynomials if you're going to add polynomial terms.
Why? Without them you have a problem resembling colinearity. In certain regions, $x^2$ will look quite simil |
27,080 | Can you add polynomial terms to multiple linear regression? | There's no rule that says you have to use all your variables. If you're trying to predict income, and your feature variables are SSN, years of schooling, and age, and you want to drop the SSN because you expect any correlation between it and income to be spurious, that's your judgment call to make. A model isn't invalid simply because there are other variables that you theoretically could have included, but didn't. Deciding what polynomial terms to include is just one of many decisions regarding feature selection.
While polynomial models often start with all terms being included, that's just so that all of them can be evaluated as to how much they are adding to the model. If it looks like a particular term is mostly just overfitting, it can be dropped in later iterations of the model. Regularization, such as lasso regression, can drop less useful variables automatically. Generally, it's better to start will a model that has too many variables, and whittle it down to the ones that are most useful, than to start with only the variables you think the model should rely on, and possibly miss out on a relationship you weren't expecting. | Can you add polynomial terms to multiple linear regression? | There's no rule that says you have to use all your variables. If you're trying to predict income, and your feature variables are SSN, years of schooling, and age, and you want to drop the SSN because | Can you add polynomial terms to multiple linear regression?
There's no rule that says you have to use all your variables. If you're trying to predict income, and your feature variables are SSN, years of schooling, and age, and you want to drop the SSN because you expect any correlation between it and income to be spurious, that's your judgment call to make. A model isn't invalid simply because there are other variables that you theoretically could have included, but didn't. Deciding what polynomial terms to include is just one of many decisions regarding feature selection.
While polynomial models often start with all terms being included, that's just so that all of them can be evaluated as to how much they are adding to the model. If it looks like a particular term is mostly just overfitting, it can be dropped in later iterations of the model. Regularization, such as lasso regression, can drop less useful variables automatically. Generally, it's better to start will a model that has too many variables, and whittle it down to the ones that are most useful, than to start with only the variables you think the model should rely on, and possibly miss out on a relationship you weren't expecting. | Can you add polynomial terms to multiple linear regression?
There's no rule that says you have to use all your variables. If you're trying to predict income, and your feature variables are SSN, years of schooling, and age, and you want to drop the SSN because |
27,081 | 95% Confidence Interval for Proportions in R | First, remember that an interval for a proportion is given by:
p_hat +/- z * sqrt(p_hat * (1-p_hat)/n)
With that being said, we can use R to solve the formula like so:
# Set CI alpha level (1-alpha/2)*100%
alpha = 0.05
# Load Data
vehicleType = c("suv", "suv", "minivan", "car", "suv", "suv", "car", "car", "car", "car", "minivan", "car", "truck", "car", "car", "car", "car", "car", "car", "car", "minivan", "car", "suv", "minivan", "car", "minivan", "suv", "suv", "suv", "car", "suv", "car", "car", "suv", "truck", "truck", "minivan", "suv", "car", "truck", "suv", "suv", "car", "car", "car", "car", "suv", "car", "car", "car", "suv", "car", "car", "car", "truck", "car", "car", "suv", "suv", "minivan", "suv", "car", "car", "car", "car", "car", "minivan", "suv", "car", "car", "suv", "minivan", "car", "car", "car", "minivan", "minivan", "minivan", "car", "truck", "car", "car", "car", "suv", "suv", "suv", "car", "suv", "suv", "car", "suv", "car", "minivan", "car", "car", "car", "car", "car", "car", "car")
# Convert from string to factor
vehicleType = factor(vehicleType)
# Find the number of obs
n = length(vehicleType)
# Find number of obs per type
vtbreakdown = table(vehicleType)
# Get the proportion
p_hat = vtbreakdown['suv']/n
# Calculate the critical z-score
z = qnorm(1-alpha/2)
# Compute the CI
p_hat + c(-1,1)*z*sqrt(p_hat*(1-p_hat)/n)
So, we have:
0.1740293 0.3459707
For the p_hat of:
0.26 | 95% Confidence Interval for Proportions in R | First, remember that an interval for a proportion is given by:
p_hat +/- z * sqrt(p_hat * (1-p_hat)/n)
With that being said, we can use R to solve the formula like so:
# Set CI alpha level (1-alpha/2 | 95% Confidence Interval for Proportions in R
First, remember that an interval for a proportion is given by:
p_hat +/- z * sqrt(p_hat * (1-p_hat)/n)
With that being said, we can use R to solve the formula like so:
# Set CI alpha level (1-alpha/2)*100%
alpha = 0.05
# Load Data
vehicleType = c("suv", "suv", "minivan", "car", "suv", "suv", "car", "car", "car", "car", "minivan", "car", "truck", "car", "car", "car", "car", "car", "car", "car", "minivan", "car", "suv", "minivan", "car", "minivan", "suv", "suv", "suv", "car", "suv", "car", "car", "suv", "truck", "truck", "minivan", "suv", "car", "truck", "suv", "suv", "car", "car", "car", "car", "suv", "car", "car", "car", "suv", "car", "car", "car", "truck", "car", "car", "suv", "suv", "minivan", "suv", "car", "car", "car", "car", "car", "minivan", "suv", "car", "car", "suv", "minivan", "car", "car", "car", "minivan", "minivan", "minivan", "car", "truck", "car", "car", "car", "suv", "suv", "suv", "car", "suv", "suv", "car", "suv", "car", "minivan", "car", "car", "car", "car", "car", "car", "car")
# Convert from string to factor
vehicleType = factor(vehicleType)
# Find the number of obs
n = length(vehicleType)
# Find number of obs per type
vtbreakdown = table(vehicleType)
# Get the proportion
p_hat = vtbreakdown['suv']/n
# Calculate the critical z-score
z = qnorm(1-alpha/2)
# Compute the CI
p_hat + c(-1,1)*z*sqrt(p_hat*(1-p_hat)/n)
So, we have:
0.1740293 0.3459707
For the p_hat of:
0.26 | 95% Confidence Interval for Proportions in R
First, remember that an interval for a proportion is given by:
p_hat +/- z * sqrt(p_hat * (1-p_hat)/n)
With that being said, we can use R to solve the formula like so:
# Set CI alpha level (1-alpha/2 |
27,082 | 95% Confidence Interval for Proportions in R | @Coatless's method will get the job done in most cases (including the OP's case). However, for completeness, I thought I'd add a couple of other options.
Bootstrap Method
The function below draws n resamples from the data vector. For each resample, it calculates the proportion of "successes" and then calculates the overall mean and 95% confidence interval
bp = function(x, lev, n = 1e3, alpha=0.05) {
res = replicate(n, sum(sample(x, length(x), replace=TRUE) == lev)/length(x))
return(list(mean=mean(res),
`95% CI`=quantile(res, c(0.5*alpha,1-0.5*alpha))))
}
bp(vehicleType, "suv")
$mean
[1] 0.259628
$`95% CI`
2.5% 97.5%
0.18 0.35
binom Package
The binom package will run the test in @Coatless's answer, which assumes the errors are normally distributed. This can result in incorrect values when the proportion of "successes" is near zero or one and/or if the sample is relatively small. binom.confint from the binom package has other options that avoid this pitfall.
In the output below, the asymptotic test is the same as the one coded by @Coatless. You can get the results for just one of the methods by using, for example, the methods="exact" argument. Also, binom.test() uses the exact (Pearson-Klopper) test by default.
library(binom)
binom.confint(sum(vehicleType=="suv"), length(vehicleType))
method x n mean lower upper
1 agresti-coull 26 100 0.2600000 0.1836007 0.3541561
2 asymptotic 26 100 0.2600000 0.1740293 0.3459707
3 bayes 26 100 0.2623762 0.1788095 0.3485750
4 cloglog 26 100 0.2600000 0.1787357 0.3485852
5 exact 26 100 0.2600000 0.1773944 0.3573121
6 logit 26 100 0.2600000 0.1835016 0.3545416
7 probit 26 100 0.2600000 0.1818365 0.3526030
8 profile 26 100 0.2600000 0.1808127 0.3513344
9 lrt 26 100 0.2600000 0.1808329 0.3513338
10 prop.test 26 100 0.2600000 0.1797427 0.3590222
11 wilson 26 100 0.2600000 0.1840470 0.3537099 | 95% Confidence Interval for Proportions in R | @Coatless's method will get the job done in most cases (including the OP's case). However, for completeness, I thought I'd add a couple of other options.
Bootstrap Method
The function below draws n r | 95% Confidence Interval for Proportions in R
@Coatless's method will get the job done in most cases (including the OP's case). However, for completeness, I thought I'd add a couple of other options.
Bootstrap Method
The function below draws n resamples from the data vector. For each resample, it calculates the proportion of "successes" and then calculates the overall mean and 95% confidence interval
bp = function(x, lev, n = 1e3, alpha=0.05) {
res = replicate(n, sum(sample(x, length(x), replace=TRUE) == lev)/length(x))
return(list(mean=mean(res),
`95% CI`=quantile(res, c(0.5*alpha,1-0.5*alpha))))
}
bp(vehicleType, "suv")
$mean
[1] 0.259628
$`95% CI`
2.5% 97.5%
0.18 0.35
binom Package
The binom package will run the test in @Coatless's answer, which assumes the errors are normally distributed. This can result in incorrect values when the proportion of "successes" is near zero or one and/or if the sample is relatively small. binom.confint from the binom package has other options that avoid this pitfall.
In the output below, the asymptotic test is the same as the one coded by @Coatless. You can get the results for just one of the methods by using, for example, the methods="exact" argument. Also, binom.test() uses the exact (Pearson-Klopper) test by default.
library(binom)
binom.confint(sum(vehicleType=="suv"), length(vehicleType))
method x n mean lower upper
1 agresti-coull 26 100 0.2600000 0.1836007 0.3541561
2 asymptotic 26 100 0.2600000 0.1740293 0.3459707
3 bayes 26 100 0.2623762 0.1788095 0.3485750
4 cloglog 26 100 0.2600000 0.1787357 0.3485852
5 exact 26 100 0.2600000 0.1773944 0.3573121
6 logit 26 100 0.2600000 0.1835016 0.3545416
7 probit 26 100 0.2600000 0.1818365 0.3526030
8 profile 26 100 0.2600000 0.1808127 0.3513344
9 lrt 26 100 0.2600000 0.1808329 0.3513338
10 prop.test 26 100 0.2600000 0.1797427 0.3590222
11 wilson 26 100 0.2600000 0.1840470 0.3537099 | 95% Confidence Interval for Proportions in R
@Coatless's method will get the job done in most cases (including the OP's case). However, for completeness, I thought I'd add a couple of other options.
Bootstrap Method
The function below draws n r |
27,083 | 95% Confidence Interval for Proportions in R | Because we are using a continuous normal distribution as an approximation of a discrete binomial distribution there should be a correction term added (0.5/N) to the above calculations:
See here for more details | 95% Confidence Interval for Proportions in R | Because we are using a continuous normal distribution as an approximation of a discrete binomial distribution there should be a correction term added (0.5/N) to the above calculations:
See here for m | 95% Confidence Interval for Proportions in R
Because we are using a continuous normal distribution as an approximation of a discrete binomial distribution there should be a correction term added (0.5/N) to the above calculations:
See here for more details | 95% Confidence Interval for Proportions in R
Because we are using a continuous normal distribution as an approximation of a discrete binomial distribution there should be a correction term added (0.5/N) to the above calculations:
See here for m |
27,084 | In R, what is the best graphics driver for using the graphs in Microsoft Word? | If you are working on a PC, it is quite convenient to insert
figures into Office documents in emf format via the clipboard.
emf is a windows native vector graphics format and it allows
you to edit the figures with MS Office tools. It's not perfect
but it's a quick way of generating a simple report.
If your documents are at all complicated, MS Word handling of
figures is horrible. | In R, what is the best graphics driver for using the graphs in Microsoft Word? | If you are working on a PC, it is quite convenient to insert
figures into Office documents in emf format via the clipboard.
emf is a windows native vector graphics format and it allows
you to edi | In R, what is the best graphics driver for using the graphs in Microsoft Word?
If you are working on a PC, it is quite convenient to insert
figures into Office documents in emf format via the clipboard.
emf is a windows native vector graphics format and it allows
you to edit the figures with MS Office tools. It's not perfect
but it's a quick way of generating a simple report.
If your documents are at all complicated, MS Word handling of
figures is horrible. | In R, what is the best graphics driver for using the graphs in Microsoft Word?
If you are working on a PC, it is quite convenient to insert
figures into Office documents in emf format via the clipboard.
emf is a windows native vector graphics format and it allows
you to edi |
27,085 | In R, what is the best graphics driver for using the graphs in Microsoft Word? | Depends on how you will be using your Word documents and what types of figures you wish to include in the document.
If the figures are standard R plots with a moderate number of points/data, then vector-based formats will provide the best reproduction and allow for easy rescaling of image size whilst having small filesize. EPS via postscript(...., onefile = FALSE, paper = "special") in such cases would be the best format if you're outputting to a PDF or printing on a laser printer that knows postscript. Unfortunately, Word uses a third-party plugin to load EPS figures which produces a crappy low-res bitmap preview which is displayed on screen - when printed you get the high quality EPS though.
If the plots could be considered rasters (surface plots or image plots [heatmaps] with a high number of "pixels"), or if the plots contain a very large number of points, retaining the vector information for such plots will result in a large file size and high processing costs to load into Word and store in memory as you are working on the document. In such cases, I would use a high-res TIFF or a PNG via tiff() or png() respectively. See the help files for assistance in setting the size of the image in pixels and the resolution. These devices will render the figure as a bitmap image, which if given sufficient size/resolution will tolerate some amount of rescaling but will tend to be far more efficiently stored when the number of data points or cells is very large.
Do consider also that not all devices support transparency, largely because the underlying file formats do not allow it; postscript() doesn't support transparency, pdf() and png() do. cairo_ps() does support transparency but in doing so will actually produce a bitmap image in EPS format, which might not be what you want.
Do note that if saving your document out to PDF, bitmap figures will be downsampled to some degree. I forget how Word controls this, but it had two settings in the Save dialog when PDF type was selected and one of those will downsample the images to produce a smaller file size. This will be associated with some loss of quality so be careful which option you choose. This is not specific to Word - OpenOffice.org and LibreOffice have the same features, but they offer far finer grained control of how the images are compressed and whether they are compressed or not. This arises because PDF was designed for both on screen and on printer reproduction. You don't need the high resolution in images if displaying on the screen for the web. Higher res images result in larger file sizes, so the intended destination of the PDF could be set, which affected how the PDF was created. | In R, what is the best graphics driver for using the graphs in Microsoft Word? | Depends on how you will be using your Word documents and what types of figures you wish to include in the document.
If the figures are standard R plots with a moderate number of points/data, then vect | In R, what is the best graphics driver for using the graphs in Microsoft Word?
Depends on how you will be using your Word documents and what types of figures you wish to include in the document.
If the figures are standard R plots with a moderate number of points/data, then vector-based formats will provide the best reproduction and allow for easy rescaling of image size whilst having small filesize. EPS via postscript(...., onefile = FALSE, paper = "special") in such cases would be the best format if you're outputting to a PDF or printing on a laser printer that knows postscript. Unfortunately, Word uses a third-party plugin to load EPS figures which produces a crappy low-res bitmap preview which is displayed on screen - when printed you get the high quality EPS though.
If the plots could be considered rasters (surface plots or image plots [heatmaps] with a high number of "pixels"), or if the plots contain a very large number of points, retaining the vector information for such plots will result in a large file size and high processing costs to load into Word and store in memory as you are working on the document. In such cases, I would use a high-res TIFF or a PNG via tiff() or png() respectively. See the help files for assistance in setting the size of the image in pixels and the resolution. These devices will render the figure as a bitmap image, which if given sufficient size/resolution will tolerate some amount of rescaling but will tend to be far more efficiently stored when the number of data points or cells is very large.
Do consider also that not all devices support transparency, largely because the underlying file formats do not allow it; postscript() doesn't support transparency, pdf() and png() do. cairo_ps() does support transparency but in doing so will actually produce a bitmap image in EPS format, which might not be what you want.
Do note that if saving your document out to PDF, bitmap figures will be downsampled to some degree. I forget how Word controls this, but it had two settings in the Save dialog when PDF type was selected and one of those will downsample the images to produce a smaller file size. This will be associated with some loss of quality so be careful which option you choose. This is not specific to Word - OpenOffice.org and LibreOffice have the same features, but they offer far finer grained control of how the images are compressed and whether they are compressed or not. This arises because PDF was designed for both on screen and on printer reproduction. You don't need the high resolution in images if displaying on the screen for the web. Higher res images result in larger file sizes, so the intended destination of the PDF could be set, which affected how the PDF was created. | In R, what is the best graphics driver for using the graphs in Microsoft Word?
Depends on how you will be using your Word documents and what types of figures you wish to include in the document.
If the figures are standard R plots with a moderate number of points/data, then vect |
27,086 | In R, what is the best graphics driver for using the graphs in Microsoft Word? | If you are on Windows try win.metafile. It is vector format, if I remember correctly, and it plays nicely with Word. | In R, what is the best graphics driver for using the graphs in Microsoft Word? | If you are on Windows try win.metafile. It is vector format, if I remember correctly, and it plays nicely with Word. | In R, what is the best graphics driver for using the graphs in Microsoft Word?
If you are on Windows try win.metafile. It is vector format, if I remember correctly, and it plays nicely with Word. | In R, what is the best graphics driver for using the graphs in Microsoft Word?
If you are on Windows try win.metafile. It is vector format, if I remember correctly, and it plays nicely with Word. |
27,087 | In R, what is the best graphics driver for using the graphs in Microsoft Word? | R graphics in windows can be pretty tricky. The biggest problem that I have is that anti-aliasing is not working properly in Windows. For some reason I need to use the Cairo device plugin to get it nicely formatted.
I've tried both Cairo and cairoDevice package and currently I find the cairoDevice to be the easiest and most reliable, there is a StackOverflow post about this.
To use the cairoDevice package all you need is to:
# Create the device
Cairo_png(filename="my_file_name.png",
width=16,
height=16,
pointsize=18)
# Do a plot
plot(x, y)
# Saves the file
dev.off()
You can also save in PDF/svg-format and then use Inkscape to edit your graph, change fonts etc and then export it to png format. | In R, what is the best graphics driver for using the graphs in Microsoft Word? | R graphics in windows can be pretty tricky. The biggest problem that I have is that anti-aliasing is not working properly in Windows. For some reason I need to use the Cairo device plugin to get it ni | In R, what is the best graphics driver for using the graphs in Microsoft Word?
R graphics in windows can be pretty tricky. The biggest problem that I have is that anti-aliasing is not working properly in Windows. For some reason I need to use the Cairo device plugin to get it nicely formatted.
I've tried both Cairo and cairoDevice package and currently I find the cairoDevice to be the easiest and most reliable, there is a StackOverflow post about this.
To use the cairoDevice package all you need is to:
# Create the device
Cairo_png(filename="my_file_name.png",
width=16,
height=16,
pointsize=18)
# Do a plot
plot(x, y)
# Saves the file
dev.off()
You can also save in PDF/svg-format and then use Inkscape to edit your graph, change fonts etc and then export it to png format. | In R, what is the best graphics driver for using the graphs in Microsoft Word?
R graphics in windows can be pretty tricky. The biggest problem that I have is that anti-aliasing is not working properly in Windows. For some reason I need to use the Cairo device plugin to get it ni |
27,088 | In R, what is the best graphics driver for using the graphs in Microsoft Word? | PDF, ps,SVG, or eps are vector based graphics device. JPG, TIFF,PNG,...etc are Raster graphics. When it comes raster graphics, the trade off is between the size and quality. By adjusting width,height and other formatting you could keep high quality in raster graphics. You could take PNG or JPG format to insert the image.
SVG images may insert in MSWORD document. You can check this. | In R, what is the best graphics driver for using the graphs in Microsoft Word? | PDF, ps,SVG, or eps are vector based graphics device. JPG, TIFF,PNG,...etc are Raster graphics. When it comes raster graphics, the trade off is between the size and quality. By adjusting width,height | In R, what is the best graphics driver for using the graphs in Microsoft Word?
PDF, ps,SVG, or eps are vector based graphics device. JPG, TIFF,PNG,...etc are Raster graphics. When it comes raster graphics, the trade off is between the size and quality. By adjusting width,height and other formatting you could keep high quality in raster graphics. You could take PNG or JPG format to insert the image.
SVG images may insert in MSWORD document. You can check this. | In R, what is the best graphics driver for using the graphs in Microsoft Word?
PDF, ps,SVG, or eps are vector based graphics device. JPG, TIFF,PNG,...etc are Raster graphics. When it comes raster graphics, the trade off is between the size and quality. By adjusting width,height |
27,089 | In R, what is the best graphics driver for using the graphs in Microsoft Word? | The easiest way migth be chosing .png files so did I. Yet word does show them quite blurred - at least in my case. Back when i was using Eviews i tried .epswhich resulted in an own set of problems but the quality was better. I think in the end you have to chose between the lesser of two evils. | In R, what is the best graphics driver for using the graphs in Microsoft Word? | The easiest way migth be chosing .png files so did I. Yet word does show them quite blurred - at least in my case. Back when i was using Eviews i tried .epswhich resulted in an own set of problems but | In R, what is the best graphics driver for using the graphs in Microsoft Word?
The easiest way migth be chosing .png files so did I. Yet word does show them quite blurred - at least in my case. Back when i was using Eviews i tried .epswhich resulted in an own set of problems but the quality was better. I think in the end you have to chose between the lesser of two evils. | In R, what is the best graphics driver for using the graphs in Microsoft Word?
The easiest way migth be chosing .png files so did I. Yet word does show them quite blurred - at least in my case. Back when i was using Eviews i tried .epswhich resulted in an own set of problems but |
27,090 | In R, what is the best graphics driver for using the graphs in Microsoft Word? | This does not directly answer your question, but you can get better integration between R and MS Word using either the R package R2wd or the commercial software Inference for R. These provide Sweave-like direct integration of R and MS Word, eliminating cut-and-paste or save-and-load, and making it easier to update plots in the document from the command line. I have not used these but I do use Sweave and recommend literate programming, which is supported by all of these tools.
Sweave is the most widely used literate programmiing tool among R users. It is LaTeX + R, and is how R vignettes and many books and journal articles are written.
The Word + R tools promise a less daunting interface for new users. LaTeX has a steeper learning curve than Word.
However, at $199/yr, inference for R makes it challenging for others to reproduce your analyses, unlike Sweave, which is part of base R. | In R, what is the best graphics driver for using the graphs in Microsoft Word? | This does not directly answer your question, but you can get better integration between R and MS Word using either the R package R2wd or the commercial software Inference for R. These provide Sweave-l | In R, what is the best graphics driver for using the graphs in Microsoft Word?
This does not directly answer your question, but you can get better integration between R and MS Word using either the R package R2wd or the commercial software Inference for R. These provide Sweave-like direct integration of R and MS Word, eliminating cut-and-paste or save-and-load, and making it easier to update plots in the document from the command line. I have not used these but I do use Sweave and recommend literate programming, which is supported by all of these tools.
Sweave is the most widely used literate programmiing tool among R users. It is LaTeX + R, and is how R vignettes and many books and journal articles are written.
The Word + R tools promise a less daunting interface for new users. LaTeX has a steeper learning curve than Word.
However, at $199/yr, inference for R makes it challenging for others to reproduce your analyses, unlike Sweave, which is part of base R. | In R, what is the best graphics driver for using the graphs in Microsoft Word?
This does not directly answer your question, but you can get better integration between R and MS Word using either the R package R2wd or the commercial software Inference for R. These provide Sweave-l |
27,091 | Why doesn't mean square error work in case of angular data? | The problem with using MSE directly on angle values is that values can be very close together on the circle, but will have a large square error. For example, 359 degrees and 1 degrees are very close together on a circle, but very far apart in terms of squared difference.
To rectify this, you should use a distance metric that reflects the fact that you're working with angles.
The Euclidean distance between two points on a circle is the length of the chord between the two points. So a simple and direct example of a distance considers the angle $\alpha$ as a point on the unit circle $(\cos \alpha, \sin \alpha)$, then computes the Euclidean distance in the ordinary way.
Elementary trigonometric identities simplify the expression.
$$\begin{align}
d_E^2 (\theta, \phi) &= (\cos \theta - \cos \phi)^2 + (\sin \theta - \sin \phi)^2 \\
&= \cos^2 \theta - 2 \cos \theta \cos \phi + \cos^2 \phi + \sin^2 \theta - 2 \sin \theta \sin \phi + \sin^2 \phi \\
d_E (\theta, \phi) &= \sqrt{2 - 2 \cos (\theta - \phi) }
\end{align}$$
By inspection, we can see that angles that are very close together have $\cos (\theta - \phi)$ close to 1, so the distance is close to 0. On the other hand, angles that are very far apart have $\cos (\theta - \phi)$ close to 0, so the distance is close to 1. This satisfies our intuitive notions of distance.
Of course, this is not the only option. This distance and some alternatives are discussed in these related threads:
Loss function (and encoding?) for angles
How to define distance for vector of angles?
Best distance measure to use to compare vectors of angles | Why doesn't mean square error work in case of angular data? | The problem with using MSE directly on angle values is that values can be very close together on the circle, but will have a large square error. For example, 359 degrees and 1 degrees are very close t | Why doesn't mean square error work in case of angular data?
The problem with using MSE directly on angle values is that values can be very close together on the circle, but will have a large square error. For example, 359 degrees and 1 degrees are very close together on a circle, but very far apart in terms of squared difference.
To rectify this, you should use a distance metric that reflects the fact that you're working with angles.
The Euclidean distance between two points on a circle is the length of the chord between the two points. So a simple and direct example of a distance considers the angle $\alpha$ as a point on the unit circle $(\cos \alpha, \sin \alpha)$, then computes the Euclidean distance in the ordinary way.
Elementary trigonometric identities simplify the expression.
$$\begin{align}
d_E^2 (\theta, \phi) &= (\cos \theta - \cos \phi)^2 + (\sin \theta - \sin \phi)^2 \\
&= \cos^2 \theta - 2 \cos \theta \cos \phi + \cos^2 \phi + \sin^2 \theta - 2 \sin \theta \sin \phi + \sin^2 \phi \\
d_E (\theta, \phi) &= \sqrt{2 - 2 \cos (\theta - \phi) }
\end{align}$$
By inspection, we can see that angles that are very close together have $\cos (\theta - \phi)$ close to 1, so the distance is close to 0. On the other hand, angles that are very far apart have $\cos (\theta - \phi)$ close to 0, so the distance is close to 1. This satisfies our intuitive notions of distance.
Of course, this is not the only option. This distance and some alternatives are discussed in these related threads:
Loss function (and encoding?) for angles
How to define distance for vector of angles?
Best distance measure to use to compare vectors of angles | Why doesn't mean square error work in case of angular data?
The problem with using MSE directly on angle values is that values can be very close together on the circle, but will have a large square error. For example, 359 degrees and 1 degrees are very close t |
27,092 | Graphics encyclopedia | For an online summary, check out A Periodic Table of Visualization Methods. | Graphics encyclopedia | For an online summary, check out A Periodic Table of Visualization Methods. | Graphics encyclopedia
For an online summary, check out A Periodic Table of Visualization Methods. | Graphics encyclopedia
For an online summary, check out A Periodic Table of Visualization Methods. |
27,093 | Graphics encyclopedia | If you fancy R, you can see the R graph gallery. | Graphics encyclopedia | If you fancy R, you can see the R graph gallery. | Graphics encyclopedia
If you fancy R, you can see the R graph gallery. | Graphics encyclopedia
If you fancy R, you can see the R graph gallery. |
27,094 | Graphics encyclopedia | Cleveland, William S. 1993. Visualizing data. ISBN 0963488406. | Graphics encyclopedia | Cleveland, William S. 1993. Visualizing data. ISBN 0963488406. | Graphics encyclopedia
Cleveland, William S. 1993. Visualizing data. ISBN 0963488406. | Graphics encyclopedia
Cleveland, William S. 1993. Visualizing data. ISBN 0963488406. |
27,095 | Graphics encyclopedia | Systat (Lee Wilkinson) was an early leader in statistical graphics software. It always has had a nice visual gallery. | Graphics encyclopedia | Systat (Lee Wilkinson) was an early leader in statistical graphics software. It always has had a nice visual gallery. | Graphics encyclopedia
Systat (Lee Wilkinson) was an early leader in statistical graphics software. It always has had a nice visual gallery. | Graphics encyclopedia
Systat (Lee Wilkinson) was an early leader in statistical graphics software. It always has had a nice visual gallery. |
27,096 | Graphics encyclopedia | A visual gallery of really creative graphics (but without much organization, unfortunately) is available on the Wolfram site (Mathematica). | Graphics encyclopedia | A visual gallery of really creative graphics (but without much organization, unfortunately) is available on the Wolfram site (Mathematica). | Graphics encyclopedia
A visual gallery of really creative graphics (but without much organization, unfortunately) is available on the Wolfram site (Mathematica). | Graphics encyclopedia
A visual gallery of really creative graphics (but without much organization, unfortunately) is available on the Wolfram site (Mathematica). |
27,097 | Graphics encyclopedia | I've also found good material at The Gallery of Data Visualization: The Best and Worst of Statistical Graphics, at
http://www.datavis.ca/gallery/index.php | Graphics encyclopedia | I've also found good material at The Gallery of Data Visualization: The Best and Worst of Statistical Graphics, at
http://www.datavis.ca/gallery/index.php | Graphics encyclopedia
I've also found good material at The Gallery of Data Visualization: The Best and Worst of Statistical Graphics, at
http://www.datavis.ca/gallery/index.php | Graphics encyclopedia
I've also found good material at The Gallery of Data Visualization: The Best and Worst of Statistical Graphics, at
http://www.datavis.ca/gallery/index.php |
27,098 | Graphics encyclopedia | Visual explanations or anything else by Tufte is inspirational. | Graphics encyclopedia | Visual explanations or anything else by Tufte is inspirational. | Graphics encyclopedia
Visual explanations or anything else by Tufte is inspirational. | Graphics encyclopedia
Visual explanations or anything else by Tufte is inspirational. |
27,099 | Graphics encyclopedia | A Tour through the Visualization Zoo (Heer et al., Visualization
8(5) 2010) offers a particularly interesting overview of "innovative" and interactive techniques for displaying data.
On a related point, a good software for data visualization, including the aforementioned gallery, is Protovis, which comes with a lot of examples. | Graphics encyclopedia | A Tour through the Visualization Zoo (Heer et al., Visualization
8(5) 2010) offers a particularly interesting overview of "innovative" and interactive techniques for displaying data.
On a related po | Graphics encyclopedia
A Tour through the Visualization Zoo (Heer et al., Visualization
8(5) 2010) offers a particularly interesting overview of "innovative" and interactive techniques for displaying data.
On a related point, a good software for data visualization, including the aforementioned gallery, is Protovis, which comes with a lot of examples. | Graphics encyclopedia
A Tour through the Visualization Zoo (Heer et al., Visualization
8(5) 2010) offers a particularly interesting overview of "innovative" and interactive techniques for displaying data.
On a related po |
27,100 | How to search for a statistical procedure in R? | rseek is pretty good. More abstract semantic queries along the lines of your second example are hard anywhere.
Also, see this SO thread from the R-faq listing there. | How to search for a statistical procedure in R? | rseek is pretty good. More abstract semantic queries along the lines of your second example are hard anywhere.
Also, see this SO thread from the R-faq listing there. | How to search for a statistical procedure in R?
rseek is pretty good. More abstract semantic queries along the lines of your second example are hard anywhere.
Also, see this SO thread from the R-faq listing there. | How to search for a statistical procedure in R?
rseek is pretty good. More abstract semantic queries along the lines of your second example are hard anywhere.
Also, see this SO thread from the R-faq listing there. |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.