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 |
|---|---|---|---|---|---|---|
28,101 | How to evaluate the goodness of fit for survial functions | Cox proportional hazards regressions for survival data can be thought of as corresponding to standard regressions in many respects. For example, Cox regressions also provide residual standard errors and R-square statistics. See the coxph function in the R survival package. (You can think of K-M curves as corresponding to non-parametric analyses in standard statistics. How would you incorporate a non-parametric test into CART?) In practice with clinical data, residual standard errors tend to be high and R-square values low in Cox regression.
Thus standard regressions and Cox regressions have similar requirements and limitations. You have to verify that that the data fit the underlying assumptions, which in Cox analysis further includes the assumption that hazards being compared are proportional over time. You will still have to avoid over-fitting and you will have to validate your model. And as I understand CART, although I don't use it myself, you will still face the difficulties posed by comparing non-nested models. | How to evaluate the goodness of fit for survial functions | Cox proportional hazards regressions for survival data can be thought of as corresponding to standard regressions in many respects. For example, Cox regressions also provide residual standard errors a | How to evaluate the goodness of fit for survial functions
Cox proportional hazards regressions for survival data can be thought of as corresponding to standard regressions in many respects. For example, Cox regressions also provide residual standard errors and R-square statistics. See the coxph function in the R survival package. (You can think of K-M curves as corresponding to non-parametric analyses in standard statistics. How would you incorporate a non-parametric test into CART?) In practice with clinical data, residual standard errors tend to be high and R-square values low in Cox regression.
Thus standard regressions and Cox regressions have similar requirements and limitations. You have to verify that that the data fit the underlying assumptions, which in Cox analysis further includes the assumption that hazards being compared are proportional over time. You will still have to avoid over-fitting and you will have to validate your model. And as I understand CART, although I don't use it myself, you will still face the difficulties posed by comparing non-nested models. | How to evaluate the goodness of fit for survial functions
Cox proportional hazards regressions for survival data can be thought of as corresponding to standard regressions in many respects. For example, Cox regressions also provide residual standard errors a |
28,102 | How to change threshold for classification in R randomForests? | Want to improve this post? Provide detailed answers to this question, including citations and an explanation of why your answer is correct. Answers without enough detail may be edited or deleted.
#set threshold or cutoff value to 0.7
cutoff=0.7
#all values lower than cutoff value 0.7 will be classified as 0 (present in this case)
RFpred[RFpred<cutoff]=0
#all values greater than cutoff value 0.7 will be classified as 1(absent in this case)
RFpred[RFpred>=cutoff]=1 | How to change threshold for classification in R randomForests? | Want to improve this post? Provide detailed answers to this question, including citations and an explanation of why your answer is correct. Answers without enough detail may be edited or deleted.
| How to change threshold for classification in R randomForests?
Want to improve this post? Provide detailed answers to this question, including citations and an explanation of why your answer is correct. Answers without enough detail may be edited or deleted.
#set threshold or cutoff value to 0.7
cutoff=0.7
#all values lower than cutoff value 0.7 will be classified as 0 (present in this case)
RFpred[RFpred<cutoff]=0
#all values greater than cutoff value 0.7 will be classified as 1(absent in this case)
RFpred[RFpred>=cutoff]=1 | How to change threshold for classification in R randomForests?
Want to improve this post? Provide detailed answers to this question, including citations and an explanation of why your answer is correct. Answers without enough detail may be edited or deleted.
|
28,103 | How to change threshold for classification in R randomForests? | Sorry you haven't gotten and attempts at answers. Would recommend Max Kuhn's book for coverage of this issue. This is a fairly broad issue. Just add some bits:
ROC curves are popular, but only make sense if you're trying to understand the trade-off between the cost False Negative and False Positive results. If CostFN=CostFP then not sure they make sense. The c-statistic and other derived measures do still have use. If you want to maximize accuracy - just tune your model for this (caret package makes this easy), don't go making an ROC curve.
Everyone uses the probabilities derived from RF models. I think think some thought should be given to doing this - these are not probabilistic models, they aren't built to do this. It often works. At a minimum I would produce a validation plot of RF probabilies on new data if I was really interested in probabilies
The simplest way would be to use "simply reclassify those with values greater than 0.7 as present, and those < 0.7 as absent".
If cost(FN) does not equal cost(FP), then you need to make the RF cost- sensitive. R does not makes this easy. The weighting function in the RandomForest package doesn't work. The best option is to play around with the sampling, undersample majority case to get cost function you want. But the relationship between sample ratio and cost isn't direct. So you might want to stick with (3)
Update
Regarding Class weights Andy Liaw:
"The current "classwt" option in the randomForest package has been there since the beginning, and is different from how the official Fortran code (version 4 and later) implements class weights. It simply account for the class weights in the Gini index calculation when splitting nodes, exactly as how a single CART tree is done when given class weights. Prof. Breiman came up with the newer class weighting scheme implemented in the newer version of his Fortran code after we found that simply using the weights in the Gini index didn't seem to help much in extremely unbalanced data (say 1:100 or worse). If using weighted Gini helps in your situation, by all means do it. I can only say that in the past it didn't give us the result we were expecting." | How to change threshold for classification in R randomForests? | Sorry you haven't gotten and attempts at answers. Would recommend Max Kuhn's book for coverage of this issue. This is a fairly broad issue. Just add some bits:
ROC curves are popular, but only m | How to change threshold for classification in R randomForests?
Sorry you haven't gotten and attempts at answers. Would recommend Max Kuhn's book for coverage of this issue. This is a fairly broad issue. Just add some bits:
ROC curves are popular, but only make sense if you're trying to understand the trade-off between the cost False Negative and False Positive results. If CostFN=CostFP then not sure they make sense. The c-statistic and other derived measures do still have use. If you want to maximize accuracy - just tune your model for this (caret package makes this easy), don't go making an ROC curve.
Everyone uses the probabilities derived from RF models. I think think some thought should be given to doing this - these are not probabilistic models, they aren't built to do this. It often works. At a minimum I would produce a validation plot of RF probabilies on new data if I was really interested in probabilies
The simplest way would be to use "simply reclassify those with values greater than 0.7 as present, and those < 0.7 as absent".
If cost(FN) does not equal cost(FP), then you need to make the RF cost- sensitive. R does not makes this easy. The weighting function in the RandomForest package doesn't work. The best option is to play around with the sampling, undersample majority case to get cost function you want. But the relationship between sample ratio and cost isn't direct. So you might want to stick with (3)
Update
Regarding Class weights Andy Liaw:
"The current "classwt" option in the randomForest package has been there since the beginning, and is different from how the official Fortran code (version 4 and later) implements class weights. It simply account for the class weights in the Gini index calculation when splitting nodes, exactly as how a single CART tree is done when given class weights. Prof. Breiman came up with the newer class weighting scheme implemented in the newer version of his Fortran code after we found that simply using the weights in the Gini index didn't seem to help much in extremely unbalanced data (say 1:100 or worse). If using weighted Gini helps in your situation, by all means do it. I can only say that in the past it didn't give us the result we were expecting." | How to change threshold for classification in R randomForests?
Sorry you haven't gotten and attempts at answers. Would recommend Max Kuhn's book for coverage of this issue. This is a fairly broad issue. Just add some bits:
ROC curves are popular, but only m |
28,104 | How is the Spearman-Brown prophecy formula affected by questions of differing difficulties? | Although I feel a little sheepish contradicting both a "respected text" as well as another CV user, it seems to me that the Spearman-Brown formula is not affected by having items of differing difficulty. To be sure, the Spearman-Brown formula is usually derived under the assumption that we have parallel items, which implies (among other things) that the items have equal difficulty. But it turns out this assumption isn't necessary; it can be relaxed to allow unequal difficulties, and the Spearman-Brown formula will still hold. I demonstrate this below.
Recall that in classical test theory, a measurement $X$ is assumed to be the sum of a "true score" component $T$ and an error component $E$, that is,
$$
X = T + E,
$$
with $T$ and $E$ uncorrelated. The assumption of parallel items is that all items have the same true scores, differing only in their error components, although these are assumed to have equal variance. In symbols, for any pair of items $X$ and $X'$,
$$
T=T'
\\\textrm{var}(E)=\textrm{var}(E').
$$
Let's see what happens when we relax the first assumption, such that the items might differ in their difficulties, and then derive the reliability of a total test score under these new assumptions. Specifically, assume that the true scores might differ by an additive constant, but the errors still have the same variance. In symbols,
$$
T=T' + c'
\\\textrm{var}(E)=\textrm{var}(E').
$$
Any differences in difficulty are captured by the additive constant. For example, if $c'>0$, then scores on $X$ tend to be higher than scores on $X'$, so that $X$ is "easier" than $X'$. We might call these essentially parallel items, in analogy to the assumption of "essential tau-equivalence" which relaxes the tau-equivalent model in a similar way.
Now to derive the reliability of a test form of such items. Consider a test consisting of $k$ essentially parallel items, the sum of which give the test score. Reliability is, by definition, the ratio of true score variance to observed score variance. For the reliability of the individual items, it follows from the definition of essential parallelism that they have the same reliability, which we denote with $\rho = \sigma^2_T/(\sigma^2_T+\sigma^2_E)$, with $\sigma^2_T$ being the true score variance and $\sigma^2_E$ the error variance. For the reliability of the total test score, we first examine the variance of the total test score, which is
$$
\begin{aligned}
\textrm{var}(\sum_{i=1}^kT_i + E_i) &= \textrm{var}(\sum_{i=1}^kT + c_i + E_i)
\\ &= k^2\sigma^2_T + k\sigma^2_E,
\end{aligned}
$$
where $T$ (no subscript) is any arbitrary true score that all the items' true scores can be shifted to via their constant terms, $\sigma^2_T$ is the true score variance, and $\sigma^2_E$ is the error variance. Notice that the constant terms drop out! This is key. So then the reliability of the total test score is
$$
\begin{aligned}
\frac{k^2\sigma^2_T}{k^2\sigma^2_T + k\sigma^2_E} &= \frac{k\sigma^2_T}{k\sigma^2_T + \sigma^2_X - \sigma^2_T}
\\&= \frac{k\rho}{1+(k-1)\rho},
\end{aligned}
$$
which is just the classical Spearman-Brown formula, unaltered. What this shows is that even when varying the "difficulty" of the items, defined as their mean scores, the Spearman-Brown formula still holds.
@JeremyMiles raises some interesting and important points about what can happen when we increase test length "in the real world," but at least according to the idealized assumptions of classical test theory, variations in item difficulty don't matter for the reliability of a test form (in stark contrast to the assumptions of modern Item Response Theory!). This same basic line of reasoning is also why we usually speak of essential tau-equivalence rather than tau-equivalence, because most all of the important results hold for the more lenient case where item difficulties (i.e., means) can differ. | How is the Spearman-Brown prophecy formula affected by questions of differing difficulties? | Although I feel a little sheepish contradicting both a "respected text" as well as another CV user, it seems to me that the Spearman-Brown formula is not affected by having items of differing difficul | How is the Spearman-Brown prophecy formula affected by questions of differing difficulties?
Although I feel a little sheepish contradicting both a "respected text" as well as another CV user, it seems to me that the Spearman-Brown formula is not affected by having items of differing difficulty. To be sure, the Spearman-Brown formula is usually derived under the assumption that we have parallel items, which implies (among other things) that the items have equal difficulty. But it turns out this assumption isn't necessary; it can be relaxed to allow unequal difficulties, and the Spearman-Brown formula will still hold. I demonstrate this below.
Recall that in classical test theory, a measurement $X$ is assumed to be the sum of a "true score" component $T$ and an error component $E$, that is,
$$
X = T + E,
$$
with $T$ and $E$ uncorrelated. The assumption of parallel items is that all items have the same true scores, differing only in their error components, although these are assumed to have equal variance. In symbols, for any pair of items $X$ and $X'$,
$$
T=T'
\\\textrm{var}(E)=\textrm{var}(E').
$$
Let's see what happens when we relax the first assumption, such that the items might differ in their difficulties, and then derive the reliability of a total test score under these new assumptions. Specifically, assume that the true scores might differ by an additive constant, but the errors still have the same variance. In symbols,
$$
T=T' + c'
\\\textrm{var}(E)=\textrm{var}(E').
$$
Any differences in difficulty are captured by the additive constant. For example, if $c'>0$, then scores on $X$ tend to be higher than scores on $X'$, so that $X$ is "easier" than $X'$. We might call these essentially parallel items, in analogy to the assumption of "essential tau-equivalence" which relaxes the tau-equivalent model in a similar way.
Now to derive the reliability of a test form of such items. Consider a test consisting of $k$ essentially parallel items, the sum of which give the test score. Reliability is, by definition, the ratio of true score variance to observed score variance. For the reliability of the individual items, it follows from the definition of essential parallelism that they have the same reliability, which we denote with $\rho = \sigma^2_T/(\sigma^2_T+\sigma^2_E)$, with $\sigma^2_T$ being the true score variance and $\sigma^2_E$ the error variance. For the reliability of the total test score, we first examine the variance of the total test score, which is
$$
\begin{aligned}
\textrm{var}(\sum_{i=1}^kT_i + E_i) &= \textrm{var}(\sum_{i=1}^kT + c_i + E_i)
\\ &= k^2\sigma^2_T + k\sigma^2_E,
\end{aligned}
$$
where $T$ (no subscript) is any arbitrary true score that all the items' true scores can be shifted to via their constant terms, $\sigma^2_T$ is the true score variance, and $\sigma^2_E$ is the error variance. Notice that the constant terms drop out! This is key. So then the reliability of the total test score is
$$
\begin{aligned}
\frac{k^2\sigma^2_T}{k^2\sigma^2_T + k\sigma^2_E} &= \frac{k\sigma^2_T}{k\sigma^2_T + \sigma^2_X - \sigma^2_T}
\\&= \frac{k\rho}{1+(k-1)\rho},
\end{aligned}
$$
which is just the classical Spearman-Brown formula, unaltered. What this shows is that even when varying the "difficulty" of the items, defined as their mean scores, the Spearman-Brown formula still holds.
@JeremyMiles raises some interesting and important points about what can happen when we increase test length "in the real world," but at least according to the idealized assumptions of classical test theory, variations in item difficulty don't matter for the reliability of a test form (in stark contrast to the assumptions of modern Item Response Theory!). This same basic line of reasoning is also why we usually speak of essential tau-equivalence rather than tau-equivalence, because most all of the important results hold for the more lenient case where item difficulties (i.e., means) can differ. | How is the Spearman-Brown prophecy formula affected by questions of differing difficulties?
Although I feel a little sheepish contradicting both a "respected text" as well as another CV user, it seems to me that the Spearman-Brown formula is not affected by having items of differing difficul |
28,105 | How is the Spearman-Brown prophecy formula affected by questions of differing difficulties? | It's not easy to say.
First, the Spearman-Brown assumes that test items (or raters) are randomly sampled from a population of test items (or raters). This is never really true, particularly of tests, because making up more items is hard, and it's likely that you'll use the better items to start with - then you'll find that the test needs to be longer, so you'll 'scrape the barrel' for items.
Second, items vary in their reliability, and the reliability isn't necessarily related to the difficulty (if it help, think of the slope and intercept of the item characteristic curve in item response theory). However, calculation of reliability (say, Cronbach's alpha, which is a form of intra-class correlation) assume that reliabilities are all equal (they assume an essential tau-equivalent measurement model - that is, that the unstandardized reliabilities of each item are all equal). That's almost certainly wrong. Adding items might go up, might go down. It depends on the items.
Here's another way to think of it. I randomly select a sample from a population, and calculate the mean and standard error of the mean. That mean will be an unbiased estimator of the population mean. Then I increase the size of my sample - the expected value of the mean is the same, but it's unlikely that it will actually be the same - it will almost certainly go up or down. Just as I expect the standard error to get smaller, but the amount it shrinks will not be consistent (and it's not impossible for the standard error to get larger.) | How is the Spearman-Brown prophecy formula affected by questions of differing difficulties? | It's not easy to say.
First, the Spearman-Brown assumes that test items (or raters) are randomly sampled from a population of test items (or raters). This is never really true, particularly of tests, | How is the Spearman-Brown prophecy formula affected by questions of differing difficulties?
It's not easy to say.
First, the Spearman-Brown assumes that test items (or raters) are randomly sampled from a population of test items (or raters). This is never really true, particularly of tests, because making up more items is hard, and it's likely that you'll use the better items to start with - then you'll find that the test needs to be longer, so you'll 'scrape the barrel' for items.
Second, items vary in their reliability, and the reliability isn't necessarily related to the difficulty (if it help, think of the slope and intercept of the item characteristic curve in item response theory). However, calculation of reliability (say, Cronbach's alpha, which is a form of intra-class correlation) assume that reliabilities are all equal (they assume an essential tau-equivalent measurement model - that is, that the unstandardized reliabilities of each item are all equal). That's almost certainly wrong. Adding items might go up, might go down. It depends on the items.
Here's another way to think of it. I randomly select a sample from a population, and calculate the mean and standard error of the mean. That mean will be an unbiased estimator of the population mean. Then I increase the size of my sample - the expected value of the mean is the same, but it's unlikely that it will actually be the same - it will almost certainly go up or down. Just as I expect the standard error to get smaller, but the amount it shrinks will not be consistent (and it's not impossible for the standard error to get larger.) | How is the Spearman-Brown prophecy formula affected by questions of differing difficulties?
It's not easy to say.
First, the Spearman-Brown assumes that test items (or raters) are randomly sampled from a population of test items (or raters). This is never really true, particularly of tests, |
28,106 | Why would a statistical model overfit if given a huge data set? | There are two sorts of problems you might encounter:
1) Computer problems because the data set is too big. These days, a few million rows with 6 columns is just not that big. But, depending on your program, your computer, your amount of RAM and probably other things, it might bog down.
2) Statistical problems. Here, a problem like you discuss will have one "problem" that I know of: Even tiny effects will be highly significant. This is not really a problem with regression, it's a problem with p values. Better to look at effect sizes (regression parameters).
3) Another sort of problem with your model is not due to number of rows, but the nature of the response variable (monthly spend). Although OLS regression does not make any assumptions about the distribution of the response (only about the error), nevertheless, models with money as the dependent variable often have non-normal errors. In addition, it often makes sense, substantively, to take the log of the response. Whether this is so in your case depends on exactly what you are trying to do. | Why would a statistical model overfit if given a huge data set? | There are two sorts of problems you might encounter:
1) Computer problems because the data set is too big. These days, a few million rows with 6 columns is just not that big. But, depending on your pr | Why would a statistical model overfit if given a huge data set?
There are two sorts of problems you might encounter:
1) Computer problems because the data set is too big. These days, a few million rows with 6 columns is just not that big. But, depending on your program, your computer, your amount of RAM and probably other things, it might bog down.
2) Statistical problems. Here, a problem like you discuss will have one "problem" that I know of: Even tiny effects will be highly significant. This is not really a problem with regression, it's a problem with p values. Better to look at effect sizes (regression parameters).
3) Another sort of problem with your model is not due to number of rows, but the nature of the response variable (monthly spend). Although OLS regression does not make any assumptions about the distribution of the response (only about the error), nevertheless, models with money as the dependent variable often have non-normal errors. In addition, it often makes sense, substantively, to take the log of the response. Whether this is so in your case depends on exactly what you are trying to do. | Why would a statistical model overfit if given a huge data set?
There are two sorts of problems you might encounter:
1) Computer problems because the data set is too big. These days, a few million rows with 6 columns is just not that big. But, depending on your pr |
28,107 | Why would a statistical model overfit if given a huge data set? | What's important is the number of individuals (rows) compared to the number of coefficients you need to estimate for the model you want to fit. Typical rules of thumb suggest about 20 observations per coefficient as a minimum, so you should be able to estimate up to 150,000 coefficients—surely more than adequate for your four predictors.
In fact you have an opportunity, not a problem, in this case: to fit a rather complex model including non-linear relationships of the response to predictors, & interactions between predictors; which may predict the response much better than a simpler one in which the relationships of the response to predictors are assumed to be linear & additive. | Why would a statistical model overfit if given a huge data set? | What's important is the number of individuals (rows) compared to the number of coefficients you need to estimate for the model you want to fit. Typical rules of thumb suggest about 20 observations per | Why would a statistical model overfit if given a huge data set?
What's important is the number of individuals (rows) compared to the number of coefficients you need to estimate for the model you want to fit. Typical rules of thumb suggest about 20 observations per coefficient as a minimum, so you should be able to estimate up to 150,000 coefficients—surely more than adequate for your four predictors.
In fact you have an opportunity, not a problem, in this case: to fit a rather complex model including non-linear relationships of the response to predictors, & interactions between predictors; which may predict the response much better than a simpler one in which the relationships of the response to predictors are assumed to be linear & additive. | Why would a statistical model overfit if given a huge data set?
What's important is the number of individuals (rows) compared to the number of coefficients you need to estimate for the model you want to fit. Typical rules of thumb suggest about 20 observations per |
28,108 | Classifier for only one class | This is possible using some approaches and is certainly a valid approach. I am not sure if random forests can do this, though.
Generating artificial data means making extra assumptions, don't do that if you don't have to.
One technique you may want to look into is so-called one-class SVM. It does exactly what you are looking for: it tries to build a model which accepts the training points and would reject points from other distributions.
Some references regarding one-class SVM:
Schölkopf, Bernhard, et al. "Estimating the support of a high-dimensional distribution." Neural computation 13.7 (2001): 1443-1471. This paper introduced the approach.
Tax, David MJ, and Robert PW Duin. "Support vector data description." Machine learning 54.1 (2004): 45-66. A different way to do the same thing, probably more intuitive.
Both of these approaches have been shown to be equivalent. The first estimates a hyperplane which separates all the training data from the origin in feature space with maximal distance. The second estimates a hypersphere with minimal radius in feature space containing the training instances.
One-class SVM is available in many SVM packages, including libsvm, scikit-learn (Python) and kernlab (R). | Classifier for only one class | This is possible using some approaches and is certainly a valid approach. I am not sure if random forests can do this, though.
Generating artificial data means making extra assumptions, don't do that | Classifier for only one class
This is possible using some approaches and is certainly a valid approach. I am not sure if random forests can do this, though.
Generating artificial data means making extra assumptions, don't do that if you don't have to.
One technique you may want to look into is so-called one-class SVM. It does exactly what you are looking for: it tries to build a model which accepts the training points and would reject points from other distributions.
Some references regarding one-class SVM:
Schölkopf, Bernhard, et al. "Estimating the support of a high-dimensional distribution." Neural computation 13.7 (2001): 1443-1471. This paper introduced the approach.
Tax, David MJ, and Robert PW Duin. "Support vector data description." Machine learning 54.1 (2004): 45-66. A different way to do the same thing, probably more intuitive.
Both of these approaches have been shown to be equivalent. The first estimates a hyperplane which separates all the training data from the origin in feature space with maximal distance. The second estimates a hypersphere with minimal radius in feature space containing the training instances.
One-class SVM is available in many SVM packages, including libsvm, scikit-learn (Python) and kernlab (R). | Classifier for only one class
This is possible using some approaches and is certainly a valid approach. I am not sure if random forests can do this, though.
Generating artificial data means making extra assumptions, don't do that |
28,109 | Classifier for only one class | Let me add some more possibilities:
The general idea is that setting a threshold to the distance from the class enables you to decide whether a sample belongs into that class or not, and regardless of whether there are other classes or not.
Mahalanobis-Distance => QDA
SIMCA (Soft Independent Modeling of Class Analogies) uses distances in PCA score space.
SIMCA is common in the chemometric literature (though seldom really set up in a one-class way).
(SVMs are already treated in @Marc Claesen's answer)
Richard G. Brereton: Chemometrics for Pattern Recognition (Wiley, 2009) has a whole chapter about one-class classification. | Classifier for only one class | Let me add some more possibilities:
The general idea is that setting a threshold to the distance from the class enables you to decide whether a sample belongs into that class or not, and regardless of | Classifier for only one class
Let me add some more possibilities:
The general idea is that setting a threshold to the distance from the class enables you to decide whether a sample belongs into that class or not, and regardless of whether there are other classes or not.
Mahalanobis-Distance => QDA
SIMCA (Soft Independent Modeling of Class Analogies) uses distances in PCA score space.
SIMCA is common in the chemometric literature (though seldom really set up in a one-class way).
(SVMs are already treated in @Marc Claesen's answer)
Richard G. Brereton: Chemometrics for Pattern Recognition (Wiley, 2009) has a whole chapter about one-class classification. | Classifier for only one class
Let me add some more possibilities:
The general idea is that setting a threshold to the distance from the class enables you to decide whether a sample belongs into that class or not, and regardless of |
28,110 | Generalized linear mixed models: model selection | Stepwise selection is wrong in multilevel models for the same reasons it is wrong in "regular" regression: The p-values will be too low, the standard errors too small, the parameter estimates biased away from 0 etc. Most important, it denies you the opportunity to think.
9 IVs is not so very many. Why did you choose those 9? Surely you had a reason.
One initial thing to do is look at a lot of plots; which precise ones depends a little on whether your data are longitudinal (in which case plots with time on the x-axis are often useful) or clustered. But surely look at relationships between the 9 IVs and your DV (parallel box plots are one simple possibility).
The ideal would be to build a few models based on substantive sense and compare them using AIC, BIC or some other measure. But don't be surprised if no particular model comes forth as clearly best. You don't say what field you work in, but in many (most?) fields, nature is complicated. Several models may fit about equally well and a different model may fit better on a different data set (even if both are random samples from the same population).
As for references - there are lots of good books on nonlinear mixed models. Which one is best for you depends on a) What field you are in b) What the nature of the data is c) What software you use.
Responding to your comment
If all 9 variables are scientifically important, I would at least consider including them all. If a variable that everyone thinks is important winds up having a small effect, that is interesting.
Certainly plot all your variables over time and in various ways.
For general issues about longitudinal multilevel models I like Hedeker and Gibbons; for nonlinear longitudinal models in SAS I like Molenberghs and Verbeke. The SAS documentation itself (for PROC GLIMMIX) also provides guidance. | Generalized linear mixed models: model selection | Stepwise selection is wrong in multilevel models for the same reasons it is wrong in "regular" regression: The p-values will be too low, the standard errors too small, the parameter estimates biased a | Generalized linear mixed models: model selection
Stepwise selection is wrong in multilevel models for the same reasons it is wrong in "regular" regression: The p-values will be too low, the standard errors too small, the parameter estimates biased away from 0 etc. Most important, it denies you the opportunity to think.
9 IVs is not so very many. Why did you choose those 9? Surely you had a reason.
One initial thing to do is look at a lot of plots; which precise ones depends a little on whether your data are longitudinal (in which case plots with time on the x-axis are often useful) or clustered. But surely look at relationships between the 9 IVs and your DV (parallel box plots are one simple possibility).
The ideal would be to build a few models based on substantive sense and compare them using AIC, BIC or some other measure. But don't be surprised if no particular model comes forth as clearly best. You don't say what field you work in, but in many (most?) fields, nature is complicated. Several models may fit about equally well and a different model may fit better on a different data set (even if both are random samples from the same population).
As for references - there are lots of good books on nonlinear mixed models. Which one is best for you depends on a) What field you are in b) What the nature of the data is c) What software you use.
Responding to your comment
If all 9 variables are scientifically important, I would at least consider including them all. If a variable that everyone thinks is important winds up having a small effect, that is interesting.
Certainly plot all your variables over time and in various ways.
For general issues about longitudinal multilevel models I like Hedeker and Gibbons; for nonlinear longitudinal models in SAS I like Molenberghs and Verbeke. The SAS documentation itself (for PROC GLIMMIX) also provides guidance. | Generalized linear mixed models: model selection
Stepwise selection is wrong in multilevel models for the same reasons it is wrong in "regular" regression: The p-values will be too low, the standard errors too small, the parameter estimates biased a |
28,111 | Generalized linear mixed models: model selection | Model selection can better be carried out using shrinkage methods such as LASSO. Stepwise methods are too liberal. A justification can be found in Tibshirani's webpage. If you are using R then there is a package called glmmLasso which allows model selection in generalized linear mixed effects models using the LASSO shrinkage method. | Generalized linear mixed models: model selection | Model selection can better be carried out using shrinkage methods such as LASSO. Stepwise methods are too liberal. A justification can be found in Tibshirani's webpage. If you are using R then there i | Generalized linear mixed models: model selection
Model selection can better be carried out using shrinkage methods such as LASSO. Stepwise methods are too liberal. A justification can be found in Tibshirani's webpage. If you are using R then there is a package called glmmLasso which allows model selection in generalized linear mixed effects models using the LASSO shrinkage method. | Generalized linear mixed models: model selection
Model selection can better be carried out using shrinkage methods such as LASSO. Stepwise methods are too liberal. A justification can be found in Tibshirani's webpage. If you are using R then there i |
28,112 | Generalized linear mixed models: model selection | A good reference for AIC based mixed model selection in R (also good for dummies) would be Zuur_2009_Mixed_Effect_Models_and_Extensions_in_Ecology_with_R, | Generalized linear mixed models: model selection | A good reference for AIC based mixed model selection in R (also good for dummies) would be Zuur_2009_Mixed_Effect_Models_and_Extensions_in_Ecology_with_R, | Generalized linear mixed models: model selection
A good reference for AIC based mixed model selection in R (also good for dummies) would be Zuur_2009_Mixed_Effect_Models_and_Extensions_in_Ecology_with_R, | Generalized linear mixed models: model selection
A good reference for AIC based mixed model selection in R (also good for dummies) would be Zuur_2009_Mixed_Effect_Models_and_Extensions_in_Ecology_with_R, |
28,113 | Gauss-Markov theorem: BLUE and OLS | I am not sure if I understood you question correctly, but if you are looking to prove that the OLS for $\hat{\beta}$ is BLUE (best linear unbiased estimator) you have to prove the following two things: First that $\hat{\beta}$ is unbiased and second that $Var(\hat{\beta})$ is the smallest among all linear unbiased estimators.
Proof that OLS estimator is unbiased can be found here http://economictheoryblog.com/2015/02/19/ols_estimator/
and proof that $Var(\hat{\beta})$ is the smallest among all linear unbiased estimators can be found here http://economictheoryblog.com/2015/02/26/markov_theorem/ | Gauss-Markov theorem: BLUE and OLS | I am not sure if I understood you question correctly, but if you are looking to prove that the OLS for $\hat{\beta}$ is BLUE (best linear unbiased estimator) you have to prove the following two things | Gauss-Markov theorem: BLUE and OLS
I am not sure if I understood you question correctly, but if you are looking to prove that the OLS for $\hat{\beta}$ is BLUE (best linear unbiased estimator) you have to prove the following two things: First that $\hat{\beta}$ is unbiased and second that $Var(\hat{\beta})$ is the smallest among all linear unbiased estimators.
Proof that OLS estimator is unbiased can be found here http://economictheoryblog.com/2015/02/19/ols_estimator/
and proof that $Var(\hat{\beta})$ is the smallest among all linear unbiased estimators can be found here http://economictheoryblog.com/2015/02/26/markov_theorem/ | Gauss-Markov theorem: BLUE and OLS
I am not sure if I understood you question correctly, but if you are looking to prove that the OLS for $\hat{\beta}$ is BLUE (best linear unbiased estimator) you have to prove the following two things |
28,114 | Gauss-Markov theorem: BLUE and OLS | It seems my hunch was correct indeed, as confirmed, e.g. on page 375 of the book
Introductory Econometrics. Relevant excerpt: | Gauss-Markov theorem: BLUE and OLS | It seems my hunch was correct indeed, as confirmed, e.g. on page 375 of the book
Introductory Econometrics. Relevant excerpt: | Gauss-Markov theorem: BLUE and OLS
It seems my hunch was correct indeed, as confirmed, e.g. on page 375 of the book
Introductory Econometrics. Relevant excerpt: | Gauss-Markov theorem: BLUE and OLS
It seems my hunch was correct indeed, as confirmed, e.g. on page 375 of the book
Introductory Econometrics. Relevant excerpt: |
28,115 | Using multiple imputation for Cox proportional hazards, then validating with rms package? | The fit.mult.impute function in the Hmisc package will draw imputations created from mice just as it will from aregImpute. cph will work with fit.mult.impute. The harder question is how to do validation through resampling when also doing multiple imputation. I don't think anyone has really solved that. I usually take the easy way out and use single imputation to validate the model, using the Hmisc transcan function, but using multiple imputation to fit the final model and to get standard errors. | Using multiple imputation for Cox proportional hazards, then validating with rms package? | The fit.mult.impute function in the Hmisc package will draw imputations created from mice just as it will from aregImpute. cph will work with fit.mult.impute. The harder question is how to do valida | Using multiple imputation for Cox proportional hazards, then validating with rms package?
The fit.mult.impute function in the Hmisc package will draw imputations created from mice just as it will from aregImpute. cph will work with fit.mult.impute. The harder question is how to do validation through resampling when also doing multiple imputation. I don't think anyone has really solved that. I usually take the easy way out and use single imputation to validate the model, using the Hmisc transcan function, but using multiple imputation to fit the final model and to get standard errors. | Using multiple imputation for Cox proportional hazards, then validating with rms package?
The fit.mult.impute function in the Hmisc package will draw imputations created from mice just as it will from aregImpute. cph will work with fit.mult.impute. The harder question is how to do valida |
28,116 | Using multiple imputation for Cox proportional hazards, then validating with rms package? | I looked into some examples in the Himsc document for fit.mult.impute() function but could not find an example for coxph. Just in case someone is looking for the same thing, here is an example of how I used fit.mult.impute() for cox regression pooling:
x1 <- factor(sample(c('a','b','c'),100,TRUE)
x2 <- (x1=='b') + 3*(x1=='c') + rnorm(100)
y <- x2 + 1*(x1=='c') + rnorm(100)
x1[1:20] <- NA
x2[18:23] <- NA
ttocvd = sample(0:20, 100, replace = TRUE)
CVD = sample(0:1, 100, replace = TRUE)
d <- data.frame(x1,x2,y, ttocvd, CVD)
f <- transcan(~y + x1 + x2+CVD+ ttocvd, n.impute=10, shrink=TRUE, data=d)
#f <- mice(d) #if using mice imputation
h <- fit.mult.impute(Surv(ttocvd, CVD) ~ x1 + x2, coxph, f, data=d)
summary(h) | Using multiple imputation for Cox proportional hazards, then validating with rms package? | I looked into some examples in the Himsc document for fit.mult.impute() function but could not find an example for coxph. Just in case someone is looking for the same thing, here is an example of how | Using multiple imputation for Cox proportional hazards, then validating with rms package?
I looked into some examples in the Himsc document for fit.mult.impute() function but could not find an example for coxph. Just in case someone is looking for the same thing, here is an example of how I used fit.mult.impute() for cox regression pooling:
x1 <- factor(sample(c('a','b','c'),100,TRUE)
x2 <- (x1=='b') + 3*(x1=='c') + rnorm(100)
y <- x2 + 1*(x1=='c') + rnorm(100)
x1[1:20] <- NA
x2[18:23] <- NA
ttocvd = sample(0:20, 100, replace = TRUE)
CVD = sample(0:1, 100, replace = TRUE)
d <- data.frame(x1,x2,y, ttocvd, CVD)
f <- transcan(~y + x1 + x2+CVD+ ttocvd, n.impute=10, shrink=TRUE, data=d)
#f <- mice(d) #if using mice imputation
h <- fit.mult.impute(Surv(ttocvd, CVD) ~ x1 + x2, coxph, f, data=d)
summary(h) | Using multiple imputation for Cox proportional hazards, then validating with rms package?
I looked into some examples in the Himsc document for fit.mult.impute() function but could not find an example for coxph. Just in case someone is looking for the same thing, here is an example of how |
28,117 | A parellel between LSA and pLSA | For simplicity, I'm giving here the connection between LSA and non-negative matrix factorization (NMF), and then show how a simple modification of the cost function leads to pLSA. As stated earlier, LSA and pLSA are both factorization methods in the sense that, up to normalization of the rows and columns, the low-rank decomposition of the document term matrix:
$$X=U\Sigma D$$
using previous notations. More simply, the document term matrix can be written as a product of two matrices:
$$ X = AB^T $$
where $A\in\Re^{N\times s}$ and $B\in\Re^{M\times s}$. For LSA, the correspondence with the previous formula is obtained by setting $A=U \sqrt{\Sigma}$ and $B=V\sqrt{\Sigma}$.
An easy way to understand the difference between LSA and NMF is to use their geometric interpretation:
LSA is the solution of:
$$ \min_{A,B} \|X - AB^T \|_F^2,$$
NMF-$L_2$ is the solution of:
$$ \min_{A\ge 0,B\ge 0} \|X - AB^T \|_F^2,$$
NMF-KL is equivalent to pLSA and is the solution of:
$$ \min_{A\ge 0,B\ge 0} KL(X|| AB^T).$$
where $KL(X||Y) = \sum_{ij} x_{ij}\log{\frac{x_{ij}}{y_{ij}}}$ is the Kullback-Leibler divergence between matrices $X$ and $Y$. It is easy to see that all the problems above do not have a unique solution, since one can multiply $A$ by a positive number and divide $B$ by the same number to obtain the same objective value. Hence,
- in the case of LSA, people usually choose an orthogonal basis sorted by decreasing eigenvalues. This is given by the SVD decomposition and identifies the LSA solution, but any other choice would be possible as it has no impact on most of the operations (cosine similarity, smoothing formula mentioned above, etc).
- in the case of NMF, an orthogonal decomposition is not possible, but the rows of $A$ are usually constrained to sum to one, because it has a direct probabilistic interpretation as $p(z_k|d_i)$.
If in addition, the rows of $X$ are normalized (i.e. sum to one), then the rows of $B$ have to sum to one, leading to the probabilistic interpretation $p(f_j|z_k)$.
There is a slight difference with the version of pLSA given in the above question because the columns of $A$ are constrained to sum to one, so that the values in $A$ are $p(d_i|z_k)$, but the difference is only a change of parametrization, the problem remaining the same.
Now, to answer the initial question, there is something subtle in the difference between LSA and pLSA (and other NMF algorithms): the non-negativity constraints induce a a "clustering effect" that is not valid in the classical LSA case because the Singular Value Decomposition solution is rotationally invariant. The non-negativity constraints somehow break this rotational invariance and gives factors with some sort of semantic meaning (topics in text analysis). The first paper to explain it is:
Donoho, David L., and Victoria C. Stodden. "When does non-negative
matrix factorization give a correct decomposition into parts?."
Advances in neural information processing systems 16: proceedings of
the 2003 conference. MIT Press, 2004. [link]
Otherwise, the relation between PLSA and NMF is described here:
Ding, Chris, Tao Li, and Wei Peng. "On the equivalence between
non-negative matrix factorization and probabilistic latent semantic
indexing." Computational Statistics & Data Analysis 52.8 (2008):
3913-3927. [link] | A parellel between LSA and pLSA | For simplicity, I'm giving here the connection between LSA and non-negative matrix factorization (NMF), and then show how a simple modification of the cost function leads to pLSA. As stated earlier, L | A parellel between LSA and pLSA
For simplicity, I'm giving here the connection between LSA and non-negative matrix factorization (NMF), and then show how a simple modification of the cost function leads to pLSA. As stated earlier, LSA and pLSA are both factorization methods in the sense that, up to normalization of the rows and columns, the low-rank decomposition of the document term matrix:
$$X=U\Sigma D$$
using previous notations. More simply, the document term matrix can be written as a product of two matrices:
$$ X = AB^T $$
where $A\in\Re^{N\times s}$ and $B\in\Re^{M\times s}$. For LSA, the correspondence with the previous formula is obtained by setting $A=U \sqrt{\Sigma}$ and $B=V\sqrt{\Sigma}$.
An easy way to understand the difference between LSA and NMF is to use their geometric interpretation:
LSA is the solution of:
$$ \min_{A,B} \|X - AB^T \|_F^2,$$
NMF-$L_2$ is the solution of:
$$ \min_{A\ge 0,B\ge 0} \|X - AB^T \|_F^2,$$
NMF-KL is equivalent to pLSA and is the solution of:
$$ \min_{A\ge 0,B\ge 0} KL(X|| AB^T).$$
where $KL(X||Y) = \sum_{ij} x_{ij}\log{\frac{x_{ij}}{y_{ij}}}$ is the Kullback-Leibler divergence between matrices $X$ and $Y$. It is easy to see that all the problems above do not have a unique solution, since one can multiply $A$ by a positive number and divide $B$ by the same number to obtain the same objective value. Hence,
- in the case of LSA, people usually choose an orthogonal basis sorted by decreasing eigenvalues. This is given by the SVD decomposition and identifies the LSA solution, but any other choice would be possible as it has no impact on most of the operations (cosine similarity, smoothing formula mentioned above, etc).
- in the case of NMF, an orthogonal decomposition is not possible, but the rows of $A$ are usually constrained to sum to one, because it has a direct probabilistic interpretation as $p(z_k|d_i)$.
If in addition, the rows of $X$ are normalized (i.e. sum to one), then the rows of $B$ have to sum to one, leading to the probabilistic interpretation $p(f_j|z_k)$.
There is a slight difference with the version of pLSA given in the above question because the columns of $A$ are constrained to sum to one, so that the values in $A$ are $p(d_i|z_k)$, but the difference is only a change of parametrization, the problem remaining the same.
Now, to answer the initial question, there is something subtle in the difference between LSA and pLSA (and other NMF algorithms): the non-negativity constraints induce a a "clustering effect" that is not valid in the classical LSA case because the Singular Value Decomposition solution is rotationally invariant. The non-negativity constraints somehow break this rotational invariance and gives factors with some sort of semantic meaning (topics in text analysis). The first paper to explain it is:
Donoho, David L., and Victoria C. Stodden. "When does non-negative
matrix factorization give a correct decomposition into parts?."
Advances in neural information processing systems 16: proceedings of
the 2003 conference. MIT Press, 2004. [link]
Otherwise, the relation between PLSA and NMF is described here:
Ding, Chris, Tao Li, and Wei Peng. "On the equivalence between
non-negative matrix factorization and probabilistic latent semantic
indexing." Computational Statistics & Data Analysis 52.8 (2008):
3913-3927. [link] | A parellel between LSA and pLSA
For simplicity, I'm giving here the connection between LSA and non-negative matrix factorization (NMF), and then show how a simple modification of the cost function leads to pLSA. As stated earlier, L |
28,118 | How should I normalize my accelerometer sensor data? | The raw signals you show above appear to be unfiltered and uncalibrated. Appropriate filtering and calibration, with some artifact rejection will in effect normalize the data.
The standard approach with accelerometer data is the following:
Filter - e.g. 4th order, zero-phase IIR lowpass or bandpass filter
Artifact rejection - threshold based
Calibrate - Ferraris et al method (Procedure for effortless in-field
calibration of three-axis rate gyros and accelerometers, F Ferraris,
U Grimaldi, M Parvis - Sensors and Actuators, 1995) method works
well for this.
It is advisable to perform artifact rejection on inertial sensor data. I would be concerned that you don't know the provenance of the data, and so you cannot guarantee that the sensors were affixed correctly and consistently (in terms of orientation and physical placement) to all subjects. If the sensors were not affixed correctly, you can get a lot of artifact in the signals, as the sensor can move relative to the body-segment. Similarly, if the sensors were orientated differently (in how they were placed) on different subjects, the data will be difficult to compare across subjects.
Given the size of the outliers you report they seem likely to be artifacts. Such artifacts would almost certain skew any calibration calculation (though their effect will be lessened by appropriate filtering) and so calibration should be performed after artifact rejection.
A simple threshold may work well for an initial artifact rejection routine, i.e. remove (or replace with NaN) all samples above a certain empirical threshold. More sophisticated techniques will adaptively calculate this threshold using a running mean or moving window.
Depending on the location of the sensor you may also wish to correct for the influence of gravity on the acceleration signals, though detailed understanding on sensor axes and positioning is crucial here. The Moe-Nillson method (R. Moe-Nilssen, A new method for evaluating motor control in gait under real-life environmental conditions. Part 1: The instrument, Clinical Biomechanics, Volume 13, Issues 4–5, June–July 1998, Pages 320-327) is the most commonly used and works well for lower back mounted inertial sensors.
A good place to start on examining the data for gesture recognition would be to break the filtered, calibrated data into epochs (e.g. 10s) and calculate a number of features per epoch and relate these to the labels you have for the data, I can't offer more specific advice without knowing more about the data set and the associated labels.
Hope this helps. | How should I normalize my accelerometer sensor data? | The raw signals you show above appear to be unfiltered and uncalibrated. Appropriate filtering and calibration, with some artifact rejection will in effect normalize the data.
The standard approach wi | How should I normalize my accelerometer sensor data?
The raw signals you show above appear to be unfiltered and uncalibrated. Appropriate filtering and calibration, with some artifact rejection will in effect normalize the data.
The standard approach with accelerometer data is the following:
Filter - e.g. 4th order, zero-phase IIR lowpass or bandpass filter
Artifact rejection - threshold based
Calibrate - Ferraris et al method (Procedure for effortless in-field
calibration of three-axis rate gyros and accelerometers, F Ferraris,
U Grimaldi, M Parvis - Sensors and Actuators, 1995) method works
well for this.
It is advisable to perform artifact rejection on inertial sensor data. I would be concerned that you don't know the provenance of the data, and so you cannot guarantee that the sensors were affixed correctly and consistently (in terms of orientation and physical placement) to all subjects. If the sensors were not affixed correctly, you can get a lot of artifact in the signals, as the sensor can move relative to the body-segment. Similarly, if the sensors were orientated differently (in how they were placed) on different subjects, the data will be difficult to compare across subjects.
Given the size of the outliers you report they seem likely to be artifacts. Such artifacts would almost certain skew any calibration calculation (though their effect will be lessened by appropriate filtering) and so calibration should be performed after artifact rejection.
A simple threshold may work well for an initial artifact rejection routine, i.e. remove (or replace with NaN) all samples above a certain empirical threshold. More sophisticated techniques will adaptively calculate this threshold using a running mean or moving window.
Depending on the location of the sensor you may also wish to correct for the influence of gravity on the acceleration signals, though detailed understanding on sensor axes and positioning is crucial here. The Moe-Nillson method (R. Moe-Nilssen, A new method for evaluating motor control in gait under real-life environmental conditions. Part 1: The instrument, Clinical Biomechanics, Volume 13, Issues 4–5, June–July 1998, Pages 320-327) is the most commonly used and works well for lower back mounted inertial sensors.
A good place to start on examining the data for gesture recognition would be to break the filtered, calibrated data into epochs (e.g. 10s) and calculate a number of features per epoch and relate these to the labels you have for the data, I can't offer more specific advice without knowing more about the data set and the associated labels.
Hope this helps. | How should I normalize my accelerometer sensor data?
The raw signals you show above appear to be unfiltered and uncalibrated. Appropriate filtering and calibration, with some artifact rejection will in effect normalize the data.
The standard approach wi |
28,119 | Why is volatility an important topic in financial econometrics? | Past volatility in the price of something is a measure of the inability of the past to predict the present, as otherwise prices would largely change smoothly just reflecting time costs, and so in many (but not all) cases it could be an indicator of how difficult it might be for the present to predict the future.
Hence it becomes an indicator of risk, and affects the values of derivatives: buying an option will tend to be more expensive if both parties believe prices are likely to be volatile in future and the option is more likely to be exercised. | Why is volatility an important topic in financial econometrics? | Past volatility in the price of something is a measure of the inability of the past to predict the present, as otherwise prices would largely change smoothly just reflecting time costs, and so in many | Why is volatility an important topic in financial econometrics?
Past volatility in the price of something is a measure of the inability of the past to predict the present, as otherwise prices would largely change smoothly just reflecting time costs, and so in many (but not all) cases it could be an indicator of how difficult it might be for the present to predict the future.
Hence it becomes an indicator of risk, and affects the values of derivatives: buying an option will tend to be more expensive if both parties believe prices are likely to be volatile in future and the option is more likely to be exercised. | Why is volatility an important topic in financial econometrics?
Past volatility in the price of something is a measure of the inability of the past to predict the present, as otherwise prices would largely change smoothly just reflecting time costs, and so in many |
28,120 | Why is volatility an important topic in financial econometrics? | I think the main reason is that many financial time series exhibit high volatility and the standard ARIMA models do not fit well to data with high volatility. So special time series models that account for this are important to generate better predictions.
The ARIMA models are well established while time series models such as GARCH that model volatility are newer and more open for extensions and theoretical development. These are reasons why this topic would be appealing to academics. | Why is volatility an important topic in financial econometrics? | I think the main reason is that many financial time series exhibit high volatility and the standard ARIMA models do not fit well to data with high volatility. So special time series models that accou | Why is volatility an important topic in financial econometrics?
I think the main reason is that many financial time series exhibit high volatility and the standard ARIMA models do not fit well to data with high volatility. So special time series models that account for this are important to generate better predictions.
The ARIMA models are well established while time series models such as GARCH that model volatility are newer and more open for extensions and theoretical development. These are reasons why this topic would be appealing to academics. | Why is volatility an important topic in financial econometrics?
I think the main reason is that many financial time series exhibit high volatility and the standard ARIMA models do not fit well to data with high volatility. So special time series models that accou |
28,121 | Why is volatility an important topic in financial econometrics? | I'm not an economist, but my guesses would be that: 1) there are several options/futures-based techniques for profiting from high volatility, and 2) higher volatility corresponds to greater risk in some sense, or at least investor confidence/nervousness. | Why is volatility an important topic in financial econometrics? | I'm not an economist, but my guesses would be that: 1) there are several options/futures-based techniques for profiting from high volatility, and 2) higher volatility corresponds to greater risk in so | Why is volatility an important topic in financial econometrics?
I'm not an economist, but my guesses would be that: 1) there are several options/futures-based techniques for profiting from high volatility, and 2) higher volatility corresponds to greater risk in some sense, or at least investor confidence/nervousness. | Why is volatility an important topic in financial econometrics?
I'm not an economist, but my guesses would be that: 1) there are several options/futures-based techniques for profiting from high volatility, and 2) higher volatility corresponds to greater risk in so |
28,122 | Why is volatility an important topic in financial econometrics? | Modern Portfolio Theory (MPT) and the Efficient Market Hypothesis (EMH) share important assumptions. Amongst them is the assumption that all investors are at all times profit maximizing, rational and risk-averse. If this is the case then excess vol and vol clusters are said to violate a strict form of the EMH since this indicates that prices may deviate from fundamentals. Of course, excess vol/vol clusters are seen at all levels of granularity in financial time series.
Financial economists seek to explain why excess vol exists and how best to incorporate it in their models. While the ideas about how to model vol don't necessarily come from financial economists, important ones, like ARCH/GARCH did, and were subsequently incorporated by financial firms in their pricing models and trading strategies. | Why is volatility an important topic in financial econometrics? | Modern Portfolio Theory (MPT) and the Efficient Market Hypothesis (EMH) share important assumptions. Amongst them is the assumption that all investors are at all times profit maximizing, rational and | Why is volatility an important topic in financial econometrics?
Modern Portfolio Theory (MPT) and the Efficient Market Hypothesis (EMH) share important assumptions. Amongst them is the assumption that all investors are at all times profit maximizing, rational and risk-averse. If this is the case then excess vol and vol clusters are said to violate a strict form of the EMH since this indicates that prices may deviate from fundamentals. Of course, excess vol/vol clusters are seen at all levels of granularity in financial time series.
Financial economists seek to explain why excess vol exists and how best to incorporate it in their models. While the ideas about how to model vol don't necessarily come from financial economists, important ones, like ARCH/GARCH did, and were subsequently incorporated by financial firms in their pricing models and trading strategies. | Why is volatility an important topic in financial econometrics?
Modern Portfolio Theory (MPT) and the Efficient Market Hypothesis (EMH) share important assumptions. Amongst them is the assumption that all investors are at all times profit maximizing, rational and |
28,123 | Why is volatility an important topic in financial econometrics? | Volatility also has an application that is rather important, which is in options pricing. The famous Black-Scholes model incorporates future volatility in its equation. So being able to forecast volatility with a high degree of accuracy is crucial in everyday life of derivative trade desk professionals. That is why so much attention is being paid in academia to the research and better understanding of volatility. | Why is volatility an important topic in financial econometrics? | Volatility also has an application that is rather important, which is in options pricing. The famous Black-Scholes model incorporates future volatility in its equation. So being able to forecast volat | Why is volatility an important topic in financial econometrics?
Volatility also has an application that is rather important, which is in options pricing. The famous Black-Scholes model incorporates future volatility in its equation. So being able to forecast volatility with a high degree of accuracy is crucial in everyday life of derivative trade desk professionals. That is why so much attention is being paid in academia to the research and better understanding of volatility. | Why is volatility an important topic in financial econometrics?
Volatility also has an application that is rather important, which is in options pricing. The famous Black-Scholes model incorporates future volatility in its equation. So being able to forecast volat |
28,124 | Why is volatility an important topic in financial econometrics? | Volatility is a very important concept in finance for the simple reason that it matters how you get there. Let's say you need to get from Chicago to Indianapolis. You have two options to get there, you could drive your nice luxury SUV with air conditioning and cruise control or you could hop into a railcar as a stowaway. Its summer and the railcar is 110 degrees inside and you're so hot after an hour that you feel like jumping out at a stop only halfway there. You get slammed into the side of the railcar and injure your shoulder and now you can't use your right arm and the pain is killing you. You now want to jump out and do anything to help alleviate the pain. You decide to tough it all out and arrive in Indianapolis three hours later, the same amount of time it took to drive. Both options resulted in the same outcome, getting from point A to point B but the railcar option was extremely uncomfortable and you considered not making the whole trip a few times.
The same goes for stock returns, the degree of discomfort experienced on the trip to year end stock market gains is expressed by standard deviation and volatility. Excessive volatility will make you want to sell out of a stock or portfolio. It can make the ride extremely uncomfortable. A rational investor, even one who claims he's in it for the long term will be tested to sell out at a bottom with too much volatility.
With volatility and standard deviation, you can calculate one of the most critical metrics of any portfolio which is risk adjusted return. Formulas like the Sharpe and Sortino ratios help quantify the risk adjusted returns of a stock or portfolio.
Aside from options pricing, this is the best application of volatility and standard deviation to portfolio construction and financial econometrics. | Why is volatility an important topic in financial econometrics? | Volatility is a very important concept in finance for the simple reason that it matters how you get there. Let's say you need to get from Chicago to Indianapolis. You have two options to get there, yo | Why is volatility an important topic in financial econometrics?
Volatility is a very important concept in finance for the simple reason that it matters how you get there. Let's say you need to get from Chicago to Indianapolis. You have two options to get there, you could drive your nice luxury SUV with air conditioning and cruise control or you could hop into a railcar as a stowaway. Its summer and the railcar is 110 degrees inside and you're so hot after an hour that you feel like jumping out at a stop only halfway there. You get slammed into the side of the railcar and injure your shoulder and now you can't use your right arm and the pain is killing you. You now want to jump out and do anything to help alleviate the pain. You decide to tough it all out and arrive in Indianapolis three hours later, the same amount of time it took to drive. Both options resulted in the same outcome, getting from point A to point B but the railcar option was extremely uncomfortable and you considered not making the whole trip a few times.
The same goes for stock returns, the degree of discomfort experienced on the trip to year end stock market gains is expressed by standard deviation and volatility. Excessive volatility will make you want to sell out of a stock or portfolio. It can make the ride extremely uncomfortable. A rational investor, even one who claims he's in it for the long term will be tested to sell out at a bottom with too much volatility.
With volatility and standard deviation, you can calculate one of the most critical metrics of any portfolio which is risk adjusted return. Formulas like the Sharpe and Sortino ratios help quantify the risk adjusted returns of a stock or portfolio.
Aside from options pricing, this is the best application of volatility and standard deviation to portfolio construction and financial econometrics. | Why is volatility an important topic in financial econometrics?
Volatility is a very important concept in finance for the simple reason that it matters how you get there. Let's say you need to get from Chicago to Indianapolis. You have two options to get there, yo |
28,125 | Mean survival time for a log-normal survival function | The median survival time, $t_{\textrm{med}}$, is the solution of $S(t) = \frac{1}{2}$; in this case, $t_{\textrm{med}} = \exp(\mu)$. This is because $\Phi(0) = \frac{1}{2}$ when $\Phi$ denotes the cumulative distribution function of a standard normal random variable.
When $\mu = 3$, the median survival time is around $20.1$ as depicted in the picture below. | Mean survival time for a log-normal survival function | The median survival time, $t_{\textrm{med}}$, is the solution of $S(t) = \frac{1}{2}$; in this case, $t_{\textrm{med}} = \exp(\mu)$. This is because $\Phi(0) = \frac{1}{2}$ when $\Phi$ denotes the cum | Mean survival time for a log-normal survival function
The median survival time, $t_{\textrm{med}}$, is the solution of $S(t) = \frac{1}{2}$; in this case, $t_{\textrm{med}} = \exp(\mu)$. This is because $\Phi(0) = \frac{1}{2}$ when $\Phi$ denotes the cumulative distribution function of a standard normal random variable.
When $\mu = 3$, the median survival time is around $20.1$ as depicted in the picture below. | Mean survival time for a log-normal survival function
The median survival time, $t_{\textrm{med}}$, is the solution of $S(t) = \frac{1}{2}$; in this case, $t_{\textrm{med}} = \exp(\mu)$. This is because $\Phi(0) = \frac{1}{2}$ when $\Phi$ denotes the cum |
28,126 | Mean survival time for a log-normal survival function | The R rms package can help:
require(rms)
f <- psm(Surv(dtime, event) ~ ..., dist='lognormal')
m <- Mean(f)
m # see analytic form
m(c(.1,.2)) # evaluate mean at linear predictor values .1, .2
m(predict(f, expand.grid(age=10:20, sex=c('male','female'))))
# evaluates mean survival time at combinations of covariate values | Mean survival time for a log-normal survival function | The R rms package can help:
require(rms)
f <- psm(Surv(dtime, event) ~ ..., dist='lognormal')
m <- Mean(f)
m # see analytic form
m(c(.1,.2)) # evaluate mean at linear predictor values .1, .2
m(predi | Mean survival time for a log-normal survival function
The R rms package can help:
require(rms)
f <- psm(Surv(dtime, event) ~ ..., dist='lognormal')
m <- Mean(f)
m # see analytic form
m(c(.1,.2)) # evaluate mean at linear predictor values .1, .2
m(predict(f, expand.grid(age=10:20, sex=c('male','female'))))
# evaluates mean survival time at combinations of covariate values | Mean survival time for a log-normal survival function
The R rms package can help:
require(rms)
f <- psm(Surv(dtime, event) ~ ..., dist='lognormal')
m <- Mean(f)
m # see analytic form
m(c(.1,.2)) # evaluate mean at linear predictor values .1, .2
m(predi |
28,127 | Mean survival time for a log-normal survival function | In case someone really does want the mean survival time as originally asked, it's $e^{\mu+{\sigma^2\over 2}}$. (In fact, the original poster should carefully consider whether they want the mean or the median for their use of the resulting number. For the example given with $\sigma=1.1$, the mean is almost twice the median.) | Mean survival time for a log-normal survival function | In case someone really does want the mean survival time as originally asked, it's $e^{\mu+{\sigma^2\over 2}}$. (In fact, the original poster should carefully consider whether they want the mean or th | Mean survival time for a log-normal survival function
In case someone really does want the mean survival time as originally asked, it's $e^{\mu+{\sigma^2\over 2}}$. (In fact, the original poster should carefully consider whether they want the mean or the median for their use of the resulting number. For the example given with $\sigma=1.1$, the mean is almost twice the median.) | Mean survival time for a log-normal survival function
In case someone really does want the mean survival time as originally asked, it's $e^{\mu+{\sigma^2\over 2}}$. (In fact, the original poster should carefully consider whether they want the mean or th |
28,128 | Advantage of kernel density estimation over parametric estimation | The answering question is "why do you model your data as a sample from a distribution?" If you want to learn something about the phenomenon behind your data, like when improving a scientific theory or testing a scientific hypothesis, using a non-parametric kernel estimator does not tell you much more than the data istself. While a parameterised model can tell much more clearly (a) whether or not the data and the model agree and (b) what are the likely values of the parameters. Depending on your goals thus drives which approach you should prefer. | Advantage of kernel density estimation over parametric estimation | The answering question is "why do you model your data as a sample from a distribution?" If you want to learn something about the phenomenon behind your data, like when improving a scientific theory or | Advantage of kernel density estimation over parametric estimation
The answering question is "why do you model your data as a sample from a distribution?" If you want to learn something about the phenomenon behind your data, like when improving a scientific theory or testing a scientific hypothesis, using a non-parametric kernel estimator does not tell you much more than the data istself. While a parameterised model can tell much more clearly (a) whether or not the data and the model agree and (b) what are the likely values of the parameters. Depending on your goals thus drives which approach you should prefer. | Advantage of kernel density estimation over parametric estimation
The answering question is "why do you model your data as a sample from a distribution?" If you want to learn something about the phenomenon behind your data, like when improving a scientific theory or |
28,129 | Advantage of kernel density estimation over parametric estimation | There could be. Kernel density estimation is a nonparametric approach. Parametric estimation requires a parametric family of distributions based on a few parameter be assumed. If you have a basis to believe the model is approxiamtely correct it is advantageous to do parametric inference. On the other hand it is possible that the data does not fit well to any member of the family. In that case it is better to use kernel density estimation because it will construct a density that reasonably fit the data. It does not require any assumption regarding parametric families.
This description may be slightly oversimplified for clarity. Let me give a specific example to make this concrete. Suppose the parametric family is the normal distribution which is defined by the two unknown parameters the mean and variance. Every distribution in the family is symmetric and bell shaped with the mean equal to the median and the mode. Now your sample does not appear to be symmetric and the sample mean is very different from the sample median. Then you have evidence to think that your assumption is wrong. So you either need to find a transformation that converts the data to fit to a nice parametric family (possibly the normal) or find an alternative parametric family. If these alternative parametric approaches do not seem to work the kernel density approach is an alternative that will work. There are a few issues (1) the kernel's shape, (2) the kernel bandwidth that determines the level of smoothness and (3) possibly a larger sample size than what you might need for a parametric family. Issue 1 has been shown in the literature to be practically unimportant. Issue 2 is important. Issue 3 depends on how large of a sample you can afford to collect. Even though these issues exist along with the implicit assumption that the distribution has a density, these assumptions may be easier to accept than the restrictive parametric assumptions. | Advantage of kernel density estimation over parametric estimation | There could be. Kernel density estimation is a nonparametric approach. Parametric estimation requires a parametric family of distributions based on a few parameter be assumed. If you have a basis to | Advantage of kernel density estimation over parametric estimation
There could be. Kernel density estimation is a nonparametric approach. Parametric estimation requires a parametric family of distributions based on a few parameter be assumed. If you have a basis to believe the model is approxiamtely correct it is advantageous to do parametric inference. On the other hand it is possible that the data does not fit well to any member of the family. In that case it is better to use kernel density estimation because it will construct a density that reasonably fit the data. It does not require any assumption regarding parametric families.
This description may be slightly oversimplified for clarity. Let me give a specific example to make this concrete. Suppose the parametric family is the normal distribution which is defined by the two unknown parameters the mean and variance. Every distribution in the family is symmetric and bell shaped with the mean equal to the median and the mode. Now your sample does not appear to be symmetric and the sample mean is very different from the sample median. Then you have evidence to think that your assumption is wrong. So you either need to find a transformation that converts the data to fit to a nice parametric family (possibly the normal) or find an alternative parametric family. If these alternative parametric approaches do not seem to work the kernel density approach is an alternative that will work. There are a few issues (1) the kernel's shape, (2) the kernel bandwidth that determines the level of smoothness and (3) possibly a larger sample size than what you might need for a parametric family. Issue 1 has been shown in the literature to be practically unimportant. Issue 2 is important. Issue 3 depends on how large of a sample you can afford to collect. Even though these issues exist along with the implicit assumption that the distribution has a density, these assumptions may be easier to accept than the restrictive parametric assumptions. | Advantage of kernel density estimation over parametric estimation
There could be. Kernel density estimation is a nonparametric approach. Parametric estimation requires a parametric family of distributions based on a few parameter be assumed. If you have a basis to |
28,130 | How to interpret these custom contrasts? | The matrix you specified for the contrasts is correct in principle. To convert it into an appropriate contrast matrix, you need to calculate the generalized inverse of your original matrix.
If M is your matrix:
M
# [,1] [,2] [,3] [,4]
#0.5 -1 0 0 0
#5 1 -1 0 0
#12.5 0 1 -1 0
#25 0 0 1 -1
#50 0 0 0 1
Now, calculate the generalized inverse using ginv and transpose the result using t:
library(MASS)
t(ginv(M))
# [,1] [,2] [,3] [,4]
#[1,] -0.8 -0.6 -0.4 -0.2
#[2,] 0.2 -0.6 -0.4 -0.2
#[3,] 0.2 0.4 -0.4 -0.2
#[4,] 0.2 0.4 0.6 -0.2
#[5,] 0.2 0.4 0.6 0.8
The result is identical to the one of @Greg Snow. Use this matrix for your analysis.
This is a much easier way than doing it manually.
There is an even easier way to generate a matrix of sliding differences (a.k.a. repeated contrasts). This can be done with the function contr.sdif and the number of factor levels as a parameter. If you have five factor levels, like in your example:
library(MASS)
contr.sdif(5)
# 2-1 3-2 4-3 5-4
#1 -0.8 -0.6 -0.4 -0.2
#2 0.2 -0.6 -0.4 -0.2
#3 0.2 0.4 -0.4 -0.2
#4 0.2 0.4 0.6 -0.2
#5 0.2 0.4 0.6 0.8 | How to interpret these custom contrasts? | The matrix you specified for the contrasts is correct in principle. To convert it into an appropriate contrast matrix, you need to calculate the generalized inverse of your original matrix.
If M is yo | How to interpret these custom contrasts?
The matrix you specified for the contrasts is correct in principle. To convert it into an appropriate contrast matrix, you need to calculate the generalized inverse of your original matrix.
If M is your matrix:
M
# [,1] [,2] [,3] [,4]
#0.5 -1 0 0 0
#5 1 -1 0 0
#12.5 0 1 -1 0
#25 0 0 1 -1
#50 0 0 0 1
Now, calculate the generalized inverse using ginv and transpose the result using t:
library(MASS)
t(ginv(M))
# [,1] [,2] [,3] [,4]
#[1,] -0.8 -0.6 -0.4 -0.2
#[2,] 0.2 -0.6 -0.4 -0.2
#[3,] 0.2 0.4 -0.4 -0.2
#[4,] 0.2 0.4 0.6 -0.2
#[5,] 0.2 0.4 0.6 0.8
The result is identical to the one of @Greg Snow. Use this matrix for your analysis.
This is a much easier way than doing it manually.
There is an even easier way to generate a matrix of sliding differences (a.k.a. repeated contrasts). This can be done with the function contr.sdif and the number of factor levels as a parameter. If you have five factor levels, like in your example:
library(MASS)
contr.sdif(5)
# 2-1 3-2 4-3 5-4
#1 -0.8 -0.6 -0.4 -0.2
#2 0.2 -0.6 -0.4 -0.2
#3 0.2 0.4 -0.4 -0.2
#4 0.2 0.4 0.6 -0.2
#5 0.2 0.4 0.6 0.8 | How to interpret these custom contrasts?
The matrix you specified for the contrasts is correct in principle. To convert it into an appropriate contrast matrix, you need to calculate the generalized inverse of your original matrix.
If M is yo |
28,131 | How to interpret these custom contrasts? | If the matrix at the top is how you are encoding the dummy variables (what you are passing to the C or contrast function in R) then they the first one is comparing the 1st level to the others (actually 0.8 times the 1st subtracted from 0.2 times the sum of the others).
The second term compares the 1st 2 levels to the last 3. The 3rd compares the 1st 3 levels to the last2 and the 4th compares the 1st 4 levels to the last one.
If you want to do the comparisons that you describe (compare each pair) then the dummy variable encoding that you want is:
[,1] [,2] [,3] [,4]
[1,] -0.8 -0.6 -0.4 -0.2
[2,] 0.2 -0.6 -0.4 -0.2
[3,] 0.2 0.4 -0.4 -0.2
[4,] 0.2 0.4 0.6 -0.2
[5,] 0.2 0.4 0.6 0.8 | How to interpret these custom contrasts? | If the matrix at the top is how you are encoding the dummy variables (what you are passing to the C or contrast function in R) then they the first one is comparing the 1st level to the others (actuall | How to interpret these custom contrasts?
If the matrix at the top is how you are encoding the dummy variables (what you are passing to the C or contrast function in R) then they the first one is comparing the 1st level to the others (actually 0.8 times the 1st subtracted from 0.2 times the sum of the others).
The second term compares the 1st 2 levels to the last 3. The 3rd compares the 1st 3 levels to the last2 and the 4th compares the 1st 4 levels to the last one.
If you want to do the comparisons that you describe (compare each pair) then the dummy variable encoding that you want is:
[,1] [,2] [,3] [,4]
[1,] -0.8 -0.6 -0.4 -0.2
[2,] 0.2 -0.6 -0.4 -0.2
[3,] 0.2 0.4 -0.4 -0.2
[4,] 0.2 0.4 0.6 -0.2
[5,] 0.2 0.4 0.6 0.8 | How to interpret these custom contrasts?
If the matrix at the top is how you are encoding the dummy variables (what you are passing to the C or contrast function in R) then they the first one is comparing the 1st level to the others (actuall |
28,132 | How to choose the best transformation to achieve linearity? | This is somewhat of an art, but there are some standard, straightforward things one can always attempt.
The first thing to do is re-express the dependent variable ($y$) to make the residuals normal. That's not really applicable in this example, where the points appear to fall along a smooth nonlinear curve with very little scatter. So we proceed to the next step.
The next thing is to re-express the independent variable ($r$) to linearize the relationship. There is a simple, easy way to do this. Pick three representative points along the curve, preferably at both ends and the middle. From the first figure I read off the ordered pairs $(r,y)$ = $(10,7)$, $(90,0)$, and $(180,-2)$. Without any information other than that $r$ appears always to be positive, a good choice is to explore the Box-Cox transformations $r \to (r^p-1)/p$ for various powers $p$, usually chosen to be multiples of $1/2$ or $1/3$ and typically between $-1$ and $1$. (The limiting value as $p$ approaches $0$ is $\log(r)$.) This transformation will create an approximate linear relationship provided the slope between the first two points equals the slope between the second pair.
For example, the slopes of the untransformed data are $(0-7)/(90-10)$ = -$0.088$ and $(-2-0)/(180-90)$ = $-0.022$. These are quite different: one is about four times the other. Trying $p=-1/2$ gives slopes of $(0-7)/(\frac{90^{-1/2}-1}{-1/2}-\frac{10^{-1/2}-1}{-1/2})$, etc., which work out to $-16.6$ and $-32.4$: now one of them is only twice the other, which is an improvement. Continuing in this fashion (a spreadsheet is convenient), I find that $p \approx 0$ works well: the slopes are now $-7.3$ and $-6.6$, almost the same value. Consequently, you should try a model of the form $y = \alpha + \beta \log(r)$. Then repeat: fit a line, examine the residuals, identify a transformation of $y$ to make them approximately symmetric, and iterate.
John Tukey provides details and many examples in his classic book Exploratory Data Analysis (Addison-Wesley, 1977). He gives similar (but slightly more involved) procedures to identify variance-stabilizing transformations of $y$. One sample dataset he supplies as an exercise concerns century-old data about mercury vapor pressures measured at various temperatures. Following this procedure enables one to rediscover the Clausius-Clapeyron relation; the residuals to the final fit can be interpreted in terms of quantum-mechanical effects occurring at atomic distances! | How to choose the best transformation to achieve linearity? | This is somewhat of an art, but there are some standard, straightforward things one can always attempt.
The first thing to do is re-express the dependent variable ($y$) to make the residuals normal. | How to choose the best transformation to achieve linearity?
This is somewhat of an art, but there are some standard, straightforward things one can always attempt.
The first thing to do is re-express the dependent variable ($y$) to make the residuals normal. That's not really applicable in this example, where the points appear to fall along a smooth nonlinear curve with very little scatter. So we proceed to the next step.
The next thing is to re-express the independent variable ($r$) to linearize the relationship. There is a simple, easy way to do this. Pick three representative points along the curve, preferably at both ends and the middle. From the first figure I read off the ordered pairs $(r,y)$ = $(10,7)$, $(90,0)$, and $(180,-2)$. Without any information other than that $r$ appears always to be positive, a good choice is to explore the Box-Cox transformations $r \to (r^p-1)/p$ for various powers $p$, usually chosen to be multiples of $1/2$ or $1/3$ and typically between $-1$ and $1$. (The limiting value as $p$ approaches $0$ is $\log(r)$.) This transformation will create an approximate linear relationship provided the slope between the first two points equals the slope between the second pair.
For example, the slopes of the untransformed data are $(0-7)/(90-10)$ = -$0.088$ and $(-2-0)/(180-90)$ = $-0.022$. These are quite different: one is about four times the other. Trying $p=-1/2$ gives slopes of $(0-7)/(\frac{90^{-1/2}-1}{-1/2}-\frac{10^{-1/2}-1}{-1/2})$, etc., which work out to $-16.6$ and $-32.4$: now one of them is only twice the other, which is an improvement. Continuing in this fashion (a spreadsheet is convenient), I find that $p \approx 0$ works well: the slopes are now $-7.3$ and $-6.6$, almost the same value. Consequently, you should try a model of the form $y = \alpha + \beta \log(r)$. Then repeat: fit a line, examine the residuals, identify a transformation of $y$ to make them approximately symmetric, and iterate.
John Tukey provides details and many examples in his classic book Exploratory Data Analysis (Addison-Wesley, 1977). He gives similar (but slightly more involved) procedures to identify variance-stabilizing transformations of $y$. One sample dataset he supplies as an exercise concerns century-old data about mercury vapor pressures measured at various temperatures. Following this procedure enables one to rediscover the Clausius-Clapeyron relation; the residuals to the final fit can be interpreted in terms of quantum-mechanical effects occurring at atomic distances! | How to choose the best transformation to achieve linearity?
This is somewhat of an art, but there are some standard, straightforward things one can always attempt.
The first thing to do is re-express the dependent variable ($y$) to make the residuals normal. |
28,133 | How to choose the best transformation to achieve linearity? | If your response variable (or rather, what will become the residuals of your response variable) on the original scale has a Normal distribution as you imply, then transforming it to create a linear relationship with the other variables will mean that it no longer is Normal and it will also change the relationship between its variance and mean values. So from that part of your description I think you are better off using non-linear regression than transforming the response. Otherwise, after linear transformation of the response, you will need a more complex error structure (although this can be a matter of judgement and you would need to check, using graphical methods).
Alternatively, investigate transformation of the explanatory variables. As well as straight transformations, you also have the option of adding in quadratic terms.
More generally, transformation is more an art than a science, if there is no existing theory to suggest what you should use as the basis of transformation. | How to choose the best transformation to achieve linearity? | If your response variable (or rather, what will become the residuals of your response variable) on the original scale has a Normal distribution as you imply, then transforming it to create a linear re | How to choose the best transformation to achieve linearity?
If your response variable (or rather, what will become the residuals of your response variable) on the original scale has a Normal distribution as you imply, then transforming it to create a linear relationship with the other variables will mean that it no longer is Normal and it will also change the relationship between its variance and mean values. So from that part of your description I think you are better off using non-linear regression than transforming the response. Otherwise, after linear transformation of the response, you will need a more complex error structure (although this can be a matter of judgement and you would need to check, using graphical methods).
Alternatively, investigate transformation of the explanatory variables. As well as straight transformations, you also have the option of adding in quadratic terms.
More generally, transformation is more an art than a science, if there is no existing theory to suggest what you should use as the basis of transformation. | How to choose the best transformation to achieve linearity?
If your response variable (or rather, what will become the residuals of your response variable) on the original scale has a Normal distribution as you imply, then transforming it to create a linear re |
28,134 | How does the expected value relate to mean, median, etc. in a non-normal distribution? | (partially converted from my now-deleted comment above)
The expected value and the arithmetic mean are the exact same thing. The median is related to the mean in a non-trivial way but you can say a few things about their relation:
when a distribution is symmetric, the mean and the median are the same
when a distribution is negatively skewed, the median is usually greater than the mean
when a distribution is positively skewed, the median is usually less than the mean | How does the expected value relate to mean, median, etc. in a non-normal distribution? | (partially converted from my now-deleted comment above)
The expected value and the arithmetic mean are the exact same thing. The median is related to the mean in a non-trivial way but you can say a f | How does the expected value relate to mean, median, etc. in a non-normal distribution?
(partially converted from my now-deleted comment above)
The expected value and the arithmetic mean are the exact same thing. The median is related to the mean in a non-trivial way but you can say a few things about their relation:
when a distribution is symmetric, the mean and the median are the same
when a distribution is negatively skewed, the median is usually greater than the mean
when a distribution is positively skewed, the median is usually less than the mean | How does the expected value relate to mean, median, etc. in a non-normal distribution?
(partially converted from my now-deleted comment above)
The expected value and the arithmetic mean are the exact same thing. The median is related to the mean in a non-trivial way but you can say a f |
28,135 | How does the expected value relate to mean, median, etc. in a non-normal distribution? | There is a nice relationship between the harmonic, the geometric, and the arithmetic mean of a log-normally distributed random variable $X \sim \mathcal{LN}\left( \mu,\sigma^2 \right)$. The parameters of the distribution are related to the different means in the following way:
$\mathrm{HM}(X) = \mathrm{e}^{\mu - \frac{1}{2}\sigma^2}$ (harmonic mean),
$\mathrm{GM}(X) = \mathrm{e}^{\mu}$ (geometric mean),
$\mathrm{AM}(X) = \mathrm{e}^{\mu + \frac{1}{2}\sigma^2}$ (arithmetic mean).
Using these identities, it is not difficult to see that the product of the harmonic and the arithmetic mean yields the square of the geometric mean, i.e.
$$
\mathrm{HM}(X) \cdot \mathrm{AM}(X) = \mathrm{GM}^2(X).
$$
Since all values are positive, we can take the squre root and find that the geometric mean of $X$ is the geometric mean of the harmonic mean of $X$ and the arithmetic mean of $X$, i.e.
$$
\mathrm{GM}(X) = \sqrt{ \mathrm{HM}(X) \cdot \mathrm{AM}(X) }.
$$
Furthermore, the well-known HM-GM-AM inequality
$$
\mathrm{HM}(X) \leq \mathrm{GM}(X) \leq \mathrm{AM}(X)
$$
can be expressed exactly as
$$
\mathrm{HM}(X) \cdot \sqrt{\mathrm{GVar}(X)} = \mathrm{GM}(X) = \dfrac{\mathrm{AM}(X)}{\sqrt{\mathrm{GVar}(X)}},
$$
where $\mathrm{GVar}(X) = \mathrm{e}^{\sigma^2}$ is the geometric variance. | How does the expected value relate to mean, median, etc. in a non-normal distribution? | There is a nice relationship between the harmonic, the geometric, and the arithmetic mean of a log-normally distributed random variable $X \sim \mathcal{LN}\left( \mu,\sigma^2 \right)$. The parameters | How does the expected value relate to mean, median, etc. in a non-normal distribution?
There is a nice relationship between the harmonic, the geometric, and the arithmetic mean of a log-normally distributed random variable $X \sim \mathcal{LN}\left( \mu,\sigma^2 \right)$. The parameters of the distribution are related to the different means in the following way:
$\mathrm{HM}(X) = \mathrm{e}^{\mu - \frac{1}{2}\sigma^2}$ (harmonic mean),
$\mathrm{GM}(X) = \mathrm{e}^{\mu}$ (geometric mean),
$\mathrm{AM}(X) = \mathrm{e}^{\mu + \frac{1}{2}\sigma^2}$ (arithmetic mean).
Using these identities, it is not difficult to see that the product of the harmonic and the arithmetic mean yields the square of the geometric mean, i.e.
$$
\mathrm{HM}(X) \cdot \mathrm{AM}(X) = \mathrm{GM}^2(X).
$$
Since all values are positive, we can take the squre root and find that the geometric mean of $X$ is the geometric mean of the harmonic mean of $X$ and the arithmetic mean of $X$, i.e.
$$
\mathrm{GM}(X) = \sqrt{ \mathrm{HM}(X) \cdot \mathrm{AM}(X) }.
$$
Furthermore, the well-known HM-GM-AM inequality
$$
\mathrm{HM}(X) \leq \mathrm{GM}(X) \leq \mathrm{AM}(X)
$$
can be expressed exactly as
$$
\mathrm{HM}(X) \cdot \sqrt{\mathrm{GVar}(X)} = \mathrm{GM}(X) = \dfrac{\mathrm{AM}(X)}{\sqrt{\mathrm{GVar}(X)}},
$$
where $\mathrm{GVar}(X) = \mathrm{e}^{\sigma^2}$ is the geometric variance. | How does the expected value relate to mean, median, etc. in a non-normal distribution?
There is a nice relationship between the harmonic, the geometric, and the arithmetic mean of a log-normally distributed random variable $X \sim \mathcal{LN}\left( \mu,\sigma^2 \right)$. The parameters |
28,136 | How does the expected value relate to mean, median, etc. in a non-normal distribution? | For completeness, there are also distributions for which the mean is not well defined. A classic example is the Cauchy distribution (this answer has a nice explanation of why). Another important example is the Pareto distribution with exponent less than 2. | How does the expected value relate to mean, median, etc. in a non-normal distribution? | For completeness, there are also distributions for which the mean is not well defined. A classic example is the Cauchy distribution (this answer has a nice explanation of why). Another important examp | How does the expected value relate to mean, median, etc. in a non-normal distribution?
For completeness, there are also distributions for which the mean is not well defined. A classic example is the Cauchy distribution (this answer has a nice explanation of why). Another important example is the Pareto distribution with exponent less than 2. | How does the expected value relate to mean, median, etc. in a non-normal distribution?
For completeness, there are also distributions for which the mean is not well defined. A classic example is the Cauchy distribution (this answer has a nice explanation of why). Another important examp |
28,137 | How does the expected value relate to mean, median, etc. in a non-normal distribution? | While it is correct that mathematically mean and expectation value are defined identically, for a skewed distribution this naming convention becomes misleading.
Imagine you are asking a friend about the housing prices in her city because you really like it there and actually think about moving to that city.
If the distribution of housing prizes were unimodal and symmetric, then your friend can tell you the mean price of houses and indeed you can expect to find most houses on the market around that mean value.
However, if the distribution of housing prices is unimodal and skewed, for example right-skewed with most houses in the lower price range to the left and only some exorbitant houses on the right, then the mean will be "skewed" to high prices on the right.
For this unimodal, skewed house price distribution you can expect to find most houses on the market around the median. | How does the expected value relate to mean, median, etc. in a non-normal distribution? | While it is correct that mathematically mean and expectation value are defined identically, for a skewed distribution this naming convention becomes misleading.
Imagine you are asking a friend about t | How does the expected value relate to mean, median, etc. in a non-normal distribution?
While it is correct that mathematically mean and expectation value are defined identically, for a skewed distribution this naming convention becomes misleading.
Imagine you are asking a friend about the housing prices in her city because you really like it there and actually think about moving to that city.
If the distribution of housing prizes were unimodal and symmetric, then your friend can tell you the mean price of houses and indeed you can expect to find most houses on the market around that mean value.
However, if the distribution of housing prices is unimodal and skewed, for example right-skewed with most houses in the lower price range to the left and only some exorbitant houses on the right, then the mean will be "skewed" to high prices on the right.
For this unimodal, skewed house price distribution you can expect to find most houses on the market around the median. | How does the expected value relate to mean, median, etc. in a non-normal distribution?
While it is correct that mathematically mean and expectation value are defined identically, for a skewed distribution this naming convention becomes misleading.
Imagine you are asking a friend about t |
28,138 | Expected number of coin tosses to get N consecutive, given M consecutive | This is a computational exercise, so think recursively. The current state of coin flipping is determined by the ordered pair $(N,M)$ with $N\ge M\ge 0$. Let the expected number of flips to reach $N$ consecutive heads be $e(N,M)$:
(1) There is a 50% chance the next flip will be heads, taking you to the state $(N,M+1)$, and a 50% chance the next flip will be tails, taking you to the state $(N,0)$. This costs one flip. Therefore the expectation (recursively) is given by
$$e(N,M) = \frac{1}{2} e(N,M+1) + \frac{1}{2} e(N,0) + 1.$$
(2) Base conditions: you have already stipulated that
$$e(N,0) = 2^{N+1}-2$$
and obviously
$$e(N,N) = 0$$
(no more flips are needed).
Here's the corresponding Mathematica program (including caching of intermediate results to speed up the recursion, which effectively makes it a dynamic programming solution):
e[n_, m_] /; n > m > 0 := e[n, m] = 1 + (e[n, m + 1] + e[n, 0])/2 // Simplify
e[n_, 0] := 2^(n + 1) - 2
e[n_, n_] := 0
The program would look similar in other programming languages that support recursion. Mathematically, we can verify that $e(N,M) = 2^{N+1} - 2^{M+1}$ simply by checking the recursion, because it obviously holds for the base cases:
$$2^{N+1} - 2^{M+1} = 1 + (2^{N+1} - 2^{M+2} + 2^{N+1} - 2)/2,$$
which is true for any $M$ and $N$, QED.
More generally, the same approach will establish that $e(N,M) = \frac{p^{-N} - p^{-M}}{1-p}$ when the coin has probability $p$ of heads. The hard part is working out the base condition $e(N,0)$. That is done by chasing the recursion out $N$ steps until finally $e(N,0)$ is expressed in terms of itself and solving:
$$\eqalign{
e(N,0) &= 1 + p e(N,1) + (1-p) e(n,0) \\
&= 1 + p\left(1 + p e(N,2) + (1-p) e(N,0)\right) + (1-p) e(N,0) \\
\cdots \\
&= 1 + p + p^2 + \cdots + p^{N-1} + (1-p)[1 + p + \cdots + p^{N-1}]e(N,0);\\
e(N,0) &= \frac{1-p^N}{1-p} + (1-p^N)e(N,0); \\
e(N,0) &= \frac{p^{-N}-1}{1-p}.
}$$ | Expected number of coin tosses to get N consecutive, given M consecutive | This is a computational exercise, so think recursively. The current state of coin flipping is determined by the ordered pair $(N,M)$ with $N\ge M\ge 0$. Let the expected number of flips to reach $N$ | Expected number of coin tosses to get N consecutive, given M consecutive
This is a computational exercise, so think recursively. The current state of coin flipping is determined by the ordered pair $(N,M)$ with $N\ge M\ge 0$. Let the expected number of flips to reach $N$ consecutive heads be $e(N,M)$:
(1) There is a 50% chance the next flip will be heads, taking you to the state $(N,M+1)$, and a 50% chance the next flip will be tails, taking you to the state $(N,0)$. This costs one flip. Therefore the expectation (recursively) is given by
$$e(N,M) = \frac{1}{2} e(N,M+1) + \frac{1}{2} e(N,0) + 1.$$
(2) Base conditions: you have already stipulated that
$$e(N,0) = 2^{N+1}-2$$
and obviously
$$e(N,N) = 0$$
(no more flips are needed).
Here's the corresponding Mathematica program (including caching of intermediate results to speed up the recursion, which effectively makes it a dynamic programming solution):
e[n_, m_] /; n > m > 0 := e[n, m] = 1 + (e[n, m + 1] + e[n, 0])/2 // Simplify
e[n_, 0] := 2^(n + 1) - 2
e[n_, n_] := 0
The program would look similar in other programming languages that support recursion. Mathematically, we can verify that $e(N,M) = 2^{N+1} - 2^{M+1}$ simply by checking the recursion, because it obviously holds for the base cases:
$$2^{N+1} - 2^{M+1} = 1 + (2^{N+1} - 2^{M+2} + 2^{N+1} - 2)/2,$$
which is true for any $M$ and $N$, QED.
More generally, the same approach will establish that $e(N,M) = \frac{p^{-N} - p^{-M}}{1-p}$ when the coin has probability $p$ of heads. The hard part is working out the base condition $e(N,0)$. That is done by chasing the recursion out $N$ steps until finally $e(N,0)$ is expressed in terms of itself and solving:
$$\eqalign{
e(N,0) &= 1 + p e(N,1) + (1-p) e(n,0) \\
&= 1 + p\left(1 + p e(N,2) + (1-p) e(N,0)\right) + (1-p) e(N,0) \\
\cdots \\
&= 1 + p + p^2 + \cdots + p^{N-1} + (1-p)[1 + p + \cdots + p^{N-1}]e(N,0);\\
e(N,0) &= \frac{1-p^N}{1-p} + (1-p^N)e(N,0); \\
e(N,0) &= \frac{p^{-N}-1}{1-p}.
}$$ | Expected number of coin tosses to get N consecutive, given M consecutive
This is a computational exercise, so think recursively. The current state of coin flipping is determined by the ordered pair $(N,M)$ with $N\ge M\ge 0$. Let the expected number of flips to reach $N$ |
28,139 | Expected number of coin tosses to get N consecutive, given M consecutive | To solve this problem, I will use stochastic processes, stopping times, and dynamic programming.
First, some definitions:
$$X_n \doteq \#\text{(of consecutive heads after the nth flip)}$$
We also allow a value for $X_0$ to mean the number of consecutive heads before we start. So, for $X_0 = 0$ and the sequence of flips HHTHHHTHTTHH, the corresponding values of $X$ are 120123010012. If we had $X_0 = M$, the values of X would be (M+1)(M+2)0123010012.
Then define the following stopping times:
$$\tau_N \doteq \min\{k: X_k = N\} \text{ and } \tau_0 \doteq \min\{k > 1: X_k = 0\} $$
The value we are looking for is the expected value of $\tau_N$, the number of flips it takes to observe N consecutive flips $(X_{\tau_N} = N)$, given that we have already observed M consecutive flips $(X_0 = M)$. Assume $M \leq N$ as the answer is trivially 0 otherwise. We compute:
$$E[\tau_N|X_0 =M] = E[\tau_N\boldsymbol{1}_{\{\tau_N < \tau_0\}} + \tau_N\boldsymbol{1}_{\{\tau_N > \tau_0\}}|X_0 =M] $$
$$ = (N-M)(\frac{1}{2})^{N-M} + E[\tau_0|\tau_N > \tau_0,X_0 =M] + (1 - (\frac{1}{2})^{N-M})E[\tau_N|X_0 = 0]$$
This leaves us to compute the last two conditional expectations.
The first corresponds to the expected number of flips before getting a tail assuming a tail is flipped before N consecutive heads are observed assuming we start with M consecutive heads. It is not too difficult to see that
$$E[\tau_0|\tau_N > \tau_0,X_0 =M] = \sum^{N-M}_{j=1}(j)(\frac{1}{2})^j = 2 - (N-M+2)(\frac{1}{2})^{N-M}$$
Now all we have to do is compute the second conditional expectation which corresponds to the expected number of flips it takes to observe N consecutive heads starting from 0. With a similar calculations, we see that
$$E[\tau_N|X_0 = 0] = E[\tau_N\boldsymbol{1}_{\{\tau_N < \tau_0\}} + \tau_N\boldsymbol{1}_{\{\tau_N > \tau_0\}}|X_0 =0]$$
$$ = N(\frac{1}{2})^{N} + E[\tau_0|\tau_N > \tau_0,X_0 =0] + (1 - (\frac{1}{2})^N)E[\tau_N|X_0 = 0]$$
$$= 2^N\lbrace N(\frac{1}{2})^{N} + (2 - (N+2)(\frac{1}{2})^{N})\rbrace$$
$$ = 2^{N+1} - 2$$
This gives a final answer of:
$$E[\tau_N|X_0 =M] = (N-M)(\frac{1}{2})^{N-M} + 2 - (N-M+2)(\frac{1}{2})^{N-M} + (1 - (\frac{1}{2})^{N-M})(2^{N+1} - 2)$$
$$ = 2^{N+1}-2^{M+1}$$
This agrees with the four test cases you've listed. With such a simple answer, there may be an easier way to compute this. | Expected number of coin tosses to get N consecutive, given M consecutive | To solve this problem, I will use stochastic processes, stopping times, and dynamic programming.
First, some definitions:
$$X_n \doteq \#\text{(of consecutive heads after the nth flip)}$$
We also | Expected number of coin tosses to get N consecutive, given M consecutive
To solve this problem, I will use stochastic processes, stopping times, and dynamic programming.
First, some definitions:
$$X_n \doteq \#\text{(of consecutive heads after the nth flip)}$$
We also allow a value for $X_0$ to mean the number of consecutive heads before we start. So, for $X_0 = 0$ and the sequence of flips HHTHHHTHTTHH, the corresponding values of $X$ are 120123010012. If we had $X_0 = M$, the values of X would be (M+1)(M+2)0123010012.
Then define the following stopping times:
$$\tau_N \doteq \min\{k: X_k = N\} \text{ and } \tau_0 \doteq \min\{k > 1: X_k = 0\} $$
The value we are looking for is the expected value of $\tau_N$, the number of flips it takes to observe N consecutive flips $(X_{\tau_N} = N)$, given that we have already observed M consecutive flips $(X_0 = M)$. Assume $M \leq N$ as the answer is trivially 0 otherwise. We compute:
$$E[\tau_N|X_0 =M] = E[\tau_N\boldsymbol{1}_{\{\tau_N < \tau_0\}} + \tau_N\boldsymbol{1}_{\{\tau_N > \tau_0\}}|X_0 =M] $$
$$ = (N-M)(\frac{1}{2})^{N-M} + E[\tau_0|\tau_N > \tau_0,X_0 =M] + (1 - (\frac{1}{2})^{N-M})E[\tau_N|X_0 = 0]$$
This leaves us to compute the last two conditional expectations.
The first corresponds to the expected number of flips before getting a tail assuming a tail is flipped before N consecutive heads are observed assuming we start with M consecutive heads. It is not too difficult to see that
$$E[\tau_0|\tau_N > \tau_0,X_0 =M] = \sum^{N-M}_{j=1}(j)(\frac{1}{2})^j = 2 - (N-M+2)(\frac{1}{2})^{N-M}$$
Now all we have to do is compute the second conditional expectation which corresponds to the expected number of flips it takes to observe N consecutive heads starting from 0. With a similar calculations, we see that
$$E[\tau_N|X_0 = 0] = E[\tau_N\boldsymbol{1}_{\{\tau_N < \tau_0\}} + \tau_N\boldsymbol{1}_{\{\tau_N > \tau_0\}}|X_0 =0]$$
$$ = N(\frac{1}{2})^{N} + E[\tau_0|\tau_N > \tau_0,X_0 =0] + (1 - (\frac{1}{2})^N)E[\tau_N|X_0 = 0]$$
$$= 2^N\lbrace N(\frac{1}{2})^{N} + (2 - (N+2)(\frac{1}{2})^{N})\rbrace$$
$$ = 2^{N+1} - 2$$
This gives a final answer of:
$$E[\tau_N|X_0 =M] = (N-M)(\frac{1}{2})^{N-M} + 2 - (N-M+2)(\frac{1}{2})^{N-M} + (1 - (\frac{1}{2})^{N-M})(2^{N+1} - 2)$$
$$ = 2^{N+1}-2^{M+1}$$
This agrees with the four test cases you've listed. With such a simple answer, there may be an easier way to compute this. | Expected number of coin tosses to get N consecutive, given M consecutive
To solve this problem, I will use stochastic processes, stopping times, and dynamic programming.
First, some definitions:
$$X_n \doteq \#\text{(of consecutive heads after the nth flip)}$$
We also |
28,140 | Expected number of coin tosses to get N consecutive, given M consecutive | Warning: the following may not be considered as a proper answer in that it does not provide a closed form solution to the question, esp. when compared with the previous answers. I however found the approach sufficiently interesting to work out the conditional distribution.
Consider the preliminary question of getting a sequence of $N$ heads out of $k$ throws, with probability $1-p(N,k)$. This is given by the recurrence formula
$$
p(N,k) = \begin{cases} 1 &\text{if } k<N\\
\sum_{m=1}^{N} \frac{1}{2^m}p(N,k-m) &\text{else}\\
\end{cases}
$$
Indeed, my reasoning is that no consecutive $N$ heads out of $k$ draws can be decomposed according to the first occurrence of a tail out of the first $N$ throws. Conditioning on whether this first tail occurs at the first, second, ..., $N$th draw leads to this recurrence relation.
Next, the probability of getting the first consecutive N heads in $m\ge N$ throws is
$$
q(N,m) =\begin{cases}
\dfrac{1}{2^N} &\text{if }m=N\
p(N,m-N-1) \dfrac{1}{2^{N+1}} &\text{if } N<m<2N+1
\end{cases}
$$
The first case is self-explanatory. the second case corresponds to a tail occuring at the $m-N-1$th draw, followed by $N$ heads, and the last case prohibits $N$ consecutive heads prior to the $m-N-1$th draw. (The two last cases could be condensed into one, granted!)
Now, the probability to get $M$ heads first and the first consecutive $N$ heads in exactly $m\ge N$ throws (and no less) is
$$
r(M,N,m) = \begin{cases}
1/2^N &\text{if }m=N\
0 &\text{if } N<m\le N+M\\
\dfrac{1}{2^{M}}\sum_{r=M+1}^{N}\dfrac{1}{2^{r-M}}q(N,m-r)&\text{if } N+M<m
\end{cases}
$$
Hence the conditional probability of waiting $m$ steps to get $N$ consecutive heads given the first $M$ consecutive heads is
$$
s(M,N,m) = \begin{cases}
1/{2^{N-M}} &\text{if }m=N\
0 &\text{if } N
\sum_{r=M+1}^{N}\dfrac{q(N,m-r)}{2^{r-M}}&\text{if } N+M
\end{cases}
$$
The expected number of draws can then be derived by
$$
\mathfrak{E}(M,N)= \sum_{m=N}^\infty m\, s(M,N,m)
$$
or $\mathfrak{E}(M,N)-M$ for the number of additional steps... | Expected number of coin tosses to get N consecutive, given M consecutive | Warning: the following may not be considered as a proper answer in that it does not provide a closed form solution to the question, esp. when compared with the previous answers. I however found the ap | Expected number of coin tosses to get N consecutive, given M consecutive
Warning: the following may not be considered as a proper answer in that it does not provide a closed form solution to the question, esp. when compared with the previous answers. I however found the approach sufficiently interesting to work out the conditional distribution.
Consider the preliminary question of getting a sequence of $N$ heads out of $k$ throws, with probability $1-p(N,k)$. This is given by the recurrence formula
$$
p(N,k) = \begin{cases} 1 &\text{if } k<N\\
\sum_{m=1}^{N} \frac{1}{2^m}p(N,k-m) &\text{else}\\
\end{cases}
$$
Indeed, my reasoning is that no consecutive $N$ heads out of $k$ draws can be decomposed according to the first occurrence of a tail out of the first $N$ throws. Conditioning on whether this first tail occurs at the first, second, ..., $N$th draw leads to this recurrence relation.
Next, the probability of getting the first consecutive N heads in $m\ge N$ throws is
$$
q(N,m) =\begin{cases}
\dfrac{1}{2^N} &\text{if }m=N\
p(N,m-N-1) \dfrac{1}{2^{N+1}} &\text{if } N<m<2N+1
\end{cases}
$$
The first case is self-explanatory. the second case corresponds to a tail occuring at the $m-N-1$th draw, followed by $N$ heads, and the last case prohibits $N$ consecutive heads prior to the $m-N-1$th draw. (The two last cases could be condensed into one, granted!)
Now, the probability to get $M$ heads first and the first consecutive $N$ heads in exactly $m\ge N$ throws (and no less) is
$$
r(M,N,m) = \begin{cases}
1/2^N &\text{if }m=N\
0 &\text{if } N<m\le N+M\\
\dfrac{1}{2^{M}}\sum_{r=M+1}^{N}\dfrac{1}{2^{r-M}}q(N,m-r)&\text{if } N+M<m
\end{cases}
$$
Hence the conditional probability of waiting $m$ steps to get $N$ consecutive heads given the first $M$ consecutive heads is
$$
s(M,N,m) = \begin{cases}
1/{2^{N-M}} &\text{if }m=N\
0 &\text{if } N
\sum_{r=M+1}^{N}\dfrac{q(N,m-r)}{2^{r-M}}&\text{if } N+M
\end{cases}
$$
The expected number of draws can then be derived by
$$
\mathfrak{E}(M,N)= \sum_{m=N}^\infty m\, s(M,N,m)
$$
or $\mathfrak{E}(M,N)-M$ for the number of additional steps... | Expected number of coin tosses to get N consecutive, given M consecutive
Warning: the following may not be considered as a proper answer in that it does not provide a closed form solution to the question, esp. when compared with the previous answers. I however found the ap |
28,141 | Best practices when treating range data as continuous | Categorical solution
Treating the values as categorical loses the crucial information about relative sizes. A standard method to overcome this is ordered logistic regression. In effect, this method "knows" that $A\lt B\lt \cdots \lt J\lt \ldots$ and, using observed relationships with regressors (such as size) fits (somewhat arbitrary) values to each category that respect the ordering.
As an illustration, consider 30 (size, abundance category) pairs generated as
size = (1/2, 3/2, 5/2, ..., 59/2)
e ~ normal(0, 1/6)
abundance = 1 + int(10^(4*size + e))
with abundance categorized into intervals [0,10], [11,25], ..., [10001,25000].
Ordered logistic regression produces a probability distribution for each category; the distribution depends on size. From such detailed information you can produce estimated values and intervals around them. Here is a plot of the 10 PDFs estimated from these data (an estimate for category 10 was not possible due to lack of data there):
Continuous solution
Why not select a numeric value to represent each category and view the uncertainty about the true abundance within the category as part of the error term?
We can analyze this as a discrete approximation to an idealized re-expression $f$ which converts abundance values $a$ into other values $f(a)$ for which the observational errors are, to a good approximation, symmetrically distributed and of roughly the same expected size regardless of $a$ (a variance-stabilizing transformation).
To simplify the analysis, suppose the categories have been chosen (based on theory or experience) to achieve such a transformation. We may assume then that $f$ re-expresses the category cutpoints $\alpha_i$ as their indexes $i$. The proposal amounts to selecting some "characteristic" value $\beta_i$ within each category $i$ and using $f(\beta_i)$ as the numerical value of abundance whenever the abundance is observed to lie between $\alpha_i$ and $\alpha_{i+1}$. This would be a proxy for the correctly re-expressed value $f(a)$.
Suppose, then, that abundance is observed with error $\varepsilon$, so that the hypothetical datum is actually $a+\varepsilon$ instead of $a$. The error made in coding this as $f(\beta_i)$ is, by definition, the difference $f(\beta_i) - f(a)$, which we can express as a difference of two terms
$$\text{error} = f(a + \varepsilon) - f(a) - \left(f(a + \varepsilon) - f(\beta_i)\right).$$
That first term, $f(a + \varepsilon) - f(a)$, is controlled by $f$ (we can't do anything about $\varepsilon$) and would appear if we did not categorize aboundances. The second term is random--it depends on $\varepsilon$--and evidently is correlated with $\varepsilon$. But we can say something about it: it must lie between $i - f(\beta_i) \lt 0$ and $i+1 - f(\beta_i) \ge 0$. Moreover, if $f$ is doing a good job, the second term might be approximately uniformly distributed. Both considerations suggest choosing $\beta_i$ so that $f(\beta_i)$ lies halfway between $i$ and $i+1$; that is, $\beta_i \approx f^{-1}(i+1/2)$.
These categories in this question form an approximately geometric progression, indicating that $f$ is a slightly distorted version of a logarithm. Therefore, we should consider using the geometric means of the interval endpoints to represent the abundance data.
Ordinary least squares regression (OLS) with this procedure gives a slope of 7.70 (standard error is 1.00) and intercept of 0.70 (standard error is 0.58), instead of a slope of 8.19 (se of 0.97) and intercept of 0.69 (se of 0.56) when regressing log abundances against size. Both exhibit regression to the mean, because theoretical slope should be close to $4 \log(10) \approx 9.21$. The categorical method exhibits a bit more regression to the mean (a smaller slope) due to the added discretization error, as expected.
This plot shows the uncategorized abundances along with a fit based on the categorized abundances (using geometric means of the category endpoints as recommended) and a fit based on the abundances themselves. The fits are remarkably close, indicating this method of replacing categories by suitably chosen numerical values works well in the example.
Some care usually is needed in choosing an appropriate "midpoint" $\beta_i$ for the two extreme categories, because often $f$ is not bounded there. (For this example I crudely took the left endpoint of the first category to be $1$ rather than $0$ and the right endpoint of the last category to be $25000$.) One solution is to solve the problem first using data not in either of the extreme categories, then use the fit to estimate appropriate values for those extreme categories, then go back and fit all the data. The p-values will be slightly too good, but overall the fit should be more accurate and less biased. | Best practices when treating range data as continuous | Categorical solution
Treating the values as categorical loses the crucial information about relative sizes. A standard method to overcome this is ordered logistic regression. In effect, this method | Best practices when treating range data as continuous
Categorical solution
Treating the values as categorical loses the crucial information about relative sizes. A standard method to overcome this is ordered logistic regression. In effect, this method "knows" that $A\lt B\lt \cdots \lt J\lt \ldots$ and, using observed relationships with regressors (such as size) fits (somewhat arbitrary) values to each category that respect the ordering.
As an illustration, consider 30 (size, abundance category) pairs generated as
size = (1/2, 3/2, 5/2, ..., 59/2)
e ~ normal(0, 1/6)
abundance = 1 + int(10^(4*size + e))
with abundance categorized into intervals [0,10], [11,25], ..., [10001,25000].
Ordered logistic regression produces a probability distribution for each category; the distribution depends on size. From such detailed information you can produce estimated values and intervals around them. Here is a plot of the 10 PDFs estimated from these data (an estimate for category 10 was not possible due to lack of data there):
Continuous solution
Why not select a numeric value to represent each category and view the uncertainty about the true abundance within the category as part of the error term?
We can analyze this as a discrete approximation to an idealized re-expression $f$ which converts abundance values $a$ into other values $f(a)$ for which the observational errors are, to a good approximation, symmetrically distributed and of roughly the same expected size regardless of $a$ (a variance-stabilizing transformation).
To simplify the analysis, suppose the categories have been chosen (based on theory or experience) to achieve such a transformation. We may assume then that $f$ re-expresses the category cutpoints $\alpha_i$ as their indexes $i$. The proposal amounts to selecting some "characteristic" value $\beta_i$ within each category $i$ and using $f(\beta_i)$ as the numerical value of abundance whenever the abundance is observed to lie between $\alpha_i$ and $\alpha_{i+1}$. This would be a proxy for the correctly re-expressed value $f(a)$.
Suppose, then, that abundance is observed with error $\varepsilon$, so that the hypothetical datum is actually $a+\varepsilon$ instead of $a$. The error made in coding this as $f(\beta_i)$ is, by definition, the difference $f(\beta_i) - f(a)$, which we can express as a difference of two terms
$$\text{error} = f(a + \varepsilon) - f(a) - \left(f(a + \varepsilon) - f(\beta_i)\right).$$
That first term, $f(a + \varepsilon) - f(a)$, is controlled by $f$ (we can't do anything about $\varepsilon$) and would appear if we did not categorize aboundances. The second term is random--it depends on $\varepsilon$--and evidently is correlated with $\varepsilon$. But we can say something about it: it must lie between $i - f(\beta_i) \lt 0$ and $i+1 - f(\beta_i) \ge 0$. Moreover, if $f$ is doing a good job, the second term might be approximately uniformly distributed. Both considerations suggest choosing $\beta_i$ so that $f(\beta_i)$ lies halfway between $i$ and $i+1$; that is, $\beta_i \approx f^{-1}(i+1/2)$.
These categories in this question form an approximately geometric progression, indicating that $f$ is a slightly distorted version of a logarithm. Therefore, we should consider using the geometric means of the interval endpoints to represent the abundance data.
Ordinary least squares regression (OLS) with this procedure gives a slope of 7.70 (standard error is 1.00) and intercept of 0.70 (standard error is 0.58), instead of a slope of 8.19 (se of 0.97) and intercept of 0.69 (se of 0.56) when regressing log abundances against size. Both exhibit regression to the mean, because theoretical slope should be close to $4 \log(10) \approx 9.21$. The categorical method exhibits a bit more regression to the mean (a smaller slope) due to the added discretization error, as expected.
This plot shows the uncategorized abundances along with a fit based on the categorized abundances (using geometric means of the category endpoints as recommended) and a fit based on the abundances themselves. The fits are remarkably close, indicating this method of replacing categories by suitably chosen numerical values works well in the example.
Some care usually is needed in choosing an appropriate "midpoint" $\beta_i$ for the two extreme categories, because often $f$ is not bounded there. (For this example I crudely took the left endpoint of the first category to be $1$ rather than $0$ and the right endpoint of the last category to be $25000$.) One solution is to solve the problem first using data not in either of the extreme categories, then use the fit to estimate appropriate values for those extreme categories, then go back and fit all the data. The p-values will be slightly too good, but overall the fit should be more accurate and less biased. | Best practices when treating range data as continuous
Categorical solution
Treating the values as categorical loses the crucial information about relative sizes. A standard method to overcome this is ordered logistic regression. In effect, this method |
28,142 | Best practices when treating range data as continuous | Consider using the logarithm of the size. | Best practices when treating range data as continuous | Consider using the logarithm of the size. | Best practices when treating range data as continuous
Consider using the logarithm of the size. | Best practices when treating range data as continuous
Consider using the logarithm of the size. |
28,143 | Understanding repeated measure ANOVA assumptions for correct interpretation of SPSS output | Your dependent variables should be normal in each cell of between-subject design. You have 2 such cells: 2 groups, so normality should be in both groups. Also, variance-covariance matrix between your 3 DV should be same in the 2 groups. You could check normality by Shapiro-Wilk test or Kolmogorov-Smirnov (with Lilliefors correction) test in EXPLORE procedure. Variance-covariance homogeneity could be tested by Box's M test (found in Discriminant analysis). Note however that ANOVA is quite robust to violations to both assumptions.
Mauchly's test checks the so called sphericity assumption which is necessary for univariate approach to repeated measures ANOVA. This assumption requires that, roughly speaking, differences between your repeated measure DVs don't intercorrelate. If the assumption is violated you should disregard "Spericity assumed" in Tests of Within-Subjects Effects table - there found some corrections (such as Greenhouse-Geisser) instead.
While Tests of Within-Subjects Effects table reflects "univariate approach" in RM-ANOVA, Multivariate Tests table reflects "multivariate approach". These two are both useful and there's a little debate which is "better". Read a little here about them, a bit more here.
Usually one won't check pairwise tests if overall effect is non-significant, it has little sense. | Understanding repeated measure ANOVA assumptions for correct interpretation of SPSS output | Your dependent variables should be normal in each cell of between-subject design. You have 2 such cells: 2 groups, so normality should be in both groups. Also, variance-covariance matrix between your | Understanding repeated measure ANOVA assumptions for correct interpretation of SPSS output
Your dependent variables should be normal in each cell of between-subject design. You have 2 such cells: 2 groups, so normality should be in both groups. Also, variance-covariance matrix between your 3 DV should be same in the 2 groups. You could check normality by Shapiro-Wilk test or Kolmogorov-Smirnov (with Lilliefors correction) test in EXPLORE procedure. Variance-covariance homogeneity could be tested by Box's M test (found in Discriminant analysis). Note however that ANOVA is quite robust to violations to both assumptions.
Mauchly's test checks the so called sphericity assumption which is necessary for univariate approach to repeated measures ANOVA. This assumption requires that, roughly speaking, differences between your repeated measure DVs don't intercorrelate. If the assumption is violated you should disregard "Spericity assumed" in Tests of Within-Subjects Effects table - there found some corrections (such as Greenhouse-Geisser) instead.
While Tests of Within-Subjects Effects table reflects "univariate approach" in RM-ANOVA, Multivariate Tests table reflects "multivariate approach". These two are both useful and there's a little debate which is "better". Read a little here about them, a bit more here.
Usually one won't check pairwise tests if overall effect is non-significant, it has little sense. | Understanding repeated measure ANOVA assumptions for correct interpretation of SPSS output
Your dependent variables should be normal in each cell of between-subject design. You have 2 such cells: 2 groups, so normality should be in both groups. Also, variance-covariance matrix between your |
28,144 | Understanding repeated measure ANOVA assumptions for correct interpretation of SPSS output | General Resource on interpreting repeated measures ANOVA with SPSS
It sounds like you need a better general resource on repeated measures ANOVA. Here are a few web resources, but in general a search for "SPSS repeated measures ANOVA" will yield many useful options.
UCLA has an example of SPSS output with interpretation by a 2 by 3 mixed ANOVA along with several other examples.
Andy Field on repeated measures ANOVA
1. Checking normality
From a practical perspective, tests of normality are often used to justify transformations. If you do apply a transformation, then you need to apply the same transformation to all cells of the design.
A common way to assess normality using SPSS is to set up your model and save the residuals and then examine the distribution of residuals.
2. Value of Mauchly's test
A common strategy is to look at Mauchly's test and if it is statistically significant, interpret either the univariate corrected tests or the multivariate tests.
3. Multivariate
I think @ttnphns has summed this up well.
4. Pairwise comparisons
I think @ttnphns has summed this up well. | Understanding repeated measure ANOVA assumptions for correct interpretation of SPSS output | General Resource on interpreting repeated measures ANOVA with SPSS
It sounds like you need a better general resource on repeated measures ANOVA. Here are a few web resources, but in general a search f | Understanding repeated measure ANOVA assumptions for correct interpretation of SPSS output
General Resource on interpreting repeated measures ANOVA with SPSS
It sounds like you need a better general resource on repeated measures ANOVA. Here are a few web resources, but in general a search for "SPSS repeated measures ANOVA" will yield many useful options.
UCLA has an example of SPSS output with interpretation by a 2 by 3 mixed ANOVA along with several other examples.
Andy Field on repeated measures ANOVA
1. Checking normality
From a practical perspective, tests of normality are often used to justify transformations. If you do apply a transformation, then you need to apply the same transformation to all cells of the design.
A common way to assess normality using SPSS is to set up your model and save the residuals and then examine the distribution of residuals.
2. Value of Mauchly's test
A common strategy is to look at Mauchly's test and if it is statistically significant, interpret either the univariate corrected tests or the multivariate tests.
3. Multivariate
I think @ttnphns has summed this up well.
4. Pairwise comparisons
I think @ttnphns has summed this up well. | Understanding repeated measure ANOVA assumptions for correct interpretation of SPSS output
General Resource on interpreting repeated measures ANOVA with SPSS
It sounds like you need a better general resource on repeated measures ANOVA. Here are a few web resources, but in general a search f |
28,145 | Degrees of freedom for Chi-squared test | How many variables are present in your cross-classification will determine the degrees of freedom of your $\chi^2$-test. In your case, your are actually cross-classifying two variables (period and country) in a 2-by-3 table.
So the dof are $(2-1)\times (3-1)=2$ (see e.g., Pearson's chi-square test for justification of its computation). I don't see where you got the $6$ in your first formula, and your expected frequencies are not correct, unless I misunderstood your dataset.
A quick check in R gives me:
> my.tab <- matrix(c(100, 59, 150, 160, 20, 50), nc=3)
> my.tab
[,1] [,2] [,3]
[1,] 100 150 20
[2,] 59 160 50
> chisq.test(my.tab)
Pearson's Chi-squared test
data: my.tab
X-squared = 23.7503, df = 2, p-value = 6.961e-06
> chisq.test(my.tab)$expected
[,1] [,2] [,3]
[1,] 79.6475 155.2876 35.06494
[2,] 79.3525 154.7124 34.93506 | Degrees of freedom for Chi-squared test | How many variables are present in your cross-classification will determine the degrees of freedom of your $\chi^2$-test. In your case, your are actually cross-classifying two variables (period and cou | Degrees of freedom for Chi-squared test
How many variables are present in your cross-classification will determine the degrees of freedom of your $\chi^2$-test. In your case, your are actually cross-classifying two variables (period and country) in a 2-by-3 table.
So the dof are $(2-1)\times (3-1)=2$ (see e.g., Pearson's chi-square test for justification of its computation). I don't see where you got the $6$ in your first formula, and your expected frequencies are not correct, unless I misunderstood your dataset.
A quick check in R gives me:
> my.tab <- matrix(c(100, 59, 150, 160, 20, 50), nc=3)
> my.tab
[,1] [,2] [,3]
[1,] 100 150 20
[2,] 59 160 50
> chisq.test(my.tab)
Pearson's Chi-squared test
data: my.tab
X-squared = 23.7503, df = 2, p-value = 6.961e-06
> chisq.test(my.tab)$expected
[,1] [,2] [,3]
[1,] 79.6475 155.2876 35.06494
[2,] 79.3525 154.7124 34.93506 | Degrees of freedom for Chi-squared test
How many variables are present in your cross-classification will determine the degrees of freedom of your $\chi^2$-test. In your case, your are actually cross-classifying two variables (period and cou |
28,146 | Degrees of freedom for Chi-squared test | Degrees of Freedom are (r-1)(c-1).
You have
2 rows : 1900-1950 and 1950-1999
3 columns: CountryI CountryII CountryIII
Thus (2-1)(3-1) = 2
The actual product of r x c should = n (total # of observations) which is six. However, this is not used in your calculation of the df.
Edit: If you were doing an 'Goodness of Fit' then yes, it would be n-1 but you have a contigency table (r x c) where r or c not equal to 1 so you have to use the (r-1)(c-1)
Edit #2 for dimbo (I can't comment): Expected values should be calculated by (row total)(column total) / (total # of observations) : Thus the expected for r1,c1 position is (270)(159) / (539) which gives the values chi gave you.
Edit #: SAS code confirming Chi
data question;
do a=1 to 2;
do b=1 to 3;
input var @@;
output;
end;
end;
datalines;
100 150 20
59 160 50
;
run;
proc freq data = question;
weight var;
tables a*b /
chisq expected norow nocol;
run;
Output
Frequency|
Expected |
Percent | 1| 2| 3| Total
--------+--------+--------+--------+
1 | 100 | 150 | 20 | 270
| 79.647 | 155.29 | 35.065 |
| 18.55 | 27.83 | 3.71 | 50.09
---------+--------+--------+--------+
2 | 59 | 160 | 50 | 269
| 79.353 | 154.71 | 34.935 |
| 10.95 | 29.68 | 9.28 | 49.91
---------+--------+--------+--------+
Total 159 310 70 539
29.50 57.51 12.99 100.00
Statistics for Table of a by b
Statistic DF Value Prob
------------------------------------------------------
Chi-Square 2 23.7503 <.0001
Likelihood Ratio Chi-Square 2 24.2964 <.0001
Mantel-Haenszel Chi-Square 1 23.3700 <.0001
Chi Coefficient 0.2099
Contingency Coefficient 0.2054
Cramer's V 0.2099
Sample Size = 539 | Degrees of freedom for Chi-squared test | Degrees of Freedom are (r-1)(c-1).
You have
2 rows : 1900-1950 and 1950-1999
3 columns: CountryI CountryII CountryIII
Thus (2-1)(3-1) = 2
The actual product of r x c should = n (total # of obs | Degrees of freedom for Chi-squared test
Degrees of Freedom are (r-1)(c-1).
You have
2 rows : 1900-1950 and 1950-1999
3 columns: CountryI CountryII CountryIII
Thus (2-1)(3-1) = 2
The actual product of r x c should = n (total # of observations) which is six. However, this is not used in your calculation of the df.
Edit: If you were doing an 'Goodness of Fit' then yes, it would be n-1 but you have a contigency table (r x c) where r or c not equal to 1 so you have to use the (r-1)(c-1)
Edit #2 for dimbo (I can't comment): Expected values should be calculated by (row total)(column total) / (total # of observations) : Thus the expected for r1,c1 position is (270)(159) / (539) which gives the values chi gave you.
Edit #: SAS code confirming Chi
data question;
do a=1 to 2;
do b=1 to 3;
input var @@;
output;
end;
end;
datalines;
100 150 20
59 160 50
;
run;
proc freq data = question;
weight var;
tables a*b /
chisq expected norow nocol;
run;
Output
Frequency|
Expected |
Percent | 1| 2| 3| Total
--------+--------+--------+--------+
1 | 100 | 150 | 20 | 270
| 79.647 | 155.29 | 35.065 |
| 18.55 | 27.83 | 3.71 | 50.09
---------+--------+--------+--------+
2 | 59 | 160 | 50 | 269
| 79.353 | 154.71 | 34.935 |
| 10.95 | 29.68 | 9.28 | 49.91
---------+--------+--------+--------+
Total 159 310 70 539
29.50 57.51 12.99 100.00
Statistics for Table of a by b
Statistic DF Value Prob
------------------------------------------------------
Chi-Square 2 23.7503 <.0001
Likelihood Ratio Chi-Square 2 24.2964 <.0001
Mantel-Haenszel Chi-Square 1 23.3700 <.0001
Chi Coefficient 0.2099
Contingency Coefficient 0.2054
Cramer's V 0.2099
Sample Size = 539 | Degrees of freedom for Chi-squared test
Degrees of Freedom are (r-1)(c-1).
You have
2 rows : 1900-1950 and 1950-1999
3 columns: CountryI CountryII CountryIII
Thus (2-1)(3-1) = 2
The actual product of r x c should = n (total # of obs |
28,147 | Degrees of freedom for Chi-squared test | Wait a minute, I think Sandra means 5 rather than 6.
Maybe chl can correct me on this ... but I think it should be rite. If we take the definition that $\chi^2$ is evaluated as follows,
$$\chi^2= \sum_{i=1}^{\#Rows}(observed_i - expected_i)^2/expected_i $$
and arrange the data as follows:
Observed[O]| Expected[E] | (O-E)^2/E
100 118.4
150 52
20 40
59 80.5
160 90
50 25
Thus, the total number of terms for calculating $\chi^2$ is 6 (as we are adding the final column of terms together which has 6 rows. As by definition, we have d.f.= no of rows or expected frequencies - 1.
Thus we obtain 5. | Degrees of freedom for Chi-squared test | Wait a minute, I think Sandra means 5 rather than 6.
Maybe chl can correct me on this ... but I think it should be rite. If we take the definition that $\chi^2$ is evaluated as follows,
$$\chi^2= \su | Degrees of freedom for Chi-squared test
Wait a minute, I think Sandra means 5 rather than 6.
Maybe chl can correct me on this ... but I think it should be rite. If we take the definition that $\chi^2$ is evaluated as follows,
$$\chi^2= \sum_{i=1}^{\#Rows}(observed_i - expected_i)^2/expected_i $$
and arrange the data as follows:
Observed[O]| Expected[E] | (O-E)^2/E
100 118.4
150 52
20 40
59 80.5
160 90
50 25
Thus, the total number of terms for calculating $\chi^2$ is 6 (as we are adding the final column of terms together which has 6 rows. As by definition, we have d.f.= no of rows or expected frequencies - 1.
Thus we obtain 5. | Degrees of freedom for Chi-squared test
Wait a minute, I think Sandra means 5 rather than 6.
Maybe chl can correct me on this ... but I think it should be rite. If we take the definition that $\chi^2$ is evaluated as follows,
$$\chi^2= \su |
28,148 | Degrees of freedom for Chi-squared test | The degrees of freedom for chi square test in contingency table is determined by the number of 'expected observations' estimated independently. In your 2x3 table since row and column totals are already known, therefore you need estimate just two expected observations using formula (row total)*(column total)/N. Remaining expected observations can be found by subtraction from row or column total. for example if you estimate the first two observations of the first row then third observation of the first row can be found be subtracting these two estimated observations from the first row total and once the first row is known you can easily find the second row expected observations as the column totals are also already known. | Degrees of freedom for Chi-squared test | The degrees of freedom for chi square test in contingency table is determined by the number of 'expected observations' estimated independently. In your 2x3 table since row and column totals are alread | Degrees of freedom for Chi-squared test
The degrees of freedom for chi square test in contingency table is determined by the number of 'expected observations' estimated independently. In your 2x3 table since row and column totals are already known, therefore you need estimate just two expected observations using formula (row total)*(column total)/N. Remaining expected observations can be found by subtraction from row or column total. for example if you estimate the first two observations of the first row then third observation of the first row can be found be subtracting these two estimated observations from the first row total and once the first row is known you can easily find the second row expected observations as the column totals are also already known. | Degrees of freedom for Chi-squared test
The degrees of freedom for chi square test in contingency table is determined by the number of 'expected observations' estimated independently. In your 2x3 table since row and column totals are alread |
28,149 | Rationale of using AUC? | For binary classifiers $C$ used for ranking (i.e. for each example $e$ we have $C(e)$ in the interval $[0, 1]$) from which the AUC is measured the AUC is equivalent to the probability that $C(e_1) > C(e_0)$ where $e_1$ is a true positive example and $e_0$ is a true negative example. Thus, choosing a model with the maximal AUC minimizes the probability that $C(e_0) \geq C(e_1)$. That is, minimizes the loss of ranking a true negative at least as large as a true positive. | Rationale of using AUC? | For binary classifiers $C$ used for ranking (i.e. for each example $e$ we have $C(e)$ in the interval $[0, 1]$) from which the AUC is measured the AUC is equivalent to the probability that $C(e_1) > C | Rationale of using AUC?
For binary classifiers $C$ used for ranking (i.e. for each example $e$ we have $C(e)$ in the interval $[0, 1]$) from which the AUC is measured the AUC is equivalent to the probability that $C(e_1) > C(e_0)$ where $e_1$ is a true positive example and $e_0$ is a true negative example. Thus, choosing a model with the maximal AUC minimizes the probability that $C(e_0) \geq C(e_1)$. That is, minimizes the loss of ranking a true negative at least as large as a true positive. | Rationale of using AUC?
For binary classifiers $C$ used for ranking (i.e. for each example $e$ we have $C(e)$ in the interval $[0, 1]$) from which the AUC is measured the AUC is equivalent to the probability that $C(e_1) > C |
28,150 | Rationale of using AUC? | Let's take a simple example of identifying good tomato from a pool of good + bad tomato. Let's say number of good tomato are 100, and bad tomato are 1000, So a total of 1100. Now your job is to identify as many good tomato as possible. One way to get all good tomato are taking all 1100 tomato. But it clearly says you are not able to differentiate b/n good vs bad.
So, What's the right way of differentiating - need to get as many good ones while picking up very few bad ones, So we need a measure something, which can say how many good ones we picked up and also say what's the bad ones count in it. AUC measure gives more weight if it's able to select more good ones with few bad ones as depicted below. which says how good you are able to differentiate b/n good and bad.
In the example you can observe that while picking up 70% good tomato, black curve picked up around 48% of bad ones (impurity), but blue one has 83% bad ones (impurity). So black curve has better AUC score compared to blue one. | Rationale of using AUC? | Let's take a simple example of identifying good tomato from a pool of good + bad tomato. Let's say number of good tomato are 100, and bad tomato are 1000, So a total of 1100. Now your job is to identi | Rationale of using AUC?
Let's take a simple example of identifying good tomato from a pool of good + bad tomato. Let's say number of good tomato are 100, and bad tomato are 1000, So a total of 1100. Now your job is to identify as many good tomato as possible. One way to get all good tomato are taking all 1100 tomato. But it clearly says you are not able to differentiate b/n good vs bad.
So, What's the right way of differentiating - need to get as many good ones while picking up very few bad ones, So we need a measure something, which can say how many good ones we picked up and also say what's the bad ones count in it. AUC measure gives more weight if it's able to select more good ones with few bad ones as depicted below. which says how good you are able to differentiate b/n good and bad.
In the example you can observe that while picking up 70% good tomato, black curve picked up around 48% of bad ones (impurity), but blue one has 83% bad ones (impurity). So black curve has better AUC score compared to blue one. | Rationale of using AUC?
Let's take a simple example of identifying good tomato from a pool of good + bad tomato. Let's say number of good tomato are 100, and bad tomato are 1000, So a total of 1100. Now your job is to identi |
28,151 | Tobit model with R | It is not in the package, just write your own command. If your regression is reg <- tobit(y~x) then the vector of effects should be
pnorm(x%*%reg$coef[-1]/reg$scale)%*%reg$coef[-1]. | Tobit model with R | It is not in the package, just write your own command. If your regression is reg <- tobit(y~x) then the vector of effects should be
pnorm(x%*%reg$coef[-1]/reg$scale)%*%reg$coef[-1]. | Tobit model with R
It is not in the package, just write your own command. If your regression is reg <- tobit(y~x) then the vector of effects should be
pnorm(x%*%reg$coef[-1]/reg$scale)%*%reg$coef[-1]. | Tobit model with R
It is not in the package, just write your own command. If your regression is reg <- tobit(y~x) then the vector of effects should be
pnorm(x%*%reg$coef[-1]/reg$scale)%*%reg$coef[-1]. |
28,152 | Tobit model with R | I had the same issue (“non-conformable arguments”) that @hans0l0 mentioned in comment above. I think I have resolved this, and will try to explain here.
First, there is an error in the equation in the original post. It should be $ϕ(xβ/σ)β_j$—i.e., there is a subscript after the second $β$ but not after the first. In a Tobit model, the marginal effect of a variable $x_j$ is determined not only by the coefficient of that particular variable (the $β_j$); an adjustment factor is also required that gets calculated from the values of other variables in the model (the $ϕ(xβ/σ)$).
From Wooldridge 2006 (p. 598):
The adjustment factor… depends on a linear function of $x$, $xβ/σ = (β_0 + β_1x_1 + … + β_kx_k)/σ$. It can be shown that the adjustment factor is strictly between zero and one.
This adjustment factor means that we have to make a choice about the values of the other variables in the model: “we must plug in values for the xj, usually the mean values or other interesting values” (Wooldridge 2006, p598). So generally this would be the mean, but it could also be the median, the top/bottom quartile, or anything else. This relates to why @hans0l0 and I were getting the “non-conformable argument” errors when we were using Alex’s code above: the “x” in that code will be a vector when what we need is a single value for the variable (mean / median / etc). I believe there is also another error in the code above in that it excludes the intercept value from the adjustment term (with the [-1] script after the first use of reg$coef). My understanding of this (but I’m happy to be corrected) is that the adjustment term should include the intercept (the $β_0$ from above).
That all said, here is an example using the dataset from AER::tobit (“Affairs”):
## Using the same model and data as in the Tobit help file
## NB: I have added the “x=TRUE” command so the model saves the x values
> fm.tobit <- tobit(affairs ~ age + yearsmarried + religiousness + occupation + rating,
data = Affairs, x=TRUE)
> fm.tobit$coef
(Intercept) age yearsmarried religiousness occupation rating
8.1741974 -0.1793326 0.5541418 -1.6862205 0.3260532 -2.2849727
> fm.tobit$scale
[1] 8.24708
## the vector of marginal effects (at mean values and for y > 0) should be as follows.
## note the [-1] used to remove the intercept term from the final vector,
## but not from within the adjustment term.
> pnorm(sum(apply(fm.tobit$x,2,FUN=mean) * fm.tobit$coef)/fm.tobit$scale) *
fm.tobit$coef[-1]
age yearsmarried religiousness occupation rating
-0.041921 0.1295365 -0.394172 0.076218 -0.534137
Important to reiterate: these are marginal effects only in the cases where y is positive (i.e. at least one affair has happened) and at the mean values of all of the explanatory variables.
If somebody would like to check those results using a program with a built-in marginal effects tool for Tobit models, I would be curious to see the comparison. Any comments and corrections will be very appreciated.
Reference:
Wooldridge, Jeffrey M. 2006. Introductory Econometrics: A Modern Approach. Thomson South-Western. 3rd Edition. | Tobit model with R | I had the same issue (“non-conformable arguments”) that @hans0l0 mentioned in comment above. I think I have resolved this, and will try to explain here.
First, there is an error in the equation in th | Tobit model with R
I had the same issue (“non-conformable arguments”) that @hans0l0 mentioned in comment above. I think I have resolved this, and will try to explain here.
First, there is an error in the equation in the original post. It should be $ϕ(xβ/σ)β_j$—i.e., there is a subscript after the second $β$ but not after the first. In a Tobit model, the marginal effect of a variable $x_j$ is determined not only by the coefficient of that particular variable (the $β_j$); an adjustment factor is also required that gets calculated from the values of other variables in the model (the $ϕ(xβ/σ)$).
From Wooldridge 2006 (p. 598):
The adjustment factor… depends on a linear function of $x$, $xβ/σ = (β_0 + β_1x_1 + … + β_kx_k)/σ$. It can be shown that the adjustment factor is strictly between zero and one.
This adjustment factor means that we have to make a choice about the values of the other variables in the model: “we must plug in values for the xj, usually the mean values or other interesting values” (Wooldridge 2006, p598). So generally this would be the mean, but it could also be the median, the top/bottom quartile, or anything else. This relates to why @hans0l0 and I were getting the “non-conformable argument” errors when we were using Alex’s code above: the “x” in that code will be a vector when what we need is a single value for the variable (mean / median / etc). I believe there is also another error in the code above in that it excludes the intercept value from the adjustment term (with the [-1] script after the first use of reg$coef). My understanding of this (but I’m happy to be corrected) is that the adjustment term should include the intercept (the $β_0$ from above).
That all said, here is an example using the dataset from AER::tobit (“Affairs”):
## Using the same model and data as in the Tobit help file
## NB: I have added the “x=TRUE” command so the model saves the x values
> fm.tobit <- tobit(affairs ~ age + yearsmarried + religiousness + occupation + rating,
data = Affairs, x=TRUE)
> fm.tobit$coef
(Intercept) age yearsmarried religiousness occupation rating
8.1741974 -0.1793326 0.5541418 -1.6862205 0.3260532 -2.2849727
> fm.tobit$scale
[1] 8.24708
## the vector of marginal effects (at mean values and for y > 0) should be as follows.
## note the [-1] used to remove the intercept term from the final vector,
## but not from within the adjustment term.
> pnorm(sum(apply(fm.tobit$x,2,FUN=mean) * fm.tobit$coef)/fm.tobit$scale) *
fm.tobit$coef[-1]
age yearsmarried religiousness occupation rating
-0.041921 0.1295365 -0.394172 0.076218 -0.534137
Important to reiterate: these are marginal effects only in the cases where y is positive (i.e. at least one affair has happened) and at the mean values of all of the explanatory variables.
If somebody would like to check those results using a program with a built-in marginal effects tool for Tobit models, I would be curious to see the comparison. Any comments and corrections will be very appreciated.
Reference:
Wooldridge, Jeffrey M. 2006. Introductory Econometrics: A Modern Approach. Thomson South-Western. 3rd Edition. | Tobit model with R
I had the same issue (“non-conformable arguments”) that @hans0l0 mentioned in comment above. I think I have resolved this, and will try to explain here.
First, there is an error in the equation in th |
28,153 | Recommended procedure for factor analysis on dichotomous data with R | To sum up, with n=45 subjects you're left with correlation-based and multivariate descriptive approaches. However, since this questionnaire is supposed to be unidimensional, this always is a good start.
What I would do:
Compute pairwise correlations for your 22 items; report the range and the median -- this will give an indication of the relative consistency of observed items responses (correlations above 0.3 are generally thought of as indicative of good convergent validity, but of course the precision of this estimate depends on the sample size); an alternative way to study the internal consistency of the questionnaire would be to compute Cronbach's alpha, although with n=45 the associated confidence interval (use bootstrap for that) will be relatively large.
Compute point-biserial correlation between items and the summated scale score; it will give you an idea of the discriminative power of each item (like loadings in FA), where values above 0.3 are indicative of a satisfactory relationship between each item and their corresponding scale.
Use a PCA to summarize the correlation matrix (it yields an equivalent interpretation to what would be obtained from a multiple correspondence analysis in case of dichotomously scored items). If your instrument behaves as a unidimensional scale for your sample, you should observe a dominant axis of variation (as reflected by the first eigenvalue).
Should you want to use R, you will find useful function in the ltm and psych package; browse the CRAN Psychometrics Task View for more packages. In case you get 100 subjects, you can try some CFA or SEM analysis with bootstrap confidence interval. (Bear in mind that loadings should be very large to consider there's a significant correlation between any item and its factor, since it should be at least two times the standard error of a reliable correlation coefficient, $2(1-r^2)/\sqrt{n}$.) | Recommended procedure for factor analysis on dichotomous data with R | To sum up, with n=45 subjects you're left with correlation-based and multivariate descriptive approaches. However, since this questionnaire is supposed to be unidimensional, this always is a good star | Recommended procedure for factor analysis on dichotomous data with R
To sum up, with n=45 subjects you're left with correlation-based and multivariate descriptive approaches. However, since this questionnaire is supposed to be unidimensional, this always is a good start.
What I would do:
Compute pairwise correlations for your 22 items; report the range and the median -- this will give an indication of the relative consistency of observed items responses (correlations above 0.3 are generally thought of as indicative of good convergent validity, but of course the precision of this estimate depends on the sample size); an alternative way to study the internal consistency of the questionnaire would be to compute Cronbach's alpha, although with n=45 the associated confidence interval (use bootstrap for that) will be relatively large.
Compute point-biserial correlation between items and the summated scale score; it will give you an idea of the discriminative power of each item (like loadings in FA), where values above 0.3 are indicative of a satisfactory relationship between each item and their corresponding scale.
Use a PCA to summarize the correlation matrix (it yields an equivalent interpretation to what would be obtained from a multiple correspondence analysis in case of dichotomously scored items). If your instrument behaves as a unidimensional scale for your sample, you should observe a dominant axis of variation (as reflected by the first eigenvalue).
Should you want to use R, you will find useful function in the ltm and psych package; browse the CRAN Psychometrics Task View for more packages. In case you get 100 subjects, you can try some CFA or SEM analysis with bootstrap confidence interval. (Bear in mind that loadings should be very large to consider there's a significant correlation between any item and its factor, since it should be at least two times the standard error of a reliable correlation coefficient, $2(1-r^2)/\sqrt{n}$.) | Recommended procedure for factor analysis on dichotomous data with R
To sum up, with n=45 subjects you're left with correlation-based and multivariate descriptive approaches. However, since this questionnaire is supposed to be unidimensional, this always is a good star |
28,154 | Recommended procedure for factor analysis on dichotomous data with R | This thread has a good Google position for the "System ist für den Rechner singulär: reziproke Konditionszahl" error using factanal (in English: "system is computationally singular: reciprocal condition number") - therefore I shall add a comment:
When the correlation matrix is calculated a priori (e.g., to pairwisely delete missing values), make sure that factanal() does not think that the matrix is the data to analze (https://stat.ethz.ch/pipermail/r-help/2007-October/142567.html).
PREVIOUS: matrix = cor(data, use="pairwise.complete.obs") # For example
WRONG: factanal(matrix, 3, rotation="varimax")
RIGHT: factanal(covmat=matrix, factors=3, rotation="varimax")
BurninLeo | Recommended procedure for factor analysis on dichotomous data with R | This thread has a good Google position for the "System ist für den Rechner singulär: reziproke Konditionszahl" error using factanal (in English: "system is computationally singular: reciprocal conditi | Recommended procedure for factor analysis on dichotomous data with R
This thread has a good Google position for the "System ist für den Rechner singulär: reziproke Konditionszahl" error using factanal (in English: "system is computationally singular: reciprocal condition number") - therefore I shall add a comment:
When the correlation matrix is calculated a priori (e.g., to pairwisely delete missing values), make sure that factanal() does not think that the matrix is the data to analze (https://stat.ethz.ch/pipermail/r-help/2007-October/142567.html).
PREVIOUS: matrix = cor(data, use="pairwise.complete.obs") # For example
WRONG: factanal(matrix, 3, rotation="varimax")
RIGHT: factanal(covmat=matrix, factors=3, rotation="varimax")
BurninLeo | Recommended procedure for factor analysis on dichotomous data with R
This thread has a good Google position for the "System ist für den Rechner singulär: reziproke Konditionszahl" error using factanal (in English: "system is computationally singular: reciprocal conditi |
28,155 | How to specify random effects in lme? | Try this, it's a standard way to do a split plot. The notation / means that method is nested in day.
lme(level~method, random=~1|day/method, data=d) | How to specify random effects in lme? | Try this, it's a standard way to do a split plot. The notation / means that method is nested in day.
lme(level~method, random=~1|day/method, data=d) | How to specify random effects in lme?
Try this, it's a standard way to do a split plot. The notation / means that method is nested in day.
lme(level~method, random=~1|day/method, data=d) | How to specify random effects in lme?
Try this, it's a standard way to do a split plot. The notation / means that method is nested in day.
lme(level~method, random=~1|day/method, data=d) |
28,156 | How to specify random effects in lme? | It would help a lot if you provided a data.frame. Now it is not clear what is a grouping factor. I judge that it is $\beta$. Then in lme notation your model should be written as follows:
lme(y~a,random=~a|b, data=mydata) | How to specify random effects in lme? | It would help a lot if you provided a data.frame. Now it is not clear what is a grouping factor. I judge that it is $\beta$. Then in lme notation your model should be written as follows:
lme(y~a,rando | How to specify random effects in lme?
It would help a lot if you provided a data.frame. Now it is not clear what is a grouping factor. I judge that it is $\beta$. Then in lme notation your model should be written as follows:
lme(y~a,random=~a|b, data=mydata) | How to specify random effects in lme?
It would help a lot if you provided a data.frame. Now it is not clear what is a grouping factor. I judge that it is $\beta$. Then in lme notation your model should be written as follows:
lme(y~a,rando |
28,157 | Why the exchangeability of random variables is essential in hierarchical bayesian models? | Exchangeability is not an essential feature of a hierarchical model (at least not at the observational level). It is basically a Bayesian analogue of "independent and identically distributed" from the standard literature. It is simply a way of describing what you know about the situation at hand. This is namely that "shuffling" does not alter your problem. One way I like to think of this is to consider the case where you were given $x_{j}=5$ but you were not told the value of $j$. If learning that $x_{j}=5$ would lead you to suspect particular values of $j$ more than others, then the sequence is not exchangeable. If it tells you nothing about $j$, then the sequence is exchangeable. Note that exhcangeability is "in the information" rather than "in reality" - it depends on what you know.
While exchangeability is not essential in terms of the observed variables, it would probably be quite difficult to fit any model without some notion of exchangeability, because without exchangeability you basically have no justification for pooling observations together. So my guess is that your inferences will be much weaker if you don't have exchangeability somewhere in the model. For example, consider $x_{i}\sim N(\mu_{i},\sigma_{i})$ for $i=1,\dots,N$. If $x_{i}$ are completely exchangeable then this means $\mu_{i}=\mu$ and $\sigma_{i}=\sigma$. If $x_{i}$ are conditionally exchangeable given $\mu_{i}$ then this means $\sigma_{i}=\sigma$. If $x_{i}$ are conditionally exchangeable given $\sigma_{i}$ then this means $\mu_{i}=\mu$. But note that in either of these two "conditionally exchangeable" cases, the quality of inference is reduced compared to the first, because there are an extra $N$ parameters that get introduced into the problem. If we have no exchangeability, then we basically have $N$ unrelated problems.
Basically exchangeability means we can make the inference $x_{i}\to \text{parameters}\to x_{j}$ for any $i$ and $j$ which are partly exchangeable | Why the exchangeability of random variables is essential in hierarchical bayesian models? | Exchangeability is not an essential feature of a hierarchical model (at least not at the observational level). It is basically a Bayesian analogue of "independent and identically distributed" from th | Why the exchangeability of random variables is essential in hierarchical bayesian models?
Exchangeability is not an essential feature of a hierarchical model (at least not at the observational level). It is basically a Bayesian analogue of "independent and identically distributed" from the standard literature. It is simply a way of describing what you know about the situation at hand. This is namely that "shuffling" does not alter your problem. One way I like to think of this is to consider the case where you were given $x_{j}=5$ but you were not told the value of $j$. If learning that $x_{j}=5$ would lead you to suspect particular values of $j$ more than others, then the sequence is not exchangeable. If it tells you nothing about $j$, then the sequence is exchangeable. Note that exhcangeability is "in the information" rather than "in reality" - it depends on what you know.
While exchangeability is not essential in terms of the observed variables, it would probably be quite difficult to fit any model without some notion of exchangeability, because without exchangeability you basically have no justification for pooling observations together. So my guess is that your inferences will be much weaker if you don't have exchangeability somewhere in the model. For example, consider $x_{i}\sim N(\mu_{i},\sigma_{i})$ for $i=1,\dots,N$. If $x_{i}$ are completely exchangeable then this means $\mu_{i}=\mu$ and $\sigma_{i}=\sigma$. If $x_{i}$ are conditionally exchangeable given $\mu_{i}$ then this means $\sigma_{i}=\sigma$. If $x_{i}$ are conditionally exchangeable given $\sigma_{i}$ then this means $\mu_{i}=\mu$. But note that in either of these two "conditionally exchangeable" cases, the quality of inference is reduced compared to the first, because there are an extra $N$ parameters that get introduced into the problem. If we have no exchangeability, then we basically have $N$ unrelated problems.
Basically exchangeability means we can make the inference $x_{i}\to \text{parameters}\to x_{j}$ for any $i$ and $j$ which are partly exchangeable | Why the exchangeability of random variables is essential in hierarchical bayesian models?
Exchangeability is not an essential feature of a hierarchical model (at least not at the observational level). It is basically a Bayesian analogue of "independent and identically distributed" from th |
28,158 | Why the exchangeability of random variables is essential in hierarchical bayesian models? | "Essential" is too vague. But surpressing the technicalities, if the sequence $X=\{X_i\}$ is exchangeable then the $X_i$ are conditionally independent given some unobserved parameter(s) $\Theta$ with a probability distribution $\pi$. That is, $p(X) = \int p(X_i|\Theta)d\pi(\Theta)$. $\Theta$ needn't be univariate or even finite dimensional and may be further represented as a mixture, etc.
Exchangability is essential in the sense that these conditional independence relationships allow us to fit models we almost certainly couldn't otherwise. | Why the exchangeability of random variables is essential in hierarchical bayesian models? | "Essential" is too vague. But surpressing the technicalities, if the sequence $X=\{X_i\}$ is exchangeable then the $X_i$ are conditionally independent given some unobserved parameter(s) $\Theta$ with | Why the exchangeability of random variables is essential in hierarchical bayesian models?
"Essential" is too vague. But surpressing the technicalities, if the sequence $X=\{X_i\}$ is exchangeable then the $X_i$ are conditionally independent given some unobserved parameter(s) $\Theta$ with a probability distribution $\pi$. That is, $p(X) = \int p(X_i|\Theta)d\pi(\Theta)$. $\Theta$ needn't be univariate or even finite dimensional and may be further represented as a mixture, etc.
Exchangability is essential in the sense that these conditional independence relationships allow us to fit models we almost certainly couldn't otherwise. | Why the exchangeability of random variables is essential in hierarchical bayesian models?
"Essential" is too vague. But surpressing the technicalities, if the sequence $X=\{X_i\}$ is exchangeable then the $X_i$ are conditionally independent given some unobserved parameter(s) $\Theta$ with |
28,159 | Why the exchangeability of random variables is essential in hierarchical bayesian models? | It isn't! I'm no expert here, but i'll give my two cents.
In general when you have a hierarchical model, say
$y|\Theta_{1} \sim \text{N}(X\Theta_{1},\sigma^2)$
$\Theta_{1}|\Theta_{2} \sim\text{N}(W\Theta_{2},\sigma^2)$
We make conditional independence assumptions, i.e., conditional on $\Theta_{2}$, the $\Theta_{1}$ are exchangeable. If the second level is not exchangeable, than you can incluce another level that makes it exchangeable. But even in the case that you can't make an assumption of exchaganbelity, the model may still be a good fit to your data at the first level.
Last, but not least, exchangeability is important only if you wanna think in terms of De Finetti's representation theorem. You might just think that priors are regularization tools that help you to fit your model. In this case, the exchangeability assumption is as good as it is your model fit to the data. In other words, if you think of Bayesian hierarchical model as way to get abetter fit to your data, then exchangeability is not essential in any sense. | Why the exchangeability of random variables is essential in hierarchical bayesian models? | It isn't! I'm no expert here, but i'll give my two cents.
In general when you have a hierarchical model, say
$y|\Theta_{1} \sim \text{N}(X\Theta_{1},\sigma^2)$
$\Theta_{1}|\Theta_{2} \sim\text{N}(W\T | Why the exchangeability of random variables is essential in hierarchical bayesian models?
It isn't! I'm no expert here, but i'll give my two cents.
In general when you have a hierarchical model, say
$y|\Theta_{1} \sim \text{N}(X\Theta_{1},\sigma^2)$
$\Theta_{1}|\Theta_{2} \sim\text{N}(W\Theta_{2},\sigma^2)$
We make conditional independence assumptions, i.e., conditional on $\Theta_{2}$, the $\Theta_{1}$ are exchangeable. If the second level is not exchangeable, than you can incluce another level that makes it exchangeable. But even in the case that you can't make an assumption of exchaganbelity, the model may still be a good fit to your data at the first level.
Last, but not least, exchangeability is important only if you wanna think in terms of De Finetti's representation theorem. You might just think that priors are regularization tools that help you to fit your model. In this case, the exchangeability assumption is as good as it is your model fit to the data. In other words, if you think of Bayesian hierarchical model as way to get abetter fit to your data, then exchangeability is not essential in any sense. | Why the exchangeability of random variables is essential in hierarchical bayesian models?
It isn't! I'm no expert here, but i'll give my two cents.
In general when you have a hierarchical model, say
$y|\Theta_{1} \sim \text{N}(X\Theta_{1},\sigma^2)$
$\Theta_{1}|\Theta_{2} \sim\text{N}(W\T |
28,160 | What's a good, generic name for chart of things by time of day? | Nick Cox (Stata Journal 2006, p403) calls this sort of plot a 'cycle plot', but notes that:
Cycle plots have been discussed under other names in the literature, including cycle-subseries plot, month plot, seasonal-by-month plot, and seasonal subseries plot.
(followed by a load of refs to textbooks and papers)
Many of these are clearly specific to seasonality, i.e. periods of one year. I still like the suggestion of 'periodic plot/chart' that I made in a comment to the question, but it appears the questioner's original suggestion of 'cycle plot/chart' is in fact the more standard generic term. | What's a good, generic name for chart of things by time of day? | Nick Cox (Stata Journal 2006, p403) calls this sort of plot a 'cycle plot', but notes that:
Cycle plots have been discussed under other names in the literature, including cycle-subseries plot, month | What's a good, generic name for chart of things by time of day?
Nick Cox (Stata Journal 2006, p403) calls this sort of plot a 'cycle plot', but notes that:
Cycle plots have been discussed under other names in the literature, including cycle-subseries plot, month plot, seasonal-by-month plot, and seasonal subseries plot.
(followed by a load of refs to textbooks and papers)
Many of these are clearly specific to seasonality, i.e. periods of one year. I still like the suggestion of 'periodic plot/chart' that I made in a comment to the question, but it appears the questioner's original suggestion of 'cycle plot/chart' is in fact the more standard generic term. | What's a good, generic name for chart of things by time of day?
Nick Cox (Stata Journal 2006, p403) calls this sort of plot a 'cycle plot', but notes that:
Cycle plots have been discussed under other names in the literature, including cycle-subseries plot, month |
28,161 | What's a good, generic name for chart of things by time of day? | What you've illustrated is a time series column (or bar) graph. The two graphs are of differing time resolution or differing time aggregation.
There may be industry specific terms for these types of charts. In finance, for example, the open-high-low-close chart is a very common time series plot:
When the x axis is time, as in your example, it's often common to illustrate the points as a line graph, instead of bars/columns. The reason for this is to put the visual emphasis on the change from one period to the next.
You might also consider graphing period-over-period. For example a year-over-year would show how the numbers for a given month (typically, although could be month or day) compare to the numbers of the prior year for the same month.
But I realize your question was about naming, not all the other cool graphs you can do ;) | What's a good, generic name for chart of things by time of day? | What you've illustrated is a time series column (or bar) graph. The two graphs are of differing time resolution or differing time aggregation.
There may be industry specific terms for these types of | What's a good, generic name for chart of things by time of day?
What you've illustrated is a time series column (or bar) graph. The two graphs are of differing time resolution or differing time aggregation.
There may be industry specific terms for these types of charts. In finance, for example, the open-high-low-close chart is a very common time series plot:
When the x axis is time, as in your example, it's often common to illustrate the points as a line graph, instead of bars/columns. The reason for this is to put the visual emphasis on the change from one period to the next.
You might also consider graphing period-over-period. For example a year-over-year would show how the numbers for a given month (typically, although could be month or day) compare to the numbers of the prior year for the same month.
But I realize your question was about naming, not all the other cool graphs you can do ;) | What's a good, generic name for chart of things by time of day?
What you've illustrated is a time series column (or bar) graph. The two graphs are of differing time resolution or differing time aggregation.
There may be industry specific terms for these types of |
28,162 | What's a good, generic name for chart of things by time of day? | I'd suggest "diurnal" or "circadian" rhythm chart. For weekly, the latter would be "circaseptan", "circamensual" for "monthly", and "circannual" for "yearly". | What's a good, generic name for chart of things by time of day? | I'd suggest "diurnal" or "circadian" rhythm chart. For weekly, the latter would be "circaseptan", "circamensual" for "monthly", and "circannual" for "yearly". | What's a good, generic name for chart of things by time of day?
I'd suggest "diurnal" or "circadian" rhythm chart. For weekly, the latter would be "circaseptan", "circamensual" for "monthly", and "circannual" for "yearly". | What's a good, generic name for chart of things by time of day?
I'd suggest "diurnal" or "circadian" rhythm chart. For weekly, the latter would be "circaseptan", "circamensual" for "monthly", and "circannual" for "yearly". |
28,163 | What's a good, generic name for chart of things by time of day? | The type of chart you've drawn is known as a Histogram http://en.wikipedia.org/wiki/Histogram | What's a good, generic name for chart of things by time of day? | The type of chart you've drawn is known as a Histogram http://en.wikipedia.org/wiki/Histogram | What's a good, generic name for chart of things by time of day?
The type of chart you've drawn is known as a Histogram http://en.wikipedia.org/wiki/Histogram | What's a good, generic name for chart of things by time of day?
The type of chart you've drawn is known as a Histogram http://en.wikipedia.org/wiki/Histogram |
28,164 | What's a good, generic name for chart of things by time of day? | Short, simple, descriptive: time series plot.
Edit: In light of the discussion, I'd vote for histogram as well. At least, thats the generic name for this kind of chart, where the hours of the day are a natural division of stacks. | What's a good, generic name for chart of things by time of day? | Short, simple, descriptive: time series plot.
Edit: In light of the discussion, I'd vote for histogram as well. At least, thats the generic name for this kind of chart, where the hours of the day are | What's a good, generic name for chart of things by time of day?
Short, simple, descriptive: time series plot.
Edit: In light of the discussion, I'd vote for histogram as well. At least, thats the generic name for this kind of chart, where the hours of the day are a natural division of stacks. | What's a good, generic name for chart of things by time of day?
Short, simple, descriptive: time series plot.
Edit: In light of the discussion, I'd vote for histogram as well. At least, thats the generic name for this kind of chart, where the hours of the day are |
28,165 | What's a good, generic name for chart of things by time of day? | Your charts are a diurnal hourly-average bar chart, and a one-week daily-average bar chart, respectively. | What's a good, generic name for chart of things by time of day? | Your charts are a diurnal hourly-average bar chart, and a one-week daily-average bar chart, respectively. | What's a good, generic name for chart of things by time of day?
Your charts are a diurnal hourly-average bar chart, and a one-week daily-average bar chart, respectively. | What's a good, generic name for chart of things by time of day?
Your charts are a diurnal hourly-average bar chart, and a one-week daily-average bar chart, respectively. |
28,166 | R: update a graph dynamically [closed] | Assuming you want to update R windows() or x11() graph, you can use functions like points() and lines() to add new points or extend lines on a graph without redraw; yet note that this won't change the axes range to accommodate points that may go out of view. In general it is usually a good idea to make the plotting itself instantaneous -- for instance by moving computation effort into making some reduced middle representation which can be plotted rapidly, like density map instead of huge number of points or reducing resolution of line plots (this may be complex though).
For holding R session for a certain time without busy wait, use Sys.sleep(). | R: update a graph dynamically [closed] | Assuming you want to update R windows() or x11() graph, you can use functions like points() and lines() to add new points or extend lines on a graph without redraw; yet note that this won't change the | R: update a graph dynamically [closed]
Assuming you want to update R windows() or x11() graph, you can use functions like points() and lines() to add new points or extend lines on a graph without redraw; yet note that this won't change the axes range to accommodate points that may go out of view. In general it is usually a good idea to make the plotting itself instantaneous -- for instance by moving computation effort into making some reduced middle representation which can be plotted rapidly, like density map instead of huge number of points or reducing resolution of line plots (this may be complex though).
For holding R session for a certain time without busy wait, use Sys.sleep(). | R: update a graph dynamically [closed]
Assuming you want to update R windows() or x11() graph, you can use functions like points() and lines() to add new points or extend lines on a graph without redraw; yet note that this won't change the |
28,167 | R: update a graph dynamically [closed] | For offline visualization, you can generate PNG files and convert them to an animated GIF using ImageMagick. I used it for demonstration (this redraw all data, though):
source(url("http://aliquote.org/pub/spin_plot.R"))
dd <- replicate(3, rnorm(100))
spin.plot(dd)
This generates several PNG files, prefixed with fig. Then, on an un*x shell,
convert -delay 20 -loop 0 fig*.png sequence.gif
gives this animation (which is inspired from Modern Applied Biostatistical Methods using S-Plus, S. Selvin, 1998):
Another option which looks much more promising is to rely on the animation package. There is an example with a Moving Window Auto-Regression that should let you go started with. | R: update a graph dynamically [closed] | For offline visualization, you can generate PNG files and convert them to an animated GIF using ImageMagick. I used it for demonstration (this redraw all data, though):
source(url("http://aliquote.org | R: update a graph dynamically [closed]
For offline visualization, you can generate PNG files and convert them to an animated GIF using ImageMagick. I used it for demonstration (this redraw all data, though):
source(url("http://aliquote.org/pub/spin_plot.R"))
dd <- replicate(3, rnorm(100))
spin.plot(dd)
This generates several PNG files, prefixed with fig. Then, on an un*x shell,
convert -delay 20 -loop 0 fig*.png sequence.gif
gives this animation (which is inspired from Modern Applied Biostatistical Methods using S-Plus, S. Selvin, 1998):
Another option which looks much more promising is to rely on the animation package. There is an example with a Moving Window Auto-Regression that should let you go started with. | R: update a graph dynamically [closed]
For offline visualization, you can generate PNG files and convert them to an animated GIF using ImageMagick. I used it for demonstration (this redraw all data, though):
source(url("http://aliquote.org |
28,168 | Web visualization libraries | IMO, Protovis is the best and is very well documented and supported. It is the basis for my webvis R package.
These are also very good, although they have more of a learning curve:
Processing
Prefuse | Web visualization libraries | IMO, Protovis is the best and is very well documented and supported. It is the basis for my webvis R package.
These are also very good, although they have more of a learning curve:
Processing
Pref | Web visualization libraries
IMO, Protovis is the best and is very well documented and supported. It is the basis for my webvis R package.
These are also very good, although they have more of a learning curve:
Processing
Prefuse | Web visualization libraries
IMO, Protovis is the best and is very well documented and supported. It is the basis for my webvis R package.
These are also very good, although they have more of a learning curve:
Processing
Pref |
28,169 | Web visualization libraries | RaphaelJS can do some pretty amazing stuff and it just got some major backing from Sencha (formerly ExtJS). Raphael is pretty smart about browsers by using a VML backend for Internet Explorer and SVG for everything else. However, the library is pretty low-level. Fortunately, the author has started another project, gRaphael, that focuses on drawing charts and graphs.
The MIT SIMILE Project also has some interesting JavaScript libraries:
Timeplot
Timeline
There is also a project to port Processing to JavaScript: ProcessingJS
Jmol is a Java applet for viewing chemical structures, but it is used as the display engine for 3D graphics in the SAGE system, which has a completely browser-based GUI.
And for an open source alternative to Google Maps, there is the excellent OpenLayers JavaScript library which powers the frontend of the equally excellent OpenStreetMap. | Web visualization libraries | RaphaelJS can do some pretty amazing stuff and it just got some major backing from Sencha (formerly ExtJS). Raphael is pretty smart about browsers by using a VML backend for Internet Explorer and SVG | Web visualization libraries
RaphaelJS can do some pretty amazing stuff and it just got some major backing from Sencha (formerly ExtJS). Raphael is pretty smart about browsers by using a VML backend for Internet Explorer and SVG for everything else. However, the library is pretty low-level. Fortunately, the author has started another project, gRaphael, that focuses on drawing charts and graphs.
The MIT SIMILE Project also has some interesting JavaScript libraries:
Timeplot
Timeline
There is also a project to port Processing to JavaScript: ProcessingJS
Jmol is a Java applet for viewing chemical structures, but it is used as the display engine for 3D graphics in the SAGE system, which has a completely browser-based GUI.
And for an open source alternative to Google Maps, there is the excellent OpenLayers JavaScript library which powers the frontend of the equally excellent OpenStreetMap. | Web visualization libraries
RaphaelJS can do some pretty amazing stuff and it just got some major backing from Sencha (formerly ExtJS). Raphael is pretty smart about browsers by using a VML backend for Internet Explorer and SVG |
28,170 | Web visualization libraries | http://insideria.com/2009/12/28-rich-data-visualization-too.html 28 Rich Data Visualization Tools
http://www.rgraph.net/ R graph
http://vis.stanford.edu/protovis/ | Web visualization libraries | http://insideria.com/2009/12/28-rich-data-visualization-too.html 28 Rich Data Visualization Tools
http://www.rgraph.net/ R graph
http://vis.stanford.edu/protovis/ | Web visualization libraries
http://insideria.com/2009/12/28-rich-data-visualization-too.html 28 Rich Data Visualization Tools
http://www.rgraph.net/ R graph
http://vis.stanford.edu/protovis/ | Web visualization libraries
http://insideria.com/2009/12/28-rich-data-visualization-too.html 28 Rich Data Visualization Tools
http://www.rgraph.net/ R graph
http://vis.stanford.edu/protovis/ |
28,171 | Web visualization libraries | There are hundreds of them. Here is a useful review of some twenty of them:
http://bigdata-madesimple.com/review-of-20-best-big-data-visualization-tools/ | Web visualization libraries | There are hundreds of them. Here is a useful review of some twenty of them:
http://bigdata-madesimple.com/review-of-20-best-big-data-visualization-tools/ | Web visualization libraries
There are hundreds of them. Here is a useful review of some twenty of them:
http://bigdata-madesimple.com/review-of-20-best-big-data-visualization-tools/ | Web visualization libraries
There are hundreds of them. Here is a useful review of some twenty of them:
http://bigdata-madesimple.com/review-of-20-best-big-data-visualization-tools/ |
28,172 | Web visualization libraries | I would recommend ChartJS, it's simple, beauty and well supported. | Web visualization libraries | I would recommend ChartJS, it's simple, beauty and well supported. | Web visualization libraries
I would recommend ChartJS, it's simple, beauty and well supported. | Web visualization libraries
I would recommend ChartJS, it's simple, beauty and well supported. |
28,173 | Calculate the standard error of the difference between two independent proportions | Confidence intervals for men and women separately. Let capital letters denote estimates: The point estimates for the proportions
of men and of woman who agree are $0.264$ and $0.323,$ respectively. The
corresponding Wald confidence intervals, based on normal approximation, are
$(0.225, 0.303)$ for men and $(0.288, 0.357)$ for women.
P.m = 132/500; P.m
[1] 0.264
SE.m = sqrt(P.m*(1-P.m)/500); SE.m
[1] 0.01971314
CI.m = P.m + qnorm(c(.025,.975))*SE.m
CI.m
[1] 0.225363 0.302637
P.w = 226/700; P.w
[1] 0.3228571
SE.w = sqrt(P.w*(1-P.w)/700); SE.w
[1] 0.01767243
CI.w = P.w + qnorm(c(.025,.975))*SE.w
CI.w
[1] 0.2882198 0.3574945
The procedure binom.test in R gives (slightly different) exact binomial
confidence intervals, $(0.226, 0.305)$ for men and $(0.288, 0.359)$ for women, as shown below.
binom.test(132,500)$conf.int
[1] 0.2258560 0.3049604
attr(,"conf.level")
[1] 0.95
binom.test(226,700)$conf.int
[1] 0.2883144 0.3589013
attr(,"conf.level")
[1] 0.95
CI for the difference between men and women.
As in the last section of the table in your question and in @Ben's Answer (+1), the (estimated) standard error for the difference P_w - P_m is as follows:
SE.d = sqrt(SE.w^2 + SE.m^2); SE.d
[1] 0.02647495
Then a 95% confidence interval for the difference, based on normal approximations,
is (0.0070, 0.1107),$ which is essentially the same
P.w-P.m + qnorm(c(.025,.975))*SE.d
[1] 0.006967198 0.110747087
In R the procedure prop.test gives the same 95% confidence interval
$(0.0070, 0.1107).$ [This interval is also based on a normal approximation; the continuity correction was declined on account
of the large sample sizes.]
prop.test(c(226,132), c(700,500), cor=F)$conf.int
[1] 0.006967198 0.110747087
attr(,"conf.level")
[1] 0.95
Notice that this 95% confidence interval does not include $0.$
Accordingly, a test the women and men have equally favorable opinions
is rejected at the 5% level (against the two-sided alternative).
The P-value of the (approximate normal) test is $0.028 < 0.05 = 5\%.$
prop.test(c(226,132), c(700,500), cor=F)$p.val
[1] 0.02802182 | Calculate the standard error of the difference between two independent proportions | Confidence intervals for men and women separately. Let capital letters denote estimates: The point estimates for the proportions
of men and of woman who agree are $0.264$ and $0.323,$ respectively. Th | Calculate the standard error of the difference between two independent proportions
Confidence intervals for men and women separately. Let capital letters denote estimates: The point estimates for the proportions
of men and of woman who agree are $0.264$ and $0.323,$ respectively. The
corresponding Wald confidence intervals, based on normal approximation, are
$(0.225, 0.303)$ for men and $(0.288, 0.357)$ for women.
P.m = 132/500; P.m
[1] 0.264
SE.m = sqrt(P.m*(1-P.m)/500); SE.m
[1] 0.01971314
CI.m = P.m + qnorm(c(.025,.975))*SE.m
CI.m
[1] 0.225363 0.302637
P.w = 226/700; P.w
[1] 0.3228571
SE.w = sqrt(P.w*(1-P.w)/700); SE.w
[1] 0.01767243
CI.w = P.w + qnorm(c(.025,.975))*SE.w
CI.w
[1] 0.2882198 0.3574945
The procedure binom.test in R gives (slightly different) exact binomial
confidence intervals, $(0.226, 0.305)$ for men and $(0.288, 0.359)$ for women, as shown below.
binom.test(132,500)$conf.int
[1] 0.2258560 0.3049604
attr(,"conf.level")
[1] 0.95
binom.test(226,700)$conf.int
[1] 0.2883144 0.3589013
attr(,"conf.level")
[1] 0.95
CI for the difference between men and women.
As in the last section of the table in your question and in @Ben's Answer (+1), the (estimated) standard error for the difference P_w - P_m is as follows:
SE.d = sqrt(SE.w^2 + SE.m^2); SE.d
[1] 0.02647495
Then a 95% confidence interval for the difference, based on normal approximations,
is (0.0070, 0.1107),$ which is essentially the same
P.w-P.m + qnorm(c(.025,.975))*SE.d
[1] 0.006967198 0.110747087
In R the procedure prop.test gives the same 95% confidence interval
$(0.0070, 0.1107).$ [This interval is also based on a normal approximation; the continuity correction was declined on account
of the large sample sizes.]
prop.test(c(226,132), c(700,500), cor=F)$conf.int
[1] 0.006967198 0.110747087
attr(,"conf.level")
[1] 0.95
Notice that this 95% confidence interval does not include $0.$
Accordingly, a test the women and men have equally favorable opinions
is rejected at the 5% level (against the two-sided alternative).
The P-value of the (approximate normal) test is $0.028 < 0.05 = 5\%.$
prop.test(c(226,132), c(700,500), cor=F)$p.val
[1] 0.02802182 | Calculate the standard error of the difference between two independent proportions
Confidence intervals for men and women separately. Let capital letters denote estimates: The point estimates for the proportions
of men and of woman who agree are $0.264$ and $0.323,$ respectively. Th |
28,174 | Calculate the standard error of the difference between two independent proportions | In order to understand this material, you should read about the properties of the variance operator. This is a quadratic operator, which operates in a specific way on linear functions of random variables. Once you understand the algebraic rules for the way this operator works, you will be able to see how to get the variance of differences between random quantities.
For completeness, I will go through the working here. Suppose we let $\hat{p}_1 = x_1/n_1$ and $\hat{p}_2 = x_2/n_2$ be the observed sample proportions, where $x_1 \sim \text{Bin}(n_1,p_1)$ and $x_2 \sim \text{Bin}(n_2,p_2)$ are binomial random variables. Assuming that these are from independent samples, using the rules for the variance operator, the true variance of the difference in proportions is:
$$\begin{align}
\mathbb{V}(\hat{p}_1-\hat{p}_2)
&= \mathbb{V} \Big( \frac{x_1}{n_1} - \frac{x_2}{n_2} \Big) \\[6pt]
&= \mathbb{V} \Big( \frac{x_1}{n_1} \Big) + \mathbb{V} \Big( -\frac{x_2}{n_2} \Big) \\[6pt]
&= \mathbb{V} \Big( \frac{x_1}{n_1} \Big) + (-1)^2 \mathbb{V} \Big( \frac{x_2}{n_2} \Big) \\[6pt]
&= \mathbb{V} \Big( \frac{x_1}{n_1} \Big) + \mathbb{V} \Big( \frac{x_2}{n_2} \Big) \\[6pt]
&= \frac{\mathbb{V}(x_1)}{n_1^2} + \frac{\mathbb{V}(x_2)}{n_2^2} \\[6pt]
&= \frac{n_1 p_1 (1-p_1)}{n_1^2} + \frac{n_2 p_2 (1-p_2)}{n_2^2} \\[6pt]
&= \frac{p_1 (1-p_1)}{n_1} + \frac{p_2 (1-p_2)}{n_2} \\[6pt]
&= \frac{p_1 q_1}{n_1} + \frac{p_2 q_2}{n_2}. \\[6pt]
\end{align}$$
Consequently, the true "standard error" of the estimator (the standard deviation of the difference between sample proportions) is:
$$\begin{align}
\text{se}
= \sqrt{\mathbb{V}(\hat{p}_1-\hat{p}_2)}
&= \sqrt{\frac{p_1 q_1}{n_1} + \frac{p_2 q_2}{n_2}}, \\[6pt]
\end{align}$$
and the "estimated standard error" (using the standard estimate) is:
$$\begin{align}
\hat{\text{se}}
&= \sqrt{\frac{\hat{p}_1 \hat{q}_1}{n_1} + \frac{\hat{p}_2 \hat{q}_2}{n_2}}. \\[6pt]
\end{align}$$
If you have a look at the working above, you will see that the negative since that occurs in the difference in proportions does not affect the variance. This is because taking the negative of a random variable just changes its direction and not its variance. Mathematically, this property is a consequence of the fact that constants inside the variance operator come out of the operator squared. | Calculate the standard error of the difference between two independent proportions | In order to understand this material, you should read about the properties of the variance operator. This is a quadratic operator, which operates in a specific way on linear functions of random varia | Calculate the standard error of the difference between two independent proportions
In order to understand this material, you should read about the properties of the variance operator. This is a quadratic operator, which operates in a specific way on linear functions of random variables. Once you understand the algebraic rules for the way this operator works, you will be able to see how to get the variance of differences between random quantities.
For completeness, I will go through the working here. Suppose we let $\hat{p}_1 = x_1/n_1$ and $\hat{p}_2 = x_2/n_2$ be the observed sample proportions, where $x_1 \sim \text{Bin}(n_1,p_1)$ and $x_2 \sim \text{Bin}(n_2,p_2)$ are binomial random variables. Assuming that these are from independent samples, using the rules for the variance operator, the true variance of the difference in proportions is:
$$\begin{align}
\mathbb{V}(\hat{p}_1-\hat{p}_2)
&= \mathbb{V} \Big( \frac{x_1}{n_1} - \frac{x_2}{n_2} \Big) \\[6pt]
&= \mathbb{V} \Big( \frac{x_1}{n_1} \Big) + \mathbb{V} \Big( -\frac{x_2}{n_2} \Big) \\[6pt]
&= \mathbb{V} \Big( \frac{x_1}{n_1} \Big) + (-1)^2 \mathbb{V} \Big( \frac{x_2}{n_2} \Big) \\[6pt]
&= \mathbb{V} \Big( \frac{x_1}{n_1} \Big) + \mathbb{V} \Big( \frac{x_2}{n_2} \Big) \\[6pt]
&= \frac{\mathbb{V}(x_1)}{n_1^2} + \frac{\mathbb{V}(x_2)}{n_2^2} \\[6pt]
&= \frac{n_1 p_1 (1-p_1)}{n_1^2} + \frac{n_2 p_2 (1-p_2)}{n_2^2} \\[6pt]
&= \frac{p_1 (1-p_1)}{n_1} + \frac{p_2 (1-p_2)}{n_2} \\[6pt]
&= \frac{p_1 q_1}{n_1} + \frac{p_2 q_2}{n_2}. \\[6pt]
\end{align}$$
Consequently, the true "standard error" of the estimator (the standard deviation of the difference between sample proportions) is:
$$\begin{align}
\text{se}
= \sqrt{\mathbb{V}(\hat{p}_1-\hat{p}_2)}
&= \sqrt{\frac{p_1 q_1}{n_1} + \frac{p_2 q_2}{n_2}}, \\[6pt]
\end{align}$$
and the "estimated standard error" (using the standard estimate) is:
$$\begin{align}
\hat{\text{se}}
&= \sqrt{\frac{\hat{p}_1 \hat{q}_1}{n_1} + \frac{\hat{p}_2 \hat{q}_2}{n_2}}. \\[6pt]
\end{align}$$
If you have a look at the working above, you will see that the negative since that occurs in the difference in proportions does not affect the variance. This is because taking the negative of a random variable just changes its direction and not its variance. Mathematically, this property is a consequence of the fact that constants inside the variance operator come out of the operator squared. | Calculate the standard error of the difference between two independent proportions
In order to understand this material, you should read about the properties of the variance operator. This is a quadratic operator, which operates in a specific way on linear functions of random varia |
28,175 | Best way to reduce false positive of binary classification to exactly 0? | Use probabilistic classifications instead of hard 0-1 classifications. That is, predict the probability for an instance to be positive. Use proper scoring rules to assess these predicted probabilities.
Then consider whether you can make decisions based on these probabilities. You may or may not want to use a single threshold to map your probabilities to hard classes. Instead, you may even want to use multiple thresholds for multiple different actions. The mapping between probabilities and decisions should be based on explicit assumptions about the costs of wrong (and correct) decisions. More here.
In a nutshell: decouple the modeling/predictive part from the decision.
Do not use accuracy as a KPI at all. It is misleading, and especially (but not only) so for unbalanced data. The exact same problems as for accuracy apply equally to FPR.
Similarly, do not overweight one class. This is analogous to oversampling, which is commonly used to "address" class imbalance - but unbalanced data are not a problem (as long as you don't use misleading KPIs like accuracy or FPR), and oversampling or weighting will not solve a non-problem. | Best way to reduce false positive of binary classification to exactly 0? | Use probabilistic classifications instead of hard 0-1 classifications. That is, predict the probability for an instance to be positive. Use proper scoring rules to assess these predicted probabilities | Best way to reduce false positive of binary classification to exactly 0?
Use probabilistic classifications instead of hard 0-1 classifications. That is, predict the probability for an instance to be positive. Use proper scoring rules to assess these predicted probabilities.
Then consider whether you can make decisions based on these probabilities. You may or may not want to use a single threshold to map your probabilities to hard classes. Instead, you may even want to use multiple thresholds for multiple different actions. The mapping between probabilities and decisions should be based on explicit assumptions about the costs of wrong (and correct) decisions. More here.
In a nutshell: decouple the modeling/predictive part from the decision.
Do not use accuracy as a KPI at all. It is misleading, and especially (but not only) so for unbalanced data. The exact same problems as for accuracy apply equally to FPR.
Similarly, do not overweight one class. This is analogous to oversampling, which is commonly used to "address" class imbalance - but unbalanced data are not a problem (as long as you don't use misleading KPIs like accuracy or FPR), and oversampling or weighting will not solve a non-problem. | Best way to reduce false positive of binary classification to exactly 0?
Use probabilistic classifications instead of hard 0-1 classifications. That is, predict the probability for an instance to be positive. Use proper scoring rules to assess these predicted probabilities |
28,176 | Best way to reduce false positive of binary classification to exactly 0? | In addition to @StephanKolassa's very important points: is binary classification actually what you need here?
Binary classification (or more generally disciminative classification) assumes that positive and negative are well-defined classes.
In contrast, one-class classifiers (aka class models) assume only the class that is modeled to be well-defined.
Such a model would detect "not that class" also for new (previously unknown) ways of a case being different from the modeled class.
One class classification is also available in probabilistic varieties (or with the output being a score or a distance to the modeled class).
All that @StefanKolassa wrote about proper scoring applies to one-class classifiers as well. By construction, one-class classifiers "do not care" about relative class frequencies, and thus also not about class imbalance.
One-class classification is closely related to outlier and anomaly detection.
A totally unrelated point: when you achieve 0 FPR with your test data, be aware of the related confidence interval. Depending on the number of positive cases you tested, you can only claim that e.g. the one-sided 95 % confidence interval for FPR is < x based on that test.
The rule of three suggests that you need to observe 0 false positives among more than about 3e6 truly negative and independent test cases to have the one-sided 95% confidence interval for the FPR lie below 1e-6.
(That is an additional point against figures of merit that are fractions of tested cases: they have high variance) | Best way to reduce false positive of binary classification to exactly 0? | In addition to @StephanKolassa's very important points: is binary classification actually what you need here?
Binary classification (or more generally disciminative classification) assumes that posit | Best way to reduce false positive of binary classification to exactly 0?
In addition to @StephanKolassa's very important points: is binary classification actually what you need here?
Binary classification (or more generally disciminative classification) assumes that positive and negative are well-defined classes.
In contrast, one-class classifiers (aka class models) assume only the class that is modeled to be well-defined.
Such a model would detect "not that class" also for new (previously unknown) ways of a case being different from the modeled class.
One class classification is also available in probabilistic varieties (or with the output being a score or a distance to the modeled class).
All that @StefanKolassa wrote about proper scoring applies to one-class classifiers as well. By construction, one-class classifiers "do not care" about relative class frequencies, and thus also not about class imbalance.
One-class classification is closely related to outlier and anomaly detection.
A totally unrelated point: when you achieve 0 FPR with your test data, be aware of the related confidence interval. Depending on the number of positive cases you tested, you can only claim that e.g. the one-sided 95 % confidence interval for FPR is < x based on that test.
The rule of three suggests that you need to observe 0 false positives among more than about 3e6 truly negative and independent test cases to have the one-sided 95% confidence interval for the FPR lie below 1e-6.
(That is an additional point against figures of merit that are fractions of tested cases: they have high variance) | Best way to reduce false positive of binary classification to exactly 0?
In addition to @StephanKolassa's very important points: is binary classification actually what you need here?
Binary classification (or more generally disciminative classification) assumes that posit |
28,177 | What is the relationship between VAE and EM algorithm? | What is the relationship between VAE and EM?
$\newcommand{\vect}[1]{\boldsymbol{\mathbf{#1}}}
\newcommand{\vx}{\vect{x}}
\newcommand{\vz}{\vect{z}}
\newcommand{\vtheta}{\vect{\theta}}
\newcommand{\Ebb}{\mathbb{E}}
\newcommand{\vphi}{\vect{\phi}}
\newcommand{L}{\mathcal{L}}
\newcommand{\elbo}{L_{\vtheta, \vphi}(\vx)}
\newcommand{\felbo}{L_{\vx}(\vtheta, q_{\vphi})}$
This answer is partially complete, but I've actually written a blog post about this that goes into the nitty-gritty details!
Notation
Observed data: $\mathcal{D} = \{\vx_1, \vx_2, \ldots, \vx_N\}$
Latent variables denoted by $\vz$.
Expectation Maximization Algorithm (Standard Version)
The EM algorithm is often (see for example Wikipedia) described as follows.
Start with a guess $\vtheta^{(0)}$, then until convergence:
Compute expectations $\Ebb_{p(\vz \mid \vx, \vtheta^{(t)})}[\log p_{\vtheta}(\vx, \vz)]$ for every data point $\vx\in \mathcal{D}$.
Choose parameter value $\vtheta^{(t+1)}$ to maximize expectations
$$
\vtheta^{(t+1)} = \arg\max_{\vtheta} \sum_{\vx\in\mathcal{D}}\Ebb_{p(\vz \mid \vx, \vtheta^{(t)})}[\log p_{\vtheta}(\vx, \vz)]
$$
Expectation-Maximization Algorithm (Rewritten)
One can rewrite the algorithm above in a slightly different way. Rather than computing expectations in the first step, we compute the distributions $p(\vz\mid, \vx, \vtheta^{(t)})$. The EM algorithm then looks as follows:
Start with a guess $\vtheta^{(0)}$, until convergence:
Compute distributions $\left\{p(\vz\mid, \vx, \vtheta^{(t)}) \, : \, \vx \in \mathcal{D}\right\}$
Choosen new parameter value in the same way as before
$$
\vtheta^{(t+1)} = \arg\max_{\vtheta} \sum_{\vx\in\mathcal{D}}\Ebb_{p(\vz \mid \vx, \vtheta^{(t)})}[\log p_{\vtheta}(\vx, \vz)]
$$
Variational Autoencoders
Why did I rewrite it like that? Because one can write the ELBO, which is usually considered as a function of $\vx$ parametrized by $\vtheta$ and $\vphi$ ($\vphi$ are the parameters of the encoder $q_{\vphi}$), as a functional of $q_{\vphi}$ and a function of $\vtheta$ that is parameterized by $\vx$ (indeed the data is fixed). This means the ELBO can be written as:
\begin{equation*}
\mathcal{L}_{\boldsymbol{\mathbf{x}}}(\boldsymbol{\mathbf{\theta}}, q_{\boldsymbol{\mathbf{\phi}}})=
\begin{cases}
\displaystyle \log p_{\boldsymbol{\mathbf{\theta}}}(\boldsymbol{\mathbf{x}})- \text{KL}(q_{\boldsymbol{\mathbf{\phi}}}\,\,||\,\,p_{\boldsymbol{\mathbf{\theta}}}(\boldsymbol{\mathbf{z}}\mid \boldsymbol{\mathbf{x}})) \qquad \qquad &(1)\\
\qquad \\
\displaystyle \mathbb{E}_{q_{\boldsymbol{\mathbf{\phi}}}}[\log p_{\boldsymbol{\mathbf{\theta}}}(\boldsymbol{\mathbf{x}}, \boldsymbol{\mathbf{z}})] - \mathbb{E}_{q_{\boldsymbol{\mathbf{\phi}}}}[\log q_{\boldsymbol{\mathbf{\phi}}}] \qquad \qquad &(2)
\end{cases}
\end{equation*}
Now we can find two identical steps as those of the EM algorithm by performing maximization of the ELBO with respect to $q_{\vphi}$ first, and then with respect to $\vtheta$
E-step: Maximize $(1)$ with respect to $q_{\vphi}$ (this makes the KL-divergence zero and the bound is tight)
$$
\left\{p_{\boldsymbol{\mathbf{\theta}}^{(t)}}(\boldsymbol{\mathbf{z}}\mid \boldsymbol{\mathbf{x}})= \arg\max_{q_{\boldsymbol{\mathbf{\phi}}}} \mathcal{L}_{\boldsymbol{\mathbf{x}}}(\boldsymbol{\mathbf{\theta}}^{(t)}, q_{\boldsymbol{\mathbf{\phi}}})\,\, : \,\, \boldsymbol{\mathbf{x}}\in\mathcal{D}\right\}
$$
M-step: Maximize $(2)$ with respect to $\vtheta$
$$
\boldsymbol{\mathbf{\theta}}^{(t+1)} = \arg\max_{\boldsymbol{\mathbf{\theta}}} \sum_{\boldsymbol{\mathbf{x}}\in\mathcal{D}} \mathcal{L}_{\boldsymbol{\mathbf{x}}}(\boldsymbol{\mathbf{\theta}}, p_{\boldsymbol{\mathbf{\theta}}^{(t)}}(\boldsymbol{\mathbf{z}}\mid \boldsymbol{\mathbf{x}}))
$$
The relationship between the Expectation Maximization algorithm and Variational Auto-Encoders can therefore be summarized as follows:
EM algorithm and VAE optimize the same objective function.
When expectations are in closed-form, one should use the EM algorithm which uses coordinate ascent.
When expectations are intractable, VAE uses stochastic gradient ascent on an unbiased estimator of the objective function. | What is the relationship between VAE and EM algorithm? | What is the relationship between VAE and EM?
$\newcommand{\vect}[1]{\boldsymbol{\mathbf{#1}}}
\newcommand{\vx}{\vect{x}}
\newcommand{\vz}{\vect{z}}
\newcommand{\vtheta}{\vect{\theta}}
\newcommand{\Eb | What is the relationship between VAE and EM algorithm?
What is the relationship between VAE and EM?
$\newcommand{\vect}[1]{\boldsymbol{\mathbf{#1}}}
\newcommand{\vx}{\vect{x}}
\newcommand{\vz}{\vect{z}}
\newcommand{\vtheta}{\vect{\theta}}
\newcommand{\Ebb}{\mathbb{E}}
\newcommand{\vphi}{\vect{\phi}}
\newcommand{L}{\mathcal{L}}
\newcommand{\elbo}{L_{\vtheta, \vphi}(\vx)}
\newcommand{\felbo}{L_{\vx}(\vtheta, q_{\vphi})}$
This answer is partially complete, but I've actually written a blog post about this that goes into the nitty-gritty details!
Notation
Observed data: $\mathcal{D} = \{\vx_1, \vx_2, \ldots, \vx_N\}$
Latent variables denoted by $\vz$.
Expectation Maximization Algorithm (Standard Version)
The EM algorithm is often (see for example Wikipedia) described as follows.
Start with a guess $\vtheta^{(0)}$, then until convergence:
Compute expectations $\Ebb_{p(\vz \mid \vx, \vtheta^{(t)})}[\log p_{\vtheta}(\vx, \vz)]$ for every data point $\vx\in \mathcal{D}$.
Choose parameter value $\vtheta^{(t+1)}$ to maximize expectations
$$
\vtheta^{(t+1)} = \arg\max_{\vtheta} \sum_{\vx\in\mathcal{D}}\Ebb_{p(\vz \mid \vx, \vtheta^{(t)})}[\log p_{\vtheta}(\vx, \vz)]
$$
Expectation-Maximization Algorithm (Rewritten)
One can rewrite the algorithm above in a slightly different way. Rather than computing expectations in the first step, we compute the distributions $p(\vz\mid, \vx, \vtheta^{(t)})$. The EM algorithm then looks as follows:
Start with a guess $\vtheta^{(0)}$, until convergence:
Compute distributions $\left\{p(\vz\mid, \vx, \vtheta^{(t)}) \, : \, \vx \in \mathcal{D}\right\}$
Choosen new parameter value in the same way as before
$$
\vtheta^{(t+1)} = \arg\max_{\vtheta} \sum_{\vx\in\mathcal{D}}\Ebb_{p(\vz \mid \vx, \vtheta^{(t)})}[\log p_{\vtheta}(\vx, \vz)]
$$
Variational Autoencoders
Why did I rewrite it like that? Because one can write the ELBO, which is usually considered as a function of $\vx$ parametrized by $\vtheta$ and $\vphi$ ($\vphi$ are the parameters of the encoder $q_{\vphi}$), as a functional of $q_{\vphi}$ and a function of $\vtheta$ that is parameterized by $\vx$ (indeed the data is fixed). This means the ELBO can be written as:
\begin{equation*}
\mathcal{L}_{\boldsymbol{\mathbf{x}}}(\boldsymbol{\mathbf{\theta}}, q_{\boldsymbol{\mathbf{\phi}}})=
\begin{cases}
\displaystyle \log p_{\boldsymbol{\mathbf{\theta}}}(\boldsymbol{\mathbf{x}})- \text{KL}(q_{\boldsymbol{\mathbf{\phi}}}\,\,||\,\,p_{\boldsymbol{\mathbf{\theta}}}(\boldsymbol{\mathbf{z}}\mid \boldsymbol{\mathbf{x}})) \qquad \qquad &(1)\\
\qquad \\
\displaystyle \mathbb{E}_{q_{\boldsymbol{\mathbf{\phi}}}}[\log p_{\boldsymbol{\mathbf{\theta}}}(\boldsymbol{\mathbf{x}}, \boldsymbol{\mathbf{z}})] - \mathbb{E}_{q_{\boldsymbol{\mathbf{\phi}}}}[\log q_{\boldsymbol{\mathbf{\phi}}}] \qquad \qquad &(2)
\end{cases}
\end{equation*}
Now we can find two identical steps as those of the EM algorithm by performing maximization of the ELBO with respect to $q_{\vphi}$ first, and then with respect to $\vtheta$
E-step: Maximize $(1)$ with respect to $q_{\vphi}$ (this makes the KL-divergence zero and the bound is tight)
$$
\left\{p_{\boldsymbol{\mathbf{\theta}}^{(t)}}(\boldsymbol{\mathbf{z}}\mid \boldsymbol{\mathbf{x}})= \arg\max_{q_{\boldsymbol{\mathbf{\phi}}}} \mathcal{L}_{\boldsymbol{\mathbf{x}}}(\boldsymbol{\mathbf{\theta}}^{(t)}, q_{\boldsymbol{\mathbf{\phi}}})\,\, : \,\, \boldsymbol{\mathbf{x}}\in\mathcal{D}\right\}
$$
M-step: Maximize $(2)$ with respect to $\vtheta$
$$
\boldsymbol{\mathbf{\theta}}^{(t+1)} = \arg\max_{\boldsymbol{\mathbf{\theta}}} \sum_{\boldsymbol{\mathbf{x}}\in\mathcal{D}} \mathcal{L}_{\boldsymbol{\mathbf{x}}}(\boldsymbol{\mathbf{\theta}}, p_{\boldsymbol{\mathbf{\theta}}^{(t)}}(\boldsymbol{\mathbf{z}}\mid \boldsymbol{\mathbf{x}}))
$$
The relationship between the Expectation Maximization algorithm and Variational Auto-Encoders can therefore be summarized as follows:
EM algorithm and VAE optimize the same objective function.
When expectations are in closed-form, one should use the EM algorithm which uses coordinate ascent.
When expectations are intractable, VAE uses stochastic gradient ascent on an unbiased estimator of the objective function. | What is the relationship between VAE and EM algorithm?
What is the relationship between VAE and EM?
$\newcommand{\vect}[1]{\boldsymbol{\mathbf{#1}}}
\newcommand{\vx}{\vect{x}}
\newcommand{\vz}{\vect{z}}
\newcommand{\vtheta}{\vect{\theta}}
\newcommand{\Eb |
28,178 | What is the relationship between VAE and EM algorithm? | As you stated, both EM and VAE are machine learning techniques/algorithms to find the latent variables z. However, despite the overall goal and even the objective function being the same, there are differences because of the complexities of the model.
There are 2 issues at hand where EM (and its variants) have limitations. These are mentioned in the original VAE paper, Auto-Encoding Variational Bayes
by Kingma & Welling.
From section 2.1 of the paper:
Very importantly, we do not make the common simplifying assumptions about the marginal or posterior probabilities. Conversely, we are here interested in a general algorithm that even works efficiently in the case of:
Intractability: the case where the integral of the marginal likelihood $p_\theta(x) = \int p_\theta(z) p_\theta(x|z) ,dz$ is intractable (so we cannot evaluate or differentiate the marginal likelihood), where the true posterior density $p_\theta(z|x) = p_\theta(x|z)p_\theta(z)/p_\theta(x)$ is intractable (so the EM algorithm cannot be used), and where the required integrals for any reasonable mean-field VB algorithm are also intractable. These intractabilities are quite common and appear in cases of moderately complicated likelihood functions $p_\theta(x|z)$, e.g. a neural network with a nonlinear hidden layer.
A large dataset: we have so much data that batch optimization is too costly; we would like to make parameter updates using small minibatches or even single datapoints. Sampling-based solutions, e.g. Monte Carlo EM, would in general be too slow, since it involves a typically expensive sampling loop per datapoint. | What is the relationship between VAE and EM algorithm? | As you stated, both EM and VAE are machine learning techniques/algorithms to find the latent variables z. However, despite the overall goal and even the objective function being the same, there are di | What is the relationship between VAE and EM algorithm?
As you stated, both EM and VAE are machine learning techniques/algorithms to find the latent variables z. However, despite the overall goal and even the objective function being the same, there are differences because of the complexities of the model.
There are 2 issues at hand where EM (and its variants) have limitations. These are mentioned in the original VAE paper, Auto-Encoding Variational Bayes
by Kingma & Welling.
From section 2.1 of the paper:
Very importantly, we do not make the common simplifying assumptions about the marginal or posterior probabilities. Conversely, we are here interested in a general algorithm that even works efficiently in the case of:
Intractability: the case where the integral of the marginal likelihood $p_\theta(x) = \int p_\theta(z) p_\theta(x|z) ,dz$ is intractable (so we cannot evaluate or differentiate the marginal likelihood), where the true posterior density $p_\theta(z|x) = p_\theta(x|z)p_\theta(z)/p_\theta(x)$ is intractable (so the EM algorithm cannot be used), and where the required integrals for any reasonable mean-field VB algorithm are also intractable. These intractabilities are quite common and appear in cases of moderately complicated likelihood functions $p_\theta(x|z)$, e.g. a neural network with a nonlinear hidden layer.
A large dataset: we have so much data that batch optimization is too costly; we would like to make parameter updates using small minibatches or even single datapoints. Sampling-based solutions, e.g. Monte Carlo EM, would in general be too slow, since it involves a typically expensive sampling loop per datapoint. | What is the relationship between VAE and EM algorithm?
As you stated, both EM and VAE are machine learning techniques/algorithms to find the latent variables z. However, despite the overall goal and even the objective function being the same, there are di |
28,179 | What does "version" mean here? | $E(Y\mid x)$ is a conditional expectation, which means it is a random variable.
The distributional properties of random variables are not changed when changes are made to those variables that obviously do not change any probabilities associated with them. In particular, when $X$ and $X^\prime$ are random variables defined on the same probability space $\Omega$ and the chance that they differ is zero, we say each is a "version" of the other.
It is also said that two versions of a random variable are almost surely equal.
Formally, $X^\prime$ is a version of $X$ when there is an event $\mathcal{E}\subset\Omega$ for which
$\mathbb{P}(\mathcal E) = 0$ ($\mathcal E$ is a set of measure zero) and
$X\mid_{\Omega\setminus\mathcal E} = X^\prime\mid_{\Omega\setminus\mathcal E}$ ($X$ and $X^\prime$ are the same function on the complement of $\mathcal E$).
It is an immediate (and obvious) consequence of probability axioms and definitions that $X$ and $X^\prime$ have the same distribution function and that $\mathbb{P}(X\ne X^\prime)=0.$
For instance, let $X$ be a random variable with a standard Normal distribution. Define $X^\prime = X$ for all $\omega\in\Omega$ except for which $X(\omega)=0,$ where we may define $X^\prime = 1$ (say). Because a Normal distribution has zero chance of equalling any particular value like $0,$ this does not change any of the distributional properties of $X:$ $X^\prime$ still has a standard Normal distribution.
The same concepts hold in any measure space. It is possible, depending on the context, that the $f$ in the question is being considered as a function $f:\mathbb{R}\to\mathbb{R}.$ In such cases the sense of "version" means with respect to Lebesgue measure rather than a probability measure. The usual terminology is that two "versions" of a function are equal almost everywhere. Thus, the assertion in the question could mean there exists a function $g$ and a set $\mathcal{E}\subset\mathbb{R}$ of Lebesgue measure zero for which property $(2)$ above holds: that is, apart from their values on $\mathcal E,$ $f$ and $g$ are the same function.
Why is this important and interesting? Because, for instance, the function $g$ defined by
$$g(x) = x^2$$
is everywhere smooth, but the function $f$ defined to equal $g$ on the irrational numbers and otherwise is (say) equal to $-1$ on all rational numbers has no derivative anywhere. Nevertheless, because the rational numbers have Lebesgue measure zero, $g$ is a version of $f.$ In this way we have stripped away "trivial" aspects of $f$ to focus on its basic underlying "structure" as revealed by $g.$ | What does "version" mean here? | $E(Y\mid x)$ is a conditional expectation, which means it is a random variable.
The distributional properties of random variables are not changed when changes are made to those variables that obviou | What does "version" mean here?
$E(Y\mid x)$ is a conditional expectation, which means it is a random variable.
The distributional properties of random variables are not changed when changes are made to those variables that obviously do not change any probabilities associated with them. In particular, when $X$ and $X^\prime$ are random variables defined on the same probability space $\Omega$ and the chance that they differ is zero, we say each is a "version" of the other.
It is also said that two versions of a random variable are almost surely equal.
Formally, $X^\prime$ is a version of $X$ when there is an event $\mathcal{E}\subset\Omega$ for which
$\mathbb{P}(\mathcal E) = 0$ ($\mathcal E$ is a set of measure zero) and
$X\mid_{\Omega\setminus\mathcal E} = X^\prime\mid_{\Omega\setminus\mathcal E}$ ($X$ and $X^\prime$ are the same function on the complement of $\mathcal E$).
It is an immediate (and obvious) consequence of probability axioms and definitions that $X$ and $X^\prime$ have the same distribution function and that $\mathbb{P}(X\ne X^\prime)=0.$
For instance, let $X$ be a random variable with a standard Normal distribution. Define $X^\prime = X$ for all $\omega\in\Omega$ except for which $X(\omega)=0,$ where we may define $X^\prime = 1$ (say). Because a Normal distribution has zero chance of equalling any particular value like $0,$ this does not change any of the distributional properties of $X:$ $X^\prime$ still has a standard Normal distribution.
The same concepts hold in any measure space. It is possible, depending on the context, that the $f$ in the question is being considered as a function $f:\mathbb{R}\to\mathbb{R}.$ In such cases the sense of "version" means with respect to Lebesgue measure rather than a probability measure. The usual terminology is that two "versions" of a function are equal almost everywhere. Thus, the assertion in the question could mean there exists a function $g$ and a set $\mathcal{E}\subset\mathbb{R}$ of Lebesgue measure zero for which property $(2)$ above holds: that is, apart from their values on $\mathcal E,$ $f$ and $g$ are the same function.
Why is this important and interesting? Because, for instance, the function $g$ defined by
$$g(x) = x^2$$
is everywhere smooth, but the function $f$ defined to equal $g$ on the irrational numbers and otherwise is (say) equal to $-1$ on all rational numbers has no derivative anywhere. Nevertheless, because the rational numbers have Lebesgue measure zero, $g$ is a version of $f.$ In this way we have stripped away "trivial" aspects of $f$ to focus on its basic underlying "structure" as revealed by $g.$ | What does "version" mean here?
$E(Y\mid x)$ is a conditional expectation, which means it is a random variable.
The distributional properties of random variables are not changed when changes are made to those variables that obviou |
28,180 | Mathematically, 1 in 3 and 10 in 30 are equal. What about in probabilities? [closed] | The probabilities are the same! However, we would treat the two differently in inference about the proportion.
Let’s construct a 95% confidence interval for the proportion in each case. The usual formula for this is:
$$
\hat{p} \pm 1.96\sqrt{\hat{p}(1-\hat{p})/n}
$$
For 1 in 3 draws, we get:
$$
0.33 \pm 1.96\sqrt{0.33(1-0.33)/3}
$$
For 10 in 30 draws, we get:
$$
0.33 \pm 1.96\sqrt{0.33(1-0.33)/30}
$$
The second situation will give the narrower confidence interval. Likewise, the p-value for a proportion test will be lower in the second case.
However, both cases give the same $1/3$ probability as the $\hat{p}$ proportion. | Mathematically, 1 in 3 and 10 in 30 are equal. What about in probabilities? [closed] | The probabilities are the same! However, we would treat the two differently in inference about the proportion.
Let’s construct a 95% confidence interval for the proportion in each case. The usual form | Mathematically, 1 in 3 and 10 in 30 are equal. What about in probabilities? [closed]
The probabilities are the same! However, we would treat the two differently in inference about the proportion.
Let’s construct a 95% confidence interval for the proportion in each case. The usual formula for this is:
$$
\hat{p} \pm 1.96\sqrt{\hat{p}(1-\hat{p})/n}
$$
For 1 in 3 draws, we get:
$$
0.33 \pm 1.96\sqrt{0.33(1-0.33)/3}
$$
For 10 in 30 draws, we get:
$$
0.33 \pm 1.96\sqrt{0.33(1-0.33)/30}
$$
The second situation will give the narrower confidence interval. Likewise, the p-value for a proportion test will be lower in the second case.
However, both cases give the same $1/3$ probability as the $\hat{p}$ proportion. | Mathematically, 1 in 3 and 10 in 30 are equal. What about in probabilities? [closed]
The probabilities are the same! However, we would treat the two differently in inference about the proportion.
Let’s construct a 95% confidence interval for the proportion in each case. The usual form |
28,181 | Mathematically, 1 in 3 and 10 in 30 are equal. What about in probabilities? [closed] | For the ball problem, the probabilities are the same and $1/3$. For truly random draws, it is neither harder nor smaller to draw one green ball in an urn consisting of 1 green & 2 red vs 1K green & 2K red. Your fighter example doesn't reflect the same situation though. | Mathematically, 1 in 3 and 10 in 30 are equal. What about in probabilities? [closed] | For the ball problem, the probabilities are the same and $1/3$. For truly random draws, it is neither harder nor smaller to draw one green ball in an urn consisting of 1 green & 2 red vs 1K green & 2K | Mathematically, 1 in 3 and 10 in 30 are equal. What about in probabilities? [closed]
For the ball problem, the probabilities are the same and $1/3$. For truly random draws, it is neither harder nor smaller to draw one green ball in an urn consisting of 1 green & 2 red vs 1K green & 2K red. Your fighter example doesn't reflect the same situation though. | Mathematically, 1 in 3 and 10 in 30 are equal. What about in probabilities? [closed]
For the ball problem, the probabilities are the same and $1/3$. For truly random draws, it is neither harder nor smaller to draw one green ball in an urn consisting of 1 green & 2 red vs 1K green & 2K |
28,182 | Mathematically, 1 in 3 and 10 in 30 are equal. What about in probabilities? [closed] | For the ball problem the probabilities are the same because every ball is equally likely to be picked.
In the 3 ball bag there are 3 possible (equally likely) balls. Any ball gets picked on average 1/{number of balls} of the time. in other words, the probability of getting the green ball is 1/3.
In the 30 ball bad there are 30 possible (equally likely) balls. Any ball gets picked on average 1/30 of the time. Suppose all the green balls were numbered 1,2,...,10.
Green1 gets picked 1/30 of the time.
Green2 gets picked 1/30 of the time.
...
Green10 gets picked 1/30 of the time.
So Green gets picked 1/30 + 1/30 + .. 1/30 = 10/30 = 1/3 of the time.
But in the fight
Not all the fighters are equal
Even if the fighters were equal (e.g. they were robots) they could gang up.
Even if the fights were separate i.e. just 10 lots of 1vs2, 1vs2 isn't a random draw.
If all the fighters are equal then I would expect 2 ALWAYS to beat 1! | Mathematically, 1 in 3 and 10 in 30 are equal. What about in probabilities? [closed] | For the ball problem the probabilities are the same because every ball is equally likely to be picked.
In the 3 ball bag there are 3 possible (equally likely) balls. Any ball gets picked on average 1/ | Mathematically, 1 in 3 and 10 in 30 are equal. What about in probabilities? [closed]
For the ball problem the probabilities are the same because every ball is equally likely to be picked.
In the 3 ball bag there are 3 possible (equally likely) balls. Any ball gets picked on average 1/{number of balls} of the time. in other words, the probability of getting the green ball is 1/3.
In the 30 ball bad there are 30 possible (equally likely) balls. Any ball gets picked on average 1/30 of the time. Suppose all the green balls were numbered 1,2,...,10.
Green1 gets picked 1/30 of the time.
Green2 gets picked 1/30 of the time.
...
Green10 gets picked 1/30 of the time.
So Green gets picked 1/30 + 1/30 + .. 1/30 = 10/30 = 1/3 of the time.
But in the fight
Not all the fighters are equal
Even if the fighters were equal (e.g. they were robots) they could gang up.
Even if the fights were separate i.e. just 10 lots of 1vs2, 1vs2 isn't a random draw.
If all the fighters are equal then I would expect 2 ALWAYS to beat 1! | Mathematically, 1 in 3 and 10 in 30 are equal. What about in probabilities? [closed]
For the ball problem the probabilities are the same because every ball is equally likely to be picked.
In the 3 ball bag there are 3 possible (equally likely) balls. Any ball gets picked on average 1/ |
28,183 | Can someone explain to me the parameters of a lognormal distribution? | assume X is lognormally distributed and Y is normally distributed where Y = log(X)
This is where you are confused. You don't make assumptions on two distributions, one of which just happens to be the log of the other.
Instead, you start with a distribution $X$. Then you consider $\log X$. If $\log X\sim N(\mu,\sigma^2)$, then we say that the original distribution $X$ is lognormal with parameters $\mu$ and $\sigma^2$.
(And then the mean of $X$ is $\exp\left(\mu+\frac{\sigma^2}{2}\right)$, for instance, so the parameters are certainly not the same. This is also why it is better to speak of the "parameters" of a lognormal, rather than of the "mean and SD" - because it's very easy to get confused whether these refer to the actual mean or the log-mean, same for SD.) | Can someone explain to me the parameters of a lognormal distribution? | assume X is lognormally distributed and Y is normally distributed where Y = log(X)
This is where you are confused. You don't make assumptions on two distributions, one of which just happens to be the | Can someone explain to me the parameters of a lognormal distribution?
assume X is lognormally distributed and Y is normally distributed where Y = log(X)
This is where you are confused. You don't make assumptions on two distributions, one of which just happens to be the log of the other.
Instead, you start with a distribution $X$. Then you consider $\log X$. If $\log X\sim N(\mu,\sigma^2)$, then we say that the original distribution $X$ is lognormal with parameters $\mu$ and $\sigma^2$.
(And then the mean of $X$ is $\exp\left(\mu+\frac{\sigma^2}{2}\right)$, for instance, so the parameters are certainly not the same. This is also why it is better to speak of the "parameters" of a lognormal, rather than of the "mean and SD" - because it's very easy to get confused whether these refer to the actual mean or the log-mean, same for SD.) | Can someone explain to me the parameters of a lognormal distribution?
assume X is lognormally distributed and Y is normally distributed where Y = log(X)
This is where you are confused. You don't make assumptions on two distributions, one of which just happens to be the |
28,184 | Can someone explain to me the parameters of a lognormal distribution? | Wikipedia has a nice article on log-normal distributions: https://en.m.wikipedia.org/wiki/Log-normal_distribution. The article reveals that the log-normally distributed X and the normally distributed log(X) have different means and standard deviations.
If X follows a log-normal distribution with parameters $\mu$ and $\sigma$, then $\mu$ and $\sigma$ represent the mean and standard deviation of the distribution of log(X), which is normal. In other words, the mean and standard deviation of the normally distributed log(X) are:
Mean of $\log(X)=\mu$
SD of $\log(X) = \sigma$
The mean and standard deviation of the log-normally distributed X are as follows:
Mean of X = $\exp(\mu + \sigma^2/2)$
SD of X = $\sqrt{\left[\exp\left(\sigma^2\right) - 1\right] \cdot \exp(2\mu + \sigma^2)}$ | Can someone explain to me the parameters of a lognormal distribution? | Wikipedia has a nice article on log-normal distributions: https://en.m.wikipedia.org/wiki/Log-normal_distribution. The article reveals that the log-normally distributed X and the normally distributed | Can someone explain to me the parameters of a lognormal distribution?
Wikipedia has a nice article on log-normal distributions: https://en.m.wikipedia.org/wiki/Log-normal_distribution. The article reveals that the log-normally distributed X and the normally distributed log(X) have different means and standard deviations.
If X follows a log-normal distribution with parameters $\mu$ and $\sigma$, then $\mu$ and $\sigma$ represent the mean and standard deviation of the distribution of log(X), which is normal. In other words, the mean and standard deviation of the normally distributed log(X) are:
Mean of $\log(X)=\mu$
SD of $\log(X) = \sigma$
The mean and standard deviation of the log-normally distributed X are as follows:
Mean of X = $\exp(\mu + \sigma^2/2)$
SD of X = $\sqrt{\left[\exp\left(\sigma^2\right) - 1\right] \cdot \exp(2\mu + \sigma^2)}$ | Can someone explain to me the parameters of a lognormal distribution?
Wikipedia has a nice article on log-normal distributions: https://en.m.wikipedia.org/wiki/Log-normal_distribution. The article reveals that the log-normally distributed X and the normally distributed |
28,185 | Why there is square in MSE (mean squared error)? | MSE has some desirable properties such as easier differentiability (as @user2974951 comments) for further analysis. Differentiability of objective function is in general very important to perform analytical calculations. Taking absolute values is called Mean Absolute Error (MAE in short). It also has applications. It's not like we always prefer MSE or MAE. Another reason, might be penalising large errors more, because if your error is large, its square is much larger. For example, if some error term, $e_i$ is 999, and the other, $e_j$, is $50$; and if we are to choose which term to decrease by an amount of $1$, MAE can choose any of them. But, MSE aims at the larger one since the square decrease is higher. | Why there is square in MSE (mean squared error)? | MSE has some desirable properties such as easier differentiability (as @user2974951 comments) for further analysis. Differentiability of objective function is in general very important to perform anal | Why there is square in MSE (mean squared error)?
MSE has some desirable properties such as easier differentiability (as @user2974951 comments) for further analysis. Differentiability of objective function is in general very important to perform analytical calculations. Taking absolute values is called Mean Absolute Error (MAE in short). It also has applications. It's not like we always prefer MSE or MAE. Another reason, might be penalising large errors more, because if your error is large, its square is much larger. For example, if some error term, $e_i$ is 999, and the other, $e_j$, is $50$; and if we are to choose which term to decrease by an amount of $1$, MAE can choose any of them. But, MSE aims at the larger one since the square decrease is higher. | Why there is square in MSE (mean squared error)?
MSE has some desirable properties such as easier differentiability (as @user2974951 comments) for further analysis. Differentiability of objective function is in general very important to perform anal |
28,186 | Why there is square in MSE (mean squared error)? | If $\hat{\theta}$ is an estimator of the parameter $\theta$ then the MSE $\mathbb{E}[(\hat{\theta} - \theta)^2]$ is the sum of the variance of $\hat{\theta}$ and the square bias :
\begin{align*}
\mathbb{E}[(\hat{\theta} - \theta)^2] &= \mathbb{E}\big [ \hat{\theta}^2 - 2\hat{\theta}\theta + \theta^2\big ] \\
&= \mathbb{E}[\hat{\theta}^2] -2\theta\mathbb{E}[\hat{\theta}] + \theta^2 \\
&=\mathbb{E}[\hat{\theta}^2] - \mathbb{E}[\hat{\theta}]^2 + \mathbb{E}[\hat{\theta}]^2 - 2\theta\mathbb{E}[\hat{\theta}] + \theta^2 \\
&= \text{Var}(\hat{\theta}) + (\mathbb{E}[\hat{\theta}] - \theta )^2 \\
&= \text{Var}(\hat{\theta}) + \text{Bias}(\hat{\theta})^2
\end{align*}
The MSE is thus made of two important characteristics of an estimator : bias and variance. An estimator may have a small bias but if it has a large variance it's not interesting. On the other hand, an estimator may be very precise, i.e small variance, but if it has a large bias it's also not interesting. The MSE takes both into account.
Moreover, one property of the MSE is that if $\hat{\theta}$ depends on $n$, the size of the sample, then if MSE($\hat{\theta}_n) \to 0$ as $n \to +\infty$ (thus both variance and bias converge to zero) $\hat{\theta}_n$ is consistent, i.e it converges in probability to $\theta$. | Why there is square in MSE (mean squared error)? | If $\hat{\theta}$ is an estimator of the parameter $\theta$ then the MSE $\mathbb{E}[(\hat{\theta} - \theta)^2]$ is the sum of the variance of $\hat{\theta}$ and the square bias :
\begin{align*}
\mat | Why there is square in MSE (mean squared error)?
If $\hat{\theta}$ is an estimator of the parameter $\theta$ then the MSE $\mathbb{E}[(\hat{\theta} - \theta)^2]$ is the sum of the variance of $\hat{\theta}$ and the square bias :
\begin{align*}
\mathbb{E}[(\hat{\theta} - \theta)^2] &= \mathbb{E}\big [ \hat{\theta}^2 - 2\hat{\theta}\theta + \theta^2\big ] \\
&= \mathbb{E}[\hat{\theta}^2] -2\theta\mathbb{E}[\hat{\theta}] + \theta^2 \\
&=\mathbb{E}[\hat{\theta}^2] - \mathbb{E}[\hat{\theta}]^2 + \mathbb{E}[\hat{\theta}]^2 - 2\theta\mathbb{E}[\hat{\theta}] + \theta^2 \\
&= \text{Var}(\hat{\theta}) + (\mathbb{E}[\hat{\theta}] - \theta )^2 \\
&= \text{Var}(\hat{\theta}) + \text{Bias}(\hat{\theta})^2
\end{align*}
The MSE is thus made of two important characteristics of an estimator : bias and variance. An estimator may have a small bias but if it has a large variance it's not interesting. On the other hand, an estimator may be very precise, i.e small variance, but if it has a large bias it's also not interesting. The MSE takes both into account.
Moreover, one property of the MSE is that if $\hat{\theta}$ depends on $n$, the size of the sample, then if MSE($\hat{\theta}_n) \to 0$ as $n \to +\infty$ (thus both variance and bias converge to zero) $\hat{\theta}_n$ is consistent, i.e it converges in probability to $\theta$. | Why there is square in MSE (mean squared error)?
If $\hat{\theta}$ is an estimator of the parameter $\theta$ then the MSE $\mathbb{E}[(\hat{\theta} - \theta)^2]$ is the sum of the variance of $\hat{\theta}$ and the square bias :
\begin{align*}
\mat |
28,187 | Why there is square in MSE (mean squared error)? | I think the some of the answers here aren’t fully answering the question. If we are penalizing the error more wouldn’t squaring it be rather arbitrary? If the mean squared error for one estimator (MSE1) is larger than the mean squared error for another estimator (MSE2) than sqrt(MSE1) > sqrt(MSE2) (proof: https://math.stackexchange.com/questions/1494484/using-proof-by-contradiction-to-show-that-xy-implies-sqrt-x-sqrt-y/1494511). The order is preserved and you are not changing anything by taking the square root and in fact not further penalizing anything.
The mean squared error (MSE) is the “distance” between the true value and the estimated value. The distance you are used to seeing is Euclidean distance in one dimension (i.e. sqrt((difference between two points)^2) ). But, how can we measure the distance between other objects? For example, how can we measure the distance between two functions? At some points of the function, the “y-value” is higher for one function and at other points the “y-value” is higher for the other function. In order to define a distance between two functions, we need a more abstract definition for distance. We will call this abstract distance a metric and we would like it to follow the following properties:
1. the distance between two objects cannot be negative
2. the distance from “A to B” is the same as the distance from “B to A”
3. the distance from “A to C” is less than or equal to the distance from “A to B” plus the distance from “B to C”
So coming back to our example of how to measure the distance between two function, if we define a metric as one function is x distance away from another function by the absolute value of the difference between the maximum y-values of the two functions, then that metric satisfies the three properties. So if g(x) can take values of 1 to 5 for all possible values of x and f(x) can take values 2 to 4 for all values of x, then the distance between g and f is 5–4=1.
Now getting back to your original question, the answer is squaring the difference between the true value and the estimated value satisfies those three properties for distance (so we don’t need to take a square root). It is the same for variance. The variance is the weighted sum of the distances between possible outcomes and the mean. The standard deviation is the square root of the variance. The reason we sometimes use standard deviation as the measure of dispersion is because the variance is in squared units. For example, (5 feet - 1 feet)^2 = 16 feet^2. How can we compare 16 feet^2 with anything that is in just feet? By taking the square root, we can compare 4 feet with other things measured in feet.
So to summarize, it doesn’t really matter if you take the square root, it’s still just measuring the distance between two thing. For variance, we want to compare it to other things with the same unit so we use standard deviation. MSE is only being compared to other MSEs so there is no need to take the square root.
Note: some of the things I wrote are not so rigorously shown or stated, but I just wanted to give you the idea of how it works. | Why there is square in MSE (mean squared error)? | I think the some of the answers here aren’t fully answering the question. If we are penalizing the error more wouldn’t squaring it be rather arbitrary? If the mean squared error for one estimator (MSE | Why there is square in MSE (mean squared error)?
I think the some of the answers here aren’t fully answering the question. If we are penalizing the error more wouldn’t squaring it be rather arbitrary? If the mean squared error for one estimator (MSE1) is larger than the mean squared error for another estimator (MSE2) than sqrt(MSE1) > sqrt(MSE2) (proof: https://math.stackexchange.com/questions/1494484/using-proof-by-contradiction-to-show-that-xy-implies-sqrt-x-sqrt-y/1494511). The order is preserved and you are not changing anything by taking the square root and in fact not further penalizing anything.
The mean squared error (MSE) is the “distance” between the true value and the estimated value. The distance you are used to seeing is Euclidean distance in one dimension (i.e. sqrt((difference between two points)^2) ). But, how can we measure the distance between other objects? For example, how can we measure the distance between two functions? At some points of the function, the “y-value” is higher for one function and at other points the “y-value” is higher for the other function. In order to define a distance between two functions, we need a more abstract definition for distance. We will call this abstract distance a metric and we would like it to follow the following properties:
1. the distance between two objects cannot be negative
2. the distance from “A to B” is the same as the distance from “B to A”
3. the distance from “A to C” is less than or equal to the distance from “A to B” plus the distance from “B to C”
So coming back to our example of how to measure the distance between two function, if we define a metric as one function is x distance away from another function by the absolute value of the difference between the maximum y-values of the two functions, then that metric satisfies the three properties. So if g(x) can take values of 1 to 5 for all possible values of x and f(x) can take values 2 to 4 for all values of x, then the distance between g and f is 5–4=1.
Now getting back to your original question, the answer is squaring the difference between the true value and the estimated value satisfies those three properties for distance (so we don’t need to take a square root). It is the same for variance. The variance is the weighted sum of the distances between possible outcomes and the mean. The standard deviation is the square root of the variance. The reason we sometimes use standard deviation as the measure of dispersion is because the variance is in squared units. For example, (5 feet - 1 feet)^2 = 16 feet^2. How can we compare 16 feet^2 with anything that is in just feet? By taking the square root, we can compare 4 feet with other things measured in feet.
So to summarize, it doesn’t really matter if you take the square root, it’s still just measuring the distance between two thing. For variance, we want to compare it to other things with the same unit so we use standard deviation. MSE is only being compared to other MSEs so there is no need to take the square root.
Note: some of the things I wrote are not so rigorously shown or stated, but I just wanted to give you the idea of how it works. | Why there is square in MSE (mean squared error)?
I think the some of the answers here aren’t fully answering the question. If we are penalizing the error more wouldn’t squaring it be rather arbitrary? If the mean squared error for one estimator (MSE |
28,188 | Posterior Predictive Distribution as Expectation of Likelihood | $\newcommand{\y}{\mathbf y}$We have
$$
E_{\theta|\y}\left[f(\theta)\right] = \int f(\theta) p(\theta | \y)\,\text d\theta
$$
just by definition of expectation (and you could cite the LOTUS as well), and since $p(\theta|\y)$ is the posterior density this is the posterior expectation of $f(\theta)$. Now choose
$$
f(\theta) = p(\tilde y | \theta)
$$
and then
$$
E_{\theta|\y}\left[p(\tilde y | \theta)\right] = \int p(\tilde y | \theta) p(\theta | \y)\,\text d\theta.
$$
I'm not sure if you also are wondering about the justification of this integral in the first place, but typically the data are assumed independent given the generating parameters so for a new point $\tilde y$ you'd have $\tilde y \perp \y | \theta$ which means
$$
p(\tilde y | \y) = \int p(\tilde y , \theta | \y)\,\text d\theta \\
= \int p(\tilde y | \theta , \y) p(\theta | \y)\,\text d\theta \\
= \int p(\tilde y | \theta) p(\theta | \y)\,\text d\theta \\
= E_{\theta|\y}\left[p(\tilde y | \theta)\right]
$$
so you can use the law of large numbers with posterior samples to produce an estimator of this density. | Posterior Predictive Distribution as Expectation of Likelihood | $\newcommand{\y}{\mathbf y}$We have
$$
E_{\theta|\y}\left[f(\theta)\right] = \int f(\theta) p(\theta | \y)\,\text d\theta
$$
just by definition of expectation (and you could cite the LOTUS as well), | Posterior Predictive Distribution as Expectation of Likelihood
$\newcommand{\y}{\mathbf y}$We have
$$
E_{\theta|\y}\left[f(\theta)\right] = \int f(\theta) p(\theta | \y)\,\text d\theta
$$
just by definition of expectation (and you could cite the LOTUS as well), and since $p(\theta|\y)$ is the posterior density this is the posterior expectation of $f(\theta)$. Now choose
$$
f(\theta) = p(\tilde y | \theta)
$$
and then
$$
E_{\theta|\y}\left[p(\tilde y | \theta)\right] = \int p(\tilde y | \theta) p(\theta | \y)\,\text d\theta.
$$
I'm not sure if you also are wondering about the justification of this integral in the first place, but typically the data are assumed independent given the generating parameters so for a new point $\tilde y$ you'd have $\tilde y \perp \y | \theta$ which means
$$
p(\tilde y | \y) = \int p(\tilde y , \theta | \y)\,\text d\theta \\
= \int p(\tilde y | \theta , \y) p(\theta | \y)\,\text d\theta \\
= \int p(\tilde y | \theta) p(\theta | \y)\,\text d\theta \\
= E_{\theta|\y}\left[p(\tilde y | \theta)\right]
$$
so you can use the law of large numbers with posterior samples to produce an estimator of this density. | Posterior Predictive Distribution as Expectation of Likelihood
$\newcommand{\y}{\mathbf y}$We have
$$
E_{\theta|\y}\left[f(\theta)\right] = \int f(\theta) p(\theta | \y)\,\text d\theta
$$
just by definition of expectation (and you could cite the LOTUS as well), |
28,189 | Raising a variance-covariance matrix to a negative half power | What the operation $C^{-\frac{1}{2}}$ refers at is the decorrelation of the underlying sample to uncorrelated components; $C^{-\frac{1}{2}}$ is used as whitening matrix. This is natural operation when looking to analyse each column/source of the original data matrix $A$ (having a covariance matrix $C$), through an uncorrelated matrix $Z$. The most common way of implementing such whitening is through the Cholesky decomposition (where we use $C = LL^T$, see this thread for an example with "colouring" a sample) but here we use slightly less uncommon Mahalanobis whitening (where we use $C= C^{0.5} C^{0.5}$).
The whole operation in R would go a bit like this:
set.seed(323)
N <- 10000;
p <- 3;
# Define the real C
( C <- base::matrix( data =c(4,2,1,2,3,2,1,2,3), ncol = 3, byrow= TRUE) )
# Generate the uncorrelated data (ground truth)
Z <- base::matrix( ncol = 3, rnorm(N*p) )
# Estimate the colouring matrix C^0.5
CSqrt <- expm::sqrtm(C)
# "Colour" the data / usually we use Cholesky (LL^T) but using C^0.5 valid too
A <- t( CSqrt %*% t(Z) )
# Get the sample estimated C
( CEst <- round( digits = 2, cov( A )) )
# Estimate the whitening matrix C^-0.5
CEstInv <- expm::sqrtm(solve(CEst))
# Whiten the data
ZEst <- t(CEstInv %*% t(A) )
# Check that indeed we have whitened the data
( round( digits = 1, cov(cbind(ZEst, Z) ) ) )
So to succinctly answer the question raised:
It means that we can decorrelate the sample $A$ that is associated with that covariance matrix $C$ in such way that we get uncorrelated components. This is commonly referred as whitening.
The general Linear Algebra idea it assumes is that a (covariance) matrix can be used as a projection operator (to generate a correlated sample by "colouring") but so does the inverse of it (to decorrelate/"whiten" a sample).
Yes, the easiest way to raise a valid covariance matrix to any power (the negative square root is just a special case) by using the eigen-decomposition of it; $C = V \Lambda V^T$, $V$ being an orthonormal matrix holding the eigenvectors of $C$ and $\Lambda$ being a diagonal matrix holding the eigenvalues. Then we can readily change the diagonal matrix $\Lambda$ as we wish and get the relevant result.
A small code snippet showcasing point 3.
# Get the eigendecomposition of the covariance matrix
myEigDec <- eigen(cov(A))
# Use the eigendecomposition to get the inverse square root
myEigDec$vectors %*% diag( 1/ sqrt( myEigDec$values) ) %*% t(myEigDec$vectors)
# Use the eigendecomposition to get the "negative half power" (same as above)
myEigDec$vectors %*% diag( ( myEigDec$values)^(-0.5) ) %*% t(myEigDec$vectors)
# And to confirm by the R library expm
solve(expm::sqrtm(cov(A))) | Raising a variance-covariance matrix to a negative half power | What the operation $C^{-\frac{1}{2}}$ refers at is the decorrelation of the underlying sample to uncorrelated components; $C^{-\frac{1}{2}}$ is used as whitening matrix. This is natural operation whe | Raising a variance-covariance matrix to a negative half power
What the operation $C^{-\frac{1}{2}}$ refers at is the decorrelation of the underlying sample to uncorrelated components; $C^{-\frac{1}{2}}$ is used as whitening matrix. This is natural operation when looking to analyse each column/source of the original data matrix $A$ (having a covariance matrix $C$), through an uncorrelated matrix $Z$. The most common way of implementing such whitening is through the Cholesky decomposition (where we use $C = LL^T$, see this thread for an example with "colouring" a sample) but here we use slightly less uncommon Mahalanobis whitening (where we use $C= C^{0.5} C^{0.5}$).
The whole operation in R would go a bit like this:
set.seed(323)
N <- 10000;
p <- 3;
# Define the real C
( C <- base::matrix( data =c(4,2,1,2,3,2,1,2,3), ncol = 3, byrow= TRUE) )
# Generate the uncorrelated data (ground truth)
Z <- base::matrix( ncol = 3, rnorm(N*p) )
# Estimate the colouring matrix C^0.5
CSqrt <- expm::sqrtm(C)
# "Colour" the data / usually we use Cholesky (LL^T) but using C^0.5 valid too
A <- t( CSqrt %*% t(Z) )
# Get the sample estimated C
( CEst <- round( digits = 2, cov( A )) )
# Estimate the whitening matrix C^-0.5
CEstInv <- expm::sqrtm(solve(CEst))
# Whiten the data
ZEst <- t(CEstInv %*% t(A) )
# Check that indeed we have whitened the data
( round( digits = 1, cov(cbind(ZEst, Z) ) ) )
So to succinctly answer the question raised:
It means that we can decorrelate the sample $A$ that is associated with that covariance matrix $C$ in such way that we get uncorrelated components. This is commonly referred as whitening.
The general Linear Algebra idea it assumes is that a (covariance) matrix can be used as a projection operator (to generate a correlated sample by "colouring") but so does the inverse of it (to decorrelate/"whiten" a sample).
Yes, the easiest way to raise a valid covariance matrix to any power (the negative square root is just a special case) by using the eigen-decomposition of it; $C = V \Lambda V^T$, $V$ being an orthonormal matrix holding the eigenvectors of $C$ and $\Lambda$ being a diagonal matrix holding the eigenvalues. Then we can readily change the diagonal matrix $\Lambda$ as we wish and get the relevant result.
A small code snippet showcasing point 3.
# Get the eigendecomposition of the covariance matrix
myEigDec <- eigen(cov(A))
# Use the eigendecomposition to get the inverse square root
myEigDec$vectors %*% diag( 1/ sqrt( myEigDec$values) ) %*% t(myEigDec$vectors)
# Use the eigendecomposition to get the "negative half power" (same as above)
myEigDec$vectors %*% diag( ( myEigDec$values)^(-0.5) ) %*% t(myEigDec$vectors)
# And to confirm by the R library expm
solve(expm::sqrtm(cov(A))) | Raising a variance-covariance matrix to a negative half power
What the operation $C^{-\frac{1}{2}}$ refers at is the decorrelation of the underlying sample to uncorrelated components; $C^{-\frac{1}{2}}$ is used as whitening matrix. This is natural operation whe |
28,190 | Raising a variance-covariance matrix to a negative half power | What does it mean to raise a covariance matrix to a negative half power?
Usually this notation is used when a matrix is raised to a negative integer power. In this case, the notation is a shortform for taking an inverse and raising to a power. I.e. $A^{-2} = (A^2)^{-1} = (A^{-1})^2$. See this question.
This can be extended to fractional powers. The first question is: What does $A^{1/2}$ mean? Well, if $B$ is the square root of a matrix $A$, that means that $BB = A$.
This question proves that the square root of the inverse is equal to the inverse of the square root, so it makes sense to define $A^{-1/2} = (A^{1/2})^{-1} = (A^{-1})^{1/2}$.
What general ideas of linear algebra does this assume?
If a matrix is positive semi-definite, it has a real square root (and a unique positive semi-definite square root). Fortunately for your purposes, any valid covariance matrix is positive semi-definite.
Is there any nice formula to raise a covariance matrix to a negative half power?
Using the definition, you should combine methods for finding inverses and finding matrix square roots. (I.e. find the inverse, then find the square root.) These problems are well-known and you shouldn't have a problem finding algorithms. | Raising a variance-covariance matrix to a negative half power | What does it mean to raise a covariance matrix to a negative half power?
Usually this notation is used when a matrix is raised to a negative integer power. In this case, the notation is a shortform f | Raising a variance-covariance matrix to a negative half power
What does it mean to raise a covariance matrix to a negative half power?
Usually this notation is used when a matrix is raised to a negative integer power. In this case, the notation is a shortform for taking an inverse and raising to a power. I.e. $A^{-2} = (A^2)^{-1} = (A^{-1})^2$. See this question.
This can be extended to fractional powers. The first question is: What does $A^{1/2}$ mean? Well, if $B$ is the square root of a matrix $A$, that means that $BB = A$.
This question proves that the square root of the inverse is equal to the inverse of the square root, so it makes sense to define $A^{-1/2} = (A^{1/2})^{-1} = (A^{-1})^{1/2}$.
What general ideas of linear algebra does this assume?
If a matrix is positive semi-definite, it has a real square root (and a unique positive semi-definite square root). Fortunately for your purposes, any valid covariance matrix is positive semi-definite.
Is there any nice formula to raise a covariance matrix to a negative half power?
Using the definition, you should combine methods for finding inverses and finding matrix square roots. (I.e. find the inverse, then find the square root.) These problems are well-known and you shouldn't have a problem finding algorithms. | Raising a variance-covariance matrix to a negative half power
What does it mean to raise a covariance matrix to a negative half power?
Usually this notation is used when a matrix is raised to a negative integer power. In this case, the notation is a shortform f |
28,191 | How does number of thresholds get chosen in roc_curve function in scikit-learn? | By definition, a ROC curve represent all possible thresholds in the interval $(-\infty, +\infty)$.
This number is infinite and of course cannot be represented with a computer. Fortunately when you have some data you can simplify this and only visit a limited number of thresholds.
This number corresponds to the number of unique values in the data + 1, or something like:
n_thresholds = len(np.unique(x)) + 1
where x is the array holding your target scores (y_score). | How does number of thresholds get chosen in roc_curve function in scikit-learn? | By definition, a ROC curve represent all possible thresholds in the interval $(-\infty, +\infty)$.
This number is infinite and of course cannot be represented with a computer. Fortunately when you hav | How does number of thresholds get chosen in roc_curve function in scikit-learn?
By definition, a ROC curve represent all possible thresholds in the interval $(-\infty, +\infty)$.
This number is infinite and of course cannot be represented with a computer. Fortunately when you have some data you can simplify this and only visit a limited number of thresholds.
This number corresponds to the number of unique values in the data + 1, or something like:
n_thresholds = len(np.unique(x)) + 1
where x is the array holding your target scores (y_score). | How does number of thresholds get chosen in roc_curve function in scikit-learn?
By definition, a ROC curve represent all possible thresholds in the interval $(-\infty, +\infty)$.
This number is infinite and of course cannot be represented with a computer. Fortunately when you hav |
28,192 | How does number of thresholds get chosen in roc_curve function in scikit-learn? | n_thresholds = len(np.unique(x)) + 1
The threshold is a continuous numerical variable but only some are not suboptimal/useful, meaning that only those thresholds would affect the confusion matrix(and hence true positive rate or/and false positive rate, and hence the ROC plot).
Which threshold would affect the confusion matrix? The unique values of data, if you move the threshold from a number greater than a unique value to a number smaller than that, the confusion matrix must change. But if you move the threshold between any two unique neighbouring data values, any value in the resultant confusion matrix would remain the same, and hence those thresholds are suboptimal.
But why add one?
thresholds[0] represents no instances being predicted and is arbitrarily set to max(y_score) + 1
Source: sklearn.metrics.roc_curve
Because it starts with the largest value in data + 1.
Reference:
ROC and AUC, Clearly Explained! | How does number of thresholds get chosen in roc_curve function in scikit-learn? | n_thresholds = len(np.unique(x)) + 1
The threshold is a continuous numerical variable but only some are not suboptimal/useful, meaning that only those thresholds would affect the confusion matrix(and | How does number of thresholds get chosen in roc_curve function in scikit-learn?
n_thresholds = len(np.unique(x)) + 1
The threshold is a continuous numerical variable but only some are not suboptimal/useful, meaning that only those thresholds would affect the confusion matrix(and hence true positive rate or/and false positive rate, and hence the ROC plot).
Which threshold would affect the confusion matrix? The unique values of data, if you move the threshold from a number greater than a unique value to a number smaller than that, the confusion matrix must change. But if you move the threshold between any two unique neighbouring data values, any value in the resultant confusion matrix would remain the same, and hence those thresholds are suboptimal.
But why add one?
thresholds[0] represents no instances being predicted and is arbitrarily set to max(y_score) + 1
Source: sklearn.metrics.roc_curve
Because it starts with the largest value in data + 1.
Reference:
ROC and AUC, Clearly Explained! | How does number of thresholds get chosen in roc_curve function in scikit-learn?
n_thresholds = len(np.unique(x)) + 1
The threshold is a continuous numerical variable but only some are not suboptimal/useful, meaning that only those thresholds would affect the confusion matrix(and |
28,193 | How does number of thresholds get chosen in roc_curve function in scikit-learn? | You can inspect the code for sklearn.metrics.roc_curve to see how it determines the number of thresholds returned. I looked at it briefly, and it says that it attempts to drop thresholds that are suboptimal (whatever that means) and these do not appear on the ROC curve. So the number of thresholds is not always equal to the number of scores. | How does number of thresholds get chosen in roc_curve function in scikit-learn? | You can inspect the code for sklearn.metrics.roc_curve to see how it determines the number of thresholds returned. I looked at it briefly, and it says that it attempts to drop thresholds that are subo | How does number of thresholds get chosen in roc_curve function in scikit-learn?
You can inspect the code for sklearn.metrics.roc_curve to see how it determines the number of thresholds returned. I looked at it briefly, and it says that it attempts to drop thresholds that are suboptimal (whatever that means) and these do not appear on the ROC curve. So the number of thresholds is not always equal to the number of scores. | How does number of thresholds get chosen in roc_curve function in scikit-learn?
You can inspect the code for sklearn.metrics.roc_curve to see how it determines the number of thresholds returned. I looked at it briefly, and it says that it attempts to drop thresholds that are subo |
28,194 | Cross-validation for timeseries data with regression | For the first question, as Richard Hardy points out, there is an excellent blog post on the topic. There is also this post and this post which I have found very helpful.
For the second question, you need to take into account the two basic approaches to multistep times series forecasting: Recursive forecasting and direct forecasting:
In recursive forecasting (also called iterated forecasting) you train your model for one step ahead forecasts only. After the training is done you apply your final model recursively to forecast 1 step ahead, 2 steps ahead, etc...until you reach the desired $n$ steps forecast horizon. To do this, you feed the forecast from each successive step back into the model to generate the next step. This approach is used by traditional forecasting algorithms like ARIMA and Exponential Smoothing algorithms, and can be also used for Machine Learning based forecasting (see this post for an example, and this post for some discussion).
Direct forecasting is when you train a separate model for each step (so you trying to "directly" forecast the $n^{th}$ step ahead instead of reaching $n$ steps recursively. See Ben Taied et al. for a discussion of direct forecasting and more complex combined approaches.
Note that Hyndman's blog post on cross validation for time series covers both one step ahead and direct forecasting.
To clarify recursive forecasting (based on the comments):
First you train your model.
Once training is done, you take $[Y_1, Y_2,....Y_t]$ to calculate $\hat{Y}_{t+1}$ (this is your 1 step ahead forecast),
then you use $[Y_2,..., Y_t,\hat{Y}_{t+1}]$ to calculate $\hat{Y}_{t+2}$, then $[Y_3,..., Y_t,\hat{Y}_{t+1}, \hat{Y}_{t+2}]$ to calculate $\hat{Y}_{t+3}$, and so on...until you reach $\hat{Y}_{t+n}$.
(Here $Y$ are actual values and $\hat{Y}$ are forecast values.) | Cross-validation for timeseries data with regression | For the first question, as Richard Hardy points out, there is an excellent blog post on the topic. There is also this post and this post which I have found very helpful.
For the second question, you | Cross-validation for timeseries data with regression
For the first question, as Richard Hardy points out, there is an excellent blog post on the topic. There is also this post and this post which I have found very helpful.
For the second question, you need to take into account the two basic approaches to multistep times series forecasting: Recursive forecasting and direct forecasting:
In recursive forecasting (also called iterated forecasting) you train your model for one step ahead forecasts only. After the training is done you apply your final model recursively to forecast 1 step ahead, 2 steps ahead, etc...until you reach the desired $n$ steps forecast horizon. To do this, you feed the forecast from each successive step back into the model to generate the next step. This approach is used by traditional forecasting algorithms like ARIMA and Exponential Smoothing algorithms, and can be also used for Machine Learning based forecasting (see this post for an example, and this post for some discussion).
Direct forecasting is when you train a separate model for each step (so you trying to "directly" forecast the $n^{th}$ step ahead instead of reaching $n$ steps recursively. See Ben Taied et al. for a discussion of direct forecasting and more complex combined approaches.
Note that Hyndman's blog post on cross validation for time series covers both one step ahead and direct forecasting.
To clarify recursive forecasting (based on the comments):
First you train your model.
Once training is done, you take $[Y_1, Y_2,....Y_t]$ to calculate $\hat{Y}_{t+1}$ (this is your 1 step ahead forecast),
then you use $[Y_2,..., Y_t,\hat{Y}_{t+1}]$ to calculate $\hat{Y}_{t+2}$, then $[Y_3,..., Y_t,\hat{Y}_{t+1}, \hat{Y}_{t+2}]$ to calculate $\hat{Y}_{t+3}$, and so on...until you reach $\hat{Y}_{t+n}$.
(Here $Y$ are actual values and $\hat{Y}$ are forecast values.) | Cross-validation for timeseries data with regression
For the first question, as Richard Hardy points out, there is an excellent blog post on the topic. There is also this post and this post which I have found very helpful.
For the second question, you |
28,195 | Hiding a Regression Model from Professor (Regression Battleship) [closed] | Simply make error term much larger than the explained part. For instance: $y_i=X_{i1}+\epsilon_i$, where $X_{ij}=\sin(i+j)$, $i=1..1000$ and $\sigma=1000000$. Of course, you have to remember what was your seed, so that you can prove to your professor that you were right and he was wrong.
Good luck identifying the phase with this noise/signal ratio. | Hiding a Regression Model from Professor (Regression Battleship) [closed] | Simply make error term much larger than the explained part. For instance: $y_i=X_{i1}+\epsilon_i$, where $X_{ij}=\sin(i+j)$, $i=1..1000$ and $\sigma=1000000$. Of course, you have to remember what was | Hiding a Regression Model from Professor (Regression Battleship) [closed]
Simply make error term much larger than the explained part. For instance: $y_i=X_{i1}+\epsilon_i$, where $X_{ij}=\sin(i+j)$, $i=1..1000$ and $\sigma=1000000$. Of course, you have to remember what was your seed, so that you can prove to your professor that you were right and he was wrong.
Good luck identifying the phase with this noise/signal ratio. | Hiding a Regression Model from Professor (Regression Battleship) [closed]
Simply make error term much larger than the explained part. For instance: $y_i=X_{i1}+\epsilon_i$, where $X_{ij}=\sin(i+j)$, $i=1..1000$ and $\sigma=1000000$. Of course, you have to remember what was |
28,196 | Hiding a Regression Model from Professor (Regression Battleship) [closed] | If his goal is to recover the true data generating process that creates $Y$, fooling your professor is fairly trivial. To give you an example, consider disturbances $\epsilon_i\sim N(0,1)$ and the following structural equations:
$$
X_1 = \epsilon_1 + \epsilon_0\\
X_2 =\epsilon_1 + \epsilon_2\\
y = X_1 + \epsilon_2
$$
Note the true DGP of $Y$, which includes only $X_1$, trivially satisfy condition 2. Condition 3 is also satisfied, since $X_1$ is the only variable to create $Y$ and you are providing $X_1$ and $X_2$.
Yet, there's no way your professor can tell if he should include only $X_1$ only $X_2$ or $X_1$ and $X_2$ to recover the true DGP of $Y$ (if you end up using this example, change the number of the variables). Most likely, he will just give you as an answer the regression with all variables, since they will all show up as significant predictors. You can extend this to 20 variables if you want to, you might want to check this answer here and a Simpson's paradox machine here.
Note all conditional expectations $E[Y|X_1]$, $E[Y|X_2]$ or $E[Y|X_1, X_2]$ are correctly specified conditional expectations, but only $E[Y|X_1]$ reflects the true DGP of $Y$. Thus, after your professor inevitably fails the task, he might argue that his goal was simply to recover any conditional expectation, or to get the best prediction of $Y$ etc. You can argue back that it wasn't what he said, since he states:
variable Y must come from a linear regression model that satisfies (...) variables that were used to create Y (...) your real model (...)
And you might spark a good discussion in class about causality, what true DGP means and identifiability in general. | Hiding a Regression Model from Professor (Regression Battleship) [closed] | If his goal is to recover the true data generating process that creates $Y$, fooling your professor is fairly trivial. To give you an example, consider disturbances $\epsilon_i\sim N(0,1)$ and the fol | Hiding a Regression Model from Professor (Regression Battleship) [closed]
If his goal is to recover the true data generating process that creates $Y$, fooling your professor is fairly trivial. To give you an example, consider disturbances $\epsilon_i\sim N(0,1)$ and the following structural equations:
$$
X_1 = \epsilon_1 + \epsilon_0\\
X_2 =\epsilon_1 + \epsilon_2\\
y = X_1 + \epsilon_2
$$
Note the true DGP of $Y$, which includes only $X_1$, trivially satisfy condition 2. Condition 3 is also satisfied, since $X_1$ is the only variable to create $Y$ and you are providing $X_1$ and $X_2$.
Yet, there's no way your professor can tell if he should include only $X_1$ only $X_2$ or $X_1$ and $X_2$ to recover the true DGP of $Y$ (if you end up using this example, change the number of the variables). Most likely, he will just give you as an answer the regression with all variables, since they will all show up as significant predictors. You can extend this to 20 variables if you want to, you might want to check this answer here and a Simpson's paradox machine here.
Note all conditional expectations $E[Y|X_1]$, $E[Y|X_2]$ or $E[Y|X_1, X_2]$ are correctly specified conditional expectations, but only $E[Y|X_1]$ reflects the true DGP of $Y$. Thus, after your professor inevitably fails the task, he might argue that his goal was simply to recover any conditional expectation, or to get the best prediction of $Y$ etc. You can argue back that it wasn't what he said, since he states:
variable Y must come from a linear regression model that satisfies (...) variables that were used to create Y (...) your real model (...)
And you might spark a good discussion in class about causality, what true DGP means and identifiability in general. | Hiding a Regression Model from Professor (Regression Battleship) [closed]
If his goal is to recover the true data generating process that creates $Y$, fooling your professor is fairly trivial. To give you an example, consider disturbances $\epsilon_i\sim N(0,1)$ and the fol |
28,197 | Hiding a Regression Model from Professor (Regression Battleship) [closed] | Use variables with multicollinearity and heteroscedasticity like income versus age: do some painful feature engineering that provides scaling problems: give NAs for some sprinkled in sparseness. The linearity piece really makes it more challenging but it could be made painful. Also, outliers would increase the problem for him upfront. | Hiding a Regression Model from Professor (Regression Battleship) [closed] | Use variables with multicollinearity and heteroscedasticity like income versus age: do some painful feature engineering that provides scaling problems: give NAs for some sprinkled in sparseness. The l | Hiding a Regression Model from Professor (Regression Battleship) [closed]
Use variables with multicollinearity and heteroscedasticity like income versus age: do some painful feature engineering that provides scaling problems: give NAs for some sprinkled in sparseness. The linearity piece really makes it more challenging but it could be made painful. Also, outliers would increase the problem for him upfront. | Hiding a Regression Model from Professor (Regression Battleship) [closed]
Use variables with multicollinearity and heteroscedasticity like income versus age: do some painful feature engineering that provides scaling problems: give NAs for some sprinkled in sparseness. The l |
28,198 | Hiding a Regression Model from Professor (Regression Battleship) [closed] | Are interaction terms allowed? If so, set all the lower order coefficients to 0 and build the entire model out of N-th order interactions (e.g. terms like $X_5X_8X_{12}X_{13}$). For 20 regressors the number of possible interactions is astronomically large and it would be very difficult to find just the ones you included. | Hiding a Regression Model from Professor (Regression Battleship) [closed] | Are interaction terms allowed? If so, set all the lower order coefficients to 0 and build the entire model out of N-th order interactions (e.g. terms like $X_5X_8X_{12}X_{13}$). For 20 regressors the | Hiding a Regression Model from Professor (Regression Battleship) [closed]
Are interaction terms allowed? If so, set all the lower order coefficients to 0 and build the entire model out of N-th order interactions (e.g. terms like $X_5X_8X_{12}X_{13}$). For 20 regressors the number of possible interactions is astronomically large and it would be very difficult to find just the ones you included. | Hiding a Regression Model from Professor (Regression Battleship) [closed]
Are interaction terms allowed? If so, set all the lower order coefficients to 0 and build the entire model out of N-th order interactions (e.g. terms like $X_5X_8X_{12}X_{13}$). For 20 regressors the |
28,199 | Hiding a Regression Model from Professor (Regression Battleship) [closed] | Choose any linear model.
Give him a data set where most samples are around x=0.
Give him few samples around x=1,000,000.
The nice thing here that the samples around x=1,000,000 are not outliers.
They are generated from the same source.
However, since the scales are so different, errors around 1M won't fit with the errors around 0.
Let's consider an example.
Our model is just
$$
Y_i^\prime = \beta_0 +\beta_1 X_{i1}^\prime + \epsilon_i
$$
We have a data set of n samples, near x=0.
We will choose 2 more points in "far enough" values.
We assume that these two point have some error.
A "far enough" value is such a value that the error for an estimation the doesn't pass directly in these two points is much larger than the error of the rest of the dataset.
Hence, linear regression will choose coefficients that will pass in these two points and will miss the rest of the dataset and be different from the underlining model.
See the following example.
{{1, 782}, {2, 3099}, {3, 110}, {4, 1266}, {5, 1381}, {1000000 ,1002169}, {1000001, 999688}}
This is in WolfarmAlpha series format.
In each pair the first item is x and the second was generated in Excel using the formula =A2+NORMINV(RAND(),0,2000).
Hence, $\beta_0=1, \beta_1=1$ and we add normally distributed random noise with mean 0 and standard deviation of 2000.
This is a lot of noise near zero but a small one near million.
Using Wolfram Alpha, you get the following linear regression $y= 178433. x - 426805$, which is quite different from the underlining distribution of $y=x$ | Hiding a Regression Model from Professor (Regression Battleship) [closed] | Choose any linear model.
Give him a data set where most samples are around x=0.
Give him few samples around x=1,000,000.
The nice thing here that the samples around x=1,000,000 are not outliers.
They | Hiding a Regression Model from Professor (Regression Battleship) [closed]
Choose any linear model.
Give him a data set where most samples are around x=0.
Give him few samples around x=1,000,000.
The nice thing here that the samples around x=1,000,000 are not outliers.
They are generated from the same source.
However, since the scales are so different, errors around 1M won't fit with the errors around 0.
Let's consider an example.
Our model is just
$$
Y_i^\prime = \beta_0 +\beta_1 X_{i1}^\prime + \epsilon_i
$$
We have a data set of n samples, near x=0.
We will choose 2 more points in "far enough" values.
We assume that these two point have some error.
A "far enough" value is such a value that the error for an estimation the doesn't pass directly in these two points is much larger than the error of the rest of the dataset.
Hence, linear regression will choose coefficients that will pass in these two points and will miss the rest of the dataset and be different from the underlining model.
See the following example.
{{1, 782}, {2, 3099}, {3, 110}, {4, 1266}, {5, 1381}, {1000000 ,1002169}, {1000001, 999688}}
This is in WolfarmAlpha series format.
In each pair the first item is x and the second was generated in Excel using the formula =A2+NORMINV(RAND(),0,2000).
Hence, $\beta_0=1, \beta_1=1$ and we add normally distributed random noise with mean 0 and standard deviation of 2000.
This is a lot of noise near zero but a small one near million.
Using Wolfram Alpha, you get the following linear regression $y= 178433. x - 426805$, which is quite different from the underlining distribution of $y=x$ | Hiding a Regression Model from Professor (Regression Battleship) [closed]
Choose any linear model.
Give him a data set where most samples are around x=0.
Give him few samples around x=1,000,000.
The nice thing here that the samples around x=1,000,000 are not outliers.
They |
28,200 | Guidance on when to use cumulative vs. stopping ratio vs. continuation ratio vs. adjacent category ordinal regression models | The key thing to consider is the interpretation of each model (more so, in fact, than the proportional odds assumption, which is essentially just a constraint one puts on the parameters in the model). Or, more specifically, "which" logit is being modeled (I'm assuming by "cumulative probability" you refer to the "cumulative logit" models).
Let's keep things simple and assume you have an outcome, $Y$, with 3 levels. Now, as with logistic regression, you are modeling this outcome using the logit function.
$$g(t) = log\left(\frac{t}{1-t}\right)$$
The choice you are making between different ordinal models comes down to a choice of $t$.
In the cumulative logit model, you are choosing $t=P(Y\leq i)$ for $i \in \{1,2\}$ (I hope you understand why we will always have $i-1$ logits for any categorical outcome of $i$ levels). So,:
$$g(P(Y\leq i)) = log\left(\frac{P(Y\leq i)}{1-P(Y\leq i)}\right)=log\left(\frac{P(Y\leq i)}{P(Y\gt i)}\right)$$
So, for any given level of $Y$, you are modeling the log-odds of $Y$ falling into or below that level versus falling into a higher level. To show it more explicitly:
$$
i=1: log\left(\frac{P(Y=1)}{P(Y=2)+ P(Y=3)}\right)
$$
$$
i=2: log\left(\frac{P(Y=1) + P(Y=2)}{P(Y=3)}\right)
$$
Notice, too, that regardless of the level, the entire response scale is being used to inform the logits. In a regression model using this logit, we are saying that the relationship between the predictors and the outcome is linear on the scale of the log cumulative odds of the response categories. The proportional odds assumption, in fact, is simply a constraint that forces the regression lines across categories to be parallel. This also means, for example, that a positive regression coefficient in this model is associated with a decrease in the outcome; i.e. that the log-odds of being in a lower ordered category has increased relative to the log-odds of being in a higher ordered category.
Now, compare this to the adjacent-category model. This model conceptualizes the denominator of the logit a little differently (i.e. it parameterizes the quantity "$1-t$" a bit more stringently):
$$g(P(Y=i)) = log\left(\frac{P(Y = i)}{P(Y = i+1)}\right)$$
That is, we are looking at the log-odds of $Y$ being at a certain level versus being at the next higher level (in addition, it can be shown that this is simply a linear transformation of the baseline-category model, where we specify a 'reference' level and compare each level of the outcome against that reference level). This gives us:
$$
i=1: log\left(\frac{P(Y=1)}{P(Y=2)}\right)
$$
$$
i=2: log\left(\frac{P(Y=2)}{P(Y=3)}\right)
$$
Compare this to what we see with the cumulative logit model. For $i=1$, we've removed a term from the denominator, while for $i=2$, we've removed a term from the numerator. More specifically, each logit is no longer informed by the entire response scale. It is only interested in contrasting adjacent categories of the response (thus the name!). In a regression context, the relationship between the predictors and the outcome is linear on the scale of the log adjacent odds of the response categories .A positive coefficient using this model is interpreted as an increase in the log-odds of being at one level of the response versus being at the next level (though, as I alluded to earlier with my comment about the baseline-category model, this can be easily reparameterized to refer to any pairwise comparisons of outcome levels).
I've bolded and italicized the points about linearity for a reason. In a logistic regression model, we are saying that the predictors are linearly related to the log-odds of the outcome being a 1 versus being a 0 (thus allowing us, after a transformation, to make inferences about the probability of the outcome being a 1, which is the intuitive interpretation we are generally seeking). But when we have multiple levels of the outcome, we need to make a decision about which log-odds to use, and thus which probability we are making inferences about.
In other words, when deciding between these two models, you have to consider which probability is actually of interest (which depends on exactly what your outcome is and how the different levels of it relate to each other). One reason the cumulative logit model is so popular is that the interpretation is fairly intuitive (especially with the proportional odds assumption imposed): how is the outcome being "shifted" into lower categories of the response based on covariate values, taking into account the entire distribution of the outcome?
The adjacent-category model, on the other hand, is interested in sequential log-odds pairs, not cumulative ones. This may be of interest; for example, it may be more powerful for comparing two specific levels in the middle of the distribution, e.g. if you had a 5-level outcome and were particularly interested in the difference between levels 2 and 3, or 3 and 4; since the cumulative model won't get directly at that comparison, the adjacent-category model may be more useful.
Now, as for continuation/stopping ratio (also called 'stage') models, I am not as familiar with these as I am with the above, so I will refrain from going too deep into them. However, from my understanding, these models are specifically used in cases where an individual can only 'continue' on to higher levels of the outcome if they have already passed through lower levels of the outcome; e.g., if you are modeling education on an ordinal scale based on the type of degree received, an individual with a master's degree has to have already received a bachelor's degree, thus they 'passed through' a lower level of the scale before reaching the higher level. The primary difference between these types of models and the above (the cumulative logit and adjacent category logit) are that these are modeling conditional log-odds; i.e. the log-odds of being at a certain level given having been at other levels. | Guidance on when to use cumulative vs. stopping ratio vs. continuation ratio vs. adjacent category o | The key thing to consider is the interpretation of each model (more so, in fact, than the proportional odds assumption, which is essentially just a constraint one puts on the parameters in the model). | Guidance on when to use cumulative vs. stopping ratio vs. continuation ratio vs. adjacent category ordinal regression models
The key thing to consider is the interpretation of each model (more so, in fact, than the proportional odds assumption, which is essentially just a constraint one puts on the parameters in the model). Or, more specifically, "which" logit is being modeled (I'm assuming by "cumulative probability" you refer to the "cumulative logit" models).
Let's keep things simple and assume you have an outcome, $Y$, with 3 levels. Now, as with logistic regression, you are modeling this outcome using the logit function.
$$g(t) = log\left(\frac{t}{1-t}\right)$$
The choice you are making between different ordinal models comes down to a choice of $t$.
In the cumulative logit model, you are choosing $t=P(Y\leq i)$ for $i \in \{1,2\}$ (I hope you understand why we will always have $i-1$ logits for any categorical outcome of $i$ levels). So,:
$$g(P(Y\leq i)) = log\left(\frac{P(Y\leq i)}{1-P(Y\leq i)}\right)=log\left(\frac{P(Y\leq i)}{P(Y\gt i)}\right)$$
So, for any given level of $Y$, you are modeling the log-odds of $Y$ falling into or below that level versus falling into a higher level. To show it more explicitly:
$$
i=1: log\left(\frac{P(Y=1)}{P(Y=2)+ P(Y=3)}\right)
$$
$$
i=2: log\left(\frac{P(Y=1) + P(Y=2)}{P(Y=3)}\right)
$$
Notice, too, that regardless of the level, the entire response scale is being used to inform the logits. In a regression model using this logit, we are saying that the relationship between the predictors and the outcome is linear on the scale of the log cumulative odds of the response categories. The proportional odds assumption, in fact, is simply a constraint that forces the regression lines across categories to be parallel. This also means, for example, that a positive regression coefficient in this model is associated with a decrease in the outcome; i.e. that the log-odds of being in a lower ordered category has increased relative to the log-odds of being in a higher ordered category.
Now, compare this to the adjacent-category model. This model conceptualizes the denominator of the logit a little differently (i.e. it parameterizes the quantity "$1-t$" a bit more stringently):
$$g(P(Y=i)) = log\left(\frac{P(Y = i)}{P(Y = i+1)}\right)$$
That is, we are looking at the log-odds of $Y$ being at a certain level versus being at the next higher level (in addition, it can be shown that this is simply a linear transformation of the baseline-category model, where we specify a 'reference' level and compare each level of the outcome against that reference level). This gives us:
$$
i=1: log\left(\frac{P(Y=1)}{P(Y=2)}\right)
$$
$$
i=2: log\left(\frac{P(Y=2)}{P(Y=3)}\right)
$$
Compare this to what we see with the cumulative logit model. For $i=1$, we've removed a term from the denominator, while for $i=2$, we've removed a term from the numerator. More specifically, each logit is no longer informed by the entire response scale. It is only interested in contrasting adjacent categories of the response (thus the name!). In a regression context, the relationship between the predictors and the outcome is linear on the scale of the log adjacent odds of the response categories .A positive coefficient using this model is interpreted as an increase in the log-odds of being at one level of the response versus being at the next level (though, as I alluded to earlier with my comment about the baseline-category model, this can be easily reparameterized to refer to any pairwise comparisons of outcome levels).
I've bolded and italicized the points about linearity for a reason. In a logistic regression model, we are saying that the predictors are linearly related to the log-odds of the outcome being a 1 versus being a 0 (thus allowing us, after a transformation, to make inferences about the probability of the outcome being a 1, which is the intuitive interpretation we are generally seeking). But when we have multiple levels of the outcome, we need to make a decision about which log-odds to use, and thus which probability we are making inferences about.
In other words, when deciding between these two models, you have to consider which probability is actually of interest (which depends on exactly what your outcome is and how the different levels of it relate to each other). One reason the cumulative logit model is so popular is that the interpretation is fairly intuitive (especially with the proportional odds assumption imposed): how is the outcome being "shifted" into lower categories of the response based on covariate values, taking into account the entire distribution of the outcome?
The adjacent-category model, on the other hand, is interested in sequential log-odds pairs, not cumulative ones. This may be of interest; for example, it may be more powerful for comparing two specific levels in the middle of the distribution, e.g. if you had a 5-level outcome and were particularly interested in the difference between levels 2 and 3, or 3 and 4; since the cumulative model won't get directly at that comparison, the adjacent-category model may be more useful.
Now, as for continuation/stopping ratio (also called 'stage') models, I am not as familiar with these as I am with the above, so I will refrain from going too deep into them. However, from my understanding, these models are specifically used in cases where an individual can only 'continue' on to higher levels of the outcome if they have already passed through lower levels of the outcome; e.g., if you are modeling education on an ordinal scale based on the type of degree received, an individual with a master's degree has to have already received a bachelor's degree, thus they 'passed through' a lower level of the scale before reaching the higher level. The primary difference between these types of models and the above (the cumulative logit and adjacent category logit) are that these are modeling conditional log-odds; i.e. the log-odds of being at a certain level given having been at other levels. | Guidance on when to use cumulative vs. stopping ratio vs. continuation ratio vs. adjacent category o
The key thing to consider is the interpretation of each model (more so, in fact, than the proportional odds assumption, which is essentially just a constraint one puts on the parameters in the model). |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.