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
40,401
On the hardness of data to learn
The notion of instance hardness may address what you are looking for. Instance hardness posits that each instance in a data set has a hardness property indicating the likelihood that it will be misclassified by a supervised learning algorithm. In a sense, instance hardness looks at the hardness of each individual rather than the hardness of the data. However, instance hardness can be aggregated to essentially characterize the the hardness of the data set. As with all aggregation methods, though, some information is lost when the data is aggregated. Hopefully this may give you some direction.
On the hardness of data to learn
The notion of instance hardness may address what you are looking for. Instance hardness posits that each instance in a data set has a hardness property indicating the likelihood that it will be miscla
On the hardness of data to learn The notion of instance hardness may address what you are looking for. Instance hardness posits that each instance in a data set has a hardness property indicating the likelihood that it will be misclassified by a supervised learning algorithm. In a sense, instance hardness looks at the hardness of each individual rather than the hardness of the data. However, instance hardness can be aggregated to essentially characterize the the hardness of the data set. As with all aggregation methods, though, some information is lost when the data is aggregated. Hopefully this may give you some direction.
On the hardness of data to learn The notion of instance hardness may address what you are looking for. Instance hardness posits that each instance in a data set has a hardness property indicating the likelihood that it will be miscla
40,402
On the hardness of data to learn
Statistical learning theory typically deals with sample complexity, i.e., how many samples do I need to produce a hypothesis having low error with high probability. More concretely, if $S$ is a set of samples and $h_S$ is the hypothesis returned by some learning algorithm when given $S$ as input, then typically one looks to produce statements of the form $$ P(\text{err}(h_S)\le \epsilon) \ge 1 - \delta $$ if $|S| \ge m$ for some $m = \text{poly}(1/\epsilon, 1/\delta)$. In the above we completely ignored how $h_S$ was generated. Computational Learning Theory is the field which deals with these types of computational issues. One may, for example, require the algorithm that produces $h_S$ to run in time $\text{poly}(1/\epsilon, 1/\delta)$, notice that the above is a necessary condition for this to be possible. Other common things studied are what happens if the algorithm has access to different information (membership queries allow the learning algorithm to query an oracle for the label of points it chooses), how many mistakes does a learner make in an online learning, what happens if the feedback is limited like in reinforcement learning, etc. There is a lot more and it is a fascinating field, but rather than list them I'll point you to the book An Introduction to Computational Learning Theory by Kearns and Vazirani, which is a great introduction to the subject.
On the hardness of data to learn
Statistical learning theory typically deals with sample complexity, i.e., how many samples do I need to produce a hypothesis having low error with high probability. More concretely, if $S$ is a set of
On the hardness of data to learn Statistical learning theory typically deals with sample complexity, i.e., how many samples do I need to produce a hypothesis having low error with high probability. More concretely, if $S$ is a set of samples and $h_S$ is the hypothesis returned by some learning algorithm when given $S$ as input, then typically one looks to produce statements of the form $$ P(\text{err}(h_S)\le \epsilon) \ge 1 - \delta $$ if $|S| \ge m$ for some $m = \text{poly}(1/\epsilon, 1/\delta)$. In the above we completely ignored how $h_S$ was generated. Computational Learning Theory is the field which deals with these types of computational issues. One may, for example, require the algorithm that produces $h_S$ to run in time $\text{poly}(1/\epsilon, 1/\delta)$, notice that the above is a necessary condition for this to be possible. Other common things studied are what happens if the algorithm has access to different information (membership queries allow the learning algorithm to query an oracle for the label of points it chooses), how many mistakes does a learner make in an online learning, what happens if the feedback is limited like in reinforcement learning, etc. There is a lot more and it is a fascinating field, but rather than list them I'll point you to the book An Introduction to Computational Learning Theory by Kearns and Vazirani, which is a great introduction to the subject.
On the hardness of data to learn Statistical learning theory typically deals with sample complexity, i.e., how many samples do I need to produce a hypothesis having low error with high probability. More concretely, if $S$ is a set of
40,403
Goodness-of-Fit for continuous variables
What are some Goodness of Fit tests or indicies for continuous case? Most goodness of fit tests are for the continuous case. There are, quite literally, hundreds of them. Besides the Kolmogorov-Smirnov test (for a fully specified distribution, based on maximum difference in ECDF) some commonly used ones include the Anderson-Darling test (also fully specified and ECDF based; a variance-weighted version of the Cramer-von Mises test) and the Shapiro-Wilk (parameters unspecified, for testing normality only). For example I am looking at Kolmogorov-Smirnov test. Okay, but why? That is, why are you testing goodness of fit? What I don't get is how one gets the emprical CDF in the first place? It's simply the sample version of the cdf. The cdf is $P(X\leq x)$, the ECDF is the same thing, with 'probability' (for the random variable) replaced with 'proportion' (of the data). That is, you compute the proportion of the data that is less than or equal to every value $x$ in the range (ECDFs only change at data values, but are still defined between them - you really only need to identify their value at each data point and to the left of the entire sample, since they're constant from each data point until the next data point) Take a small set of numbers and try it. Here we go, a sample of three data values: 13.2 15.8 17.5 now, for the following $x$ values, what is the proportion of the data $\leq x$? x = 10, 13.2-$\varepsilon$, 13.2, 13.2+$\varepsilon$, 15, 15.8, 17.5-$\varepsilon$, 19 (where $\varepsilon$ is some very small number) Can you see how it works? (Hint: the first five answers are 0, 0, 1/3, 1/3, 1/3 and the last one is 1; the full ECDF is plotted at the end of my answer) What I mean is, let's say I do a regression analysis with gaussian errors. What prompts you to use this example? Did something (a book, say, or a website) lead you to think you ought to use a goodness of fit test in this situation? I have the maximum likelihood estimate of the parameters. Now I also need to do a density estimation for the emprical CDF? Empirical cdf of what? Note that the KS is a test, not an estimate. What hypothesis are you testing and why? Aren't they the same thing? No, they're quite different, as discussed below. Isn't my likelihood already giving me a goodness of fit? The likelihood for the regression tells you about fit of the line; in the case below, how close the red line is to the data. You could replace the data with another set of values with the same summary statistics but a different distribution, and the likelihood would be identical. See the Anscombe quartet for a good example of how very different data could have the same likelihood surface. By contrast, With a goodness of fit test, you're checking the shape of some distribution, like a normal distribution with some mean and variance, fits the data (the KS measures the discrepancy from the hypothesized distribution by looking at the ECDF, giving a test that doesn't change when you transform both halves of the comparison - making it nonparametric): So how does this relate to linear regression? Some people try to test whether the assumption of normality around the line holds (such as the distribution in the green strip in the first plot), as a check on the assumption about the error distribution: but this check is done across all x, not just some particular x (I did showed values near a particular $x$ to emphasize it's the conditional distribution of $y$ - or equivalently, the distribution of the errors - that is relevant). -- it's not clear from your description if that's what you mean to ask about, though. However: 1) formally testing goodness of fit as a check on assumptions isn't necessarily suitable; (i) it answers the wrong question (the relevant question is 'what is the impact on my inference of the degree of non-normality we have?'), and (ii) only tells you anything when it's of almost no use to you to know it (goodness of fit tests tend to show significance in medium to large samples, where it usually doesn't matter much, and tend not to be significant in small samples where it matters most), and (iii) changing what you do based on the outcome is usually less appropriate than simply assuming you'd reject the null in the first place (your regression inference doesn't have the desired properties). 2) even without all that, the KS is a test for a fully specified distribution. You have to specify the mean and standard deviation for each data point before you see any data. If you're estimating the mean (say by fitting a line) and a standard deviation (say by the standard error of the residuals, s), then you simply shouldn't be using the KS test. There are tests for the situation where you estimate the mean and variance (the equivalent to the KS test is called the Lilliefors test), but for normality the standard is the Shapiro Wilk test (though the simpler Shapiro-Francia test is almost as powerful, most stats software implements the full Shapiro-Wilk test). Why do I need KS? Well, basically you don't. There is almost never a circumstance when that's a good choice for the situation you describe. My suggestion is, to either use some procedure that doesn't assume normality (e.g. some robust approach, or perhaps least square but with inference based on resampling), or if you're in a position to reasonably assume normality, double-check the reasonableness of the assumption with a diagnostic display (like a Q-Q plot; incidentally the Shapiro-Francia test is effectively based on the $R^2$ in that plot). In large samples, normality is less important to your inference (for everything but prediction intervals), so you can tolerate larger deviations from normality (equal variance and independence assumptions matter much more). In small samples, you're more dependent on the assumption for your testing and confidence intervals, but you simply can't be sure how bad the degree of non-normality you have is. You're better with small samples to simply work as if your data were non-normal. (There are a number of good robust options, but you should usually also consider the potential impact of influential points, not just of potential y-outliers.) ECDF for the small example data set earlier in the answer:
Goodness-of-Fit for continuous variables
What are some Goodness of Fit tests or indicies for continuous case? Most goodness of fit tests are for the continuous case. There are, quite literally, hundreds of them. Besides the Kolmogorov-Smirn
Goodness-of-Fit for continuous variables What are some Goodness of Fit tests or indicies for continuous case? Most goodness of fit tests are for the continuous case. There are, quite literally, hundreds of them. Besides the Kolmogorov-Smirnov test (for a fully specified distribution, based on maximum difference in ECDF) some commonly used ones include the Anderson-Darling test (also fully specified and ECDF based; a variance-weighted version of the Cramer-von Mises test) and the Shapiro-Wilk (parameters unspecified, for testing normality only). For example I am looking at Kolmogorov-Smirnov test. Okay, but why? That is, why are you testing goodness of fit? What I don't get is how one gets the emprical CDF in the first place? It's simply the sample version of the cdf. The cdf is $P(X\leq x)$, the ECDF is the same thing, with 'probability' (for the random variable) replaced with 'proportion' (of the data). That is, you compute the proportion of the data that is less than or equal to every value $x$ in the range (ECDFs only change at data values, but are still defined between them - you really only need to identify their value at each data point and to the left of the entire sample, since they're constant from each data point until the next data point) Take a small set of numbers and try it. Here we go, a sample of three data values: 13.2 15.8 17.5 now, for the following $x$ values, what is the proportion of the data $\leq x$? x = 10, 13.2-$\varepsilon$, 13.2, 13.2+$\varepsilon$, 15, 15.8, 17.5-$\varepsilon$, 19 (where $\varepsilon$ is some very small number) Can you see how it works? (Hint: the first five answers are 0, 0, 1/3, 1/3, 1/3 and the last one is 1; the full ECDF is plotted at the end of my answer) What I mean is, let's say I do a regression analysis with gaussian errors. What prompts you to use this example? Did something (a book, say, or a website) lead you to think you ought to use a goodness of fit test in this situation? I have the maximum likelihood estimate of the parameters. Now I also need to do a density estimation for the emprical CDF? Empirical cdf of what? Note that the KS is a test, not an estimate. What hypothesis are you testing and why? Aren't they the same thing? No, they're quite different, as discussed below. Isn't my likelihood already giving me a goodness of fit? The likelihood for the regression tells you about fit of the line; in the case below, how close the red line is to the data. You could replace the data with another set of values with the same summary statistics but a different distribution, and the likelihood would be identical. See the Anscombe quartet for a good example of how very different data could have the same likelihood surface. By contrast, With a goodness of fit test, you're checking the shape of some distribution, like a normal distribution with some mean and variance, fits the data (the KS measures the discrepancy from the hypothesized distribution by looking at the ECDF, giving a test that doesn't change when you transform both halves of the comparison - making it nonparametric): So how does this relate to linear regression? Some people try to test whether the assumption of normality around the line holds (such as the distribution in the green strip in the first plot), as a check on the assumption about the error distribution: but this check is done across all x, not just some particular x (I did showed values near a particular $x$ to emphasize it's the conditional distribution of $y$ - or equivalently, the distribution of the errors - that is relevant). -- it's not clear from your description if that's what you mean to ask about, though. However: 1) formally testing goodness of fit as a check on assumptions isn't necessarily suitable; (i) it answers the wrong question (the relevant question is 'what is the impact on my inference of the degree of non-normality we have?'), and (ii) only tells you anything when it's of almost no use to you to know it (goodness of fit tests tend to show significance in medium to large samples, where it usually doesn't matter much, and tend not to be significant in small samples where it matters most), and (iii) changing what you do based on the outcome is usually less appropriate than simply assuming you'd reject the null in the first place (your regression inference doesn't have the desired properties). 2) even without all that, the KS is a test for a fully specified distribution. You have to specify the mean and standard deviation for each data point before you see any data. If you're estimating the mean (say by fitting a line) and a standard deviation (say by the standard error of the residuals, s), then you simply shouldn't be using the KS test. There are tests for the situation where you estimate the mean and variance (the equivalent to the KS test is called the Lilliefors test), but for normality the standard is the Shapiro Wilk test (though the simpler Shapiro-Francia test is almost as powerful, most stats software implements the full Shapiro-Wilk test). Why do I need KS? Well, basically you don't. There is almost never a circumstance when that's a good choice for the situation you describe. My suggestion is, to either use some procedure that doesn't assume normality (e.g. some robust approach, or perhaps least square but with inference based on resampling), or if you're in a position to reasonably assume normality, double-check the reasonableness of the assumption with a diagnostic display (like a Q-Q plot; incidentally the Shapiro-Francia test is effectively based on the $R^2$ in that plot). In large samples, normality is less important to your inference (for everything but prediction intervals), so you can tolerate larger deviations from normality (equal variance and independence assumptions matter much more). In small samples, you're more dependent on the assumption for your testing and confidence intervals, but you simply can't be sure how bad the degree of non-normality you have is. You're better with small samples to simply work as if your data were non-normal. (There are a number of good robust options, but you should usually also consider the potential impact of influential points, not just of potential y-outliers.) ECDF for the small example data set earlier in the answer:
Goodness-of-Fit for continuous variables What are some Goodness of Fit tests or indicies for continuous case? Most goodness of fit tests are for the continuous case. There are, quite literally, hundreds of them. Besides the Kolmogorov-Smirn
40,404
Goodness-of-Fit for continuous variables
The empirical CDF simply assigns a probability of $\frac{1}{N}$ to each sample point. Then you construct a CDF like you would for the discrete case. Not sure why you are using KS in regression. If you assumed gaussian errors and did MLE, then you have effectively fitted a normal distribution to your residuals. You could estimate the density of your residulas using your fitted values (simple approach) or increasingly more sophisticated approaches. BTW: Likelihood does not give goodness of fit, it merely says how likely the sample would have been had it been drawn from your fitted distribution. It says nothing about how likely the actual distribution is. The KS test is meant to determine if it is likely that a given, specific distribution, generated the results. It is different than the likelihood of the data, given a distribution. There is a wrinkle to this as well: If you first fit parameters via MLE then run the KS test on that distribution, you need to adjust for the fact that you used the sample to generate the parameters.
Goodness-of-Fit for continuous variables
The empirical CDF simply assigns a probability of $\frac{1}{N}$ to each sample point. Then you construct a CDF like you would for the discrete case. Not sure why you are using KS in regression. If you
Goodness-of-Fit for continuous variables The empirical CDF simply assigns a probability of $\frac{1}{N}$ to each sample point. Then you construct a CDF like you would for the discrete case. Not sure why you are using KS in regression. If you assumed gaussian errors and did MLE, then you have effectively fitted a normal distribution to your residuals. You could estimate the density of your residulas using your fitted values (simple approach) or increasingly more sophisticated approaches. BTW: Likelihood does not give goodness of fit, it merely says how likely the sample would have been had it been drawn from your fitted distribution. It says nothing about how likely the actual distribution is. The KS test is meant to determine if it is likely that a given, specific distribution, generated the results. It is different than the likelihood of the data, given a distribution. There is a wrinkle to this as well: If you first fit parameters via MLE then run the KS test on that distribution, you need to adjust for the fact that you used the sample to generate the parameters.
Goodness-of-Fit for continuous variables The empirical CDF simply assigns a probability of $\frac{1}{N}$ to each sample point. Then you construct a CDF like you would for the discrete case. Not sure why you are using KS in regression. If you
40,405
Why is standard error sometimes used for "error bands" in plots?
Mostly its that "it's been done that way in the past", but in some domains it is precisely because the authors are not drawing statistical inferences directly from the reported standard errors (even though, for the example paper it might be reasonable to do so). As an example, physics research papers often depict the standard errors related to (estimated) statistical errors in the data collection. These are usually estimated from running (as much a possible) the same experimental multiple times using the same setup and estimating the variance. However, these statistical errors are only very rarely used in a direct confidence interval/degree of significance type of assessment. This is due to the fact that in most experiments systematic errors of various type are likely to be larger than the statistical errors, and these types of errors are not amenable to statistical analysis. Thus, representing the 95% confidence interval based on just the statistical errors could be deceiving. Experimental particle physicists in particular go to great pains to identify statistical uncertainties, systematic uncertainties and then combine them (in physics community approved ways) into confidence intervals (the preprints on the discovery of the Higgs boson are probably easily found examples of this).
Why is standard error sometimes used for "error bands" in plots?
Mostly its that "it's been done that way in the past", but in some domains it is precisely because the authors are not drawing statistical inferences directly from the reported standard errors (even t
Why is standard error sometimes used for "error bands" in plots? Mostly its that "it's been done that way in the past", but in some domains it is precisely because the authors are not drawing statistical inferences directly from the reported standard errors (even though, for the example paper it might be reasonable to do so). As an example, physics research papers often depict the standard errors related to (estimated) statistical errors in the data collection. These are usually estimated from running (as much a possible) the same experimental multiple times using the same setup and estimating the variance. However, these statistical errors are only very rarely used in a direct confidence interval/degree of significance type of assessment. This is due to the fact that in most experiments systematic errors of various type are likely to be larger than the statistical errors, and these types of errors are not amenable to statistical analysis. Thus, representing the 95% confidence interval based on just the statistical errors could be deceiving. Experimental particle physicists in particular go to great pains to identify statistical uncertainties, systematic uncertainties and then combine them (in physics community approved ways) into confidence intervals (the preprints on the discovery of the Higgs boson are probably easily found examples of this).
Why is standard error sometimes used for "error bands" in plots? Mostly its that "it's been done that way in the past", but in some domains it is precisely because the authors are not drawing statistical inferences directly from the reported standard errors (even t
40,406
Why is standard error sometimes used for "error bands" in plots?
Whether from convention or otherwise, it is honest in the sense that it is easy for the reader to develop their own idea of significance, ie mentally the reader can consider a multiple of, say 2 or 3 times larger to get their own idea of significance. In a sense you are letting the data speak for itself rather than speaking for the data. From that perspective it is logical to provide SE as the basis for banding. In my view, however, the caption of the chart should clearly state that the basis of banding is, in fact, one SE. Similarly these should not be identified in any way as confidence intervals but simply as properties of the data set.
Why is standard error sometimes used for "error bands" in plots?
Whether from convention or otherwise, it is honest in the sense that it is easy for the reader to develop their own idea of significance, ie mentally the reader can consider a multiple of, say 2 or 3
Why is standard error sometimes used for "error bands" in plots? Whether from convention or otherwise, it is honest in the sense that it is easy for the reader to develop their own idea of significance, ie mentally the reader can consider a multiple of, say 2 or 3 times larger to get their own idea of significance. In a sense you are letting the data speak for itself rather than speaking for the data. From that perspective it is logical to provide SE as the basis for banding. In my view, however, the caption of the chart should clearly state that the basis of banding is, in fact, one SE. Similarly these should not be identified in any way as confidence intervals but simply as properties of the data set.
Why is standard error sometimes used for "error bands" in plots? Whether from convention or otherwise, it is honest in the sense that it is easy for the reader to develop their own idea of significance, ie mentally the reader can consider a multiple of, say 2 or 3
40,407
Open source classification algorithms, preferably in C++ [closed]
dlib http://dlib.net/ Machine Learning (including classification) http://dlib.net/ml.html Examples: http://dlib.net/multiclass_classification_ex.cpp.html Shark http://image.diku.dk/shark/sphinx_pages/build/html/ http://image.diku.dk/shark/sphinx_pages/build/html/rest_sources/tutorials/tutorials.html Shogun - A Large Scale Machine Learning Toolbox http://shogun-toolbox.org/ http://shogun-toolbox.org/doc/en/current/methods.html http://shogun-toolbox.org/doc/en/current/libshogun_examples.html // Note: the aforementioned example has me rather worried in that it seems this library is not following best practices of modern C++: in particular, raw pointers and manual new/delete are usually a bad practice without a specific, well-motivated need (that I find lacking in the context of the presented examples). See: http://herbsutter.com/elements-of-modern-c-style/ Vowpal Wabbit https://en.wikipedia.org/wiki/Vowpal_Wabbit https://github.com/JohnLangford/vowpal_wabbit/wiki Written in C++, can be used as a library; examples: https://github.com/JohnLangford/vowpal_wabbit/tree/master/library // Note: manual invocations of VW::initialize and VW::finish operating on a raw pointer vw* raise concerns similar to the ones above; example: https://github.com/JohnLangford/vowpal_wabbit/blob/master/library/library_example.cc For more, see also Machine Learning Open Source Software: http://mloss.org/software/language/c__/ You may also find the following of use: - https://stackoverflow.com/questions/3167024/fastest-general-machine-learning-library - https://stackoverflow.com/questions/2915341/which-machine-learning-library-to-use
Open source classification algorithms, preferably in C++ [closed]
dlib http://dlib.net/ Machine Learning (including classification) http://dlib.net/ml.html Examples: http://dlib.net/multiclass_classification_ex.cpp.html Shark http://image.diku.dk/shark/sphinx_pages/
Open source classification algorithms, preferably in C++ [closed] dlib http://dlib.net/ Machine Learning (including classification) http://dlib.net/ml.html Examples: http://dlib.net/multiclass_classification_ex.cpp.html Shark http://image.diku.dk/shark/sphinx_pages/build/html/ http://image.diku.dk/shark/sphinx_pages/build/html/rest_sources/tutorials/tutorials.html Shogun - A Large Scale Machine Learning Toolbox http://shogun-toolbox.org/ http://shogun-toolbox.org/doc/en/current/methods.html http://shogun-toolbox.org/doc/en/current/libshogun_examples.html // Note: the aforementioned example has me rather worried in that it seems this library is not following best practices of modern C++: in particular, raw pointers and manual new/delete are usually a bad practice without a specific, well-motivated need (that I find lacking in the context of the presented examples). See: http://herbsutter.com/elements-of-modern-c-style/ Vowpal Wabbit https://en.wikipedia.org/wiki/Vowpal_Wabbit https://github.com/JohnLangford/vowpal_wabbit/wiki Written in C++, can be used as a library; examples: https://github.com/JohnLangford/vowpal_wabbit/tree/master/library // Note: manual invocations of VW::initialize and VW::finish operating on a raw pointer vw* raise concerns similar to the ones above; example: https://github.com/JohnLangford/vowpal_wabbit/blob/master/library/library_example.cc For more, see also Machine Learning Open Source Software: http://mloss.org/software/language/c__/ You may also find the following of use: - https://stackoverflow.com/questions/3167024/fastest-general-machine-learning-library - https://stackoverflow.com/questions/2915341/which-machine-learning-library-to-use
Open source classification algorithms, preferably in C++ [closed] dlib http://dlib.net/ Machine Learning (including classification) http://dlib.net/ml.html Examples: http://dlib.net/multiclass_classification_ex.cpp.html Shark http://image.diku.dk/shark/sphinx_pages/
40,408
Open source classification algorithms, preferably in C++ [closed]
What you really need is OpenCV . OpenCV (Open Source Computer Vision Library) is an open source computer vision and machine learning software library. It has C++, C, Python and Java interfaces and supports Windows, Linux, Android and Mac OS. You may find there lots of solutions for computer vision recognition problems.
Open source classification algorithms, preferably in C++ [closed]
What you really need is OpenCV . OpenCV (Open Source Computer Vision Library) is an open source computer vision and machine learning software library. It has C++, C, Python and Java interfaces and sup
Open source classification algorithms, preferably in C++ [closed] What you really need is OpenCV . OpenCV (Open Source Computer Vision Library) is an open source computer vision and machine learning software library. It has C++, C, Python and Java interfaces and supports Windows, Linux, Android and Mac OS. You may find there lots of solutions for computer vision recognition problems.
Open source classification algorithms, preferably in C++ [closed] What you really need is OpenCV . OpenCV (Open Source Computer Vision Library) is an open source computer vision and machine learning software library. It has C++, C, Python and Java interfaces and sup
40,409
Open source classification algorithms, preferably in C++ [closed]
LIBSVM, de facto standard for SVM learning (BSD license): home page implemented in C, so trivial to use in C++ interfaces in various languages available, including R (kernlab), Python (scikit-learn), ... Shameless self advertisement: EnsembleSVM home page github implemented in C++11 EnsembleSVM is a toolbox for fast nonlinear learning with SVMs. Licensed under LGPL v3. Some basic info is available in our paper.
Open source classification algorithms, preferably in C++ [closed]
LIBSVM, de facto standard for SVM learning (BSD license): home page implemented in C, so trivial to use in C++ interfaces in various languages available, including R (kernlab), Python (scikit-learn),
Open source classification algorithms, preferably in C++ [closed] LIBSVM, de facto standard for SVM learning (BSD license): home page implemented in C, so trivial to use in C++ interfaces in various languages available, including R (kernlab), Python (scikit-learn), ... Shameless self advertisement: EnsembleSVM home page github implemented in C++11 EnsembleSVM is a toolbox for fast nonlinear learning with SVMs. Licensed under LGPL v3. Some basic info is available in our paper.
Open source classification algorithms, preferably in C++ [closed] LIBSVM, de facto standard for SVM learning (BSD license): home page implemented in C, so trivial to use in C++ interfaces in various languages available, including R (kernlab), Python (scikit-learn),
40,410
Open source classification algorithms, preferably in C++ [closed]
VlFeat http://www.vlfeat.org/ is great computer vision library written in pure C.
Open source classification algorithms, preferably in C++ [closed]
VlFeat http://www.vlfeat.org/ is great computer vision library written in pure C.
Open source classification algorithms, preferably in C++ [closed] VlFeat http://www.vlfeat.org/ is great computer vision library written in pure C.
Open source classification algorithms, preferably in C++ [closed] VlFeat http://www.vlfeat.org/ is great computer vision library written in pure C.
40,411
3 way or 2 way anova?
This is clearly a designed experiment, & looks very much as if it was intended as a $3^{3-1}$ design for continuous predictors. The coding suggests that, & the names of the predictors suggest things that could be measured quantitatively, or at least treated as such with a pinch of salt. If so: the three main effects are orthogonal, each partially confounded with a second-order interaction between the other two predictors; each quadratic effect is orthogonal to the two other predictors; & there are no true replicates. The aim may have been to get independent estimates of the main effects, with 5 degrees of freedom for the residuals, while allowing an independent check for curvature for each predictor separately, in the confident assumption of no interactions. Perhaps to estimate some or all of the quadratic terms, noting that the inclusion of, say, temp squared won't affect the coefficient estimates for acid or time. Such designs aren't too common; it's rare to be concerned with curvature in each predictor separately but not with interactions between predictors. More often you'd see a full factorial design (for the three-predictor case—a fractional factorial when there are more predictors) along with some centre points to check for curvature & provide a pure error estimate; an orthogonal block of axial points (plus some more centre points) being added when necessary to allow estimation of the quadratic effects. If you're sure you want to treat each predictor as categorical then the best you can do is fit just the main effects (which will still be orthogonal), leaving only 2 degrees of freedom for the residuals as @January points out.
3 way or 2 way anova?
This is clearly a designed experiment, & looks very much as if it was intended as a $3^{3-1}$ design for continuous predictors. The coding suggests that, & the names of the predictors suggest things t
3 way or 2 way anova? This is clearly a designed experiment, & looks very much as if it was intended as a $3^{3-1}$ design for continuous predictors. The coding suggests that, & the names of the predictors suggest things that could be measured quantitatively, or at least treated as such with a pinch of salt. If so: the three main effects are orthogonal, each partially confounded with a second-order interaction between the other two predictors; each quadratic effect is orthogonal to the two other predictors; & there are no true replicates. The aim may have been to get independent estimates of the main effects, with 5 degrees of freedom for the residuals, while allowing an independent check for curvature for each predictor separately, in the confident assumption of no interactions. Perhaps to estimate some or all of the quadratic terms, noting that the inclusion of, say, temp squared won't affect the coefficient estimates for acid or time. Such designs aren't too common; it's rare to be concerned with curvature in each predictor separately but not with interactions between predictors. More often you'd see a full factorial design (for the three-predictor case—a fractional factorial when there are more predictors) along with some centre points to check for curvature & provide a pure error estimate; an orthogonal block of axial points (plus some more centre points) being added when necessary to allow estimation of the quadratic effects. If you're sure you want to treat each predictor as categorical then the best you can do is fit just the main effects (which will still be orthogonal), leaving only 2 degrees of freedom for the residuals as @January points out.
3 way or 2 way anova? This is clearly a designed experiment, & looks very much as if it was intended as a $3^{3-1}$ design for continuous predictors. The coding suggests that, & the names of the predictors suggest things t
40,412
Continuous dependent variable between 0 and 1 fitted with sigmoidal function
I don't think beta regression, as suggested by @O_Devinyak, will work well for this case as there are exact 0s and 1s in the data and the beta distribution only works for values between, but not including, 0 and 1. A solution that has become more popular in economics is the so-called fractional logit model, which economists tend to attribute to Papke and Wooldridge (1996), though the basic idea can be traced back to at least Wedderburn (1974). Nowadays it is fairly easy to estimate such models. For example in Stata (the statistical program I know best) you would use the glm program in combination with the link(logit) family(binomial) vce(robust) options. Wedderburn, R. W. 1974. Quasi-likelihood functions, generalized linear models, and the Gauss—Newton method. Biometrika, 61(3): 439-447. Papke, Leslie E. and Jeffrey M. Wooldridge. 1996. Econometric methods for fractional response variables with an application to 401(k) Plan participation rates. Journal of Applied Econometrics, 11(6): 619-632.
Continuous dependent variable between 0 and 1 fitted with sigmoidal function
I don't think beta regression, as suggested by @O_Devinyak, will work well for this case as there are exact 0s and 1s in the data and the beta distribution only works for values between, but not inclu
Continuous dependent variable between 0 and 1 fitted with sigmoidal function I don't think beta regression, as suggested by @O_Devinyak, will work well for this case as there are exact 0s and 1s in the data and the beta distribution only works for values between, but not including, 0 and 1. A solution that has become more popular in economics is the so-called fractional logit model, which economists tend to attribute to Papke and Wooldridge (1996), though the basic idea can be traced back to at least Wedderburn (1974). Nowadays it is fairly easy to estimate such models. For example in Stata (the statistical program I know best) you would use the glm program in combination with the link(logit) family(binomial) vce(robust) options. Wedderburn, R. W. 1974. Quasi-likelihood functions, generalized linear models, and the Gauss—Newton method. Biometrika, 61(3): 439-447. Papke, Leslie E. and Jeffrey M. Wooldridge. 1996. Econometric methods for fractional response variables with an application to 401(k) Plan participation rates. Journal of Applied Econometrics, 11(6): 619-632.
Continuous dependent variable between 0 and 1 fitted with sigmoidal function I don't think beta regression, as suggested by @O_Devinyak, will work well for this case as there are exact 0s and 1s in the data and the beta distribution only works for values between, but not inclu
40,413
How to test whether linear models fit separately to two groups are better than a single model applied to both groups?
If you are conducting studies to deepen your theoretical understanding of some topic, this is a great thing to wonder about. Fortunately, there are well-developed statistical methods for assessing this question. What you do is fit both a full model that encompasses the possibility that the relationship differs between men and women, and a reduced model that assumes there is no such difference. Then you perform a nested model test. The way to make a model that allows for there to be a differing relationship by sex is to include an interaction term in addition to variables for income and sex. Here is what such a model would look like: $$ \text{Happiness}=\beta_0 + \beta_1\text{Income} + \beta_2\text{Sex} + \beta_3\text{Income}\times\text{Sex} + \varepsilon $$ Note that sex would be represented by a dummy code, that is, a vector of $1$s and $0$s, where the $1$s indicated, e.g., that the person was a man. The reduced model would look like this: $$ \text{Happiness}=\beta_0 + \beta_1\text{Income} + \varepsilon $$ Thus, the models differ in two parameters, and the larger model 'reduces' to the smaller one if $\beta_2=\beta_3=0$. To simultaneously test whether both parameters are 0, you perform a nested model test. (I have discussed such tests here: Testing for moderation with continuous vs categorical moderators, albeit in a different context.) If you decide to keep the larger model, the implication is that the relationship between income an happiness for women is: $$ \text{Happiness}=\beta_0 + \beta_1\text{Income} + \varepsilon $$ And the relationship for men is: $$ \text{Happiness}=\underbrace{(\beta_0 + \beta_2)}_{\text{intercept}} + \underbrace{(\beta_1+\beta_3)}_{\text{slope}}\text{Income} + \varepsilon $$ (Again, this assumes that men are $1$, and women are $0$.)
How to test whether linear models fit separately to two groups are better than a single model applie
If you are conducting studies to deepen your theoretical understanding of some topic, this is a great thing to wonder about. Fortunately, there are well-developed statistical methods for assessing th
How to test whether linear models fit separately to two groups are better than a single model applied to both groups? If you are conducting studies to deepen your theoretical understanding of some topic, this is a great thing to wonder about. Fortunately, there are well-developed statistical methods for assessing this question. What you do is fit both a full model that encompasses the possibility that the relationship differs between men and women, and a reduced model that assumes there is no such difference. Then you perform a nested model test. The way to make a model that allows for there to be a differing relationship by sex is to include an interaction term in addition to variables for income and sex. Here is what such a model would look like: $$ \text{Happiness}=\beta_0 + \beta_1\text{Income} + \beta_2\text{Sex} + \beta_3\text{Income}\times\text{Sex} + \varepsilon $$ Note that sex would be represented by a dummy code, that is, a vector of $1$s and $0$s, where the $1$s indicated, e.g., that the person was a man. The reduced model would look like this: $$ \text{Happiness}=\beta_0 + \beta_1\text{Income} + \varepsilon $$ Thus, the models differ in two parameters, and the larger model 'reduces' to the smaller one if $\beta_2=\beta_3=0$. To simultaneously test whether both parameters are 0, you perform a nested model test. (I have discussed such tests here: Testing for moderation with continuous vs categorical moderators, albeit in a different context.) If you decide to keep the larger model, the implication is that the relationship between income an happiness for women is: $$ \text{Happiness}=\beta_0 + \beta_1\text{Income} + \varepsilon $$ And the relationship for men is: $$ \text{Happiness}=\underbrace{(\beta_0 + \beta_2)}_{\text{intercept}} + \underbrace{(\beta_1+\beta_3)}_{\text{slope}}\text{Income} + \varepsilon $$ (Again, this assumes that men are $1$, and women are $0$.)
How to test whether linear models fit separately to two groups are better than a single model applie If you are conducting studies to deepen your theoretical understanding of some topic, this is a great thing to wonder about. Fortunately, there are well-developed statistical methods for assessing th
40,414
How to model variables, where instead of values we observe intervals?
In Stata, both cases can be handled with the interval regression command intreg, which is generalization of the Tobit. It can handle point, interval, or left/right censored data (or a mixture of them all). It does assume error term normality, but the log transformation can often work if your data require and permit it. I am not sure if there are canned non-Stata implementations, but there are formulas and references at the end of the manual link. It is a fairly straight-forward likelihood function that should be fairly easy to maximize. There's also a nice comparison between the ordered probit approach and interval regression using the value of the log likelihood for the first case scenario. Here's a very simple simulation with $N=5000, Y=\alpha + \beta \cdot X + \varepsilon =\frac{1}{2} + 1 \cdot X + \mathcal{N}[0,1]$: #delimit; clear all; set seed 10011979; set obs 5000; gen x = rnormal(); gen ystar = 0.5 + 1*x + rnormal(); gen ylb = ystar - int((5-1)*runiform()); gen yub = ystar + int((5-1)*runiform()); intreg ylb yub x; Every observation has a variable interval constructed by adding/subtracting a random uniform number to the true value, so the intervals may overlap. The data basically looks like this: As you can see, 2 observations are uncensored (i.e., point data). The output is: Interval regression Number of obs = 5000 LR chi2(1) = 2102.49 Log likelihood = -3580.5326 Prob > chi2 = 0.0000 ------------------------------------------------------------------------------ | Coef. Std. Err. z P>|z| [95% Conf. Interval] -------------+---------------------------------------------------------------- x | .979912 .0192016 51.03 0.000 .9422775 1.017546 _cons | .4757097 .0190327 24.99 0.000 .4384063 .5130131 -------------+---------------------------------------------------------------- /lnsigma | .0336532 .0143186 2.35 0.019 .0055893 .0617171 -------------+---------------------------------------------------------------- sigma | 1.034226 .0148086 1.005605 1.063661 ------------------------------------------------------------------------------ Observation summary: 0 left-censored observations 326 uncensored observations 0 right-censored observations 4674 interval observations It seems like all the parameters, including the standard deviation of the error, are fairly close to the true values.
How to model variables, where instead of values we observe intervals?
In Stata, both cases can be handled with the interval regression command intreg, which is generalization of the Tobit. It can handle point, interval, or left/right censored data (or a mixture of them
How to model variables, where instead of values we observe intervals? In Stata, both cases can be handled with the interval regression command intreg, which is generalization of the Tobit. It can handle point, interval, or left/right censored data (or a mixture of them all). It does assume error term normality, but the log transformation can often work if your data require and permit it. I am not sure if there are canned non-Stata implementations, but there are formulas and references at the end of the manual link. It is a fairly straight-forward likelihood function that should be fairly easy to maximize. There's also a nice comparison between the ordered probit approach and interval regression using the value of the log likelihood for the first case scenario. Here's a very simple simulation with $N=5000, Y=\alpha + \beta \cdot X + \varepsilon =\frac{1}{2} + 1 \cdot X + \mathcal{N}[0,1]$: #delimit; clear all; set seed 10011979; set obs 5000; gen x = rnormal(); gen ystar = 0.5 + 1*x + rnormal(); gen ylb = ystar - int((5-1)*runiform()); gen yub = ystar + int((5-1)*runiform()); intreg ylb yub x; Every observation has a variable interval constructed by adding/subtracting a random uniform number to the true value, so the intervals may overlap. The data basically looks like this: As you can see, 2 observations are uncensored (i.e., point data). The output is: Interval regression Number of obs = 5000 LR chi2(1) = 2102.49 Log likelihood = -3580.5326 Prob > chi2 = 0.0000 ------------------------------------------------------------------------------ | Coef. Std. Err. z P>|z| [95% Conf. Interval] -------------+---------------------------------------------------------------- x | .979912 .0192016 51.03 0.000 .9422775 1.017546 _cons | .4757097 .0190327 24.99 0.000 .4384063 .5130131 -------------+---------------------------------------------------------------- /lnsigma | .0336532 .0143186 2.35 0.019 .0055893 .0617171 -------------+---------------------------------------------------------------- sigma | 1.034226 .0148086 1.005605 1.063661 ------------------------------------------------------------------------------ Observation summary: 0 left-censored observations 326 uncensored observations 0 right-censored observations 4674 interval observations It seems like all the parameters, including the standard deviation of the error, are fairly close to the true values.
How to model variables, where instead of values we observe intervals? In Stata, both cases can be handled with the interval regression command intreg, which is generalization of the Tobit. It can handle point, interval, or left/right censored data (or a mixture of them
40,415
How to model variables, where instead of values we observe intervals?
You are looking for interval regression: In R you can use the survival package as explained here Or you can try with the intReg package using the intReg function
How to model variables, where instead of values we observe intervals?
You are looking for interval regression: In R you can use the survival package as explained here Or you can try with the intReg package using the intReg function
How to model variables, where instead of values we observe intervals? You are looking for interval regression: In R you can use the survival package as explained here Or you can try with the intReg package using the intReg function
How to model variables, where instead of values we observe intervals? You are looking for interval regression: In R you can use the survival package as explained here Or you can try with the intReg package using the intReg function
40,416
Is a post-hoc test supposed to be performed on transformed or original data?
Yes, you should use the same, transformed data throughout the analysis. Tukey's test makes the same assumptions as the ANOVA.
Is a post-hoc test supposed to be performed on transformed or original data?
Yes, you should use the same, transformed data throughout the analysis. Tukey's test makes the same assumptions as the ANOVA.
Is a post-hoc test supposed to be performed on transformed or original data? Yes, you should use the same, transformed data throughout the analysis. Tukey's test makes the same assumptions as the ANOVA.
Is a post-hoc test supposed to be performed on transformed or original data? Yes, you should use the same, transformed data throughout the analysis. Tukey's test makes the same assumptions as the ANOVA.
40,417
What is the way to represent factor variables in scikit-learn while using Random Forests?
It seems that you're comparing scikit-learn's Random Forest with randomForest package in R, where this package deals with categorical variables automatically. However in scikit-learn you have to preprocess your data yourself. To do this, you could use DictVectorizer class, which would create new binary features for every new value of your original feature.
What is the way to represent factor variables in scikit-learn while using Random Forests?
It seems that you're comparing scikit-learn's Random Forest with randomForest package in R, where this package deals with categorical variables automatically. However in scikit-learn you have to prepr
What is the way to represent factor variables in scikit-learn while using Random Forests? It seems that you're comparing scikit-learn's Random Forest with randomForest package in R, where this package deals with categorical variables automatically. However in scikit-learn you have to preprocess your data yourself. To do this, you could use DictVectorizer class, which would create new binary features for every new value of your original feature.
What is the way to represent factor variables in scikit-learn while using Random Forests? It seems that you're comparing scikit-learn's Random Forest with randomForest package in R, where this package deals with categorical variables automatically. However in scikit-learn you have to prepr
40,418
Limited Information Maximum Likelihood (LIML) estimation in R?
There are a number of ways to motivate the LIML estimator, the primary one being that it is a member of the family of IV estimators known as the $k$-class estimators. Also, to my knowledge, a direct implementation of the LIML estimator is not available in R (see the sem package though). $k$-class IV estimators Consider the linear instrumental variables regression model: $$ \begin{align} \boldsymbol{Y}_1 &= \mathbf{Y}_2\boldsymbol{\beta} + \mathbf{Z}_1\boldsymbol{\delta} + \boldsymbol{\varepsilon}\\ &= \mathbf{X}\boldsymbol{\gamma} + \boldsymbol{\varepsilon}\\ \mathbf{Y}_2 &= \mathbf{Z}_1\mathbf{\Pi}_1 + \mathbf{Z}_2\mathbf{\Pi}_2+ \mathbf{V}\\ &= \mathbf{Z}\mathbf{\Pi} + \mathbf{V}\\ \mathbb{E}(\boldsymbol{\varepsilon} \mid \mathbf{Z}) &= \boldsymbol{0} \end{align} $$ where $\mathbf{Z}_1$ is the matrix of included exogenous covariates, and $\mathbf{Z}_2$ is the matrix of excluded exogenous covariates. $\mathbf{Y}_2$ is the matrix of endogenous covariates. Then the $k$-class estimators, defined by Theil, can be written as solutions to the set of equations $$ \mathbf{X}'(\boldsymbol{i}_N - k\mathbf{M}_{\mathbf{Z}})\mathbf{X}\hat{\boldsymbol{\beta}}_{KC} = \mathbf{X}'(\boldsymbol{i}_N - k\mathbf{M}_{\mathbf{Z}})\boldsymbol{Y} $$ where $\mathbf{M}_{\mathbf{Z}} = \boldsymbol{i}_N - \mathbf{Z}\left(\mathbf{Z}'\mathbf{Z}\right)^{-1}\mathbf{Z}$ is the orthogonal projection matrix. Various choices of $k$ yield special cases, for example, the 2SLS corresponds to $k=1$. A very crude implementation of a $k$-class estimators in R is as follows: library(foreign) library(zoo) library(AER) #========================================================== # load and pre-process the data #========================================================== download.file(url = 'http://people.stern.nyu.edu/wgreene/Text/tables/TableF4-1.txt', destfile = 'mroz.txt') # read in the file dfMroz = read.table('mroz.txt', header = TRUE, skip = 36) names(dfMroz) = tolower(names(dfMroz)) summary(dfMroz) #========================================================== # k-class estimator (example: k = 0.9) #========================================================== # 2SLS estimator; to check that the formula is okay ivreg(log(ww) ~ ax. + I(ax.^2) + we | ax. + I(ax.^2) + kl6 + k618 + wa, data = dfMroz, subset = ww > 0) # OK # IV regression formula formulaMrozKC = as.Formula(log(ww) ~ ax. + I(ax.^2) + we | ax. + I(ax.^2) + kl6 + k618 + wa) ## get the model matrices mfMrozKC = model.frame(formulaMrozKC, data = dfMroz, subset = ww > 0) vY = model.response(mfMrozKC) mX = model.matrix(formulaMrozKC, data = mfMrozKC, rhs = 1) mZ = model.matrix(formulaMrozKC, data = mfMrozKC, rhs = 2) mMZ = diag(428) - mZ %*% solve(t(mZ) %*% mZ) %*% t(mZ) # k-class estimator (k = 0.9) dK = 0.9 solve(a = t(mX) %*% (diag(428) - dK*mMZ) %*% mX, b = t(mX) %*% (diag(428) - dK*mMZ) %*% vY, tol = 1e-10) LIML estimator The LIML estimator is had by setting $k$ in the $k$-class estimators to be the minimum eigenvalue of the matrix: $$ \left(\mathbf{Y} \mathbf{M}_{\mathbf{Z}}\mathbf{Y}\right)^{-1/2}\mathbf{Y} \mathbf{M}_{\mathbf{Z}_1}\mathbf{Y} \left(\mathbf{Y} \mathbf{M}_{\mathbf{Z}}\mathbf{Y}\right)^{-1/2} $$ where $\mathbf{Y} = [\boldsymbol{Y}_1, \mathbf{Y}_2]$. For a detailed discussion, see Davidson and MacKinnon (2001), pg. 539--. R implementation A very crude implementation of this in R is as follows (no guarantees about numerical efficiency are made): #========================================================== # LIML estimator (example: k = 0.9) #========================================================== # function to compute the inverse square root of a matrix fnMatSqrtInverse = function(mA) { ei = eigen(mA) d = ei$values d = (d+abs(d))/2 d2 = 1/sqrt(d) d2[d == 0] = 0 return(ei$vectors %*% diag(d2) %*% t(ei$vectors)) } mY2 = mX[, setdiff(colnames(mX), colnames(mZ))] mZ1 = mZ[, intersect(colnames(mX), colnames(mZ))] mMZ1 = diag(428) - mZ1 %*% solve(t(mZ1) %*% mZ1) %*% t(mZ1) mYStar = cbind(vY, mY2) mYZY = t(mYStar) %*% mMZ %*% mYStar mLeftRight = fnMatSqrtInverse(mYZY) dK.LIML = sort(eigen(b %*% (t(mYStar) %*% mMZ1 %*% mYStar) %*% b, only.values = TRUE)$values)[1] # LIML estimator solve(a = t(mX) %*% (diag(428) - dK.LIML*mMZ) %*% mX, b = t(mX) %*% (diag(428) - dK.LIML*mMZ) %*% vY, tol = 1e-10) The computation of the matrix square root inverse is borrowed from here.
Limited Information Maximum Likelihood (LIML) estimation in R?
There are a number of ways to motivate the LIML estimator, the primary one being that it is a member of the family of IV estimators known as the $k$-class estimators. Also, to my knowledge, a direct i
Limited Information Maximum Likelihood (LIML) estimation in R? There are a number of ways to motivate the LIML estimator, the primary one being that it is a member of the family of IV estimators known as the $k$-class estimators. Also, to my knowledge, a direct implementation of the LIML estimator is not available in R (see the sem package though). $k$-class IV estimators Consider the linear instrumental variables regression model: $$ \begin{align} \boldsymbol{Y}_1 &= \mathbf{Y}_2\boldsymbol{\beta} + \mathbf{Z}_1\boldsymbol{\delta} + \boldsymbol{\varepsilon}\\ &= \mathbf{X}\boldsymbol{\gamma} + \boldsymbol{\varepsilon}\\ \mathbf{Y}_2 &= \mathbf{Z}_1\mathbf{\Pi}_1 + \mathbf{Z}_2\mathbf{\Pi}_2+ \mathbf{V}\\ &= \mathbf{Z}\mathbf{\Pi} + \mathbf{V}\\ \mathbb{E}(\boldsymbol{\varepsilon} \mid \mathbf{Z}) &= \boldsymbol{0} \end{align} $$ where $\mathbf{Z}_1$ is the matrix of included exogenous covariates, and $\mathbf{Z}_2$ is the matrix of excluded exogenous covariates. $\mathbf{Y}_2$ is the matrix of endogenous covariates. Then the $k$-class estimators, defined by Theil, can be written as solutions to the set of equations $$ \mathbf{X}'(\boldsymbol{i}_N - k\mathbf{M}_{\mathbf{Z}})\mathbf{X}\hat{\boldsymbol{\beta}}_{KC} = \mathbf{X}'(\boldsymbol{i}_N - k\mathbf{M}_{\mathbf{Z}})\boldsymbol{Y} $$ where $\mathbf{M}_{\mathbf{Z}} = \boldsymbol{i}_N - \mathbf{Z}\left(\mathbf{Z}'\mathbf{Z}\right)^{-1}\mathbf{Z}$ is the orthogonal projection matrix. Various choices of $k$ yield special cases, for example, the 2SLS corresponds to $k=1$. A very crude implementation of a $k$-class estimators in R is as follows: library(foreign) library(zoo) library(AER) #========================================================== # load and pre-process the data #========================================================== download.file(url = 'http://people.stern.nyu.edu/wgreene/Text/tables/TableF4-1.txt', destfile = 'mroz.txt') # read in the file dfMroz = read.table('mroz.txt', header = TRUE, skip = 36) names(dfMroz) = tolower(names(dfMroz)) summary(dfMroz) #========================================================== # k-class estimator (example: k = 0.9) #========================================================== # 2SLS estimator; to check that the formula is okay ivreg(log(ww) ~ ax. + I(ax.^2) + we | ax. + I(ax.^2) + kl6 + k618 + wa, data = dfMroz, subset = ww > 0) # OK # IV regression formula formulaMrozKC = as.Formula(log(ww) ~ ax. + I(ax.^2) + we | ax. + I(ax.^2) + kl6 + k618 + wa) ## get the model matrices mfMrozKC = model.frame(formulaMrozKC, data = dfMroz, subset = ww > 0) vY = model.response(mfMrozKC) mX = model.matrix(formulaMrozKC, data = mfMrozKC, rhs = 1) mZ = model.matrix(formulaMrozKC, data = mfMrozKC, rhs = 2) mMZ = diag(428) - mZ %*% solve(t(mZ) %*% mZ) %*% t(mZ) # k-class estimator (k = 0.9) dK = 0.9 solve(a = t(mX) %*% (diag(428) - dK*mMZ) %*% mX, b = t(mX) %*% (diag(428) - dK*mMZ) %*% vY, tol = 1e-10) LIML estimator The LIML estimator is had by setting $k$ in the $k$-class estimators to be the minimum eigenvalue of the matrix: $$ \left(\mathbf{Y} \mathbf{M}_{\mathbf{Z}}\mathbf{Y}\right)^{-1/2}\mathbf{Y} \mathbf{M}_{\mathbf{Z}_1}\mathbf{Y} \left(\mathbf{Y} \mathbf{M}_{\mathbf{Z}}\mathbf{Y}\right)^{-1/2} $$ where $\mathbf{Y} = [\boldsymbol{Y}_1, \mathbf{Y}_2]$. For a detailed discussion, see Davidson and MacKinnon (2001), pg. 539--. R implementation A very crude implementation of this in R is as follows (no guarantees about numerical efficiency are made): #========================================================== # LIML estimator (example: k = 0.9) #========================================================== # function to compute the inverse square root of a matrix fnMatSqrtInverse = function(mA) { ei = eigen(mA) d = ei$values d = (d+abs(d))/2 d2 = 1/sqrt(d) d2[d == 0] = 0 return(ei$vectors %*% diag(d2) %*% t(ei$vectors)) } mY2 = mX[, setdiff(colnames(mX), colnames(mZ))] mZ1 = mZ[, intersect(colnames(mX), colnames(mZ))] mMZ1 = diag(428) - mZ1 %*% solve(t(mZ1) %*% mZ1) %*% t(mZ1) mYStar = cbind(vY, mY2) mYZY = t(mYStar) %*% mMZ %*% mYStar mLeftRight = fnMatSqrtInverse(mYZY) dK.LIML = sort(eigen(b %*% (t(mYStar) %*% mMZ1 %*% mYStar) %*% b, only.values = TRUE)$values)[1] # LIML estimator solve(a = t(mX) %*% (diag(428) - dK.LIML*mMZ) %*% mX, b = t(mX) %*% (diag(428) - dK.LIML*mMZ) %*% vY, tol = 1e-10) The computation of the matrix square root inverse is borrowed from here.
Limited Information Maximum Likelihood (LIML) estimation in R? There are a number of ways to motivate the LIML estimator, the primary one being that it is a member of the family of IV estimators known as the $k$-class estimators. Also, to my knowledge, a direct i
40,419
Limited Information Maximum Likelihood (LIML) estimation in R?
I made an implementation of the k-class in a package, currently hosted on github, RCompAngrist (dedicated to replicate examples in Angrist and Pishke's book). The function kclass() uses the same interface than ivreg, and let to pre-specify k (obtaining OLS, 2SLS, any estim) or estimating it. It seeks to use slightly more efficient computation, mainly through a QR decomposition, but is still under development. With the actual development version, you can obtain the same results than above: library(devtools) install_github(repo = "RCompAngrist", username = "MatthieuStigler", subdir = "RcompAngrist") library(RCompAngrist) # run example of fg nu download.file(url = 'http://people.stern.nyu.edu/wgreene/Text/tables/TableF4-1.txt', destfile = 'mroz.txt') dfMroz = read.table('mroz.txt', header = TRUE, skip = 36) names(dfMroz) = tolower(names(dfMroz)) # do subset outside (currently arg subset within kclass does not work well) dfMroz2 <- subset(dfMroz, ww>0) # estimate 2SLS (k=1): same results than ivreg (different order though) kclass(log(ww) ~ ax. + I(ax.^2) + we | ax. + I(ax.^2) + kl6 + k618 + wa, data = dfMroz2, k=1) # estimate k-class with k= 0.9 k_0_9_kclass <- kclass(log(ww) ~ ax. + I(ax.^2) + we | ax. + I(ax.^2) + kl6 + k618 + wa, data = dfMroz2, k=0.9) ## Compare results with code of fg nu k_0_9_manual <- solve(a = t(mX) %*% (diag(428) - dK*mMZ) %*% mX, b = t(mX) %*% (diag(428) - dK*mMZ) %*% vY, tol = 1e-10) all.equal(coef(k_0_9_kclass), k_0_9_manual[c(4,1,2,3),1], check.attributes = FALSE) # obtain k value: leave arg k NULL: k_0_9_kclass <- kclass(log(ww) ~ ax. + I(ax.^2) + we | ax. + I(ax.^2) + kl6 + k618 + wa, data = dfMroz2) # same k than code of fg nu? Could not compare as missing b, to be done soon
Limited Information Maximum Likelihood (LIML) estimation in R?
I made an implementation of the k-class in a package, currently hosted on github, RCompAngrist (dedicated to replicate examples in Angrist and Pishke's book). The function kclass() uses the same inter
Limited Information Maximum Likelihood (LIML) estimation in R? I made an implementation of the k-class in a package, currently hosted on github, RCompAngrist (dedicated to replicate examples in Angrist and Pishke's book). The function kclass() uses the same interface than ivreg, and let to pre-specify k (obtaining OLS, 2SLS, any estim) or estimating it. It seeks to use slightly more efficient computation, mainly through a QR decomposition, but is still under development. With the actual development version, you can obtain the same results than above: library(devtools) install_github(repo = "RCompAngrist", username = "MatthieuStigler", subdir = "RcompAngrist") library(RCompAngrist) # run example of fg nu download.file(url = 'http://people.stern.nyu.edu/wgreene/Text/tables/TableF4-1.txt', destfile = 'mroz.txt') dfMroz = read.table('mroz.txt', header = TRUE, skip = 36) names(dfMroz) = tolower(names(dfMroz)) # do subset outside (currently arg subset within kclass does not work well) dfMroz2 <- subset(dfMroz, ww>0) # estimate 2SLS (k=1): same results than ivreg (different order though) kclass(log(ww) ~ ax. + I(ax.^2) + we | ax. + I(ax.^2) + kl6 + k618 + wa, data = dfMroz2, k=1) # estimate k-class with k= 0.9 k_0_9_kclass <- kclass(log(ww) ~ ax. + I(ax.^2) + we | ax. + I(ax.^2) + kl6 + k618 + wa, data = dfMroz2, k=0.9) ## Compare results with code of fg nu k_0_9_manual <- solve(a = t(mX) %*% (diag(428) - dK*mMZ) %*% mX, b = t(mX) %*% (diag(428) - dK*mMZ) %*% vY, tol = 1e-10) all.equal(coef(k_0_9_kclass), k_0_9_manual[c(4,1,2,3),1], check.attributes = FALSE) # obtain k value: leave arg k NULL: k_0_9_kclass <- kclass(log(ww) ~ ax. + I(ax.^2) + we | ax. + I(ax.^2) + kl6 + k618 + wa, data = dfMroz2) # same k than code of fg nu? Could not compare as missing b, to be done soon
Limited Information Maximum Likelihood (LIML) estimation in R? I made an implementation of the k-class in a package, currently hosted on github, RCompAngrist (dedicated to replicate examples in Angrist and Pishke's book). The function kclass() uses the same inter
40,420
Limited Information Maximum Likelihood (LIML) estimation in R?
The R package ivmodel implements the LIML estimator (link here).
Limited Information Maximum Likelihood (LIML) estimation in R?
The R package ivmodel implements the LIML estimator (link here).
Limited Information Maximum Likelihood (LIML) estimation in R? The R package ivmodel implements the LIML estimator (link here).
Limited Information Maximum Likelihood (LIML) estimation in R? The R package ivmodel implements the LIML estimator (link here).
40,421
Is conditional logit a specific form of GLM? And what are its specificities?
Your reference says that clogit is a special form of Cox regression, not the GLMM. So you are probably mixing things up. The conditional logit log-likelihood is (reverse engineering the LaTeX code from the Stata manual): conditional on $\sum_{j=1}^{n_i} y_{ij} = k_{1i}$, $$ {\rm Pr}\Bigl[(y_{i1},\ldots,y_{i{n_i}})|\sum_{j=1}^{n_i} y_{ij} = k_{1i}\Bigr] = \frac{\exp(\sum_{j=1}^{n_i} y_{ij} x_{ij}'\beta)}{\sum_{{\bf d}_i\in S_i}\exp(\sum_{j=1}^{n_i} y_{ij} x_{ij}'\beta)} $$ where $S_i$ is a set of all possible combinations of $n_i$ binary outcomes, with $k_{1i}$ ones and remaining zeroes, so the summation index-vector has components $d_{ij}$ that are 0/1 with $\sum_{i=1}^{n_i} d_{ij} = k_{1i}$. That's a pretty weird likelihood to me. Denoting the denominator as $f_i(n_i,k_{1i})$, the conditional log-likelihood is $$ \ln L = \sum_{i=1}^n \biggl[ \sum_{j=1}^{n_i} y_{ij} x_{ij}'\beta - \ln f_i(n_i, k_{1i}) \biggr] $$ This likelihood can be computed exactly, although the computational time goes up steeply as $p^2 \sum_{i=1}^n n_i \min(k_{1i}, n_i - k_{1i})$ where $p={\rm dim}\, \beta = {\rm dim}\, x_{ij}$. This is the likelihood that should be identical to the stratified Cox regression, which I won't try to entertain here. The mixed model likelihood (again, adopting from Stata manuals) is based on integrating out the random effects: $$ {\rm Pr}(y_{i1}, \ldots, y_{1{n_i}} |x_{i1}, \ldots, x_{i{n_i}})=\int_{-\infty}^{+\infty} \frac{\exp(-\nu_i^2/2\sigma_\nu^2)}{\sigma_\nu \sqrt{2\pi}} \prod_{i=1}^{n_i}F(y_{ij}, x_{ij}'\beta + \nu_i) $$ where $ F(y,z) = \Bigl\{ 1+\exp\bigl[ (-1)^y z \bigr] \Bigr\}^{-1} $ is a witty way to write down the logistic contribution for the outcome $y=0,1$. This likelihood cannot be computed exactly, and in practice is approximated numerically using a set of Gaussian quadrature points with abscissas $a_m$ and weights $w_m$ resembling the density of the standard normal density on a grid, producing (in the simplest version) $$ \ln L \approx \sum_{i=1}^n \ln\biggl[ \sqrt{2} \sum_{m=1}^M w_m \frac{1}{\sigma_\nu \sqrt{2\pi}} \prod_{i=1}^{n_i}F(y_{ij}, x_{ij}'\beta + \sqrt{2} \sigma_\nu a_m) \biggr] $$ (The $\exp(\nu_i^2)$-like terms disappear due to the full quadrature formula, but since it is designed for the physicist' erf() function rather than statisticians' $\Phi()$ function, it works with $\exp(-z^2)$ rather than $\exp(-z^2/2)$; hence the weird $\sqrt{2}$ in a couple of places.) Computational time for $\ln L$ itself is proportional to $nM$, but since you need to take the second order derivatives for Newton-Raphson, feel free to multiply by $p^2$. Smarter computational schemes aka adaptive Gaussian quadratures try to find a better location and scale parameters for the quadrature to make the approximation more accurate. In fact, that latter Stata manual describes the differences between the GLMM (aka random effect xtlogit, in econometric slang) and conditional logit (aka fixed effect xtlogit), and might be worth a more serious reading.
Is conditional logit a specific form of GLM? And what are its specificities?
Your reference says that clogit is a special form of Cox regression, not the GLMM. So you are probably mixing things up. The conditional logit log-likelihood is (reverse engineering the LaTeX code fro
Is conditional logit a specific form of GLM? And what are its specificities? Your reference says that clogit is a special form of Cox regression, not the GLMM. So you are probably mixing things up. The conditional logit log-likelihood is (reverse engineering the LaTeX code from the Stata manual): conditional on $\sum_{j=1}^{n_i} y_{ij} = k_{1i}$, $$ {\rm Pr}\Bigl[(y_{i1},\ldots,y_{i{n_i}})|\sum_{j=1}^{n_i} y_{ij} = k_{1i}\Bigr] = \frac{\exp(\sum_{j=1}^{n_i} y_{ij} x_{ij}'\beta)}{\sum_{{\bf d}_i\in S_i}\exp(\sum_{j=1}^{n_i} y_{ij} x_{ij}'\beta)} $$ where $S_i$ is a set of all possible combinations of $n_i$ binary outcomes, with $k_{1i}$ ones and remaining zeroes, so the summation index-vector has components $d_{ij}$ that are 0/1 with $\sum_{i=1}^{n_i} d_{ij} = k_{1i}$. That's a pretty weird likelihood to me. Denoting the denominator as $f_i(n_i,k_{1i})$, the conditional log-likelihood is $$ \ln L = \sum_{i=1}^n \biggl[ \sum_{j=1}^{n_i} y_{ij} x_{ij}'\beta - \ln f_i(n_i, k_{1i}) \biggr] $$ This likelihood can be computed exactly, although the computational time goes up steeply as $p^2 \sum_{i=1}^n n_i \min(k_{1i}, n_i - k_{1i})$ where $p={\rm dim}\, \beta = {\rm dim}\, x_{ij}$. This is the likelihood that should be identical to the stratified Cox regression, which I won't try to entertain here. The mixed model likelihood (again, adopting from Stata manuals) is based on integrating out the random effects: $$ {\rm Pr}(y_{i1}, \ldots, y_{1{n_i}} |x_{i1}, \ldots, x_{i{n_i}})=\int_{-\infty}^{+\infty} \frac{\exp(-\nu_i^2/2\sigma_\nu^2)}{\sigma_\nu \sqrt{2\pi}} \prod_{i=1}^{n_i}F(y_{ij}, x_{ij}'\beta + \nu_i) $$ where $ F(y,z) = \Bigl\{ 1+\exp\bigl[ (-1)^y z \bigr] \Bigr\}^{-1} $ is a witty way to write down the logistic contribution for the outcome $y=0,1$. This likelihood cannot be computed exactly, and in practice is approximated numerically using a set of Gaussian quadrature points with abscissas $a_m$ and weights $w_m$ resembling the density of the standard normal density on a grid, producing (in the simplest version) $$ \ln L \approx \sum_{i=1}^n \ln\biggl[ \sqrt{2} \sum_{m=1}^M w_m \frac{1}{\sigma_\nu \sqrt{2\pi}} \prod_{i=1}^{n_i}F(y_{ij}, x_{ij}'\beta + \sqrt{2} \sigma_\nu a_m) \biggr] $$ (The $\exp(\nu_i^2)$-like terms disappear due to the full quadrature formula, but since it is designed for the physicist' erf() function rather than statisticians' $\Phi()$ function, it works with $\exp(-z^2)$ rather than $\exp(-z^2/2)$; hence the weird $\sqrt{2}$ in a couple of places.) Computational time for $\ln L$ itself is proportional to $nM$, but since you need to take the second order derivatives for Newton-Raphson, feel free to multiply by $p^2$. Smarter computational schemes aka adaptive Gaussian quadratures try to find a better location and scale parameters for the quadrature to make the approximation more accurate. In fact, that latter Stata manual describes the differences between the GLMM (aka random effect xtlogit, in econometric slang) and conditional logit (aka fixed effect xtlogit), and might be worth a more serious reading.
Is conditional logit a specific form of GLM? And what are its specificities? Your reference says that clogit is a special form of Cox regression, not the GLMM. So you are probably mixing things up. The conditional logit log-likelihood is (reverse engineering the LaTeX code fro
40,422
Why does this criterion characterize the median of a continuous random variable?
When $a$ is a local minimum of $\mathbb{E}|X-a|$, that means for sufficiently small $\varepsilon$ the value of this expectation will not decrease when $a$ is changed to $a + \varepsilon$: $$0 \le \mathbb{E}|X-(a+\varepsilon)| - \mathbb{E}|X-a| = \mathbb{E}[|X-(a+\varepsilon)| - |X-a|].$$ Consider the case where $\varepsilon \ge 0$. The argument of the right hand side equals $\varepsilon$ for $X \le a$, $-\varepsilon$ for $X \ge a+\varepsilon$, and otherwise has magnitude less than $\varepsilon$. Therefore, letting $F$ be the CDF of $X$ and integrating, it is now evident that the right hand side is the sum of three things: $\varepsilon F(a)$ coming from $X \le a$, $-\varepsilon (1-F(a+\varepsilon))$ coming from $X \ge a$, and Something less than $\varepsilon(F(a+\varepsilon) - F(a))$ coming from $a \lt X \lt a+\varepsilon$. The continuity assumption for the distribution of $X$, which amounts to assuming $F$ is differentiable, is tantamount to saying that the third part equals $F'(a)\varepsilon^2 + o(\varepsilon^2)$. Similarly, the second part can be expanded $$-\varepsilon (1-F(a+\varepsilon)) = \varepsilon(F(a)-1) + F'(a)\varepsilon^2 + o(\varepsilon^2).$$ Adding all three up yields $$0 \le \mathbb{E}[|X-(a+\varepsilon)| - |X-a|] = \varepsilon(2F(a)-1) + O(\varepsilon^2).$$ It should be evident that the same result holds when $\varepsilon \lt 0$. (Just apply the preceding result to the variable $-X$.) This inequality can be true for arbitrarily small $\varepsilon$ if and only if the coefficient of $\varepsilon$ is zero, whence $$2F(a) - 1=0.$$ Accordingly, at any local minimum $a^*$, $F(a^*) = 1/2$. That defines a median. (Note that the median might not be unique: if $F$ is constant in a neighborhood of a median, all values in that neighborhood will be local minima.)
Why does this criterion characterize the median of a continuous random variable?
When $a$ is a local minimum of $\mathbb{E}|X-a|$, that means for sufficiently small $\varepsilon$ the value of this expectation will not decrease when $a$ is changed to $a + \varepsilon$: $$0 \le \mat
Why does this criterion characterize the median of a continuous random variable? When $a$ is a local minimum of $\mathbb{E}|X-a|$, that means for sufficiently small $\varepsilon$ the value of this expectation will not decrease when $a$ is changed to $a + \varepsilon$: $$0 \le \mathbb{E}|X-(a+\varepsilon)| - \mathbb{E}|X-a| = \mathbb{E}[|X-(a+\varepsilon)| - |X-a|].$$ Consider the case where $\varepsilon \ge 0$. The argument of the right hand side equals $\varepsilon$ for $X \le a$, $-\varepsilon$ for $X \ge a+\varepsilon$, and otherwise has magnitude less than $\varepsilon$. Therefore, letting $F$ be the CDF of $X$ and integrating, it is now evident that the right hand side is the sum of three things: $\varepsilon F(a)$ coming from $X \le a$, $-\varepsilon (1-F(a+\varepsilon))$ coming from $X \ge a$, and Something less than $\varepsilon(F(a+\varepsilon) - F(a))$ coming from $a \lt X \lt a+\varepsilon$. The continuity assumption for the distribution of $X$, which amounts to assuming $F$ is differentiable, is tantamount to saying that the third part equals $F'(a)\varepsilon^2 + o(\varepsilon^2)$. Similarly, the second part can be expanded $$-\varepsilon (1-F(a+\varepsilon)) = \varepsilon(F(a)-1) + F'(a)\varepsilon^2 + o(\varepsilon^2).$$ Adding all three up yields $$0 \le \mathbb{E}[|X-(a+\varepsilon)| - |X-a|] = \varepsilon(2F(a)-1) + O(\varepsilon^2).$$ It should be evident that the same result holds when $\varepsilon \lt 0$. (Just apply the preceding result to the variable $-X$.) This inequality can be true for arbitrarily small $\varepsilon$ if and only if the coefficient of $\varepsilon$ is zero, whence $$2F(a) - 1=0.$$ Accordingly, at any local minimum $a^*$, $F(a^*) = 1/2$. That defines a median. (Note that the median might not be unique: if $F$ is constant in a neighborhood of a median, all values in that neighborhood will be local minima.)
Why does this criterion characterize the median of a continuous random variable? When $a$ is a local minimum of $\mathbb{E}|X-a|$, that means for sufficiently small $\varepsilon$ the value of this expectation will not decrease when $a$ is changed to $a + \varepsilon$: $$0 \le \mat
40,423
Why does this criterion characterize the median of a continuous random variable?
Here's a simple conceptual explanation. You want to park your car and walk to two different stores. If you park anywhere on the line between them, your total walking distance will be minimized because if you move the car the distance to one store will increase by exactly the amount that the distance to the other decreases. If you park beyond either store (on the extension of that line) you'll have to walk further. Now add another two stores and think about it the same way. If you have an odd number of stores, you'll park in the middle one and the total distances to the others will be minimized. (The store owner may get upset but we're doing a thought experiment here.)
Why does this criterion characterize the median of a continuous random variable?
Here's a simple conceptual explanation. You want to park your car and walk to two different stores. If you park anywhere on the line between them, your total walking distance will be minimized becau
Why does this criterion characterize the median of a continuous random variable? Here's a simple conceptual explanation. You want to park your car and walk to two different stores. If you park anywhere on the line between them, your total walking distance will be minimized because if you move the car the distance to one store will increase by exactly the amount that the distance to the other decreases. If you park beyond either store (on the extension of that line) you'll have to walk further. Now add another two stores and think about it the same way. If you have an odd number of stores, you'll park in the middle one and the total distances to the others will be minimized. (The store owner may get upset but we're doing a thought experiment here.)
Why does this criterion characterize the median of a continuous random variable? Here's a simple conceptual explanation. You want to park your car and walk to two different stores. If you park anywhere on the line between them, your total walking distance will be minimized becau
40,424
Why does this criterion characterize the median of a continuous random variable?
A faster resolution of the minimisation is based on the representation (by an integration by part) $$\int_0^\infty x \text{d}F(x)=\int_0^\infty (1-F(x))\text{d}x$$ which leads to \begin{align*}\mathbb{E}[|X-a|]&=\int_{-\infty}^a (a-x) \text{d}F(x)+\int^{\infty}_a (x-a) \text{d}F(x)\\&=\int_{-\infty}^a F(x) \text{d}x+\int^{\infty}_a (1-F(x)) \text{d}x\\ \end{align*} Differentiating in $a$ and setting the value to zero leads to the equation $$F(a)-(1-F(a))=0$$that is$$F(a)=\frac{1}{2}$$
Why does this criterion characterize the median of a continuous random variable?
A faster resolution of the minimisation is based on the representation (by an integration by part) $$\int_0^\infty x \text{d}F(x)=\int_0^\infty (1-F(x))\text{d}x$$ which leads to \begin{align*}\mathbb
Why does this criterion characterize the median of a continuous random variable? A faster resolution of the minimisation is based on the representation (by an integration by part) $$\int_0^\infty x \text{d}F(x)=\int_0^\infty (1-F(x))\text{d}x$$ which leads to \begin{align*}\mathbb{E}[|X-a|]&=\int_{-\infty}^a (a-x) \text{d}F(x)+\int^{\infty}_a (x-a) \text{d}F(x)\\&=\int_{-\infty}^a F(x) \text{d}x+\int^{\infty}_a (1-F(x)) \text{d}x\\ \end{align*} Differentiating in $a$ and setting the value to zero leads to the equation $$F(a)-(1-F(a))=0$$that is$$F(a)=\frac{1}{2}$$
Why does this criterion characterize the median of a continuous random variable? A faster resolution of the minimisation is based on the representation (by an integration by part) $$\int_0^\infty x \text{d}F(x)=\int_0^\infty (1-F(x))\text{d}x$$ which leads to \begin{align*}\mathbb
40,425
Handling poor inter-rater reliability while minimizing the loss of data
In a previous job I ran into this a lot. All sorts of inconsistencies. Like @rolando2 I don't think any general solution is going to be nearly as good as what you can come up with on your own; you would then just have to justify it to whoever your audience is. However, one thing you can do is a series of sensitivity analyses, treating the data different ways. that is, if two questions have answers that are inconsistent you could first run the analysis assuming everyone answered the first question correctly and then as if everyone answered the second question correctly. For some specific inconsistencies, there are known results. For example, it is known that if you ask people "how old are you?" and "When were you born?" the latter answers will be more accurate. In general, if the questions are such that stigma is attached to one answer, the more stigmatized answer is likely to be correct.
Handling poor inter-rater reliability while minimizing the loss of data
In a previous job I ran into this a lot. All sorts of inconsistencies. Like @rolando2 I don't think any general solution is going to be nearly as good as what you can come up with on your own; you wou
Handling poor inter-rater reliability while minimizing the loss of data In a previous job I ran into this a lot. All sorts of inconsistencies. Like @rolando2 I don't think any general solution is going to be nearly as good as what you can come up with on your own; you would then just have to justify it to whoever your audience is. However, one thing you can do is a series of sensitivity analyses, treating the data different ways. that is, if two questions have answers that are inconsistent you could first run the analysis assuming everyone answered the first question correctly and then as if everyone answered the second question correctly. For some specific inconsistencies, there are known results. For example, it is known that if you ask people "how old are you?" and "When were you born?" the latter answers will be more accurate. In general, if the questions are such that stigma is attached to one answer, the more stigmatized answer is likely to be correct.
Handling poor inter-rater reliability while minimizing the loss of data In a previous job I ran into this a lot. All sorts of inconsistencies. Like @rolando2 I don't think any general solution is going to be nearly as good as what you can come up with on your own; you wou
40,426
Handling poor inter-rater reliability while minimizing the loss of data
Structural equation modeling may help here, particularly confirmatory factor analysis, which allows you to test whether your hypothesized measurement model fits the data and if not, how you might adjust it to do so, for example by dropping items. Like exploratory factor analysis, CFA models survey responses (or other items measuring some latent construct) as arising from one or more underlying dimensions and random error. Generally you need at least three items per construct to identify a measurement model though with multiple dimensions you can sometimes get away with only two. Once you've specified your latent constructs and the items hypothesized to measure each construct, you estimate the model and you will get a number of fit indexes that you can use to judge whether your model is adequate. You can compare different models by means of various criteria as well. You can inspect factor loadings and error variances for each item to see whether it seems to be a good item for measuring the underlying construct or not. This gives you guidance as to which items (i.e. columns in your data set) may be dropped from your model. Beyond just creating a measurement model, you can further specify directional relations between latent constructs using a structural equation model (SEM). This is preferable to using, for example, traditional linear regression because measurement error is explicitly modeled whereas in the usual approach only random error in the outcome variable is assumed. You can use the sem package in R to build CFA and SEM models. I have not used that package however. I have used Mplus and Amos and prefer Mplus for the great variety of structural equation models it can handle including those with binary indicators. For a reference, I like Kline's book on SEM.
Handling poor inter-rater reliability while minimizing the loss of data
Structural equation modeling may help here, particularly confirmatory factor analysis, which allows you to test whether your hypothesized measurement model fits the data and if not, how you might adju
Handling poor inter-rater reliability while minimizing the loss of data Structural equation modeling may help here, particularly confirmatory factor analysis, which allows you to test whether your hypothesized measurement model fits the data and if not, how you might adjust it to do so, for example by dropping items. Like exploratory factor analysis, CFA models survey responses (or other items measuring some latent construct) as arising from one or more underlying dimensions and random error. Generally you need at least three items per construct to identify a measurement model though with multiple dimensions you can sometimes get away with only two. Once you've specified your latent constructs and the items hypothesized to measure each construct, you estimate the model and you will get a number of fit indexes that you can use to judge whether your model is adequate. You can compare different models by means of various criteria as well. You can inspect factor loadings and error variances for each item to see whether it seems to be a good item for measuring the underlying construct or not. This gives you guidance as to which items (i.e. columns in your data set) may be dropped from your model. Beyond just creating a measurement model, you can further specify directional relations between latent constructs using a structural equation model (SEM). This is preferable to using, for example, traditional linear regression because measurement error is explicitly modeled whereas in the usual approach only random error in the outcome variable is assumed. You can use the sem package in R to build CFA and SEM models. I have not used that package however. I have used Mplus and Amos and prefer Mplus for the great variety of structural equation models it can handle including those with binary indicators. For a reference, I like Kline's book on SEM.
Handling poor inter-rater reliability while minimizing the loss of data Structural equation modeling may help here, particularly confirmatory factor analysis, which allows you to test whether your hypothesized measurement model fits the data and if not, how you might adju
40,427
Replicating simulation results from a paper
Note: In the original post, I noted that (aside from a minor error which has since been corrected) this was actually a problem with plotting the density, not with the simulation. At the time I wasn't sure what was going on, but I found that truncating the data seemed to solve the problem, so I recommended that. I have since figured out the real problem, so I decided to edit this to suggest a better solution. With $n=3$, the distribution we are simulating from has very heavy tails. Even though the mean is zero and the inter-quartile range is about 4, in 100,000 draws (or more) we get a few on the order of 1,000,000 in absolute value. By default, the density function estimates the density at 512 equally-spaced points that completely cover the range of the data (plus a little). In this case, we were only interested in plotting the density over a very small portion of that range--for $x \in [0,5]$. As a result, when we plotted that window, we got what looked like a flat horizontal line, which connected the estimates at points on the order of -2000 and 2000. Not very useful. My original solution, truncating the data, gave decent looking plots, but wasn't really very satisfying. So I played around with it a bit and figured out the problem and how to solve it: the density function has arguments from and to, which give lower and upper bounds between which is estimates the density. By setting from=0, to=5 we get the following plot, without any truncation: This is both easier and more correct (since the density is distorted slightly by the truncation) than my original solution. The complete code I used (adapted slightly from the code provided in the question) is: v <- rt(100000, 1)/sqrt(3-2) w <- rchisq(100000,2) z <- rnorm(n=100000, m=0, sd=1) z_eff_3 <- v + z * sqrt((3*(1+v*v))/w) plot(density(z_eff_3,from=0,to=5),xlim=c(0,5)) Hope that helps.
Replicating simulation results from a paper
Note: In the original post, I noted that (aside from a minor error which has since been corrected) this was actually a problem with plotting the density, not with the simulation. At the time I wasn't
Replicating simulation results from a paper Note: In the original post, I noted that (aside from a minor error which has since been corrected) this was actually a problem with plotting the density, not with the simulation. At the time I wasn't sure what was going on, but I found that truncating the data seemed to solve the problem, so I recommended that. I have since figured out the real problem, so I decided to edit this to suggest a better solution. With $n=3$, the distribution we are simulating from has very heavy tails. Even though the mean is zero and the inter-quartile range is about 4, in 100,000 draws (or more) we get a few on the order of 1,000,000 in absolute value. By default, the density function estimates the density at 512 equally-spaced points that completely cover the range of the data (plus a little). In this case, we were only interested in plotting the density over a very small portion of that range--for $x \in [0,5]$. As a result, when we plotted that window, we got what looked like a flat horizontal line, which connected the estimates at points on the order of -2000 and 2000. Not very useful. My original solution, truncating the data, gave decent looking plots, but wasn't really very satisfying. So I played around with it a bit and figured out the problem and how to solve it: the density function has arguments from and to, which give lower and upper bounds between which is estimates the density. By setting from=0, to=5 we get the following plot, without any truncation: This is both easier and more correct (since the density is distorted slightly by the truncation) than my original solution. The complete code I used (adapted slightly from the code provided in the question) is: v <- rt(100000, 1)/sqrt(3-2) w <- rchisq(100000,2) z <- rnorm(n=100000, m=0, sd=1) z_eff_3 <- v + z * sqrt((3*(1+v*v))/w) plot(density(z_eff_3,from=0,to=5),xlim=c(0,5)) Hope that helps.
Replicating simulation results from a paper Note: In the original post, I noted that (aside from a minor error which has since been corrected) this was actually a problem with plotting the density, not with the simulation. At the time I wasn't
40,428
How do I create and interpret an interaction plot in ggplot2?
The original suggestion for displaying an interaction via box-plot does not quite make sense in this instance, since both of your variables that define the interaction are continuous. You could dichotomize either G or P, but you do not have much data to work with. Because of this, I would suggest coplots (a description of what they are can be found in; Cleveland, William. 1994. Coplots, nonparametric regression, and conditionally parametric fits. IMS Lecture Notes Monograph Series 24: 21-36. PDF available in link from Project Euclid. Below is a coplot of the election2012 data generated by the code coplot(VP ~ P | G, data = election2012). So this is assessing the effect of P on VP conditional on varying values of G. Although your description makes it sound like this is a fishing expedition, we may entertain the possibility that an interaction between these two variables exist. The coplot seems to show that for lower values of G the effect of P is positive, and for higher values of G the effect of P is negative. After assessing marginal histograms and bivariate scatterplots of VP, P, G and the interaction between P and G, it seemed to me that 1932 was likely a high leverage value for the interaction effect. Below are four scatterplots, showing the marginal relationships between VP and the mean centered V, G and the interaction of V and G (what I named int_gpcent). I have highlighted 1932 as a red dot. The last plot on the lower right is the residuals of the linear model lm(VP ~ g_cent + p_cent, data = election2012) against int_gpcent. Below I provide code that shows when removing 1932 from the linear model lm(VP ~ g_cent + p_cent + int_gpcent, data = election2012) the interaction of G and P fail to reach statistical significance. Of course this is all just exploratory (one would also want to assess if any temporal correlation occurs in the series, but hopefully this is a good start. Save ggplot for when you have a better idea of what you exactly want to plot! #data and directory stuff mydir <- "C:\\Documents and Settings\\andrew.wheeler\\Desktop\\R_interaction" setwd(mydir) election2012 <- read.table("election2012.txt", header=T, quote="\"") #making interaction variable election2012$g_cent <- election2012$G - mean(election2012$G) election2012$p_cent <- election2012$P - mean(election2012$P) election2012$int_gpcent <- election2012$g_cent * election2012$p_cent summary(election2012) View(election2012) par(mfrow= c(2, 2)) hist(election2012$VP) hist(election2012$G) hist(election2012$P) hist(election2012$int_gpcent) #scatterplot & correlation matrix cor(election2012[c("VP", "g_cent", "p_cent", "int_gpcent")]) pairs(election2012[c("VP", "g_cent", "p_cent", "int_gpcent")]) #lets just check out a coplot for interactions #coplot(VP ~ G | P, data = election2012) coplot(VP ~ P | G, data = election2012) #example of coplot - http://stackoverflow.com/questions/5857726/how-to-delete-the-given-in-a-coplot-using-r #onto models model1 <- lm(VP ~ g_cent + p_cent, data = election2012) summary(model1) election2012$resid_m1 <- residuals(model1) election2012$color <- "black" election2012$color[14] <- "red" attach(election2012) par(mfrow = c(2,2)) plot(x = g_cent,y = VP, col = color, pch = 16) plot(x = p_cent,y = VP, col = color, pch = 16) plot(x = int_gpcent,y = VP, col = color, pch = 16) plot(x = int_gpcent,y = resid_m1, col = color, pch = 16) #what does the same model look like with 1932 removed model1_int <- lm(VP ~ g_cent + p_cent + int_gpcent, data = election2012) summary(model1_int) model2_int <- lm(VP ~ g_cent + p_cent + int_gpcent, data = election2012[-14,]) summary(model2)
How do I create and interpret an interaction plot in ggplot2?
The original suggestion for displaying an interaction via box-plot does not quite make sense in this instance, since both of your variables that define the interaction are continuous. You could dichot
How do I create and interpret an interaction plot in ggplot2? The original suggestion for displaying an interaction via box-plot does not quite make sense in this instance, since both of your variables that define the interaction are continuous. You could dichotomize either G or P, but you do not have much data to work with. Because of this, I would suggest coplots (a description of what they are can be found in; Cleveland, William. 1994. Coplots, nonparametric regression, and conditionally parametric fits. IMS Lecture Notes Monograph Series 24: 21-36. PDF available in link from Project Euclid. Below is a coplot of the election2012 data generated by the code coplot(VP ~ P | G, data = election2012). So this is assessing the effect of P on VP conditional on varying values of G. Although your description makes it sound like this is a fishing expedition, we may entertain the possibility that an interaction between these two variables exist. The coplot seems to show that for lower values of G the effect of P is positive, and for higher values of G the effect of P is negative. After assessing marginal histograms and bivariate scatterplots of VP, P, G and the interaction between P and G, it seemed to me that 1932 was likely a high leverage value for the interaction effect. Below are four scatterplots, showing the marginal relationships between VP and the mean centered V, G and the interaction of V and G (what I named int_gpcent). I have highlighted 1932 as a red dot. The last plot on the lower right is the residuals of the linear model lm(VP ~ g_cent + p_cent, data = election2012) against int_gpcent. Below I provide code that shows when removing 1932 from the linear model lm(VP ~ g_cent + p_cent + int_gpcent, data = election2012) the interaction of G and P fail to reach statistical significance. Of course this is all just exploratory (one would also want to assess if any temporal correlation occurs in the series, but hopefully this is a good start. Save ggplot for when you have a better idea of what you exactly want to plot! #data and directory stuff mydir <- "C:\\Documents and Settings\\andrew.wheeler\\Desktop\\R_interaction" setwd(mydir) election2012 <- read.table("election2012.txt", header=T, quote="\"") #making interaction variable election2012$g_cent <- election2012$G - mean(election2012$G) election2012$p_cent <- election2012$P - mean(election2012$P) election2012$int_gpcent <- election2012$g_cent * election2012$p_cent summary(election2012) View(election2012) par(mfrow= c(2, 2)) hist(election2012$VP) hist(election2012$G) hist(election2012$P) hist(election2012$int_gpcent) #scatterplot & correlation matrix cor(election2012[c("VP", "g_cent", "p_cent", "int_gpcent")]) pairs(election2012[c("VP", "g_cent", "p_cent", "int_gpcent")]) #lets just check out a coplot for interactions #coplot(VP ~ G | P, data = election2012) coplot(VP ~ P | G, data = election2012) #example of coplot - http://stackoverflow.com/questions/5857726/how-to-delete-the-given-in-a-coplot-using-r #onto models model1 <- lm(VP ~ g_cent + p_cent, data = election2012) summary(model1) election2012$resid_m1 <- residuals(model1) election2012$color <- "black" election2012$color[14] <- "red" attach(election2012) par(mfrow = c(2,2)) plot(x = g_cent,y = VP, col = color, pch = 16) plot(x = p_cent,y = VP, col = color, pch = 16) plot(x = int_gpcent,y = VP, col = color, pch = 16) plot(x = int_gpcent,y = resid_m1, col = color, pch = 16) #what does the same model look like with 1932 removed model1_int <- lm(VP ~ g_cent + p_cent + int_gpcent, data = election2012) summary(model1_int) model2_int <- lm(VP ~ g_cent + p_cent + int_gpcent, data = election2012[-14,]) summary(model2)
How do I create and interpret an interaction plot in ggplot2? The original suggestion for displaying an interaction via box-plot does not quite make sense in this instance, since both of your variables that define the interaction are continuous. You could dichot
40,429
Why are RBMs symmetric?
Well, RBM is an energy based model, and as such it has undirected edges, and thus you could say "symmetric weights". The probability distribution over visible and hidden units, defined by the RBM is based on the Energy function: $$E = -\sum_{i,j} w_{ij} \, v_i \, h_j -\sum_i \alpha_i \, v_i - \sum_i \beta_i \, h_i$$ As you can see, even if you wanted to somehow introduce asymmetric weights, they would average out. In short, usage of asymmetric weights simply makes no sense in case of RBM, since it is an energy-based model defined by an undirected graph. Now, you wanted to know "What is the intuition behind this design decision". I guess you could ask this question here, "Why make RBM's energy based models defined by an undirected graph? Why not use a directed graph?". And it would be a damn deep question. The short answer is: you can. A model similar to RBM with directed egdes is called sigmoid belief net. They are directed graphs, and not energy based. They are different in how they are trained, and in where the problems with training arises. Since it's not directly connected to your original question, and I just thought you might be interested, I'll drop you great learning material for both RBM and sigmoid belief nets: https://class.coursera.org/neuralnets-2012-001/lecture/index The class is taught by Geoffrey Hinton himself. I highly recommend it if you are interested in neural networks in general. Also, it might be a good idea to download the videos now, since class closes in few weeks, and then they won't be available anymore. The lectures most relevant to your question, that will also really make your understanding of RBM much deeper are 11, 12, 13, 14.
Why are RBMs symmetric?
Well, RBM is an energy based model, and as such it has undirected edges, and thus you could say "symmetric weights". The probability distribution over visible and hidden units, defined by the RBM is b
Why are RBMs symmetric? Well, RBM is an energy based model, and as such it has undirected edges, and thus you could say "symmetric weights". The probability distribution over visible and hidden units, defined by the RBM is based on the Energy function: $$E = -\sum_{i,j} w_{ij} \, v_i \, h_j -\sum_i \alpha_i \, v_i - \sum_i \beta_i \, h_i$$ As you can see, even if you wanted to somehow introduce asymmetric weights, they would average out. In short, usage of asymmetric weights simply makes no sense in case of RBM, since it is an energy-based model defined by an undirected graph. Now, you wanted to know "What is the intuition behind this design decision". I guess you could ask this question here, "Why make RBM's energy based models defined by an undirected graph? Why not use a directed graph?". And it would be a damn deep question. The short answer is: you can. A model similar to RBM with directed egdes is called sigmoid belief net. They are directed graphs, and not energy based. They are different in how they are trained, and in where the problems with training arises. Since it's not directly connected to your original question, and I just thought you might be interested, I'll drop you great learning material for both RBM and sigmoid belief nets: https://class.coursera.org/neuralnets-2012-001/lecture/index The class is taught by Geoffrey Hinton himself. I highly recommend it if you are interested in neural networks in general. Also, it might be a good idea to download the videos now, since class closes in few weeks, and then they won't be available anymore. The lectures most relevant to your question, that will also really make your understanding of RBM much deeper are 11, 12, 13, 14.
Why are RBMs symmetric? Well, RBM is an energy based model, and as such it has undirected edges, and thus you could say "symmetric weights". The probability distribution over visible and hidden units, defined by the RBM is b
40,430
Why are RBMs symmetric?
Back propagation Neural Network works in a "inductive/causal" way, that is, the i-th layer induces the (i+1)-th layer. It is one way directional, not bi-directional. As a result, we get a "deterministic" result rather than a stochastic result. On the other hand, the RBM, as said, is energy based. The transition is bi-directional. That is, the i-th layer can affect (i+1)-th layer, and the (i+1)-th layer can affect the i-th layer as well. In such a "bi-directional" network, intuition tells us that "symmetric" network weights provides great potential benefits. "Symmetric" means the propagation weights from the i-th layer to the (i+1)-th layer is the same as the propagation weights from the (i+1)-th layer to the i-th layer in a RBM. i ----> (i+1) equal i <---- (i+1) Why it is symmetric? I guess... a symmetric network has a good chance to be stable. If not symmetric, with two different sets of weights on the left direction from the right direction, the network may behave as unstable as a "ping-pong" game, back and forth and back and forth and... explode. Further, again I guess, if it is asymmetric, then even if the network reaches some equilibrium, the energy distribution may not be Boltzmann distribution, and we should not call it Boltzmann machine anymore. With symmetric weights on both directions, (and if we give the network long enough time/iterations, no matter what the initialized h and v), the RBM network can reach an equilibrium. The equilibrium does not mean that v and h are fixed binary vectors, but it means that v and h will have a fixed probability to be binary vectors. There are a number of states in one equilibrium. Each state corresponds to a probability. Each state corresponds to an energy of the whole network. We are interested in making the network to reach the equilibrium of an energy as small as possible. For example, say v= 1 bit, h= 1 bit, we have 4 combinations, vh ={00, 01, 10, 11}, then on an equilibrium, we have fixed probability of Prob(vh=00) state 00 Prob(vh=01) state 01 Prob(vh=10) state 10 Prob(vh=11) state 11 and of course Prob(vh=00)+Prob(vh=01)+Prob(vh=10)+Prob(vh=11)=1 The Probs are defined by the definition of RBM, apparently. $$ Prob(v,h) = \frac{e^{-E(v,h)}} {Z} $$ where $Z$ is the sum of all possible states, $Z = \sum_{v,h} e^{-E(v,h)}$. (refer to wiki RBM) Note: symmetric does not mean that the weight matrix, which is noted as W in many literatures, is a symmetric matrix. NO, W is not a symmetric matrix. For one thing, a symmetric matrix is always square. However, apparently RBM weights matrix does not have to be a square matrix. That is, the number of hidden units do not have to be same as visible units. It is very misleading that many literature claim that the RBM weight matrix is "symmetric".
Why are RBMs symmetric?
Back propagation Neural Network works in a "inductive/causal" way, that is, the i-th layer induces the (i+1)-th layer. It is one way directional, not bi-directional. As a result, we get a "determinist
Why are RBMs symmetric? Back propagation Neural Network works in a "inductive/causal" way, that is, the i-th layer induces the (i+1)-th layer. It is one way directional, not bi-directional. As a result, we get a "deterministic" result rather than a stochastic result. On the other hand, the RBM, as said, is energy based. The transition is bi-directional. That is, the i-th layer can affect (i+1)-th layer, and the (i+1)-th layer can affect the i-th layer as well. In such a "bi-directional" network, intuition tells us that "symmetric" network weights provides great potential benefits. "Symmetric" means the propagation weights from the i-th layer to the (i+1)-th layer is the same as the propagation weights from the (i+1)-th layer to the i-th layer in a RBM. i ----> (i+1) equal i <---- (i+1) Why it is symmetric? I guess... a symmetric network has a good chance to be stable. If not symmetric, with two different sets of weights on the left direction from the right direction, the network may behave as unstable as a "ping-pong" game, back and forth and back and forth and... explode. Further, again I guess, if it is asymmetric, then even if the network reaches some equilibrium, the energy distribution may not be Boltzmann distribution, and we should not call it Boltzmann machine anymore. With symmetric weights on both directions, (and if we give the network long enough time/iterations, no matter what the initialized h and v), the RBM network can reach an equilibrium. The equilibrium does not mean that v and h are fixed binary vectors, but it means that v and h will have a fixed probability to be binary vectors. There are a number of states in one equilibrium. Each state corresponds to a probability. Each state corresponds to an energy of the whole network. We are interested in making the network to reach the equilibrium of an energy as small as possible. For example, say v= 1 bit, h= 1 bit, we have 4 combinations, vh ={00, 01, 10, 11}, then on an equilibrium, we have fixed probability of Prob(vh=00) state 00 Prob(vh=01) state 01 Prob(vh=10) state 10 Prob(vh=11) state 11 and of course Prob(vh=00)+Prob(vh=01)+Prob(vh=10)+Prob(vh=11)=1 The Probs are defined by the definition of RBM, apparently. $$ Prob(v,h) = \frac{e^{-E(v,h)}} {Z} $$ where $Z$ is the sum of all possible states, $Z = \sum_{v,h} e^{-E(v,h)}$. (refer to wiki RBM) Note: symmetric does not mean that the weight matrix, which is noted as W in many literatures, is a symmetric matrix. NO, W is not a symmetric matrix. For one thing, a symmetric matrix is always square. However, apparently RBM weights matrix does not have to be a square matrix. That is, the number of hidden units do not have to be same as visible units. It is very misleading that many literature claim that the RBM weight matrix is "symmetric".
Why are RBMs symmetric? Back propagation Neural Network works in a "inductive/causal" way, that is, the i-th layer induces the (i+1)-th layer. It is one way directional, not bi-directional. As a result, we get a "determinist
40,431
Why does log likelihood function for a model use SSE/n and not SSE/df?
To expand on a very good answer that Placidia gave: Unbiasedness is not necessarily the best possible property for an estimator. Shrinkage estimators applied in situations of multiple collinearity or with many possible regressors (lasso) are intentionally biased, and this is done to improve their other properties (easier interpretation of the results). Any Bayesian posterior mean or posterior mode estimator with an informative prior is biased; it does not mean that we want to dismiss this whole area of statistics. As far as other criteria of performance of a statistical estimator go, the mean squared error (MSE) is a popular criterion: by how far the estimator is off, on average, disregarding whether it is biased or not. The best estimator of the population $\sigma^2$ is then the one that has not $n-1$, not $n$, but $n+1$ in the denominator. So if your inferential target is the population variance, you might want to use the estimator that divides the sum of squared errors by $n+1$. The observation that the MLE $S^2$ does not appear to make much sense in regression context has been made earlier, of course, and corrections have been proposed to force it to use the "right" degrees of freedom. This is the idea of restricted maximum likelihood (REML), where the estimators are defined conditioning on the residual subspace that has the "right" dimension. Yet another useful property of the ML is transformation invariance. If $S^2$ is the MLE of $\sigma^2$, then automatically $S$ is the MLE of $\sigma$, and $\ln S$ is the estimator of $\ln(\sigma)$. This comes handy in software code: maximizing with respect to $S$ or $S^2$ is being complicated by the quantity being non-negative, while maximizing with respect to $\ln S$ does not involve any constraints. (You'd observe that by Jensen's inequality, unbiasedness of an estimator $$s^2 = \frac1{n-1} \sum (Y_i - \bar Y)^2$$ is easily destroyed by any transformation: $s$ is not an unbiased estimate of $\sigma$. In fact, the unbiased estimator of $\sigma$ is pretty difficult to construct, and I won't be too much ashamed to admit that I don't know one off the top of my head.)
Why does log likelihood function for a model use SSE/n and not SSE/df?
To expand on a very good answer that Placidia gave: Unbiasedness is not necessarily the best possible property for an estimator. Shrinkage estimators applied in situations of multiple collinearity or
Why does log likelihood function for a model use SSE/n and not SSE/df? To expand on a very good answer that Placidia gave: Unbiasedness is not necessarily the best possible property for an estimator. Shrinkage estimators applied in situations of multiple collinearity or with many possible regressors (lasso) are intentionally biased, and this is done to improve their other properties (easier interpretation of the results). Any Bayesian posterior mean or posterior mode estimator with an informative prior is biased; it does not mean that we want to dismiss this whole area of statistics. As far as other criteria of performance of a statistical estimator go, the mean squared error (MSE) is a popular criterion: by how far the estimator is off, on average, disregarding whether it is biased or not. The best estimator of the population $\sigma^2$ is then the one that has not $n-1$, not $n$, but $n+1$ in the denominator. So if your inferential target is the population variance, you might want to use the estimator that divides the sum of squared errors by $n+1$. The observation that the MLE $S^2$ does not appear to make much sense in regression context has been made earlier, of course, and corrections have been proposed to force it to use the "right" degrees of freedom. This is the idea of restricted maximum likelihood (REML), where the estimators are defined conditioning on the residual subspace that has the "right" dimension. Yet another useful property of the ML is transformation invariance. If $S^2$ is the MLE of $\sigma^2$, then automatically $S$ is the MLE of $\sigma$, and $\ln S$ is the estimator of $\ln(\sigma)$. This comes handy in software code: maximizing with respect to $S$ or $S^2$ is being complicated by the quantity being non-negative, while maximizing with respect to $\ln S$ does not involve any constraints. (You'd observe that by Jensen's inequality, unbiasedness of an estimator $$s^2 = \frac1{n-1} \sum (Y_i - \bar Y)^2$$ is easily destroyed by any transformation: $s$ is not an unbiased estimate of $\sigma$. In fact, the unbiased estimator of $\sigma$ is pretty difficult to construct, and I won't be too much ashamed to admit that I don't know one off the top of my head.)
Why does log likelihood function for a model use SSE/n and not SSE/df? To expand on a very good answer that Placidia gave: Unbiasedness is not necessarily the best possible property for an estimator. Shrinkage estimators applied in situations of multiple collinearity or
40,432
Why does log likelihood function for a model use SSE/n and not SSE/df?
The same situation happens in the simplest Normal means model: $Y=\mu + \epsilon$, with $\epsilon$ ~ N(0,$\sigma^2$). The MLE of $\sigma^2$ is the sum of squares about the mean divided by n: $$S^2=\sum \frac{(Y_i-\bar{Y})^2}{n}$$. However, this quantity is a biased estimator: $E(S^2) \neq \sigma^2$. Dividing the sum of squares by $n-1$ instead of $n$ gives an unbiased estimator of the variance. Furthermore, $\sum \frac{(Y_i-\bar{Y})^2}{\sigma^2(n-1)}$ has a $\chi^2$ distribution with $n-1$ degrees of freedom. And ratios of independent mean squares will have the F distribution. Statistical inference offers several criteria for "bestness" in estimators: these include unbiasedness, minimum variance, minimizer of a loss function and (increasingly) predictive accuracy. Being the maximum likelihood estimator is also considered desirable, because the likelihood (supposedly) contains all relevant information about the model (this is debatable and has been debated). The MLE usually manages to be asymptotically unbiased and efficient. What this means for a finite sample depends on the model. Linear regression with Normal errors works much like the simple normal means model that I gave here: the unbiased estimator for the variance is not the MLE. The unbiased estimator is preferred because of its nice distributional properties. Geometrically, you are partitioning $R^n$ into two linear subspaces: one to contain the model and one to contain the residuals. The dimension of the residual space is the degrees of freedom.
Why does log likelihood function for a model use SSE/n and not SSE/df?
The same situation happens in the simplest Normal means model: $Y=\mu + \epsilon$, with $\epsilon$ ~ N(0,$\sigma^2$). The MLE of $\sigma^2$ is the sum of squares about the mean divided by n: $$S^2=\su
Why does log likelihood function for a model use SSE/n and not SSE/df? The same situation happens in the simplest Normal means model: $Y=\mu + \epsilon$, with $\epsilon$ ~ N(0,$\sigma^2$). The MLE of $\sigma^2$ is the sum of squares about the mean divided by n: $$S^2=\sum \frac{(Y_i-\bar{Y})^2}{n}$$. However, this quantity is a biased estimator: $E(S^2) \neq \sigma^2$. Dividing the sum of squares by $n-1$ instead of $n$ gives an unbiased estimator of the variance. Furthermore, $\sum \frac{(Y_i-\bar{Y})^2}{\sigma^2(n-1)}$ has a $\chi^2$ distribution with $n-1$ degrees of freedom. And ratios of independent mean squares will have the F distribution. Statistical inference offers several criteria for "bestness" in estimators: these include unbiasedness, minimum variance, minimizer of a loss function and (increasingly) predictive accuracy. Being the maximum likelihood estimator is also considered desirable, because the likelihood (supposedly) contains all relevant information about the model (this is debatable and has been debated). The MLE usually manages to be asymptotically unbiased and efficient. What this means for a finite sample depends on the model. Linear regression with Normal errors works much like the simple normal means model that I gave here: the unbiased estimator for the variance is not the MLE. The unbiased estimator is preferred because of its nice distributional properties. Geometrically, you are partitioning $R^n$ into two linear subspaces: one to contain the model and one to contain the residuals. The dimension of the residual space is the degrees of freedom.
Why does log likelihood function for a model use SSE/n and not SSE/df? The same situation happens in the simplest Normal means model: $Y=\mu + \epsilon$, with $\epsilon$ ~ N(0,$\sigma^2$). The MLE of $\sigma^2$ is the sum of squares about the mean divided by n: $$S^2=\su
40,433
Box-Ljung test on white noise series
Let us do a simulation where we apply the test 1000 times for time series of length 120. > fun <- function(n) {Box.test(rnorm(n),type="Ljung-Box",lag=log(n))$p.value} > set.seed(111) > mc <- sapply(rep(120,1000),fun) > sum(mc<0.05)/length(mc) [1] 0.039 So you get 39 cases out of 1000 for which the null is rejected if we assume threshold 0.05. This is perfectly normal. The test statistic is a random variable which has a distribution. This means that it can get values which are unlikely, or likely with small probability. We reject the null hypothesis when the value is unlikely, yet by doing this we commit Type I error.
Box-Ljung test on white noise series
Let us do a simulation where we apply the test 1000 times for time series of length 120. > fun <- function(n) {Box.test(rnorm(n),type="Ljung-Box",lag=log(n))$p.value} > set.seed(111) > mc <- sapply(re
Box-Ljung test on white noise series Let us do a simulation where we apply the test 1000 times for time series of length 120. > fun <- function(n) {Box.test(rnorm(n),type="Ljung-Box",lag=log(n))$p.value} > set.seed(111) > mc <- sapply(rep(120,1000),fun) > sum(mc<0.05)/length(mc) [1] 0.039 So you get 39 cases out of 1000 for which the null is rejected if we assume threshold 0.05. This is perfectly normal. The test statistic is a random variable which has a distribution. This means that it can get values which are unlikely, or likely with small probability. We reject the null hypothesis when the value is unlikely, yet by doing this we commit Type I error.
Box-Ljung test on white noise series Let us do a simulation where we apply the test 1000 times for time series of length 120. > fun <- function(n) {Box.test(rnorm(n),type="Ljung-Box",lag=log(n))$p.value} > set.seed(111) > mc <- sapply(re
40,434
Box-Ljung test on white noise series
This subsequence testing is actually related to the locally stationary extension of the Box test to detect time-varying dependencies (paper). Under the null hypothesis of independent white noise you can compute the Box test on $N$ non-overlapping subwindows over your time series, add them all together, and then test the sum of these test statistics for significance. This works out since asymptotically the test statistic of window $i$ has a $\chi^2$ distribution with $k_i$ degrees of freedom, where $k_i$ is the lags tested in subwindow $i$, $i = 1, \ldots, N$. Under the null they are independent, and the sum of independent $\chi^2$ random variables has again a $\chi^2$ distribution with $K = \sum_{i=1}^{N} k_i$ degrees of freedom. This should answer why one subwindow of your time series may have a low p-value; but when you add all sub-window test statistic, this one large test statistic in your particular window will be balanced with some extremely low test statistics in other subwindows. Overall, you will get again the right test coverage. See the paper above for technical details. For R code and a data application see this blog post or the other stackoverflow post: ``Nice example where a series without a unit root is non stationary?''
Box-Ljung test on white noise series
This subsequence testing is actually related to the locally stationary extension of the Box test to detect time-varying dependencies (paper). Under the null hypothesis of independent white noise you c
Box-Ljung test on white noise series This subsequence testing is actually related to the locally stationary extension of the Box test to detect time-varying dependencies (paper). Under the null hypothesis of independent white noise you can compute the Box test on $N$ non-overlapping subwindows over your time series, add them all together, and then test the sum of these test statistics for significance. This works out since asymptotically the test statistic of window $i$ has a $\chi^2$ distribution with $k_i$ degrees of freedom, where $k_i$ is the lags tested in subwindow $i$, $i = 1, \ldots, N$. Under the null they are independent, and the sum of independent $\chi^2$ random variables has again a $\chi^2$ distribution with $K = \sum_{i=1}^{N} k_i$ degrees of freedom. This should answer why one subwindow of your time series may have a low p-value; but when you add all sub-window test statistic, this one large test statistic in your particular window will be balanced with some extremely low test statistics in other subwindows. Overall, you will get again the right test coverage. See the paper above for technical details. For R code and a data application see this blog post or the other stackoverflow post: ``Nice example where a series without a unit root is non stationary?''
Box-Ljung test on white noise series This subsequence testing is actually related to the locally stationary extension of the Box test to detect time-varying dependencies (paper). Under the null hypothesis of independent white noise you c
40,435
Visualization of binned frequency distribution in R
This kind of plot could be generated with geom_rect. Your data: names <- read.csv("http://samswift.org/files/app_c.csv") sum50 <- tapply(names$count, (seq_along(names$count)-1) %/% 50, sum) First, we need additional variables: The cumulative sum: cum <- rev(cumsum(rev(sum50))) Put all into a data frame. The variables start and stop indicate where the rectangles should begin and end, respectively: data <- data.frame(sum = sum50, names = paste(as.numeric(names(sum50)) * 50 + 1, as.numeric(names(sum50)) * 50 + 50, sep = "-"), start = c(cum[-1], 0), stop = cum, stringsAsFactors = FALSE) data$names[nrow(data)] <- paste(as.numeric(names(sum50)[length(sum50)]) * 50 + 1, as.numeric(names(sum50)[length(sum50)]) * 50 + nrow(names) %% 50, sep = "-") The variable center is the center between start and stop position: data$center <- (data$stop - data$start)/2 + data$start For this example, I use the first five rows: data <- data[1:5, ] Plot: library(ggplot2) ggplot(data, aes(xmin = start, xmax = stop, ymin = 0, ymax = sum)) + geom_rect(fill = NA, colour = "black") + scale_x_reverse("bin", breaks = data$center, labels = data$names) + coord_equal() # because we want squares This is the version based on the complete data set. You should consider using only a subset of x-axis labels.
Visualization of binned frequency distribution in R
This kind of plot could be generated with geom_rect. Your data: names <- read.csv("http://samswift.org/files/app_c.csv") sum50 <- tapply(names$count, (seq_along(names$count)-1) %/% 50, sum) First, w
Visualization of binned frequency distribution in R This kind of plot could be generated with geom_rect. Your data: names <- read.csv("http://samswift.org/files/app_c.csv") sum50 <- tapply(names$count, (seq_along(names$count)-1) %/% 50, sum) First, we need additional variables: The cumulative sum: cum <- rev(cumsum(rev(sum50))) Put all into a data frame. The variables start and stop indicate where the rectangles should begin and end, respectively: data <- data.frame(sum = sum50, names = paste(as.numeric(names(sum50)) * 50 + 1, as.numeric(names(sum50)) * 50 + 50, sep = "-"), start = c(cum[-1], 0), stop = cum, stringsAsFactors = FALSE) data$names[nrow(data)] <- paste(as.numeric(names(sum50)[length(sum50)]) * 50 + 1, as.numeric(names(sum50)[length(sum50)]) * 50 + nrow(names) %% 50, sep = "-") The variable center is the center between start and stop position: data$center <- (data$stop - data$start)/2 + data$start For this example, I use the first five rows: data <- data[1:5, ] Plot: library(ggplot2) ggplot(data, aes(xmin = start, xmax = stop, ymin = 0, ymax = sum)) + geom_rect(fill = NA, colour = "black") + scale_x_reverse("bin", breaks = data$center, labels = data$names) + coord_equal() # because we want squares This is the version based on the complete data set. You should consider using only a subset of x-axis labels.
Visualization of binned frequency distribution in R This kind of plot could be generated with geom_rect. Your data: names <- read.csv("http://samswift.org/files/app_c.csv") sum50 <- tapply(names$count, (seq_along(names$count)-1) %/% 50, sum) First, w
40,436
What is better for time series prediction: AR or ARIMA?
ARIMA is more general. It allows fitting certain nonstationary time series and even stationary series that cannot be fit by low order autoregressive models.
What is better for time series prediction: AR or ARIMA?
ARIMA is more general. It allows fitting certain nonstationary time series and even stationary series that cannot be fit by low order autoregressive models.
What is better for time series prediction: AR or ARIMA? ARIMA is more general. It allows fitting certain nonstationary time series and even stationary series that cannot be fit by low order autoregressive models.
What is better for time series prediction: AR or ARIMA? ARIMA is more general. It allows fitting certain nonstationary time series and even stationary series that cannot be fit by low order autoregressive models.
40,437
What is better for time series prediction: AR or ARIMA?
At the heart of ARIMA modelling is the concept of: letting the data speak for itself. As gung has already said, you should use a model that is consistent with the data. Sometimes an AR model provides an adequate representation of the data generating mechanism. Other times an ARIMA model is more appropriate. The key to ARIMA modelling is in employing the iterative process of identification, estimation, and diagnostic checking. Thus, it is advisable not to choose the model a priori. Again, let the data do the talking. It is, however, worth keeping in mind the principle of parsimony when building ARIMA models. If you are in a situation in which there are two candidate models for the final model, and one has only 1 parameter to be estimated while the alternative has, say, 10 or 20 (or even an infinite amount!), then your best bet is probably going with the more parsimonious model; the one with 1 parameter. Note that in situations like this that it wouldn't do any harm to monitor both models over time. Finally, it should be recognized that AR and ARIMA models are models from within the same class of models (so, in one sense they share the same degree of complexity) and that a properly constructed ARIMA model - whether the outcome be an AR or ARIMA - will produce optimal forecasts. That is, no other univariate, linear, fixed parameter models have a smaller mean-squared forecast error. It follows that, if you choose the AR model when an ARIMA model is the correct one, the model you have built will not be properly constructed and your forecasts will be sub-optimal.
What is better for time series prediction: AR or ARIMA?
At the heart of ARIMA modelling is the concept of: letting the data speak for itself. As gung has already said, you should use a model that is consistent with the data. Sometimes an AR model provi
What is better for time series prediction: AR or ARIMA? At the heart of ARIMA modelling is the concept of: letting the data speak for itself. As gung has already said, you should use a model that is consistent with the data. Sometimes an AR model provides an adequate representation of the data generating mechanism. Other times an ARIMA model is more appropriate. The key to ARIMA modelling is in employing the iterative process of identification, estimation, and diagnostic checking. Thus, it is advisable not to choose the model a priori. Again, let the data do the talking. It is, however, worth keeping in mind the principle of parsimony when building ARIMA models. If you are in a situation in which there are two candidate models for the final model, and one has only 1 parameter to be estimated while the alternative has, say, 10 or 20 (or even an infinite amount!), then your best bet is probably going with the more parsimonious model; the one with 1 parameter. Note that in situations like this that it wouldn't do any harm to monitor both models over time. Finally, it should be recognized that AR and ARIMA models are models from within the same class of models (so, in one sense they share the same degree of complexity) and that a properly constructed ARIMA model - whether the outcome be an AR or ARIMA - will produce optimal forecasts. That is, no other univariate, linear, fixed parameter models have a smaller mean-squared forecast error. It follows that, if you choose the AR model when an ARIMA model is the correct one, the model you have built will not be properly constructed and your forecasts will be sub-optimal.
What is better for time series prediction: AR or ARIMA? At the heart of ARIMA modelling is the concept of: letting the data speak for itself. As gung has already said, you should use a model that is consistent with the data. Sometimes an AR model provi
40,438
In a neural network with N covariates, are >N hidden units useless?
No, there is no need to worry about this, because the non-linear transformation means that the feature space generated by the hidden layer neurons can be of higher dimension than the input space without being linearly dependent. Consider Ripley's synthetic benchmark dataset, which consists of two classes, each of which is represented by two Gaussian clusters, which looks like this: A good solution can be obtained by placing a radial basis function on each cluster and then using a linear discriminant on the output of these four hidden units. You should find that (even) the normal equations for linear regression are numerically well conditioned, which suggests that linear dependence isn't an issue. The non-linear transformation is indeed the reason for this. Note that if you use regularisation (which I would recommend for any MLP application), then linear dependence isn't a problem anyway.
In a neural network with N covariates, are >N hidden units useless?
No, there is no need to worry about this, because the non-linear transformation means that the feature space generated by the hidden layer neurons can be of higher dimension than the input space witho
In a neural network with N covariates, are >N hidden units useless? No, there is no need to worry about this, because the non-linear transformation means that the feature space generated by the hidden layer neurons can be of higher dimension than the input space without being linearly dependent. Consider Ripley's synthetic benchmark dataset, which consists of two classes, each of which is represented by two Gaussian clusters, which looks like this: A good solution can be obtained by placing a radial basis function on each cluster and then using a linear discriminant on the output of these four hidden units. You should find that (even) the normal equations for linear regression are numerically well conditioned, which suggests that linear dependence isn't an issue. The non-linear transformation is indeed the reason for this. Note that if you use regularisation (which I would recommend for any MLP application), then linear dependence isn't a problem anyway.
In a neural network with N covariates, are >N hidden units useless? No, there is no need to worry about this, because the non-linear transformation means that the feature space generated by the hidden layer neurons can be of higher dimension than the input space witho
40,439
Laplacian-Beltrami approximation based on an empirical sample
This is only a hint on how to approach this problem, where I try to point out a number of questions that have to be clarified before a complete answer can be given. We assume that $\nu$ is a probability measure. First, as an operator, $L^t$ needs a domain. We assume initially that the domain is the Hilbert space $H = L^2(M, \nu)$, but this will be taken up for revision at the end. Lets also split the operator into two parts. Let $k_t(x,y) = e^{-||x-y||^2/4t}$. The first term in the operator can be written as $$f \mapsto \theta^t f$$ where $\theta^t = \int_M k_t(x,y) d\nu(y)$. Thus it is simply a scalar multiplication of the identity operator. The second term is $$f \mapsto I^t(f) := \int_M f(y) k_t(\cdot, y) d\nu(y),$$ which is an integral operator. Since $\nu$ is a probability measure and $|k_t(x,y)| \leq 1$ it follows that $I^t(f) \in H$ and $I^t$ is a bounded operator. As I understand the question, empirical versions of these two operators are formed by replacing the measure $\nu$ by an empirical measure $\varepsilon_n$ obtained by sampling $n$ points independently from $\nu$. Focusing on the integral operator $I^t$ and its empirical approximation $I^t_n$ we would like to know if $I^t_n$ is a good approximation of $I^t$ and in which ways. If we fix $f \in H$ and $x \in M$ then $$I_n^t(f)(x) = \frac{1}{n} \sum_{i=1}^n f(x_i) k(x, x_i),$$ and since the random variables $f(x_i) k(x,x_i)$ for fixed $f$ and $x$ are i.i.d. with mean $I^t(f)(x)$ it follows from the usual law of large numbers that $$I^t_n(f)(x) \rightarrow I^t(f)(x) \quad \text{a.s.}$$ for $n \to \infty$. Since $f(x_i)^2 k(x_i, x)^2 \leq f(x_i)^2$ and $f \in H$ is square integrable, the random variables have finite variance and the standard CLT can be used to assess the accuracy. However, we might want to say something about the approximation uniformly over $f$ and / or $x$. If we fix $f \in H$ does it hold that $$||I^t_n(f) - I^t(f)||_2 \rightarrow 0 \quad \text{a.s.}$$ for $n \to \infty$? Moreover, since $I_n^t$ and $I^t$ are bounded operators on $H$ we could also ask if $$||I^t_n - I^t|| \rightarrow 0 \quad \text{a.s.}$$ for $n \to \infty$ with $||\cdot||$ the operator norm on the Banach space of bounded operators? In both cases above we ask for a law of large numbers to hold in a certain vector space $-$ the Hilbert space $H$ or the Banach space of bounded operators. A solid reference is Probability in Banach Spaces by Ledoux and Talagrand. Central limit results stating that $\sqrt{n}(I^t_n - I^t)$ or $\sqrt{n}(I^t_n(f) - I^t(f))$ are approximately Gaussian processes can also be obtained in some cases. To obtain good results it might be necessary to restrict attention to a different domain than $H$. One possibility is a Sobolev space for nice choices of $M$ where the functions have some degree of smoothness.
Laplacian-Beltrami approximation based on an empirical sample
This is only a hint on how to approach this problem, where I try to point out a number of questions that have to be clarified before a complete answer can be given. We assume that $\nu$ is a probabili
Laplacian-Beltrami approximation based on an empirical sample This is only a hint on how to approach this problem, where I try to point out a number of questions that have to be clarified before a complete answer can be given. We assume that $\nu$ is a probability measure. First, as an operator, $L^t$ needs a domain. We assume initially that the domain is the Hilbert space $H = L^2(M, \nu)$, but this will be taken up for revision at the end. Lets also split the operator into two parts. Let $k_t(x,y) = e^{-||x-y||^2/4t}$. The first term in the operator can be written as $$f \mapsto \theta^t f$$ where $\theta^t = \int_M k_t(x,y) d\nu(y)$. Thus it is simply a scalar multiplication of the identity operator. The second term is $$f \mapsto I^t(f) := \int_M f(y) k_t(\cdot, y) d\nu(y),$$ which is an integral operator. Since $\nu$ is a probability measure and $|k_t(x,y)| \leq 1$ it follows that $I^t(f) \in H$ and $I^t$ is a bounded operator. As I understand the question, empirical versions of these two operators are formed by replacing the measure $\nu$ by an empirical measure $\varepsilon_n$ obtained by sampling $n$ points independently from $\nu$. Focusing on the integral operator $I^t$ and its empirical approximation $I^t_n$ we would like to know if $I^t_n$ is a good approximation of $I^t$ and in which ways. If we fix $f \in H$ and $x \in M$ then $$I_n^t(f)(x) = \frac{1}{n} \sum_{i=1}^n f(x_i) k(x, x_i),$$ and since the random variables $f(x_i) k(x,x_i)$ for fixed $f$ and $x$ are i.i.d. with mean $I^t(f)(x)$ it follows from the usual law of large numbers that $$I^t_n(f)(x) \rightarrow I^t(f)(x) \quad \text{a.s.}$$ for $n \to \infty$. Since $f(x_i)^2 k(x_i, x)^2 \leq f(x_i)^2$ and $f \in H$ is square integrable, the random variables have finite variance and the standard CLT can be used to assess the accuracy. However, we might want to say something about the approximation uniformly over $f$ and / or $x$. If we fix $f \in H$ does it hold that $$||I^t_n(f) - I^t(f)||_2 \rightarrow 0 \quad \text{a.s.}$$ for $n \to \infty$? Moreover, since $I_n^t$ and $I^t$ are bounded operators on $H$ we could also ask if $$||I^t_n - I^t|| \rightarrow 0 \quad \text{a.s.}$$ for $n \to \infty$ with $||\cdot||$ the operator norm on the Banach space of bounded operators? In both cases above we ask for a law of large numbers to hold in a certain vector space $-$ the Hilbert space $H$ or the Banach space of bounded operators. A solid reference is Probability in Banach Spaces by Ledoux and Talagrand. Central limit results stating that $\sqrt{n}(I^t_n - I^t)$ or $\sqrt{n}(I^t_n(f) - I^t(f))$ are approximately Gaussian processes can also be obtained in some cases. To obtain good results it might be necessary to restrict attention to a different domain than $H$. One possibility is a Sobolev space for nice choices of $M$ where the functions have some degree of smoothness.
Laplacian-Beltrami approximation based on an empirical sample This is only a hint on how to approach this problem, where I try to point out a number of questions that have to be clarified before a complete answer can be given. We assume that $\nu$ is a probabili
40,440
Reference on factor analysis with categorical variables
I think the best method, in your case, is to factor analyze the polychoric correlation matrix. In R, the 'psych' package allows you to perform the polychoric factor analysis (by the fa.poly command) and also to compute the factor scores. Here the documentation and this web page may be useful. Moreover, the 'psych' package contains the fa.parallel.poly function, that is very useful to choose the optimal number of factors to retain by Monte Carlo simulation. With the missing values, you can either exlude them from analysis or replace them with the mean or the median values. Here is a recent paper that confirms the superiority of the polychoric factor analysis: Holgado–Tello, F. C., Chacón–Moscoso, S., Barbero–García, I., & Vila–Abad E. (2010). Polychoric versus Pearson correlations in exploratory and confirmatory factor analysis of ordinal variables. Quality and quantity, 44 (1), 153-166. In response to your second questions, principal component analysis and factor analysis are not the same thing. If your aim is to simply reduce your data, so principal component is the election technique. Otherwise, if you want to explore the underlying dimensions of your questionnaire, you have to use factor analysis. In PCA, the components derive from the variables (by maximizing the variance), while in FA are the factors that explain the variables, so the pattern is opposite. To my knowledge, this is the only important aspect to keep in consideration when you have to choose between the two methods. fa.poly conducts a FA, and you can specify the factoring method (GLS, WLS, PF...). If you want to conduct a PCA, I think you can use principal, but submitting to the analysis not the raw data but the polychoric correlations matrix. Check the 'psych' documentation for these aspects, I never done a categorical principal component analysis.
Reference on factor analysis with categorical variables
I think the best method, in your case, is to factor analyze the polychoric correlation matrix. In R, the 'psych' package allows you to perform the polychoric factor analysis (by the fa.poly command) a
Reference on factor analysis with categorical variables I think the best method, in your case, is to factor analyze the polychoric correlation matrix. In R, the 'psych' package allows you to perform the polychoric factor analysis (by the fa.poly command) and also to compute the factor scores. Here the documentation and this web page may be useful. Moreover, the 'psych' package contains the fa.parallel.poly function, that is very useful to choose the optimal number of factors to retain by Monte Carlo simulation. With the missing values, you can either exlude them from analysis or replace them with the mean or the median values. Here is a recent paper that confirms the superiority of the polychoric factor analysis: Holgado–Tello, F. C., Chacón–Moscoso, S., Barbero–García, I., & Vila–Abad E. (2010). Polychoric versus Pearson correlations in exploratory and confirmatory factor analysis of ordinal variables. Quality and quantity, 44 (1), 153-166. In response to your second questions, principal component analysis and factor analysis are not the same thing. If your aim is to simply reduce your data, so principal component is the election technique. Otherwise, if you want to explore the underlying dimensions of your questionnaire, you have to use factor analysis. In PCA, the components derive from the variables (by maximizing the variance), while in FA are the factors that explain the variables, so the pattern is opposite. To my knowledge, this is the only important aspect to keep in consideration when you have to choose between the two methods. fa.poly conducts a FA, and you can specify the factoring method (GLS, WLS, PF...). If you want to conduct a PCA, I think you can use principal, but submitting to the analysis not the raw data but the polychoric correlations matrix. Check the 'psych' documentation for these aspects, I never done a categorical principal component analysis.
Reference on factor analysis with categorical variables I think the best method, in your case, is to factor analyze the polychoric correlation matrix. In R, the 'psych' package allows you to perform the polychoric factor analysis (by the fa.poly command) a
40,441
Gradient descent and elastic-net logistic regression
It took me a while to figure it out, but I thought I share my results here. The algorithms used for optimization by Friedman et al. and Genkin et al. are different. The latter use an Majorization-Minimization algorithm and Friedman et al. use iteratively re-weighted least squares (IRLS). Both use coordinate descent inside these particular frameworks, Genkin et al. to find a solution in the MM framework and Friedman et al. to solve the penalized weighted least squares problem inside an IRLS iteration. This means they essentially apply the update formula for weighted least squares: $$ b_j^\text{new} = S \left( \frac{1}{n} \sum_{i=1}^n w_i x_{ij} \left[ y_i - \beta_0 - \sum_{\substack{k=1 \\ k \neq j}}^r \beta_k x_{ik} \right], \lambda \alpha \right) \cdot \left( \frac{1}{n} \sum_{i=1}^n w_i x_{ij}^2 + \lambda (1 - \alpha) \right)^{-1} , $$ where the right hand site is evaluated at the current estimates of $\beta$ and $S(z, \gamma) = \mathrm{sign}(z) (|z| - \gamma)$. In the case of logistic regression the weight $w_i = \pi(x_i)(1-\pi(x_i))$ and the response $z_i$ ($= y_i$ in the formula above) becomes $$ z_i = \beta_0 + \beta^T x_i + \frac{y_i - \pi(x_i)}{\pi(x_i)(1-\pi(x_i))} ,$$ where $x_i$ denotes the $i$-th row of $X \in \mathbb{R}^{n \times r}$, $y_i \in \{0, 1\}$ the class label, and $$\pi(x_i) = \frac{ \exp(\beta_0 + \beta^T x_i) }{1 + \exp(\beta_0 + \beta^T x_i)} .$$ Substituting, the first term in the update formula becomes for logistic regression: $$ \frac{1}{n} \sum_{i=1}^n w_i x_{ij} \left[ z_i - \beta_0 - \sum_{\substack{k=1 \\ k \neq j}}^r \beta_k x_{ik} \right] \\ = \frac{1}{n} \sum_{i=1}^n w_i x_{ij} \left[ z_i - \beta_0 - \beta^T x_i + \beta_j x_{ij} \right] \\ = \frac{1}{n} \sum_{i=1}^n \pi(x_i)(1 - \pi(x_i)) x_{ij} \left[ \beta_0 + \beta^T x_i + \frac{y_i - \pi(x_i)}{\pi(x_i)(1 - \pi(x_i))} - \beta_0 - \beta^T x_i + \beta_j x_{ij} \right] \\ = \frac{1}{n} \sum_{i=1}^n \pi(x_i)(1 - \pi(x_i)) x_{ij} \left[\frac{y_i - \pi(x_i)}{\pi(x_i)(1 - \pi(x_i))} + \beta_j x_{ij} \right] \\ = \frac{1}{n} \sum_{i=1}^n x_{ij} (y_i - \pi(x_i)) + \pi(x_i)(1 - \pi(x_i)) x_{ij}^2 \beta_j . $$ The intercept $\beta_0$ can be updated by applying $$ \beta_0^\text{new} = \beta_0^\text{old} + \sum_{i=1}^n \frac{y_i - \pi(x_i)}{\pi(x_i)(1 - \pi(x_i))} .$$ Finally, Friedman et al. update $r_i = y_i - \pi(x_i)$ incrementally each time $\beta$ changes: $$ r_i = r_i - \Delta \beta_j \pi(x_i)(1 - \pi(x_i)) x_{ij} ,$$ where $\Delta \beta_j = \beta_j^\text{new} - \beta_j^\text{old}$ is the difference between the old and new estimate for $\beta_j$.
Gradient descent and elastic-net logistic regression
It took me a while to figure it out, but I thought I share my results here. The algorithms used for optimization by Friedman et al. and Genkin et al. are different. The latter use an Majorization-Mini
Gradient descent and elastic-net logistic regression It took me a while to figure it out, but I thought I share my results here. The algorithms used for optimization by Friedman et al. and Genkin et al. are different. The latter use an Majorization-Minimization algorithm and Friedman et al. use iteratively re-weighted least squares (IRLS). Both use coordinate descent inside these particular frameworks, Genkin et al. to find a solution in the MM framework and Friedman et al. to solve the penalized weighted least squares problem inside an IRLS iteration. This means they essentially apply the update formula for weighted least squares: $$ b_j^\text{new} = S \left( \frac{1}{n} \sum_{i=1}^n w_i x_{ij} \left[ y_i - \beta_0 - \sum_{\substack{k=1 \\ k \neq j}}^r \beta_k x_{ik} \right], \lambda \alpha \right) \cdot \left( \frac{1}{n} \sum_{i=1}^n w_i x_{ij}^2 + \lambda (1 - \alpha) \right)^{-1} , $$ where the right hand site is evaluated at the current estimates of $\beta$ and $S(z, \gamma) = \mathrm{sign}(z) (|z| - \gamma)$. In the case of logistic regression the weight $w_i = \pi(x_i)(1-\pi(x_i))$ and the response $z_i$ ($= y_i$ in the formula above) becomes $$ z_i = \beta_0 + \beta^T x_i + \frac{y_i - \pi(x_i)}{\pi(x_i)(1-\pi(x_i))} ,$$ where $x_i$ denotes the $i$-th row of $X \in \mathbb{R}^{n \times r}$, $y_i \in \{0, 1\}$ the class label, and $$\pi(x_i) = \frac{ \exp(\beta_0 + \beta^T x_i) }{1 + \exp(\beta_0 + \beta^T x_i)} .$$ Substituting, the first term in the update formula becomes for logistic regression: $$ \frac{1}{n} \sum_{i=1}^n w_i x_{ij} \left[ z_i - \beta_0 - \sum_{\substack{k=1 \\ k \neq j}}^r \beta_k x_{ik} \right] \\ = \frac{1}{n} \sum_{i=1}^n w_i x_{ij} \left[ z_i - \beta_0 - \beta^T x_i + \beta_j x_{ij} \right] \\ = \frac{1}{n} \sum_{i=1}^n \pi(x_i)(1 - \pi(x_i)) x_{ij} \left[ \beta_0 + \beta^T x_i + \frac{y_i - \pi(x_i)}{\pi(x_i)(1 - \pi(x_i))} - \beta_0 - \beta^T x_i + \beta_j x_{ij} \right] \\ = \frac{1}{n} \sum_{i=1}^n \pi(x_i)(1 - \pi(x_i)) x_{ij} \left[\frac{y_i - \pi(x_i)}{\pi(x_i)(1 - \pi(x_i))} + \beta_j x_{ij} \right] \\ = \frac{1}{n} \sum_{i=1}^n x_{ij} (y_i - \pi(x_i)) + \pi(x_i)(1 - \pi(x_i)) x_{ij}^2 \beta_j . $$ The intercept $\beta_0$ can be updated by applying $$ \beta_0^\text{new} = \beta_0^\text{old} + \sum_{i=1}^n \frac{y_i - \pi(x_i)}{\pi(x_i)(1 - \pi(x_i))} .$$ Finally, Friedman et al. update $r_i = y_i - \pi(x_i)$ incrementally each time $\beta$ changes: $$ r_i = r_i - \Delta \beta_j \pi(x_i)(1 - \pi(x_i)) x_{ij} ,$$ where $\Delta \beta_j = \beta_j^\text{new} - \beta_j^\text{old}$ is the difference between the old and new estimate for $\beta_j$.
Gradient descent and elastic-net logistic regression It took me a while to figure it out, but I thought I share my results here. The algorithms used for optimization by Friedman et al. and Genkin et al. are different. The latter use an Majorization-Mini
40,442
Factor analysis for ordinal variables that have different categories
I feel, from your description of the task, that it can be solved by means of quantifying (turning ordinal-level into scale-level) variables the way that the predictions or associatiations are maximized. This is known as optimal scaling and is implemented in SPSS (and, of course, in R, I believe). You might choose between 3 procedures, all adopting optimal scaling: Categorical PCA (CATPCA, or PRINCALS). Use this if you want PCA or Factor analysis. The procedure itself is PCA, not Factor analysis in narrow sense of the word implying communalities. If you need Factor analysis per se you may input the quantified variables obtained in CATPCA to standard Factor analysis procedure. Having identified components or factors behind your independent "resource" variables and having obtained the factor scores you could then check their effect on each dependent variable via ordinal regression (for example). Categorical Canonical Correlation analysis (OVERALS). Use this to draw latent "traits" which are loaded simultaneously by both independed and dependent sets of variables. You might want to read something about canonical correlations if you are not familiar with it. Categorical regression (CATREG). This is OVERALS in case one of the two sets of variables contains just one variable. Use it if you want to model effects of your independent variables on each dependent variable separately. It is like usual linear regression, only that it is nonlinear because of optimal scaling.
Factor analysis for ordinal variables that have different categories
I feel, from your description of the task, that it can be solved by means of quantifying (turning ordinal-level into scale-level) variables the way that the predictions or associatiations are maximize
Factor analysis for ordinal variables that have different categories I feel, from your description of the task, that it can be solved by means of quantifying (turning ordinal-level into scale-level) variables the way that the predictions or associatiations are maximized. This is known as optimal scaling and is implemented in SPSS (and, of course, in R, I believe). You might choose between 3 procedures, all adopting optimal scaling: Categorical PCA (CATPCA, or PRINCALS). Use this if you want PCA or Factor analysis. The procedure itself is PCA, not Factor analysis in narrow sense of the word implying communalities. If you need Factor analysis per se you may input the quantified variables obtained in CATPCA to standard Factor analysis procedure. Having identified components or factors behind your independent "resource" variables and having obtained the factor scores you could then check their effect on each dependent variable via ordinal regression (for example). Categorical Canonical Correlation analysis (OVERALS). Use this to draw latent "traits" which are loaded simultaneously by both independed and dependent sets of variables. You might want to read something about canonical correlations if you are not familiar with it. Categorical regression (CATREG). This is OVERALS in case one of the two sets of variables contains just one variable. Use it if you want to model effects of your independent variables on each dependent variable separately. It is like usual linear regression, only that it is nonlinear because of optimal scaling.
Factor analysis for ordinal variables that have different categories I feel, from your description of the task, that it can be solved by means of quantifying (turning ordinal-level into scale-level) variables the way that the predictions or associatiations are maximize
40,443
Factor analysis for ordinal variables that have different categories
A kind of PCA applied to categorical data is MCA (Multiple Correspondence analysis) that let you detect underlying structures in a data set.
Factor analysis for ordinal variables that have different categories
A kind of PCA applied to categorical data is MCA (Multiple Correspondence analysis) that let you detect underlying structures in a data set.
Factor analysis for ordinal variables that have different categories A kind of PCA applied to categorical data is MCA (Multiple Correspondence analysis) that let you detect underlying structures in a data set.
Factor analysis for ordinal variables that have different categories A kind of PCA applied to categorical data is MCA (Multiple Correspondence analysis) that let you detect underlying structures in a data set.
40,444
Suitable number of classes for SVM in text categorization
Following answer is based on my own personal insights of doing text analysis. Of course, an increase in the number of categories will increase the time significantly since you have bigger matrix dimensions and so on. But it's not necessary a bad approach. Moreover first strategy looks somehow strange to me since the result of guessing subgroup maybe interfered with bad result of guessing the group (some subcategories can be significally different from other categories or subcategories, but the whole can not). So I would probably go with the second strategy. In second approach you will need quite much computational power. The error you're getting is that your RAM memory is full (also swap if you have one). There are couple basic suggestions concerning this problem. Try to reduce your doc-term matrixes. That includes removing stopwords, punctuation, removing words that have no meaning whatsoever. This is very common procedure but sometime one can consider creating his own bigger filter. Don't use whole amount of articles, instead use only the sample. Well, sampling is one of the most simplest procedures to reduce the amount of computing. The most lazy solution, either get a pc with more operative memory or increase your swap memory and let computer do the rest. These are more common approaches in your second case. I might would skip through the package called RTextTools that makes all of this work easier. Another insight would be using another approach rather than SVM. I'm not sure, but I think there are already implemented classification algorithms that implies that some of your categories have subcategories. And as always don't forget to protect your progress when R crashes by saving workspace, .Rdata and then loading it. Also try to use R's garbage collector gc().
Suitable number of classes for SVM in text categorization
Following answer is based on my own personal insights of doing text analysis. Of course, an increase in the number of categories will increase the time significantly since you have bigger matrix dimen
Suitable number of classes for SVM in text categorization Following answer is based on my own personal insights of doing text analysis. Of course, an increase in the number of categories will increase the time significantly since you have bigger matrix dimensions and so on. But it's not necessary a bad approach. Moreover first strategy looks somehow strange to me since the result of guessing subgroup maybe interfered with bad result of guessing the group (some subcategories can be significally different from other categories or subcategories, but the whole can not). So I would probably go with the second strategy. In second approach you will need quite much computational power. The error you're getting is that your RAM memory is full (also swap if you have one). There are couple basic suggestions concerning this problem. Try to reduce your doc-term matrixes. That includes removing stopwords, punctuation, removing words that have no meaning whatsoever. This is very common procedure but sometime one can consider creating his own bigger filter. Don't use whole amount of articles, instead use only the sample. Well, sampling is one of the most simplest procedures to reduce the amount of computing. The most lazy solution, either get a pc with more operative memory or increase your swap memory and let computer do the rest. These are more common approaches in your second case. I might would skip through the package called RTextTools that makes all of this work easier. Another insight would be using another approach rather than SVM. I'm not sure, but I think there are already implemented classification algorithms that implies that some of your categories have subcategories. And as always don't forget to protect your progress when R crashes by saving workspace, .Rdata and then loading it. Also try to use R's garbage collector gc().
Suitable number of classes for SVM in text categorization Following answer is based on my own personal insights of doing text analysis. Of course, an increase in the number of categories will increase the time significantly since you have bigger matrix dimen
40,445
Suitable number of classes for SVM in text categorization
You might want to consider using LibLINEAR instead of (Lib)SVM. It is said to run faster than SVM for cases like document classification, though I'm not sure how it effects memory usage (see section 'When to use LIBLINEAR but not LIBSVM'). Here is the package for R.
Suitable number of classes for SVM in text categorization
You might want to consider using LibLINEAR instead of (Lib)SVM. It is said to run faster than SVM for cases like document classification, though I'm not sure how it effects memory usage (see section '
Suitable number of classes for SVM in text categorization You might want to consider using LibLINEAR instead of (Lib)SVM. It is said to run faster than SVM for cases like document classification, though I'm not sure how it effects memory usage (see section 'When to use LIBLINEAR but not LIBSVM'). Here is the package for R.
Suitable number of classes for SVM in text categorization You might want to consider using LibLINEAR instead of (Lib)SVM. It is said to run faster than SVM for cases like document classification, though I'm not sure how it effects memory usage (see section '
40,446
Suitable number of classes for SVM in text categorization
I work as a project manager & software engineer at a small, research oriented software company. We have recently completed a text categorization project and made many experiments on the way. We work with a Lineer SVM implementation I coded in C# based on Platt's "Sequential Minimal Optimization" Algorithm and later improvements for the linear case. The items are product definitions being sold on the internet. Our categories is a two level tree with about 15 first level nodes and 200 leaves. Here is a two sentence summary of what I have learned: Success depends on the quality of the training set much more than the exact methodology. Although it is true that SVM performs somewhat better than Decision Trees, Nearest Neighboors and any other "simple" approach, selecting the kernel, optimizing the system parameters make little difference in terms of success rate. Our experiments included the comparison of the two approaches you wrote about. Although my common sense still tells me that first approach should perform better, there was no statistically significant difference in terms of success rate in our experiments: very likely, when a product is classified, either both approaches classify it correctly, of neither. For the RAM usage, I don't know about R to make concrete suggestions. However I can give some general advice, in case you have not already implemented these steps: Remove stop words Remove uncommon words (i.e. words that occur in less than say 10 documents) Format and Stem all the words so that COME, come, came, coming, etc. are mapped to the same term. (There are free libraries for this) SVM needs much memory during training. Still, 24 Gb seems more than enough to me. (Again, I don't know anything about the R implementation) However here is an experiment you may perform, which if succeeds will make training much faster, and will consume much less resources: If you have 300 categories, construct 300 different training sets and Support Vector Machines. For each category let your training set consist of 100 positive samples and say 400 randomly selected negative samples (find the optimum number by experimentation). You will have 300 different term-document matrices but each will be of much less size. When a document is to be classified, ask each SVM and return the category with the maximum value.
Suitable number of classes for SVM in text categorization
I work as a project manager & software engineer at a small, research oriented software company. We have recently completed a text categorization project and made many experiments on the way. We work
Suitable number of classes for SVM in text categorization I work as a project manager & software engineer at a small, research oriented software company. We have recently completed a text categorization project and made many experiments on the way. We work with a Lineer SVM implementation I coded in C# based on Platt's "Sequential Minimal Optimization" Algorithm and later improvements for the linear case. The items are product definitions being sold on the internet. Our categories is a two level tree with about 15 first level nodes and 200 leaves. Here is a two sentence summary of what I have learned: Success depends on the quality of the training set much more than the exact methodology. Although it is true that SVM performs somewhat better than Decision Trees, Nearest Neighboors and any other "simple" approach, selecting the kernel, optimizing the system parameters make little difference in terms of success rate. Our experiments included the comparison of the two approaches you wrote about. Although my common sense still tells me that first approach should perform better, there was no statistically significant difference in terms of success rate in our experiments: very likely, when a product is classified, either both approaches classify it correctly, of neither. For the RAM usage, I don't know about R to make concrete suggestions. However I can give some general advice, in case you have not already implemented these steps: Remove stop words Remove uncommon words (i.e. words that occur in less than say 10 documents) Format and Stem all the words so that COME, come, came, coming, etc. are mapped to the same term. (There are free libraries for this) SVM needs much memory during training. Still, 24 Gb seems more than enough to me. (Again, I don't know anything about the R implementation) However here is an experiment you may perform, which if succeeds will make training much faster, and will consume much less resources: If you have 300 categories, construct 300 different training sets and Support Vector Machines. For each category let your training set consist of 100 positive samples and say 400 randomly selected negative samples (find the optimum number by experimentation). You will have 300 different term-document matrices but each will be of much less size. When a document is to be classified, ask each SVM and return the category with the maximum value.
Suitable number of classes for SVM in text categorization I work as a project manager & software engineer at a small, research oriented software company. We have recently completed a text categorization project and made many experiments on the way. We work
40,447
Limit of a convolution and sum of distribution functions
I have found some info on this problem. This question is about the proof of a theorem due to Feller, to be found on volume 2 of his "Introduction to Probability Theory and its Applications" (p. 278-279). Here is a restatement. $\mathbf{Theorem.}$ Let $X_1,\dots,X_n$ be independent random variables with distribution functions satisfying $1-F_i(x)\sim x^{-\alpha}L_i(x)$, where $L_i$ is slowly varying at infinity. Then, the convolution $G_n:=F_1\star\dots\star F_n$ has a regularly varying tail such that $$1-G_n(x)\sim x^{-\alpha}(L_1(x)+\dots+L_n(x)) \, .$$ Feller proves the case with two random variables and just states that the general result follows by induction. By the way, his proof of the $n=2$ case is a gem. So we already know from Feller that the theorem holds for two random variables. To prove the induction step, suppose that the theorem holds for $n-1$ random variables, which means that $$1-G_{n-1}(x)\sim x^{-\alpha}(L_1(x)+\dots+L_{n-1}(x)) \, .$$ Since the sum of slowly varying functions is a slowly varying function itself, we have that $X_1+\dots+X_{n-1}$ is a random variable, independent of $X_n$, whose distribution function $G_{n-1}$ satisfies the tail hypothesis of the theorem, that is, $1-G_{n-1}(x)\sim x^{-\alpha}M(x)$, where the slowly varying $M=L_1+\dots+L_{n-1}$. By the associativity of the convolution, we know that $$ G_n = F_1\star\dots\star F_{n-1}\star F_n = (F_1\star\dots\star F_{n-1})\star F_n = G_{n-1}\star F_n\, , $$ and we are back to the (already proved by Feller) case of two random variables satisfying the hypotheses of the theorem. Therefore, $$ 1 - G_n(x) \sim x^{-\alpha}(M(x)+L_n(x)) = x^{-\alpha}(L_1(x)+\dots+L_{n-1}(x)+L_n(x)) \, . $$ Hence, the tail of $G_n$ satisfies the necessary property, the theorem holds for $n$ random variables, and we are done with the induction step.
Limit of a convolution and sum of distribution functions
I have found some info on this problem. This question is about the proof of a theorem due to Feller, to be found on volume 2 of his "Introduction to Probability Theory and its Applications" (p. 278-27
Limit of a convolution and sum of distribution functions I have found some info on this problem. This question is about the proof of a theorem due to Feller, to be found on volume 2 of his "Introduction to Probability Theory and its Applications" (p. 278-279). Here is a restatement. $\mathbf{Theorem.}$ Let $X_1,\dots,X_n$ be independent random variables with distribution functions satisfying $1-F_i(x)\sim x^{-\alpha}L_i(x)$, where $L_i$ is slowly varying at infinity. Then, the convolution $G_n:=F_1\star\dots\star F_n$ has a regularly varying tail such that $$1-G_n(x)\sim x^{-\alpha}(L_1(x)+\dots+L_n(x)) \, .$$ Feller proves the case with two random variables and just states that the general result follows by induction. By the way, his proof of the $n=2$ case is a gem. So we already know from Feller that the theorem holds for two random variables. To prove the induction step, suppose that the theorem holds for $n-1$ random variables, which means that $$1-G_{n-1}(x)\sim x^{-\alpha}(L_1(x)+\dots+L_{n-1}(x)) \, .$$ Since the sum of slowly varying functions is a slowly varying function itself, we have that $X_1+\dots+X_{n-1}$ is a random variable, independent of $X_n$, whose distribution function $G_{n-1}$ satisfies the tail hypothesis of the theorem, that is, $1-G_{n-1}(x)\sim x^{-\alpha}M(x)$, where the slowly varying $M=L_1+\dots+L_{n-1}$. By the associativity of the convolution, we know that $$ G_n = F_1\star\dots\star F_{n-1}\star F_n = (F_1\star\dots\star F_{n-1})\star F_n = G_{n-1}\star F_n\, , $$ and we are back to the (already proved by Feller) case of two random variables satisfying the hypotheses of the theorem. Therefore, $$ 1 - G_n(x) \sim x^{-\alpha}(M(x)+L_n(x)) = x^{-\alpha}(L_1(x)+\dots+L_{n-1}(x)+L_n(x)) \, . $$ Hence, the tail of $G_n$ satisfies the necessary property, the theorem holds for $n$ random variables, and we are done with the induction step.
Limit of a convolution and sum of distribution functions I have found some info on this problem. This question is about the proof of a theorem due to Feller, to be found on volume 2 of his "Introduction to Probability Theory and its Applications" (p. 278-27
40,448
Limit of a convolution and sum of distribution functions
You would use induction. Assume it is true for n and then show for n+1. Also write P{X1+X2+...+Xn +Xn=1>x] as P{X1+X2+...+Xn>x-Xn+1] which equals ∫P{X1+X2+...+Xn>x-y]f(y) dy where fis the density for Xn+1. Then try to express the ratio as a factor times the ratio in the form of the induction hypothesis for n. Then limit of product should be the product of the limits evaluate the two limits. One goes to 1 by the induction hypothesis and then the other factor should also converge to 1.
Limit of a convolution and sum of distribution functions
You would use induction. Assume it is true for n and then show for n+1. Also write P{X1+X2+...+Xn +Xn=1>x] as P{X1+X2+...+Xn>x-Xn+1] which equals ∫P{X1+X2+...+Xn>x-y]f(y) dy where fis the density f
Limit of a convolution and sum of distribution functions You would use induction. Assume it is true for n and then show for n+1. Also write P{X1+X2+...+Xn +Xn=1>x] as P{X1+X2+...+Xn>x-Xn+1] which equals ∫P{X1+X2+...+Xn>x-y]f(y) dy where fis the density for Xn+1. Then try to express the ratio as a factor times the ratio in the form of the induction hypothesis for n. Then limit of product should be the product of the limits evaluate the two limits. One goes to 1 by the induction hypothesis and then the other factor should also converge to 1.
Limit of a convolution and sum of distribution functions You would use induction. Assume it is true for n and then show for n+1. Also write P{X1+X2+...+Xn +Xn=1>x] as P{X1+X2+...+Xn>x-Xn+1] which equals ∫P{X1+X2+...+Xn>x-y]f(y) dy where fis the density f
40,449
What if an overall ANOVA is not significant, but specific contrasts are?
The answer to your question reflects your view of overall (or experimentwise) alpha. If, before you collected your data, you set forth planned comparisons (and it sounds like you did that), then after you collect the data you do those and only those comparisons, and there is no reason to look at any other comparisons (AKA contrasts) nor at the overall ANOVA. Why did you look at the overall ANOVA? If you did both planned comparisons and ad hoc comparisons, then you inflated your experimentwise alpha, which some consider a serious error. Of course, you might do ad hoc comparisons to help you plan your future research, but not report them. Also, it seems you have two DVs and did two ANOVAs. In general, if you do two ANOVAs each with p = .05 then you have inflated your experimentwise alpha. Therefore, when doing 2 ANOVAs you might reduce the alpha level for each of your two ANOVAs to maintain your experimentwise alpha. Alternatively, you might do a MANOVA (i.e., a multivariate analysis of variance) which allows you to consider both DVs simultaneously. Of course, you should also be looking at effect sizes, to help you understand the meaning of your data.
What if an overall ANOVA is not significant, but specific contrasts are?
The answer to your question reflects your view of overall (or experimentwise) alpha. If, before you collected your data, you set forth planned comparisons (and it sounds like you did that), then afte
What if an overall ANOVA is not significant, but specific contrasts are? The answer to your question reflects your view of overall (or experimentwise) alpha. If, before you collected your data, you set forth planned comparisons (and it sounds like you did that), then after you collect the data you do those and only those comparisons, and there is no reason to look at any other comparisons (AKA contrasts) nor at the overall ANOVA. Why did you look at the overall ANOVA? If you did both planned comparisons and ad hoc comparisons, then you inflated your experimentwise alpha, which some consider a serious error. Of course, you might do ad hoc comparisons to help you plan your future research, but not report them. Also, it seems you have two DVs and did two ANOVAs. In general, if you do two ANOVAs each with p = .05 then you have inflated your experimentwise alpha. Therefore, when doing 2 ANOVAs you might reduce the alpha level for each of your two ANOVAs to maintain your experimentwise alpha. Alternatively, you might do a MANOVA (i.e., a multivariate analysis of variance) which allows you to consider both DVs simultaneously. Of course, you should also be looking at effect sizes, to help you understand the meaning of your data.
What if an overall ANOVA is not significant, but specific contrasts are? The answer to your question reflects your view of overall (or experimentwise) alpha. If, before you collected your data, you set forth planned comparisons (and it sounds like you did that), then afte
40,450
What if an overall ANOVA is not significant, but specific contrasts are?
Yes you need to adjust alpha, especially if you do planned comparisons that are non-orthogonal. If you have set the contrasts in an ANOVA and tested the orthogonality between them, you can descompose the SC and df of the ANOVA. The planned comparison are always more powerful than traditional post hoc test, but in cases where the contrast are non.orthogonal you have inflated the experimentwise error. you can check for orthogonality among contrast in many textboxs. However i don´t undestand if you have set that time was factor with two levels, why are you performing a contrast between those times?
What if an overall ANOVA is not significant, but specific contrasts are?
Yes you need to adjust alpha, especially if you do planned comparisons that are non-orthogonal. If you have set the contrasts in an ANOVA and tested the orthogonality between them, you can descompose
What if an overall ANOVA is not significant, but specific contrasts are? Yes you need to adjust alpha, especially if you do planned comparisons that are non-orthogonal. If you have set the contrasts in an ANOVA and tested the orthogonality between them, you can descompose the SC and df of the ANOVA. The planned comparison are always more powerful than traditional post hoc test, but in cases where the contrast are non.orthogonal you have inflated the experimentwise error. you can check for orthogonality among contrast in many textboxs. However i don´t undestand if you have set that time was factor with two levels, why are you performing a contrast between those times?
What if an overall ANOVA is not significant, but specific contrasts are? Yes you need to adjust alpha, especially if you do planned comparisons that are non-orthogonal. If you have set the contrasts in an ANOVA and tested the orthogonality between them, you can descompose
40,451
Variable ordering using PCA
It is described in Michael Friendly's American Statistician paper on corrgrams, Preprint PDF here. See section on correlation ordering. Also if you look at the source of the corrgram library you will see some other potential ways to order the data as well. To describe what the code is doing in a nut-shell, the variables in the correlation matrix are ordered according to the correlations with the first and the second principle components extracted from that same correlation matrix. If you look at the Eigenvector plot in the Friendly paper (Figure 3), the code atan(e2/e1) is the angle between the ray associated with a particular variable and the horizontal axis. The variables are sorted by this angle, in a counter-clockwise order. If the whole picture were squeezed horizontally by the square root of the first eigenvalue, and vertically by the square root of the second eigenvalue (this would not change the order!), then the $x$ and $y$ coordinates of each ray's endpoint would be exactly the correlations of this variable with PC1 and with PC2. Again the reason for the ordering is given in the Friendly paper, but we almost always want more similar things next to more similar things (in either graphics or tables). Frequently the ordering is more informative than the numbers or the graph! Here in this example "more similar" is defined in terms of correlations to the first and the second principle components. Also note I assume the first if statement in the code prevents this ordering from occurring if the correlation matrix is not full rank.
Variable ordering using PCA
It is described in Michael Friendly's American Statistician paper on corrgrams, Preprint PDF here. See section on correlation ordering. Also if you look at the source of the corrgram library you will
Variable ordering using PCA It is described in Michael Friendly's American Statistician paper on corrgrams, Preprint PDF here. See section on correlation ordering. Also if you look at the source of the corrgram library you will see some other potential ways to order the data as well. To describe what the code is doing in a nut-shell, the variables in the correlation matrix are ordered according to the correlations with the first and the second principle components extracted from that same correlation matrix. If you look at the Eigenvector plot in the Friendly paper (Figure 3), the code atan(e2/e1) is the angle between the ray associated with a particular variable and the horizontal axis. The variables are sorted by this angle, in a counter-clockwise order. If the whole picture were squeezed horizontally by the square root of the first eigenvalue, and vertically by the square root of the second eigenvalue (this would not change the order!), then the $x$ and $y$ coordinates of each ray's endpoint would be exactly the correlations of this variable with PC1 and with PC2. Again the reason for the ordering is given in the Friendly paper, but we almost always want more similar things next to more similar things (in either graphics or tables). Frequently the ordering is more informative than the numbers or the graph! Here in this example "more similar" is defined in terms of correlations to the first and the second principle components. Also note I assume the first if statement in the code prevents this ordering from occurring if the correlation matrix is not full rank.
Variable ordering using PCA It is described in Michael Friendly's American Statistician paper on corrgrams, Preprint PDF here. See section on correlation ordering. Also if you look at the source of the corrgram library you will
40,452
Simple regression models for data with a breakpoint
This will be an R-centric answer. One approach is to wrap the call to lm in a function which is passed the breakpoint and constructs a regression conditional upon that breakpoint, then minimize the deviance of the fitted model conditional upon the breakpoint by just iterating over the possible values for the breakpoint. This maximizes the profile log likelihood for the breakpoint, and, in general (i.e., not just for this problem) if the function interior to the breakpoint iteration (lm in this case) finds maximum likelihood estimates conditional upon the parameter passed to it, the whole procedure finds the joint maximum likelihood estimates for all the parameters. For example: # True model: y = a + b*(obs. no >= shift) + c*x # a = 0, b = 1, c = 1, shift at observation 31 # Construct sample data x <- rnorm(100) shift <- c(rep(0,30),rep(1,70)) y <- shift + x + rnorm(100) # Find deviance conditional upon breakpoint lm.shift <- function(y, x, shift.obs) { shift.var <- c(rep(0, (shift.obs-1)), rep(1, length(y)-shift.obs+1)) deviance(lm(y~x+shift.var)) } # Find deviance of all breakpoint values dev.value <- rep(0, length(y)) for (i in 1:length(y)) { dev.value[i] <- lm.shift(y, x, i) } # Calculate profile-ll based confidence interval estimate <- which.min(dev.value) profile.95.dev <- min(dev.value) + qchisq(0.95,1) est.lb.95 <- max(which(dev.value[1:estimate] > profile.95.dev)) est.ub.95 <- est -1 + min(which(dev.value[estimate:length(y)] > profile.95.dev)) > estimate [1] 30 > est.lb.95 [1] 28 > est.ub.95 [1] 33 So our estimate is 30 with a 95% confidence interval of 28 - 33. Pretty tight, but that was a pretty big shift relative to the standard deviation of the error term too. Note some messiness is involved in calculating the profile log-likelihood based confidence interval, but the basic idea is to find the largest index less than the estimate with a deviance greater than the cutoff level for the lower bound and the smallest index larger than the estimate with a deviance greater than the cutoff level for the upper bound. One really should plot the deviance curve out, just to make sure you don't have multiple local minima that are close to as good as each other, which might tell you something interesting about the assumed model (or the data):
Simple regression models for data with a breakpoint
This will be an R-centric answer. One approach is to wrap the call to lm in a function which is passed the breakpoint and constructs a regression conditional upon that breakpoint, then minimize the d
Simple regression models for data with a breakpoint This will be an R-centric answer. One approach is to wrap the call to lm in a function which is passed the breakpoint and constructs a regression conditional upon that breakpoint, then minimize the deviance of the fitted model conditional upon the breakpoint by just iterating over the possible values for the breakpoint. This maximizes the profile log likelihood for the breakpoint, and, in general (i.e., not just for this problem) if the function interior to the breakpoint iteration (lm in this case) finds maximum likelihood estimates conditional upon the parameter passed to it, the whole procedure finds the joint maximum likelihood estimates for all the parameters. For example: # True model: y = a + b*(obs. no >= shift) + c*x # a = 0, b = 1, c = 1, shift at observation 31 # Construct sample data x <- rnorm(100) shift <- c(rep(0,30),rep(1,70)) y <- shift + x + rnorm(100) # Find deviance conditional upon breakpoint lm.shift <- function(y, x, shift.obs) { shift.var <- c(rep(0, (shift.obs-1)), rep(1, length(y)-shift.obs+1)) deviance(lm(y~x+shift.var)) } # Find deviance of all breakpoint values dev.value <- rep(0, length(y)) for (i in 1:length(y)) { dev.value[i] <- lm.shift(y, x, i) } # Calculate profile-ll based confidence interval estimate <- which.min(dev.value) profile.95.dev <- min(dev.value) + qchisq(0.95,1) est.lb.95 <- max(which(dev.value[1:estimate] > profile.95.dev)) est.ub.95 <- est -1 + min(which(dev.value[estimate:length(y)] > profile.95.dev)) > estimate [1] 30 > est.lb.95 [1] 28 > est.ub.95 [1] 33 So our estimate is 30 with a 95% confidence interval of 28 - 33. Pretty tight, but that was a pretty big shift relative to the standard deviation of the error term too. Note some messiness is involved in calculating the profile log-likelihood based confidence interval, but the basic idea is to find the largest index less than the estimate with a deviance greater than the cutoff level for the lower bound and the smallest index larger than the estimate with a deviance greater than the cutoff level for the upper bound. One really should plot the deviance curve out, just to make sure you don't have multiple local minima that are close to as good as each other, which might tell you something interesting about the assumed model (or the data):
Simple regression models for data with a breakpoint This will be an R-centric answer. One approach is to wrap the call to lm in a function which is passed the breakpoint and constructs a regression conditional upon that breakpoint, then minimize the d
40,453
Simple regression models for data with a breakpoint
This is an example of detecting a change in intercept (B0 in your notation ) or sometimes referred to a level or step shift. This often occurs in time series data where a variable in the model is impacted by a 0,0,0,0,0,0,1,1,1,1,1,1 ..... phenomenon at or around some unknown arbitrary point. It is referred to as Intervention Detection see as the break point (intervention) is found (detected) by trial and error aka a search process. If your data is not time series it is possible to use a time series package that identifies Interventions while specifying a frequency of "1" and disableing any ARMA structure thus yielding a model that you require.I your data is time series as might be expected then you need to consider Intervention Detection in he presence of ARIMA structure and PDL's (ADL's) in the user-suggested input/causal series. If you wished to post your data I would demonstrate this to you and the list. Additionally you might look at Outlier detection for generic time series and/or www.forecastingsolutions.com/publications/Introducing_cart.pdf
Simple regression models for data with a breakpoint
This is an example of detecting a change in intercept (B0 in your notation ) or sometimes referred to a level or step shift. This often occurs in time series data where a variable in the model is impa
Simple regression models for data with a breakpoint This is an example of detecting a change in intercept (B0 in your notation ) or sometimes referred to a level or step shift. This often occurs in time series data where a variable in the model is impacted by a 0,0,0,0,0,0,1,1,1,1,1,1 ..... phenomenon at or around some unknown arbitrary point. It is referred to as Intervention Detection see as the break point (intervention) is found (detected) by trial and error aka a search process. If your data is not time series it is possible to use a time series package that identifies Interventions while specifying a frequency of "1" and disableing any ARMA structure thus yielding a model that you require.I your data is time series as might be expected then you need to consider Intervention Detection in he presence of ARIMA structure and PDL's (ADL's) in the user-suggested input/causal series. If you wished to post your data I would demonstrate this to you and the list. Additionally you might look at Outlier detection for generic time series and/or www.forecastingsolutions.com/publications/Introducing_cart.pdf
Simple regression models for data with a breakpoint This is an example of detecting a change in intercept (B0 in your notation ) or sometimes referred to a level or step shift. This often occurs in time series data where a variable in the model is impa
40,454
Simple regression models for data with a breakpoint
Sounds like you want a spline regression with a single knot. In SAS see PROC TRANSREG. In R see (e.g) the Splines package.
Simple regression models for data with a breakpoint
Sounds like you want a spline regression with a single knot. In SAS see PROC TRANSREG. In R see (e.g) the Splines package.
Simple regression models for data with a breakpoint Sounds like you want a spline regression with a single knot. In SAS see PROC TRANSREG. In R see (e.g) the Splines package.
Simple regression models for data with a breakpoint Sounds like you want a spline regression with a single knot. In SAS see PROC TRANSREG. In R see (e.g) the Splines package.
40,455
Benchmark dataset for decision tree algorithm
I would recommend the UCI repository you're mentioning. It has been around for quite some time, contains many data sets and is frequently referenced in scientific publications.
Benchmark dataset for decision tree algorithm
I would recommend the UCI repository you're mentioning. It has been around for quite some time, contains many data sets and is frequently referenced in scientific publications.
Benchmark dataset for decision tree algorithm I would recommend the UCI repository you're mentioning. It has been around for quite some time, contains many data sets and is frequently referenced in scientific publications.
Benchmark dataset for decision tree algorithm I would recommend the UCI repository you're mentioning. It has been around for quite some time, contains many data sets and is frequently referenced in scientific publications.
40,456
Benchmark dataset for decision tree algorithm
You're on the right track with the UCI repository. MLcomp is another great resource, and will automatically score your algorithm on multiple datasets.
Benchmark dataset for decision tree algorithm
You're on the right track with the UCI repository. MLcomp is another great resource, and will automatically score your algorithm on multiple datasets.
Benchmark dataset for decision tree algorithm You're on the right track with the UCI repository. MLcomp is another great resource, and will automatically score your algorithm on multiple datasets.
Benchmark dataset for decision tree algorithm You're on the right track with the UCI repository. MLcomp is another great resource, and will automatically score your algorithm on multiple datasets.
40,457
Benchmark dataset for decision tree algorithm
You could try having a look at the datasets from Kaggle competitions at kaggle.com. Some require a fair degree of pre-processing, but there are some relatively 'clean' datasets there. You can see how your algorithm performs by submitting predictions to either current or past competitions and see how well it performs relatively to other participants.
Benchmark dataset for decision tree algorithm
You could try having a look at the datasets from Kaggle competitions at kaggle.com. Some require a fair degree of pre-processing, but there are some relatively 'clean' datasets there. You can see how
Benchmark dataset for decision tree algorithm You could try having a look at the datasets from Kaggle competitions at kaggle.com. Some require a fair degree of pre-processing, but there are some relatively 'clean' datasets there. You can see how your algorithm performs by submitting predictions to either current or past competitions and see how well it performs relatively to other participants.
Benchmark dataset for decision tree algorithm You could try having a look at the datasets from Kaggle competitions at kaggle.com. Some require a fair degree of pre-processing, but there are some relatively 'clean' datasets there. You can see how
40,458
Benchmark dataset for decision tree algorithm
Thought I should mention milksets, a Python wrapper around some UCI datasets. It appears to have 7 of the datasets, and produces them as a simple 2D Numpy array.
Benchmark dataset for decision tree algorithm
Thought I should mention milksets, a Python wrapper around some UCI datasets. It appears to have 7 of the datasets, and produces them as a simple 2D Numpy array.
Benchmark dataset for decision tree algorithm Thought I should mention milksets, a Python wrapper around some UCI datasets. It appears to have 7 of the datasets, and produces them as a simple 2D Numpy array.
Benchmark dataset for decision tree algorithm Thought I should mention milksets, a Python wrapper around some UCI datasets. It appears to have 7 of the datasets, and produces them as a simple 2D Numpy array.
40,459
Problem with character vectors and linear regression in R
You can build a formula from character vectors using standard R functions and as.formula(). The trick is to note that you need to have a full formula (containing at least a ~) for R to create a formula object for you. Here is an example ## predictors vars <- "x1 + x2 + x3 + x4 + x5" ## dummy data for example dat <- data.frame(matrix(rnorm(120), ncol = 6)) names(dat) <- c("y", paste("x", 1:5, sep = "")) ## create a formula - here we need to paste on the response part ## y ~ form <- as.formula(paste("y ~", vars)) ## Fit the model using `form` mod <- lm(form, data = dat) If you print form you'll see that R has created a special object that no longer prints as a character string would: > form y ~ x1 + x2 + x3 + x4 + x5
Problem with character vectors and linear regression in R
You can build a formula from character vectors using standard R functions and as.formula(). The trick is to note that you need to have a full formula (containing at least a ~) for R to create a formul
Problem with character vectors and linear regression in R You can build a formula from character vectors using standard R functions and as.formula(). The trick is to note that you need to have a full formula (containing at least a ~) for R to create a formula object for you. Here is an example ## predictors vars <- "x1 + x2 + x3 + x4 + x5" ## dummy data for example dat <- data.frame(matrix(rnorm(120), ncol = 6)) names(dat) <- c("y", paste("x", 1:5, sep = "")) ## create a formula - here we need to paste on the response part ## y ~ form <- as.formula(paste("y ~", vars)) ## Fit the model using `form` mod <- lm(form, data = dat) If you print form you'll see that R has created a special object that no longer prints as a character string would: > form y ~ x1 + x2 + x3 + x4 + x5
Problem with character vectors and linear regression in R You can build a formula from character vectors using standard R functions and as.formula(). The trick is to note that you need to have a full formula (containing at least a ~) for R to create a formul
40,460
Probability of winning a tournament
The model described in the links is not the diffusion model. The model you are trying to implement is called the Independent Chip Model or ICM. They give different estimates for your expected share of second and lower place prizes. Here are two ways to describe the ICM: (1) Determine the winner so that each player's chance to win is proportional to his chip count. Then remove that player's chips, and determine the second place player so that each non-winner's chance to place second is proportional to his chip count. Repeat. (2) Randomly remove the chips one at a time so that each remaining chip has the same chance to be removed next. When your last chip is removed, you are eliminated. It's not obvious that these are the same model. In fact, it's clear that the first description only depends on the proportion of chips, and doesn't require that the number of chips is an integer. It's not obvious that the second method gives the same chance to place second if the stacks are $(100,200,300)$ as for $(1,2,3)$. (In other models, these situations are different.) However, you can see that these are equivalent (when both are defined) by a third description: (3) Each player marks all of his chips. Then they are shuffled and ordered. Players are ranked by their highest chips. Description (1) corresponds to looking at the top of the ordering. Description (2) corresponds to looking at the bottom. You can find a lot of information about the Independent Chip Model on the web because it is used by serious tournament poker players, particularly those who play Sit-N-Go (SNG)/Single Table Tournaments (STTs). See, for example, this Nash Equilibrium Calculator for push/fold decisions in STTs which uses the ICM. There are other models like the diffusion model, but the Independent Chip Model seems good enough and is easier to compute. You can find a section on the ICM in my book, The Math of Hold'em, and I have also made videos on it for poker instructional sites. One of the other answers asks why bother since it's all luck. Understanding equities assuming that you have no skill advantage (but the stacks are not equal) is how many serious poker players GET an advantage. Getting all-in with a $60\%$ chance to win and negligible dead money is sometimes great, and sometimes terrible. The equities say which. Also, if you run a poker server, you need to be prepared to divide the prize money fairly in case the server crashes during the tournament. A poker server asked me for help with this. As you have noted, a naive implementation which computes your chance to place $p$ out of $n$ players sums over many terms, $(n-1) \times (n-2) \times ... \times (n-p) = \frac{(n-1)!}{(n-p-1)!}$. This may be too large in practice. One improvement I use in my program ICM Explorer is to memoize the probabilities with each subset of up to $p-1$ opponents removed. If you are computing each probability, this takes $n 2^{n-1}$ steps instead of $(n-1)!$, which makes the difference between whether you can calculate the case $n=10$ crisply, and whether you can calculate the case $n=20$ in under a second versus not at all. If you have repeated stack sizes among your opponents, you can remember how many of them have been eliminated instead of which subset. This is particularly useful when you are analyzing multitable tournaments where you only see the stacks at your table, or only a few front-runners, and you assume everyone else you don't see has the same stack size. This makes calculating your equity feasible for large tournaments. This method has a complexity roughly equal to $k \prod_{i=1}^k (m_i+1)$ where there are $k$ different stack sizes among your opponents whose multiplicities are $m_1, ... ,m_k$. There is one implementation I know about which lets the user calculate ICM equities for multitable tournaments. This uses a simulation. The author assured me that it converges rapidly to within a $0.1\%$ chance for each place. In case you need more accuracy, one simple variance reduction method works very well: Estimate your luck from being chosen or not to finish next at each step by the exact calculations with fewer distinct stack sizes. Subtract this estimate of luck (a vector) from the vector of probabilities obtained in the simulation. For example, suppose your stack is $1000$, and you have $2$ opponents with stacks of $500$ and one with $1500$. If one of the players with $500$ wins, your remaining opponents will average $1000$, so you estimate your chances using the ICM exactly assuming $2$ opponents with $1000$ chips. Since all stacks would be equal, by symmetry all $3$ players would have an equal chance to finish second, third, and fourth, so your place distribution would be $(0,1/3,1/3,1/3)$. If the big stack wins, your remaining opponents average $500$, and the ICM says your place distribution is $(0,1/2,1/3,1/6)$. If you win, obviously your place distribution is $(1,0,0,0)$. The weighted average is $$\frac{1000}{3500}(0,1/3,1/3,1/3) + \frac{1500}{3500}(0,1/2,1/3,1/6) + \frac{1000}{3500}(1,0,0,0) = (2/7,13/42,5/21,1/6).$$ So, if in your trial, you win, then you estimate your luck for that step by $(1,0,0,0) - (2/7,13/42,5/21,1/6)$, and subtract this from the result of the trial. If the big stack wins, the trial isn't over, but you estimate your luck for this step by $(0,1/2,1/3,1/6)-(2/7,13/42,5/21,1/6)$, and subtract this and future luck estimates from the outcome of the trial. The luck estimate averages to $(0,0,0,0)$ and greatly reduces the number of trials needed to achieve a given level of accuracy, particularly for the places closer to first, which are most important for estimating your fair share of the prize money. The distribution of the other stacks matters, but except in extreme situations, you only see a large effect if you are close to the "money," which means that there are at most a few more players than there are prizes. Let's assume the prize structure is the one PokerStars uses for $180$ player tournaments: $0.3, 0.2, 0.119, 0.08, 0.065, 0.05, 0.035, 0.026, 0.017$ for places $1-9$, and a flat $0.012$ for places $10-18$. Let's consider $2$ pairs of situations. First, you are one of $180$ equal stacks. Your equity is $1/180$ of the prize pool, or $0.5556\%$. Suppose you have doubled up, eliminating one player, and you have $178$ opponents with a stack half as large as yours. According to the ICM, your chance to finish in first place is $1.1111\%$, second $1.1049\%$, ... $18$th $1.0056\%$ for an equity of $1.0917\%$. The quotient $0.5556/1.0917 = 50.887\%$ is how much equity you need to want to get all-in with no dead money with $180$ equal stacks. Suppose there are $60$ players with a stack equal to yours (including you), $60$ with half of your stack, and $60$ with half again as much as your stack. According to the ICM, your equity is $0.5572\%$ of the prize pool. Next, suppose you double up against an equal stack. Your equity increases to $1.0948\%$ of the prize pool. The equity you need to risk elimination for this is $0.5572/1.0948 = 50.894\%$. Your expected share of the prize money didn't depend much on the stacks of the other players, and the equity you need to risk your whole stack depended even less on the stacks of the other players. These become sensitive to the stacks of your opponents once you get down to about $25-30$ players left with $18$ prizes.
Probability of winning a tournament
The model described in the links is not the diffusion model. The model you are trying to implement is called the Independent Chip Model or ICM. They give different estimates for your expected share of
Probability of winning a tournament The model described in the links is not the diffusion model. The model you are trying to implement is called the Independent Chip Model or ICM. They give different estimates for your expected share of second and lower place prizes. Here are two ways to describe the ICM: (1) Determine the winner so that each player's chance to win is proportional to his chip count. Then remove that player's chips, and determine the second place player so that each non-winner's chance to place second is proportional to his chip count. Repeat. (2) Randomly remove the chips one at a time so that each remaining chip has the same chance to be removed next. When your last chip is removed, you are eliminated. It's not obvious that these are the same model. In fact, it's clear that the first description only depends on the proportion of chips, and doesn't require that the number of chips is an integer. It's not obvious that the second method gives the same chance to place second if the stacks are $(100,200,300)$ as for $(1,2,3)$. (In other models, these situations are different.) However, you can see that these are equivalent (when both are defined) by a third description: (3) Each player marks all of his chips. Then they are shuffled and ordered. Players are ranked by their highest chips. Description (1) corresponds to looking at the top of the ordering. Description (2) corresponds to looking at the bottom. You can find a lot of information about the Independent Chip Model on the web because it is used by serious tournament poker players, particularly those who play Sit-N-Go (SNG)/Single Table Tournaments (STTs). See, for example, this Nash Equilibrium Calculator for push/fold decisions in STTs which uses the ICM. There are other models like the diffusion model, but the Independent Chip Model seems good enough and is easier to compute. You can find a section on the ICM in my book, The Math of Hold'em, and I have also made videos on it for poker instructional sites. One of the other answers asks why bother since it's all luck. Understanding equities assuming that you have no skill advantage (but the stacks are not equal) is how many serious poker players GET an advantage. Getting all-in with a $60\%$ chance to win and negligible dead money is sometimes great, and sometimes terrible. The equities say which. Also, if you run a poker server, you need to be prepared to divide the prize money fairly in case the server crashes during the tournament. A poker server asked me for help with this. As you have noted, a naive implementation which computes your chance to place $p$ out of $n$ players sums over many terms, $(n-1) \times (n-2) \times ... \times (n-p) = \frac{(n-1)!}{(n-p-1)!}$. This may be too large in practice. One improvement I use in my program ICM Explorer is to memoize the probabilities with each subset of up to $p-1$ opponents removed. If you are computing each probability, this takes $n 2^{n-1}$ steps instead of $(n-1)!$, which makes the difference between whether you can calculate the case $n=10$ crisply, and whether you can calculate the case $n=20$ in under a second versus not at all. If you have repeated stack sizes among your opponents, you can remember how many of them have been eliminated instead of which subset. This is particularly useful when you are analyzing multitable tournaments where you only see the stacks at your table, or only a few front-runners, and you assume everyone else you don't see has the same stack size. This makes calculating your equity feasible for large tournaments. This method has a complexity roughly equal to $k \prod_{i=1}^k (m_i+1)$ where there are $k$ different stack sizes among your opponents whose multiplicities are $m_1, ... ,m_k$. There is one implementation I know about which lets the user calculate ICM equities for multitable tournaments. This uses a simulation. The author assured me that it converges rapidly to within a $0.1\%$ chance for each place. In case you need more accuracy, one simple variance reduction method works very well: Estimate your luck from being chosen or not to finish next at each step by the exact calculations with fewer distinct stack sizes. Subtract this estimate of luck (a vector) from the vector of probabilities obtained in the simulation. For example, suppose your stack is $1000$, and you have $2$ opponents with stacks of $500$ and one with $1500$. If one of the players with $500$ wins, your remaining opponents will average $1000$, so you estimate your chances using the ICM exactly assuming $2$ opponents with $1000$ chips. Since all stacks would be equal, by symmetry all $3$ players would have an equal chance to finish second, third, and fourth, so your place distribution would be $(0,1/3,1/3,1/3)$. If the big stack wins, your remaining opponents average $500$, and the ICM says your place distribution is $(0,1/2,1/3,1/6)$. If you win, obviously your place distribution is $(1,0,0,0)$. The weighted average is $$\frac{1000}{3500}(0,1/3,1/3,1/3) + \frac{1500}{3500}(0,1/2,1/3,1/6) + \frac{1000}{3500}(1,0,0,0) = (2/7,13/42,5/21,1/6).$$ So, if in your trial, you win, then you estimate your luck for that step by $(1,0,0,0) - (2/7,13/42,5/21,1/6)$, and subtract this from the result of the trial. If the big stack wins, the trial isn't over, but you estimate your luck for this step by $(0,1/2,1/3,1/6)-(2/7,13/42,5/21,1/6)$, and subtract this and future luck estimates from the outcome of the trial. The luck estimate averages to $(0,0,0,0)$ and greatly reduces the number of trials needed to achieve a given level of accuracy, particularly for the places closer to first, which are most important for estimating your fair share of the prize money. The distribution of the other stacks matters, but except in extreme situations, you only see a large effect if you are close to the "money," which means that there are at most a few more players than there are prizes. Let's assume the prize structure is the one PokerStars uses for $180$ player tournaments: $0.3, 0.2, 0.119, 0.08, 0.065, 0.05, 0.035, 0.026, 0.017$ for places $1-9$, and a flat $0.012$ for places $10-18$. Let's consider $2$ pairs of situations. First, you are one of $180$ equal stacks. Your equity is $1/180$ of the prize pool, or $0.5556\%$. Suppose you have doubled up, eliminating one player, and you have $178$ opponents with a stack half as large as yours. According to the ICM, your chance to finish in first place is $1.1111\%$, second $1.1049\%$, ... $18$th $1.0056\%$ for an equity of $1.0917\%$. The quotient $0.5556/1.0917 = 50.887\%$ is how much equity you need to want to get all-in with no dead money with $180$ equal stacks. Suppose there are $60$ players with a stack equal to yours (including you), $60$ with half of your stack, and $60$ with half again as much as your stack. According to the ICM, your equity is $0.5572\%$ of the prize pool. Next, suppose you double up against an equal stack. Your equity increases to $1.0948\%$ of the prize pool. The equity you need to risk elimination for this is $0.5572/1.0948 = 50.894\%$. Your expected share of the prize money didn't depend much on the stacks of the other players, and the equity you need to risk your whole stack depended even less on the stacks of the other players. These become sensitive to the stacks of your opponents once you get down to about $25-30$ players left with $18$ prizes.
Probability of winning a tournament The model described in the links is not the diffusion model. The model you are trying to implement is called the Independent Chip Model or ICM. They give different estimates for your expected share of
40,461
Probability of winning a tournament
Do players keep playing until they run out of chips? Suppose we assume players A B C each have some number of chips and keep playing until they have 0. Suppose we further assume odds of winning a hand are either 1/3, 1/3, 1/3 or some other value (per Michelle's comment about skill). Suppose we further assume each pot consists of either win (+2) or loss (-1) -- an unrealistic but simplifying assumption. Then doesn't this become a question of the relative probability of hitting 0 first? There's literature I'm not really familiar with that deals with this (Martingale wagers, but without the increasing bets). With multiple tables, equal chip pools per table and 1 winner per table 2nd round would be p=1/3. More: I did some quick simulations along these lines. Each player is equally skilled. A always starts with 50% of the chips, B 1/3 of the chips and C 1/6 of the chips. I just varied the total number of chips. I did 3 runs at 3 levels, each consisting of 2000 simulations until only 1 player was left (18,000 simulations total). This suggests that it might indeed be as simple as p(I win) = my proportion of chips.
Probability of winning a tournament
Do players keep playing until they run out of chips? Suppose we assume players A B C each have some number of chips and keep playing until they have 0. Suppose we further assume odds of winning a han
Probability of winning a tournament Do players keep playing until they run out of chips? Suppose we assume players A B C each have some number of chips and keep playing until they have 0. Suppose we further assume odds of winning a hand are either 1/3, 1/3, 1/3 or some other value (per Michelle's comment about skill). Suppose we further assume each pot consists of either win (+2) or loss (-1) -- an unrealistic but simplifying assumption. Then doesn't this become a question of the relative probability of hitting 0 first? There's literature I'm not really familiar with that deals with this (Martingale wagers, but without the increasing bets). With multiple tables, equal chip pools per table and 1 winner per table 2nd round would be p=1/3. More: I did some quick simulations along these lines. Each player is equally skilled. A always starts with 50% of the chips, B 1/3 of the chips and C 1/6 of the chips. I just varied the total number of chips. I did 3 runs at 3 levels, each consisting of 2000 simulations until only 1 player was left (18,000 simulations total). This suggests that it might indeed be as simple as p(I win) = my proportion of chips.
Probability of winning a tournament Do players keep playing until they run out of chips? Suppose we assume players A B C each have some number of chips and keep playing until they have 0. Suppose we further assume odds of winning a han
40,462
Probability of winning a tournament
I suspect you are making this more complex than it needs to be. If there are 27 million players (or even 27 thousand - I think you have a typo) and the game is pure chance and we can reasonably assume that no player has a significant number of chips compared to the total number of chips... Then your chance of winning is: $\frac{my chips} {total chips}$ Your change of coming second, given you didn't win, is: $\frac{mychips}{totalchips-winnerchips}$ which is effectively the same as your chance of winning. And so on. Given the vast numbers involved and if as you say it is all chance I doubt it is worthwhile doing any more sophisticated calculation. The secret of "statistical tricks" is to know when to use an approximation :-)
Probability of winning a tournament
I suspect you are making this more complex than it needs to be. If there are 27 million players (or even 27 thousand - I think you have a typo) and the game is pure chance and we can reasonably assum
Probability of winning a tournament I suspect you are making this more complex than it needs to be. If there are 27 million players (or even 27 thousand - I think you have a typo) and the game is pure chance and we can reasonably assume that no player has a significant number of chips compared to the total number of chips... Then your chance of winning is: $\frac{my chips} {total chips}$ Your change of coming second, given you didn't win, is: $\frac{mychips}{totalchips-winnerchips}$ which is effectively the same as your chance of winning. And so on. Given the vast numbers involved and if as you say it is all chance I doubt it is worthwhile doing any more sophisticated calculation. The secret of "statistical tricks" is to know when to use an approximation :-)
Probability of winning a tournament I suspect you are making this more complex than it needs to be. If there are 27 million players (or even 27 thousand - I think you have a typo) and the game is pure chance and we can reasonably assum
40,463
Oversampling in logistic regression
If you are thinking about oversampling based on the outcome then you have to be quite careful. In general this is not ok. Endogenous sampling schemes will give you biased results. See Wooldridge chapter 17. In the case of the Logit model things are somewhat different. Borrowing from Manski the thing is that in general response based sampling reveals: $P(x|y=1)$ and $P(x|y=0)$, but nothing about the probability of $P(y|x)$. However, if $P(x|y=1)>0$ and $P(x|y=0)>0$ and also $P(y=1|x)$ approaches zero (in other words, it has the property of the rare disease assumption), then for the LOGIT model (due to its nice exponential functional form), outcome based sampling point identifies relative and attributable risk. Relative risk is also known as the odds ratio when the rare disease assumption is true. For the complete proof check pages 112 and 113 of Manski's book that I recommended above. OK, so we have established that if you are only looking at the odds ratios, outcome based sampling and logit should be OK. Of course, you can only get odds ratios, you won't be able to identify the intercept therefore you must be very very careful about what to conclude ... Now to your question: In principle, if you have the entire population, you should not need to oversample since you have all cases ... That should be clear. In practice that is rarely true since most likely you will only have a sample of the population. When that happens, what Gary King shows is that there are some benefits on doing outcome based sampling and applying finite sample corrections: Gary King Rare Events Logit. Finally (without having read it in detail) I believe that the point of the blog that you are referring to above is precisely the one that I am making here. That if you have no other alternative than to oversample a class of the population based on the outcome to get a minimum amount of observations, then, with the logistic regression and if you are looking at the odds ratio you should be fine. It is not that they recommend it, but it might be your only option.
Oversampling in logistic regression
If you are thinking about oversampling based on the outcome then you have to be quite careful. In general this is not ok. Endogenous sampling schemes will give you biased results. See Wooldridge chap
Oversampling in logistic regression If you are thinking about oversampling based on the outcome then you have to be quite careful. In general this is not ok. Endogenous sampling schemes will give you biased results. See Wooldridge chapter 17. In the case of the Logit model things are somewhat different. Borrowing from Manski the thing is that in general response based sampling reveals: $P(x|y=1)$ and $P(x|y=0)$, but nothing about the probability of $P(y|x)$. However, if $P(x|y=1)>0$ and $P(x|y=0)>0$ and also $P(y=1|x)$ approaches zero (in other words, it has the property of the rare disease assumption), then for the LOGIT model (due to its nice exponential functional form), outcome based sampling point identifies relative and attributable risk. Relative risk is also known as the odds ratio when the rare disease assumption is true. For the complete proof check pages 112 and 113 of Manski's book that I recommended above. OK, so we have established that if you are only looking at the odds ratios, outcome based sampling and logit should be OK. Of course, you can only get odds ratios, you won't be able to identify the intercept therefore you must be very very careful about what to conclude ... Now to your question: In principle, if you have the entire population, you should not need to oversample since you have all cases ... That should be clear. In practice that is rarely true since most likely you will only have a sample of the population. When that happens, what Gary King shows is that there are some benefits on doing outcome based sampling and applying finite sample corrections: Gary King Rare Events Logit. Finally (without having read it in detail) I believe that the point of the blog that you are referring to above is precisely the one that I am making here. That if you have no other alternative than to oversample a class of the population based on the outcome to get a minimum amount of observations, then, with the logistic regression and if you are looking at the odds ratio you should be fine. It is not that they recommend it, but it might be your only option.
Oversampling in logistic regression If you are thinking about oversampling based on the outcome then you have to be quite careful. In general this is not ok. Endogenous sampling schemes will give you biased results. See Wooldridge chap
40,464
What do you do with your testing data?
I would retrain the model using the training and test partitions; there doesn't seem much to lose from doing so, and the final model will probably perform slightly better than the pessimistic (as it is based on a smaller training set) performance estimate. If the dataset is small, a better solution would be to combine the training and test sets and use bootstrap replication. You can use the out-of-bag performance estimator for whatever fine tuning you need to do, and you can just use the same bootstrap committee (i.e. bagging) for the validation set predictions. For small datasets bagging is very useful because if you use a single test/training split, the test set performance is highly variable die to the small size of the test set, so it is an unreliable estimator of true performance. The out-of-bag estimator generally has a lower variance and is a better guide to performance. Likewise the predictor itself is less variable with bagging that if trained on a single training set.
What do you do with your testing data?
I would retrain the model using the training and test partitions; there doesn't seem much to lose from doing so, and the final model will probably perform slightly better than the pessimistic (as it i
What do you do with your testing data? I would retrain the model using the training and test partitions; there doesn't seem much to lose from doing so, and the final model will probably perform slightly better than the pessimistic (as it is based on a smaller training set) performance estimate. If the dataset is small, a better solution would be to combine the training and test sets and use bootstrap replication. You can use the out-of-bag performance estimator for whatever fine tuning you need to do, and you can just use the same bootstrap committee (i.e. bagging) for the validation set predictions. For small datasets bagging is very useful because if you use a single test/training split, the test set performance is highly variable die to the small size of the test set, so it is an unreliable estimator of true performance. The out-of-bag estimator generally has a lower variance and is a better guide to performance. Likewise the predictor itself is less variable with bagging that if trained on a single training set.
What do you do with your testing data? I would retrain the model using the training and test partitions; there doesn't seem much to lose from doing so, and the final model will probably perform slightly better than the pessimistic (as it i
40,465
How to use segmented package to fit a piecewise linear regression with one breakpoint?
It appears that what is happening is that one of the estimates for a breakpoint is moving outside the range of offer during the fitting procedure. (You can deduce this by typing seg.lm.fit at the prompt and fighting your way through the code.) You can work around this by specifying PSI, the starting values for the breakpoints. I also set seg.control=list(stop.if.error=FALSE) to try to work around the problem, but that didn't help. I reran your model with PSI=c(15) and it worked, but with PSI=c(15,25) I got an iteration count exceeded error message, which I could not overcome even by setting the maximum number of iterations to 1,000. I would take this as meaning that one breakpoint is all you're going to be able to estimate with this function and data. As an extra note, if you plot(sqrt(demand)~offer), the relationship looks a lot closer to linear than just demand~offer, so you might want to try a transform of the data rather than a piecewise linear model.
How to use segmented package to fit a piecewise linear regression with one breakpoint?
It appears that what is happening is that one of the estimates for a breakpoint is moving outside the range of offer during the fitting procedure. (You can deduce this by typing seg.lm.fit at the pro
How to use segmented package to fit a piecewise linear regression with one breakpoint? It appears that what is happening is that one of the estimates for a breakpoint is moving outside the range of offer during the fitting procedure. (You can deduce this by typing seg.lm.fit at the prompt and fighting your way through the code.) You can work around this by specifying PSI, the starting values for the breakpoints. I also set seg.control=list(stop.if.error=FALSE) to try to work around the problem, but that didn't help. I reran your model with PSI=c(15) and it worked, but with PSI=c(15,25) I got an iteration count exceeded error message, which I could not overcome even by setting the maximum number of iterations to 1,000. I would take this as meaning that one breakpoint is all you're going to be able to estimate with this function and data. As an extra note, if you plot(sqrt(demand)~offer), the relationship looks a lot closer to linear than just demand~offer, so you might want to try a transform of the data rather than a piecewise linear model.
How to use segmented package to fit a piecewise linear regression with one breakpoint? It appears that what is happening is that one of the estimates for a breakpoint is moving outside the range of offer during the fitting procedure. (You can deduce this by typing seg.lm.fit at the pro
40,466
Predicting Y using X for the following data
This is really an illustrated comment. It's not at all clear that the relationship is heteroscedastic. It may appear so in large part due to the decreasing number of observations with larger $x$. Take this simulation, for example: This kernel density plot shows 20,000 iid draws from $(X,Y)$ where $X$ has a $B(1,5)$ distribution, $Y$ has a lognormal distribution (geometric mean = $\log(0.2)$, geometric SD = $0.45$), and $X$ and $Y$ are independent. Here are histograms of their marginal densities: The appearance of heteroscedasticity arises solely from the scarcity of $(X,Y)$ values for larger $X$. This appearance is further exaggerated by the skewness of $Y$. This suggests that to begin with, you take some vertical slices through the data, say near both ends (low $X$ and high $X$) and the middle, and fit distributions to the $Y$ values found within those slices. Is there evidence that these distributions really are different? If so, how do they differ? E.g., do they have similar shapes with varying first and second moments? If their shapes appear significantly different, are they at least approximated by distributions within a three-parameter family (for location, scale, and shape)? This will suggest appropriate follow-on analyses (including, perhaps, some re-expression of the $Y$ values).
Predicting Y using X for the following data
This is really an illustrated comment. It's not at all clear that the relationship is heteroscedastic. It may appear so in large part due to the decreasing number of observations with larger $x$. Ta
Predicting Y using X for the following data This is really an illustrated comment. It's not at all clear that the relationship is heteroscedastic. It may appear so in large part due to the decreasing number of observations with larger $x$. Take this simulation, for example: This kernel density plot shows 20,000 iid draws from $(X,Y)$ where $X$ has a $B(1,5)$ distribution, $Y$ has a lognormal distribution (geometric mean = $\log(0.2)$, geometric SD = $0.45$), and $X$ and $Y$ are independent. Here are histograms of their marginal densities: The appearance of heteroscedasticity arises solely from the scarcity of $(X,Y)$ values for larger $X$. This appearance is further exaggerated by the skewness of $Y$. This suggests that to begin with, you take some vertical slices through the data, say near both ends (low $X$ and high $X$) and the middle, and fit distributions to the $Y$ values found within those slices. Is there evidence that these distributions really are different? If so, how do they differ? E.g., do they have similar shapes with varying first and second moments? If their shapes appear significantly different, are they at least approximated by distributions within a three-parameter family (for location, scale, and shape)? This will suggest appropriate follow-on analyses (including, perhaps, some re-expression of the $Y$ values).
Predicting Y using X for the following data This is really an illustrated comment. It's not at all clear that the relationship is heteroscedastic. It may appear so in large part due to the decreasing number of observations with larger $x$. Ta
40,467
Predicting Y using X for the following data
If you are merely interested in modelling the mean of the above relationship, the solution to address the heteroskedasticity should not be complicated (there is a chance though that I am completely mistaken with what I say here). OLS estimators are not biased from heteroskedasticity and so you only have to worry about the standard errors, i.e. issues regarding the statistical significance. You can use heteroskedasticity robust standard error estimates. Those are more conservative than the normal ones but with the amount of data you have my guess is that you still have highly significant results. From the "mean vs mean" plot you provided, I would guess the right specifiation could be a logarithmic model y ~ log(x) or so. You can then estimate this using OLS with robust standard errors. If you want to model the boundaries etc, things become more complicated and it will depend a lot on what you want to do with it.
Predicting Y using X for the following data
If you are merely interested in modelling the mean of the above relationship, the solution to address the heteroskedasticity should not be complicated (there is a chance though that I am completely mi
Predicting Y using X for the following data If you are merely interested in modelling the mean of the above relationship, the solution to address the heteroskedasticity should not be complicated (there is a chance though that I am completely mistaken with what I say here). OLS estimators are not biased from heteroskedasticity and so you only have to worry about the standard errors, i.e. issues regarding the statistical significance. You can use heteroskedasticity robust standard error estimates. Those are more conservative than the normal ones but with the amount of data you have my guess is that you still have highly significant results. From the "mean vs mean" plot you provided, I would guess the right specifiation could be a logarithmic model y ~ log(x) or so. You can then estimate this using OLS with robust standard errors. If you want to model the boundaries etc, things become more complicated and it will depend a lot on what you want to do with it.
Predicting Y using X for the following data If you are merely interested in modelling the mean of the above relationship, the solution to address the heteroskedasticity should not be complicated (there is a chance though that I am completely mi
40,468
Testing for confounding
First, it isn't terribly complicated to check for the association of Z on X or Y, even in survival analysis. Propensity scores and Inverse Probability of Treatment Weights (both common methods for adjusting for confounding in a survival context), along with other somewhat more esoteric methods are based on estimating the relationship between the covariate and the exposure or outcome. You can compare the adjusted and unadjusted score to evaluate whether or not there is confounding, but only if you have reason to believe there's confounding there in the first place. Just a raw comparison of the adjusted and unadjusted estimates run the risk of having actually induced confounding by adjusting for a variable that is affected by both the exposure and the outcome. Check up on the literature on directed acyclic graphs for covariate selection, and read about "colliders" for an explanation of this phenomena. But once something is believed to be a confounder for any number of reasons - subject matter expertise, the use of a DAG, establishing that the variable meets the criteria for a confounder, one can use what you're suggesting - which is normally called a change-in-estimate approach - to check whether or not its a "problem", based on how much the estimate changes. The threshold for what is a problem varies, but in Epidemiology, it's often a 10% change in estimate that's used to say something confounds the exposure-disease relationship enough to be worth adjusting for.
Testing for confounding
First, it isn't terribly complicated to check for the association of Z on X or Y, even in survival analysis. Propensity scores and Inverse Probability of Treatment Weights (both common methods for adj
Testing for confounding First, it isn't terribly complicated to check for the association of Z on X or Y, even in survival analysis. Propensity scores and Inverse Probability of Treatment Weights (both common methods for adjusting for confounding in a survival context), along with other somewhat more esoteric methods are based on estimating the relationship between the covariate and the exposure or outcome. You can compare the adjusted and unadjusted score to evaluate whether or not there is confounding, but only if you have reason to believe there's confounding there in the first place. Just a raw comparison of the adjusted and unadjusted estimates run the risk of having actually induced confounding by adjusting for a variable that is affected by both the exposure and the outcome. Check up on the literature on directed acyclic graphs for covariate selection, and read about "colliders" for an explanation of this phenomena. But once something is believed to be a confounder for any number of reasons - subject matter expertise, the use of a DAG, establishing that the variable meets the criteria for a confounder, one can use what you're suggesting - which is normally called a change-in-estimate approach - to check whether or not its a "problem", based on how much the estimate changes. The threshold for what is a problem varies, but in Epidemiology, it's often a 10% change in estimate that's used to say something confounds the exposure-disease relationship enough to be worth adjusting for.
Testing for confounding First, it isn't terribly complicated to check for the association of Z on X or Y, even in survival analysis. Propensity scores and Inverse Probability of Treatment Weights (both common methods for adj
40,469
Testing for confounding
There is no test for confounding, unfortunately. If you think Z is a confounder, adjust for it. It's not sufficient to look at changes (of size 10% or otherwise) because, even when Z isn't a confounder, when using non-collapsible measures of effect - like odds ratios - the parameter estimated in the adjusted analysis is different from that estimated in the unadjusted analysis.
Testing for confounding
There is no test for confounding, unfortunately. If you think Z is a confounder, adjust for it. It's not sufficient to look at changes (of size 10% or otherwise) because, even when Z isn't a confound
Testing for confounding There is no test for confounding, unfortunately. If you think Z is a confounder, adjust for it. It's not sufficient to look at changes (of size 10% or otherwise) because, even when Z isn't a confounder, when using non-collapsible measures of effect - like odds ratios - the parameter estimated in the adjusted analysis is different from that estimated in the unadjusted analysis.
Testing for confounding There is no test for confounding, unfortunately. If you think Z is a confounder, adjust for it. It's not sufficient to look at changes (of size 10% or otherwise) because, even when Z isn't a confound
40,470
Contrasts to ANOVA in R
Look at ?contrasts and ?lm. The default contrasts in R are different than those of SAS, but the difference is explained and you can specify the alternate form. (Am I correct in thinking you wanted to compare output with SAS?) I didn't keep your ":" in the formula since I thought it would be clearer to include a full interaction "*". model1 <- lm(yld ~ rep + parent1*parent2, data = mydf, contrasts = list(parent1="contr.SAS", parent2="contr.SAS")) model1 # note I did not retain your mode-eleven spelling. #--------------------- Coefficients: (Intercept) rep parent11 parent12 1.500e+01 2.079e-15 6.872e-17 4.262e-16 parent13 parent14 parent21 parent22 -7.692e-16 5.000e-01 -4.500e+00 -2.500e+00 parent23 parent24 parent11:parent21 parent12:parent21 -2.500e+00 -2.000e+00 NA NA parent13:parent21 parent14:parent21 parent11:parent22 parent12:parent22 NA NA 5.000e-01 NA parent13:parent22 parent14:parent22 parent11:parent23 parent12:parent23 NA NA -9.873e-16 2.040e-16 parent13:parent23 parent14:parent23 parent11:parent24 parent12:parent24 NA NA 5.000e-01 1.500e+00 parent13:parent24 parent14:parent24 5.000e-01 NA Also note that some of your contrast coefficients are effectively 0, for instance: "rep", parents(11,12,13), parent11:parent23 and parent12:parent23.
Contrasts to ANOVA in R
Look at ?contrasts and ?lm. The default contrasts in R are different than those of SAS, but the difference is explained and you can specify the alternate form. (Am I correct in thinking you wanted to
Contrasts to ANOVA in R Look at ?contrasts and ?lm. The default contrasts in R are different than those of SAS, but the difference is explained and you can specify the alternate form. (Am I correct in thinking you wanted to compare output with SAS?) I didn't keep your ":" in the formula since I thought it would be clearer to include a full interaction "*". model1 <- lm(yld ~ rep + parent1*parent2, data = mydf, contrasts = list(parent1="contr.SAS", parent2="contr.SAS")) model1 # note I did not retain your mode-eleven spelling. #--------------------- Coefficients: (Intercept) rep parent11 parent12 1.500e+01 2.079e-15 6.872e-17 4.262e-16 parent13 parent14 parent21 parent22 -7.692e-16 5.000e-01 -4.500e+00 -2.500e+00 parent23 parent24 parent11:parent21 parent12:parent21 -2.500e+00 -2.000e+00 NA NA parent13:parent21 parent14:parent21 parent11:parent22 parent12:parent22 NA NA 5.000e-01 NA parent13:parent22 parent14:parent22 parent11:parent23 parent12:parent23 NA NA -9.873e-16 2.040e-16 parent13:parent23 parent14:parent23 parent11:parent24 parent12:parent24 NA NA 5.000e-01 1.500e+00 parent13:parent24 parent14:parent24 5.000e-01 NA Also note that some of your contrast coefficients are effectively 0, for instance: "rep", parents(11,12,13), parent11:parent23 and parent12:parent23.
Contrasts to ANOVA in R Look at ?contrasts and ?lm. The default contrasts in R are different than those of SAS, but the difference is explained and you can specify the alternate form. (Am I correct in thinking you wanted to
40,471
Contrasts to ANOVA in R
Have a look on An R companion to "Experimental Design" by Vikneswaran. See chapter 5 in particular on "Orthogonality, Orthogonal Decomposition, and their Role in Modern Experimental Design".
Contrasts to ANOVA in R
Have a look on An R companion to "Experimental Design" by Vikneswaran. See chapter 5 in particular on "Orthogonality, Orthogonal Decomposition, and their Role in Modern Experimental Design".
Contrasts to ANOVA in R Have a look on An R companion to "Experimental Design" by Vikneswaran. See chapter 5 in particular on "Orthogonality, Orthogonal Decomposition, and their Role in Modern Experimental Design".
Contrasts to ANOVA in R Have a look on An R companion to "Experimental Design" by Vikneswaran. See chapter 5 in particular on "Orthogonality, Orthogonal Decomposition, and their Role in Modern Experimental Design".
40,472
Can categorical data only take finitely or countably infinitely many values?
"Categorical" is not a well-defined mathematical term, so to answer this question we have to look to how this word is intended to be used. It is employed in contrast to "ordinal," "interval," and "ratio." One way to understand the primary distinctions is in terms of the groups of allowable re-expressions of the values. In the case of the latter three, there is an order that must preserved, whence all re-expressions must be monotonic (order preserving). For categorical variables, any bijection (including permutations) is ok: Beyond that, anything goes with the nominal [categorical] scale. (Stevens, quoted in the Wikipedia article.) Another concept of "categorical" is that each outcome must be distinguishable from every other. This strongly suggests that any probability measure must be totally discrete: that is, all subsets are measurable, implying that each category will have its own well-defined probability. (This is not the case for continuous distributions.) This would seem to indicate that the number of categories should be finite or at most countable, but that is not evident in the literature. For instance, an archetypal example of a categorical variable is a set of names. The set of all possible names on any finite alphabet is countable but not finite. It is therefore useful to allow countably infinite sets to be categorical. For example, if we are studying names given to babies, it is convenient to let the sample space consist of all possible names (rather than all names that we know of). A slightly less realistic, but still conceivable, example of a categorical variable would be one that uses real numbers for names. In effect, such a variable would ignore all the usual mathematical structure on this set. I don't see any problem with such a usage, but it's worth observing that the axioms of probability imply that any probability distribution valid in this context would (a) assign a non-negative value to each real number and (b) would assign a non-zero value to at most a countable infinity of the reals. One application involving an uncountable sample space that supports categorical random variables of infinite, even uncountable, support is the study of random graphs. To understand the rate of growth of some property of graphs, we would want to contemplate graphs on 0, 1, ..., $n$, ... nodes, so it's convenient to allow graphs to have countably many nodes. Random variables defined on this set can have various types. For instance, the mean vertex degree (if finite) could be considered of ratio type; the total vertex degree could be considered of ordinal type (and, therefore--by forgetting the ordering--is a nice example of a countable discrete variable). If we also allow a graph to have arbitrarily many edges and are interested in, say, its connected components, then we would have a naturally occurring category that is uncountable (because each connected component determines the subset of nodes it contains and there are uncountably many subsets of a countable set). To summarize, it is reasonable to allow categorical values to attain an uncountable infinity of possible values, while recognizing that at most a countable number of them could ever have positive probabilities. This must be a discrete distribution, because all subsets are measurable, which is not the case for continuous distributions.
Can categorical data only take finitely or countably infinitely many values?
"Categorical" is not a well-defined mathematical term, so to answer this question we have to look to how this word is intended to be used. It is employed in contrast to "ordinal," "interval," and "ra
Can categorical data only take finitely or countably infinitely many values? "Categorical" is not a well-defined mathematical term, so to answer this question we have to look to how this word is intended to be used. It is employed in contrast to "ordinal," "interval," and "ratio." One way to understand the primary distinctions is in terms of the groups of allowable re-expressions of the values. In the case of the latter three, there is an order that must preserved, whence all re-expressions must be monotonic (order preserving). For categorical variables, any bijection (including permutations) is ok: Beyond that, anything goes with the nominal [categorical] scale. (Stevens, quoted in the Wikipedia article.) Another concept of "categorical" is that each outcome must be distinguishable from every other. This strongly suggests that any probability measure must be totally discrete: that is, all subsets are measurable, implying that each category will have its own well-defined probability. (This is not the case for continuous distributions.) This would seem to indicate that the number of categories should be finite or at most countable, but that is not evident in the literature. For instance, an archetypal example of a categorical variable is a set of names. The set of all possible names on any finite alphabet is countable but not finite. It is therefore useful to allow countably infinite sets to be categorical. For example, if we are studying names given to babies, it is convenient to let the sample space consist of all possible names (rather than all names that we know of). A slightly less realistic, but still conceivable, example of a categorical variable would be one that uses real numbers for names. In effect, such a variable would ignore all the usual mathematical structure on this set. I don't see any problem with such a usage, but it's worth observing that the axioms of probability imply that any probability distribution valid in this context would (a) assign a non-negative value to each real number and (b) would assign a non-zero value to at most a countable infinity of the reals. One application involving an uncountable sample space that supports categorical random variables of infinite, even uncountable, support is the study of random graphs. To understand the rate of growth of some property of graphs, we would want to contemplate graphs on 0, 1, ..., $n$, ... nodes, so it's convenient to allow graphs to have countably many nodes. Random variables defined on this set can have various types. For instance, the mean vertex degree (if finite) could be considered of ratio type; the total vertex degree could be considered of ordinal type (and, therefore--by forgetting the ordering--is a nice example of a countable discrete variable). If we also allow a graph to have arbitrarily many edges and are interested in, say, its connected components, then we would have a naturally occurring category that is uncountable (because each connected component determines the subset of nodes it contains and there are uncountably many subsets of a countable set). To summarize, it is reasonable to allow categorical values to attain an uncountable infinity of possible values, while recognizing that at most a countable number of them could ever have positive probabilities. This must be a discrete distribution, because all subsets are measurable, which is not the case for continuous distributions.
Can categorical data only take finitely or countably infinitely many values? "Categorical" is not a well-defined mathematical term, so to answer this question we have to look to how this word is intended to be used. It is employed in contrast to "ordinal," "interval," and "ra
40,473
Can categorical data only take finitely or countably infinitely many values?
Alright, here's my attempt at an answer, from my (admittedly imperfect) understanding of your question. "Categorical data" is something of a fuzzy and problematic term to begin with. Similar to the "I know it when I see it" definition of obscene material. There are some very clear cases of categorical data, where the values of a variable fall into a small number of clearly defined categories. Beyond that, there be dragons. At some point you get enough categories that your "categorical" variable could likely be treated as a continuous variable. Or alternately, using either subject matter knowledge or a description of a distribution, you can break a continuous variable up into categorical chunks and treat it as categorical. So there's really two answers to your question: Theory Answer: No. You could have infinitely many categories, but for some reason decide not to call it a continuous variable. If you allow for decimal-based categories of an utterly unbounded variable, there's no reason I can see it wouldn't be be uncountably infinite. I'm not sure how often this ends up coming up. In my experience at least, fairly rarely. Applied Answer: The cardinality of most things that would ever reasonably be called categorical data have a cardinality vastly below the cardinality of N. As noted above, there are exceptions, often subject to vague judgement calls.
Can categorical data only take finitely or countably infinitely many values?
Alright, here's my attempt at an answer, from my (admittedly imperfect) understanding of your question. "Categorical data" is something of a fuzzy and problematic term to begin with. Similar to the "I
Can categorical data only take finitely or countably infinitely many values? Alright, here's my attempt at an answer, from my (admittedly imperfect) understanding of your question. "Categorical data" is something of a fuzzy and problematic term to begin with. Similar to the "I know it when I see it" definition of obscene material. There are some very clear cases of categorical data, where the values of a variable fall into a small number of clearly defined categories. Beyond that, there be dragons. At some point you get enough categories that your "categorical" variable could likely be treated as a continuous variable. Or alternately, using either subject matter knowledge or a description of a distribution, you can break a continuous variable up into categorical chunks and treat it as categorical. So there's really two answers to your question: Theory Answer: No. You could have infinitely many categories, but for some reason decide not to call it a continuous variable. If you allow for decimal-based categories of an utterly unbounded variable, there's no reason I can see it wouldn't be be uncountably infinite. I'm not sure how often this ends up coming up. In my experience at least, fairly rarely. Applied Answer: The cardinality of most things that would ever reasonably be called categorical data have a cardinality vastly below the cardinality of N. As noted above, there are exceptions, often subject to vague judgement calls.
Can categorical data only take finitely or countably infinitely many values? Alright, here's my attempt at an answer, from my (admittedly imperfect) understanding of your question. "Categorical data" is something of a fuzzy and problematic term to begin with. Similar to the "I
40,474
Can categorical data only take finitely or countably infinitely many values?
Categorical data is discrete - otherwise it would be hard to assign categories to the data. My take is this: the natural numbers are discrete and thus categorical. They are also ordinal and interval data, but also categorical. Since the natural numbers are countably infinite we see that there are categorical variables that can take countably infinite values. That does not mean, though, that this applies for all categorical variables.
Can categorical data only take finitely or countably infinitely many values?
Categorical data is discrete - otherwise it would be hard to assign categories to the data. My take is this: the natural numbers are discrete and thus categorical. They are also ordinal and interval d
Can categorical data only take finitely or countably infinitely many values? Categorical data is discrete - otherwise it would be hard to assign categories to the data. My take is this: the natural numbers are discrete and thus categorical. They are also ordinal and interval data, but also categorical. Since the natural numbers are countably infinite we see that there are categorical variables that can take countably infinite values. That does not mean, though, that this applies for all categorical variables.
Can categorical data only take finitely or countably infinitely many values? Categorical data is discrete - otherwise it would be hard to assign categories to the data. My take is this: the natural numbers are discrete and thus categorical. They are also ordinal and interval d
40,475
How to deal with outliers?
I've recommended two methods in the past. They depend on the nature of the data in a general sense. If the outliers are part of a well known distribution of data with a well known problem with outliers then, if others haven't done it already, analyze the distribution with and without outliers, using a variety of ways of handling them, and see what happens. You're going to be dealing with this data a lot. You might as well understand an outlier problem. For example, Ratcliff has a nice little paper on reaction times that you might look at as an example. If there are papers like that for your example then read them. If the outliers are from a data set that is relatively unique then analyze them for your specific situation. Analyze both with and without them, and perhaps with a replacement alternative, if you have a reason for one, and report your results of this assessment. So, in short, analyze and document. That's the best thing to do. I should make it clear that an outlier needs to be defined relatively independently of the statistical distribution (in extent, not necessarily shape). For example, with reaction times you may define short outliers as those that aren't really reactions to the stimulus but instead, anticipations. Long ones might have a similar definition in that they are not reactions to the stimulus onset but something else (with the something else being potentially a variety of things). Going through and finding that 3% of your data points were more than 2 SDs away from the mean does not demonstrate that you have a small amount of outliers. On the contrary, it suggests you have no outliers and should keep them all.
How to deal with outliers?
I've recommended two methods in the past. They depend on the nature of the data in a general sense. If the outliers are part of a well known distribution of data with a well known problem with outl
How to deal with outliers? I've recommended two methods in the past. They depend on the nature of the data in a general sense. If the outliers are part of a well known distribution of data with a well known problem with outliers then, if others haven't done it already, analyze the distribution with and without outliers, using a variety of ways of handling them, and see what happens. You're going to be dealing with this data a lot. You might as well understand an outlier problem. For example, Ratcliff has a nice little paper on reaction times that you might look at as an example. If there are papers like that for your example then read them. If the outliers are from a data set that is relatively unique then analyze them for your specific situation. Analyze both with and without them, and perhaps with a replacement alternative, if you have a reason for one, and report your results of this assessment. So, in short, analyze and document. That's the best thing to do. I should make it clear that an outlier needs to be defined relatively independently of the statistical distribution (in extent, not necessarily shape). For example, with reaction times you may define short outliers as those that aren't really reactions to the stimulus but instead, anticipations. Long ones might have a similar definition in that they are not reactions to the stimulus onset but something else (with the something else being potentially a variety of things). Going through and finding that 3% of your data points were more than 2 SDs away from the mean does not demonstrate that you have a small amount of outliers. On the contrary, it suggests you have no outliers and should keep them all.
How to deal with outliers? I've recommended two methods in the past. They depend on the nature of the data in a general sense. If the outliers are part of a well known distribution of data with a well known problem with outl
40,476
Hidden Markov model (forward algorithm) in R
Let $\mathbf{X}$ be an observation sequence and $\lambda$ be a Hidden Markov Model (HMM). Then the forward algorithm determines $\textrm{Pr}(\mathbf{X}|\lambda)$, the likelihood of realizing sequence $\mathbf{X}$ from HMM $\lambda$. In more plain English terms... Let's say you trained up your HMM $\lambda$ and you'd like to see how likely it is that $\lambda$ produced some sequence $\mathbf{X}$. The forward algorithm would do this for you. If you get a relatively high likelihood, there's a good chance that $\lambda$ produced $\mathbf{X}$. If you had two HMMs $\lambda_1$ and $\lambda_2$, you might conclude the one with the higher likelihood is the best model to explain your $\mathbf{X}$. Let's look at some R code...First we'll initialize an HMM. (I got this from the HMM manuals on CRAN http://cran.r-project.org/web/packages/HMM/HMM.pdf).... require('HMM') # Initialise HMM hmm = initHMM(c("A","B"), c("L","R"), transProbs=matrix(c(.8,.2,.2,.8),2), emissionProbs=matrix(c(.6,.4,.4,.6),2)) print(hmm) # Sequence of observations observations = c("L","L","R","R") This is an HMM in which has an 80% chance of staying in whatever hidden state it was in at time $t$ when it transitions to time $t+1$. It has two hidden states, A and B. It emits two observations, L and R. The emission probabilities are contained in emissionProbs. We store the observation sequence $\mathbf{X}$ in observations. logForwardProbabilities = forward(hmm,observations) forwardProbabilities = exp(logForwardProbabilities) forwardProbabilities is now a matrix containing the probability of realizing the observation sequence up to time $t$ and ending up in state $i$. Hidden states $i$ are in rows and times $t$ are in columns. If we want the probability of the overall sequence, we use column 4 because it is the last timestep. The resulting 2 element row vector contains the probabilities of ending in A and ending in B. Their sum is the total probability of realizing $\mathbf{X}$. finalAnswer = sum(forwardProbabilities[,4])
Hidden Markov model (forward algorithm) in R
Let $\mathbf{X}$ be an observation sequence and $\lambda$ be a Hidden Markov Model (HMM). Then the forward algorithm determines $\textrm{Pr}(\mathbf{X}|\lambda)$, the likelihood of realizing sequence
Hidden Markov model (forward algorithm) in R Let $\mathbf{X}$ be an observation sequence and $\lambda$ be a Hidden Markov Model (HMM). Then the forward algorithm determines $\textrm{Pr}(\mathbf{X}|\lambda)$, the likelihood of realizing sequence $\mathbf{X}$ from HMM $\lambda$. In more plain English terms... Let's say you trained up your HMM $\lambda$ and you'd like to see how likely it is that $\lambda$ produced some sequence $\mathbf{X}$. The forward algorithm would do this for you. If you get a relatively high likelihood, there's a good chance that $\lambda$ produced $\mathbf{X}$. If you had two HMMs $\lambda_1$ and $\lambda_2$, you might conclude the one with the higher likelihood is the best model to explain your $\mathbf{X}$. Let's look at some R code...First we'll initialize an HMM. (I got this from the HMM manuals on CRAN http://cran.r-project.org/web/packages/HMM/HMM.pdf).... require('HMM') # Initialise HMM hmm = initHMM(c("A","B"), c("L","R"), transProbs=matrix(c(.8,.2,.2,.8),2), emissionProbs=matrix(c(.6,.4,.4,.6),2)) print(hmm) # Sequence of observations observations = c("L","L","R","R") This is an HMM in which has an 80% chance of staying in whatever hidden state it was in at time $t$ when it transitions to time $t+1$. It has two hidden states, A and B. It emits two observations, L and R. The emission probabilities are contained in emissionProbs. We store the observation sequence $\mathbf{X}$ in observations. logForwardProbabilities = forward(hmm,observations) forwardProbabilities = exp(logForwardProbabilities) forwardProbabilities is now a matrix containing the probability of realizing the observation sequence up to time $t$ and ending up in state $i$. Hidden states $i$ are in rows and times $t$ are in columns. If we want the probability of the overall sequence, we use column 4 because it is the last timestep. The resulting 2 element row vector contains the probabilities of ending in A and ending in B. Their sum is the total probability of realizing $\mathbf{X}$. finalAnswer = sum(forwardProbabilities[,4])
Hidden Markov model (forward algorithm) in R Let $\mathbf{X}$ be an observation sequence and $\lambda$ be a Hidden Markov Model (HMM). Then the forward algorithm determines $\textrm{Pr}(\mathbf{X}|\lambda)$, the likelihood of realizing sequence
40,477
Higher order generalization of the multivariate normal distribution
I don't think there is a positive answer to your question. The beauty of the normal distribution, univariate or multivariate, is that it is easily defined by the cumulants of order higher than two being zero. (The cumulant of order $k$ is the normalized $k$-th derivative of the characteristic function: $\kappa_k = i^{-k} \frac{\partial^k}{\partial t^k} \phi (t) |_{t=0}$.) The CLT states essentially that for all $k$, $\kappa_k = o(1)$ as $n\to\infty$ (and the rate can be established). However, the property of zero cumulants is very fragile. Once you depart from zero third cumulant, all higher order cumulants have to be non-zero, as well: there is no distribution for which $\kappa_4=0$ if $\kappa_3\neq 0$. So for each value of skewness (which apparently is reflected in the third cumulant), there's a range of reasonable values for other cumulants, and the beauty of the distribution will be in the eyes of the beholder. In a way, the "closest relative" of the multivariate normal distribution is the skew-normal distribution. Its density is the normal density "filtered" by a normal cdf: $f(x;\Sigma,\alpha) = 2f(x;\mu,\Sigma)\Phi(\alpha'x)$ where $f(x;\Sigma)$ is the density of a multivariate normal with mean zero vector and covariance matrix $\Sigma$, and $\Phi(z)$ is the standard normal cdf. So you don't really have a tensor here, but only a skewing vector. Nicely enough, for $\alpha=0$, you get the special case of a multivariate normal distribution. Another way to approach the issue is from the point of view of stable laws. A stable law is a distribution such that the linear transformation of random variables having this distribution again has this distribution, possibly scaled and shifted. The normal distribution is an obvious example; and Cauchy is yet another example, although far less obvious. Stable laws are defined implicitly by their characteristic function: $\phi(t) = \exp[ i t \mu - |ct|^\alpha (1-i \beta \, {\rm sign} (t) \Phi]$. Here, $\mu$ is the shift parameter, $c$ is the scale parameter, $\alpha$ is the stability parameter, $\beta$ is the asymmetry parameter, and $\Phi=\tan(\pi\alpha/2)$ for $\alpha\neq1$, and $\Phi=-2/\pi \ln|t|$ for $\alpha=1$. ($\alpha=2, \beta=0$ gives the normal distribution; $\alpha=1, \beta=0$ gives the Cauchy distribution; moments beyond the first one exist only for $\alpha=2$.) Wikipedia provides a bunch of pictures. The multivariate extensions of stable laws do exist, too (thanks to @mpiktas for pointing them out!).
Higher order generalization of the multivariate normal distribution
I don't think there is a positive answer to your question. The beauty of the normal distribution, univariate or multivariate, is that it is easily defined by the cumulants of order higher than two bei
Higher order generalization of the multivariate normal distribution I don't think there is a positive answer to your question. The beauty of the normal distribution, univariate or multivariate, is that it is easily defined by the cumulants of order higher than two being zero. (The cumulant of order $k$ is the normalized $k$-th derivative of the characteristic function: $\kappa_k = i^{-k} \frac{\partial^k}{\partial t^k} \phi (t) |_{t=0}$.) The CLT states essentially that for all $k$, $\kappa_k = o(1)$ as $n\to\infty$ (and the rate can be established). However, the property of zero cumulants is very fragile. Once you depart from zero third cumulant, all higher order cumulants have to be non-zero, as well: there is no distribution for which $\kappa_4=0$ if $\kappa_3\neq 0$. So for each value of skewness (which apparently is reflected in the third cumulant), there's a range of reasonable values for other cumulants, and the beauty of the distribution will be in the eyes of the beholder. In a way, the "closest relative" of the multivariate normal distribution is the skew-normal distribution. Its density is the normal density "filtered" by a normal cdf: $f(x;\Sigma,\alpha) = 2f(x;\mu,\Sigma)\Phi(\alpha'x)$ where $f(x;\Sigma)$ is the density of a multivariate normal with mean zero vector and covariance matrix $\Sigma$, and $\Phi(z)$ is the standard normal cdf. So you don't really have a tensor here, but only a skewing vector. Nicely enough, for $\alpha=0$, you get the special case of a multivariate normal distribution. Another way to approach the issue is from the point of view of stable laws. A stable law is a distribution such that the linear transformation of random variables having this distribution again has this distribution, possibly scaled and shifted. The normal distribution is an obvious example; and Cauchy is yet another example, although far less obvious. Stable laws are defined implicitly by their characteristic function: $\phi(t) = \exp[ i t \mu - |ct|^\alpha (1-i \beta \, {\rm sign} (t) \Phi]$. Here, $\mu$ is the shift parameter, $c$ is the scale parameter, $\alpha$ is the stability parameter, $\beta$ is the asymmetry parameter, and $\Phi=\tan(\pi\alpha/2)$ for $\alpha\neq1$, and $\Phi=-2/\pi \ln|t|$ for $\alpha=1$. ($\alpha=2, \beta=0$ gives the normal distribution; $\alpha=1, \beta=0$ gives the Cauchy distribution; moments beyond the first one exist only for $\alpha=2$.) Wikipedia provides a bunch of pictures. The multivariate extensions of stable laws do exist, too (thanks to @mpiktas for pointing them out!).
Higher order generalization of the multivariate normal distribution I don't think there is a positive answer to your question. The beauty of the normal distribution, univariate or multivariate, is that it is easily defined by the cumulants of order higher than two bei
40,478
Model errors, residuals and heteroscedasticity
Conclusions It makes no sense to model the variance of the residuals explicitly, because the variance depends on the fitting procedure, which is not part of the model. We must model the variance of the errors and then, for our chosen fitting procedure, we may determine the distribution of the residuals. Assumptions The question asks how to interpret "$\varepsilon_i$," but unfortunately it does not define $X$, $X_i$, or $\sigma^2$. Nevertheless we can make some guesses that may be useful: Evidently each $\varepsilon_i$ is a random variable with a numerical (not vector) value, because it refers either to an "error" or a residual. Therefore "$\sigma^2 \times X_i$" must be a number. Taking $\sigma^2$ to be a scale parameter, we conclude that the $X_i$ are numbers. The $X_i$ could be random variables, but if so, this is a complicated model. For simplicity (and because it doesn't affect the concepts or nature of the subsequent analysis), let's take them to be fixed values (one for each $i$). So, let the $X_i$ be either independent values or covariates, treated as known and measured without appreciable error. Restatement of the question This situation is a general regression setting. To be clear and specific, let the index $i$ designate observations; for each $i$, let $Z_i$ be a vector of independent values; let $g$ be a (known) real-valued function with $X_i = g(Z_i)$; let $\theta$ be a vector of (unknown) model parameters to be estimated; let $Y_i$ be the dependent values; let $\sigma$ be another (scalar) parameter, known or unknown; and let $f$ be the (known) function referred to in the question. In these terms I guess the model in question is of the form $$Y_i = f(Z_i, \theta) + \varepsilon_i$$ and the errors $\varepsilon_i$ are assumed to be independent, normally distributed with zero mean, and to have variance $$Var(\varepsilon_i)=\sigma^2 g(Z_i).$$ Let $\hat{\theta}$ be any estimates of the parameters. Specifically, $\hat{\theta}$ is some function $t$ of all the data: $$\hat{\theta} = t(\mathbf{Z}, \mathbf{Y}) = t(\mathbf{Z}, f(\mathbf{Z}, \theta)+\mathbf{\varepsilon})$$ ($\mathbf{Z}$ is the vector of $Z_i$, $\mathbf{Y}$ is the vector of $Y_i$, and $\varepsilon$ is the vector of $\varepsilon_i$). $t$ is the estimator, often least squares or maximum likelihood. The fitted model therefore is $$\hat{Y} = f(Z, \hat{\theta})$$ and the residuals, by definition, are $$e_i = \hat{Y_i} - f(Z_i, \hat{\theta}).$$ Now the question, at least as I have interpreted it, can be restated: "Would it be correct to say that $Var(\varepsilon)$ should be modeled as a function of $X$ or would it be better to say that $Var(e)$ should be modeled as a function of $X$?" Analysis At this point it is clear that the $\varepsilon_i$ have nothing to do with the fitting procedure or the parameter estimates $\hat{\theta}$. Recalling that $\hat{\theta}$ is determined by the estimation procedure $t$ and that $t$ is deterministic (it's a specific function of its arguments), we note that the $e_i$ are random only insofar as $t$ depends on the errors $\varepsilon_i$. Therefore their variances, $Var(e_i)$, depend (in a potentially complicated way) on $t$ itself. Trying to model $Var(e)$ would inextricably link the underlying model (an approximate description of reality) with the parameter estimation procedure, which makes little sense and could only be counterproductive.
Model errors, residuals and heteroscedasticity
Conclusions It makes no sense to model the variance of the residuals explicitly, because the variance depends on the fitting procedure, which is not part of the model. We must model the variance of t
Model errors, residuals and heteroscedasticity Conclusions It makes no sense to model the variance of the residuals explicitly, because the variance depends on the fitting procedure, which is not part of the model. We must model the variance of the errors and then, for our chosen fitting procedure, we may determine the distribution of the residuals. Assumptions The question asks how to interpret "$\varepsilon_i$," but unfortunately it does not define $X$, $X_i$, or $\sigma^2$. Nevertheless we can make some guesses that may be useful: Evidently each $\varepsilon_i$ is a random variable with a numerical (not vector) value, because it refers either to an "error" or a residual. Therefore "$\sigma^2 \times X_i$" must be a number. Taking $\sigma^2$ to be a scale parameter, we conclude that the $X_i$ are numbers. The $X_i$ could be random variables, but if so, this is a complicated model. For simplicity (and because it doesn't affect the concepts or nature of the subsequent analysis), let's take them to be fixed values (one for each $i$). So, let the $X_i$ be either independent values or covariates, treated as known and measured without appreciable error. Restatement of the question This situation is a general regression setting. To be clear and specific, let the index $i$ designate observations; for each $i$, let $Z_i$ be a vector of independent values; let $g$ be a (known) real-valued function with $X_i = g(Z_i)$; let $\theta$ be a vector of (unknown) model parameters to be estimated; let $Y_i$ be the dependent values; let $\sigma$ be another (scalar) parameter, known or unknown; and let $f$ be the (known) function referred to in the question. In these terms I guess the model in question is of the form $$Y_i = f(Z_i, \theta) + \varepsilon_i$$ and the errors $\varepsilon_i$ are assumed to be independent, normally distributed with zero mean, and to have variance $$Var(\varepsilon_i)=\sigma^2 g(Z_i).$$ Let $\hat{\theta}$ be any estimates of the parameters. Specifically, $\hat{\theta}$ is some function $t$ of all the data: $$\hat{\theta} = t(\mathbf{Z}, \mathbf{Y}) = t(\mathbf{Z}, f(\mathbf{Z}, \theta)+\mathbf{\varepsilon})$$ ($\mathbf{Z}$ is the vector of $Z_i$, $\mathbf{Y}$ is the vector of $Y_i$, and $\varepsilon$ is the vector of $\varepsilon_i$). $t$ is the estimator, often least squares or maximum likelihood. The fitted model therefore is $$\hat{Y} = f(Z, \hat{\theta})$$ and the residuals, by definition, are $$e_i = \hat{Y_i} - f(Z_i, \hat{\theta}).$$ Now the question, at least as I have interpreted it, can be restated: "Would it be correct to say that $Var(\varepsilon)$ should be modeled as a function of $X$ or would it be better to say that $Var(e)$ should be modeled as a function of $X$?" Analysis At this point it is clear that the $\varepsilon_i$ have nothing to do with the fitting procedure or the parameter estimates $\hat{\theta}$. Recalling that $\hat{\theta}$ is determined by the estimation procedure $t$ and that $t$ is deterministic (it's a specific function of its arguments), we note that the $e_i$ are random only insofar as $t$ depends on the errors $\varepsilon_i$. Therefore their variances, $Var(e_i)$, depend (in a potentially complicated way) on $t$ itself. Trying to model $Var(e)$ would inextricably link the underlying model (an approximate description of reality) with the parameter estimation procedure, which makes little sense and could only be counterproductive.
Model errors, residuals and heteroscedasticity Conclusions It makes no sense to model the variance of the residuals explicitly, because the variance depends on the fitting procedure, which is not part of the model. We must model the variance of t
40,479
Model errors, residuals and heteroscedasticity
A generative model for heteroskedastic regression would be to say that the responses were drawn from a normal distribution where the mean and variance are functions of the explanatory variables, i.e. $y_i \sim N(f(x_i;\beta_\mu), g(x_i;\beta_\sigma))$ where $\beta_\mu$ and $\beta_\sigma$ are the parameters of the two component models, and are generally jointly optimised by minimising the negative log-likelihood. The functions $f(\cdot)$ and $g(\cdot)$ estimate the conditional mean and conditional variance of the target distribution; there isn't any real need to talk about "residuals" or "statistical errors". I would say that it would be better to state that "the conditional variance of the response variable is modelled as a function of $X$".
Model errors, residuals and heteroscedasticity
A generative model for heteroskedastic regression would be to say that the responses were drawn from a normal distribution where the mean and variance are functions of the explanatory variables, i.e.
Model errors, residuals and heteroscedasticity A generative model for heteroskedastic regression would be to say that the responses were drawn from a normal distribution where the mean and variance are functions of the explanatory variables, i.e. $y_i \sim N(f(x_i;\beta_\mu), g(x_i;\beta_\sigma))$ where $\beta_\mu$ and $\beta_\sigma$ are the parameters of the two component models, and are generally jointly optimised by minimising the negative log-likelihood. The functions $f(\cdot)$ and $g(\cdot)$ estimate the conditional mean and conditional variance of the target distribution; there isn't any real need to talk about "residuals" or "statistical errors". I would say that it would be better to state that "the conditional variance of the response variable is modelled as a function of $X$".
Model errors, residuals and heteroscedasticity A generative model for heteroskedastic regression would be to say that the responses were drawn from a normal distribution where the mean and variance are functions of the explanatory variables, i.e.
40,480
Fit between two curves
This is kind of like the analysis of animal tracking data that I have to do in lab. My reflex would be something like this: First define a linearized track as @Iterator suggested. I do this by defining a spline with somewhere between 3 and 20 control points. You can either fit the spline through all of your data or use something absolute like the physical shape of the taxi runway, or the optimal path that textbook-perfect taxi-ing would produce. Whatever you choose, let's call this the reference path. Then densely sample that spline - find 100,000 points or so along the spline evenly spaced from beginning to end. Next, for each point in time, and for each trajectory, determine two things: (x) the identity of point along the reference path that's closest to the XY position of the plane at that point in time, and (y) the euclidean distance between the instantaneous data point and that closest spline point. Plotting y as a function of x gives you a plot of distance between the plane and the reference path, by distance along that path. If you define your reference path to be the spline through Plane A's trajectory, and make the plot described above for Plane B with respect to that path, you'll have a the distance between the planes as a function of their course along the track, independent of time. Here's some commented code that does the trick. Works on my computer with the test data here. % Script to determine distance between 2 paths as a function % of distance along the first path % % Path 1 is used to fit a spline. That spline is densely interpolated % For a given point along path 2, path1 interpolation points are searched % for the one with the lowest euclidean distance. The distance to the % nearest Path1 interpolation point ALONG path 1 is that path 2 points' % "reference path distance", and the distance between the interpolation % point and the path 2 point is the "reference path deviance" % % Because the points along path 1 aren't monotonically moving from the % beginning of the path to the end, in order to fit a smooth spline over % path 1, I have the user click spline control points over path 1. A % temporary spline is fit to the user's clicked points, and the temporary % spline is used to break the path 1 data into small groups of data. The % centroid of each group is taken a control point for building a path 1 % spline. %% Load data. path1 and path2 are each 2xn [x_data; y_data] %% load pos_data.mat path1 path2; %% Plot raw data & get spline points from user %% figure; plot(path1(1,:),path1(2,:),'b'); % First path hold on; plot(path2(1,:),path2(2,:),'r'); % Second path [spl_x, spl_y] = getpts(); % Mouse-clicks to define spline user_path = [spl_x'; spl_y']; % Rearrange to same format as path1,2 %% Make spline from user points %% n_xx = 100; % n_xx interp points for temporary spline n_x = size(user_path,2); % n_x samples, 2 values each xx_t = linspace(0,1,n_xx); % the interpolants x_t = linspace(0,1,n_x); % the parameter for our parametric fn of time yy_t = spline(x_t,user_path,xx_t); % yy is the points along the path at xx plot( yy_t(1,:), yy_t(2,:), '.b', 'LineWidth', 4 ); %% Break path1 points into groups by nearest tmp spline interpolant %% % For each path1 point, find the nearest temp spline point TRI = delaunay( yy_t(1,:), yy_t(2,:) ); index = dsearch( yy_t(1,:), yy_t(2,:), TRI, path1(1,:), path1(2,:) ); path1_x = zeros(2,n_xx); % make 1 path1 spline control point for each path1 point group % there are n_xx bins for points in path1. Determine the n_xx centroids % of the groups of points falling in each of those bins. for n = 1:n_xx path1_x(:,n) = [ mean(path1(1, index==n)); ... mean(path1(2, index==n))]; end %% Use the centroids just obtained as control points for a 'path1 spline'. %% n_xx = 1000; % we'll densely sample the path1 spline n_x = size(path1_x,2); % although we have only 50 control points for path1 spline xx_p1 = linspace(0, 1, n_xx); % where to interpolate into path1 spline x_p1 = linspace(0, 1, n_x); % the parameter: distance along temporary spline yy_p1 = spline(x_p1, path1_x, xx_p1); % spline x&y coordinates along path1 figure; plot( path1(1,:), path1(2,:), '.', 'MarkerSize', 10); hold on; plot( yy_p1(1,:), yy_p1(2,:), '-'); %% 'Linearize' Path 2 by finding the nearest point along path1 spline for each path2 point. %% TRI = delaunay( yy_p1(1,:), yy_p1(2,:) ); index = dsearch( yy_p1(1,:), yy_p1(2,:), TRI, path2(1,:), path2(2,:)); path2_dist_along = xx_p1(1,index); % distance along the path1 spline for each path2 point % is just the interpolation value of the % path1 spline % deviance is the euclidian distance between each path2 point and its % closest path1_spline counterpart path2_deviance = sqrt((path2(1,:) - yy_p1(1,index)).^2 + (path2(2,:) - yy_p1(2,index)).^2); figure; plot(path2_dist_along, path2_deviance,'.'); My paths are not nice and even like yours :/ Animal tracking status-quo. So there is a work-around for fitting a spline to that somewhat messy raw data. And here's the output of the script. NB: if that were plotted as a line graph instead of a scatterplot, you would see that the points are not in order along the x axis, and the x axis isn't evenly sampled. This could be fixed by some combination of interpolating and smoothing I think, but the solution probably depends on exactly how you want your output to be formatted, so I didn't code it up. I tried to make the code clear, but please let me know if anything is confusing. Fun question to work on, thanks.
Fit between two curves
This is kind of like the analysis of animal tracking data that I have to do in lab. My reflex would be something like this: First define a linearized track as @Iterator suggested. I do this by defin
Fit between two curves This is kind of like the analysis of animal tracking data that I have to do in lab. My reflex would be something like this: First define a linearized track as @Iterator suggested. I do this by defining a spline with somewhere between 3 and 20 control points. You can either fit the spline through all of your data or use something absolute like the physical shape of the taxi runway, or the optimal path that textbook-perfect taxi-ing would produce. Whatever you choose, let's call this the reference path. Then densely sample that spline - find 100,000 points or so along the spline evenly spaced from beginning to end. Next, for each point in time, and for each trajectory, determine two things: (x) the identity of point along the reference path that's closest to the XY position of the plane at that point in time, and (y) the euclidean distance between the instantaneous data point and that closest spline point. Plotting y as a function of x gives you a plot of distance between the plane and the reference path, by distance along that path. If you define your reference path to be the spline through Plane A's trajectory, and make the plot described above for Plane B with respect to that path, you'll have a the distance between the planes as a function of their course along the track, independent of time. Here's some commented code that does the trick. Works on my computer with the test data here. % Script to determine distance between 2 paths as a function % of distance along the first path % % Path 1 is used to fit a spline. That spline is densely interpolated % For a given point along path 2, path1 interpolation points are searched % for the one with the lowest euclidean distance. The distance to the % nearest Path1 interpolation point ALONG path 1 is that path 2 points' % "reference path distance", and the distance between the interpolation % point and the path 2 point is the "reference path deviance" % % Because the points along path 1 aren't monotonically moving from the % beginning of the path to the end, in order to fit a smooth spline over % path 1, I have the user click spline control points over path 1. A % temporary spline is fit to the user's clicked points, and the temporary % spline is used to break the path 1 data into small groups of data. The % centroid of each group is taken a control point for building a path 1 % spline. %% Load data. path1 and path2 are each 2xn [x_data; y_data] %% load pos_data.mat path1 path2; %% Plot raw data & get spline points from user %% figure; plot(path1(1,:),path1(2,:),'b'); % First path hold on; plot(path2(1,:),path2(2,:),'r'); % Second path [spl_x, spl_y] = getpts(); % Mouse-clicks to define spline user_path = [spl_x'; spl_y']; % Rearrange to same format as path1,2 %% Make spline from user points %% n_xx = 100; % n_xx interp points for temporary spline n_x = size(user_path,2); % n_x samples, 2 values each xx_t = linspace(0,1,n_xx); % the interpolants x_t = linspace(0,1,n_x); % the parameter for our parametric fn of time yy_t = spline(x_t,user_path,xx_t); % yy is the points along the path at xx plot( yy_t(1,:), yy_t(2,:), '.b', 'LineWidth', 4 ); %% Break path1 points into groups by nearest tmp spline interpolant %% % For each path1 point, find the nearest temp spline point TRI = delaunay( yy_t(1,:), yy_t(2,:) ); index = dsearch( yy_t(1,:), yy_t(2,:), TRI, path1(1,:), path1(2,:) ); path1_x = zeros(2,n_xx); % make 1 path1 spline control point for each path1 point group % there are n_xx bins for points in path1. Determine the n_xx centroids % of the groups of points falling in each of those bins. for n = 1:n_xx path1_x(:,n) = [ mean(path1(1, index==n)); ... mean(path1(2, index==n))]; end %% Use the centroids just obtained as control points for a 'path1 spline'. %% n_xx = 1000; % we'll densely sample the path1 spline n_x = size(path1_x,2); % although we have only 50 control points for path1 spline xx_p1 = linspace(0, 1, n_xx); % where to interpolate into path1 spline x_p1 = linspace(0, 1, n_x); % the parameter: distance along temporary spline yy_p1 = spline(x_p1, path1_x, xx_p1); % spline x&y coordinates along path1 figure; plot( path1(1,:), path1(2,:), '.', 'MarkerSize', 10); hold on; plot( yy_p1(1,:), yy_p1(2,:), '-'); %% 'Linearize' Path 2 by finding the nearest point along path1 spline for each path2 point. %% TRI = delaunay( yy_p1(1,:), yy_p1(2,:) ); index = dsearch( yy_p1(1,:), yy_p1(2,:), TRI, path2(1,:), path2(2,:)); path2_dist_along = xx_p1(1,index); % distance along the path1 spline for each path2 point % is just the interpolation value of the % path1 spline % deviance is the euclidian distance between each path2 point and its % closest path1_spline counterpart path2_deviance = sqrt((path2(1,:) - yy_p1(1,index)).^2 + (path2(2,:) - yy_p1(2,index)).^2); figure; plot(path2_dist_along, path2_deviance,'.'); My paths are not nice and even like yours :/ Animal tracking status-quo. So there is a work-around for fitting a spline to that somewhat messy raw data. And here's the output of the script. NB: if that were plotted as a line graph instead of a scatterplot, you would see that the points are not in order along the x axis, and the x axis isn't evenly sampled. This could be fixed by some combination of interpolating and smoothing I think, but the solution probably depends on exactly how you want your output to be formatted, so I didn't code it up. I tried to make the code clear, but please let me know if anything is confusing. Fun question to work on, thanks.
Fit between two curves This is kind of like the analysis of animal tracking data that I have to do in lab. My reflex would be something like this: First define a linearized track as @Iterator suggested. I do this by defin
40,481
Fit between two curves
My suggestion is to rescale the points to be proportions of the length of the arc (the curve). At that point, you can look at interpolations, such as (0,0.01, ..., 1.00) of the arc length and compare the correlation, or whatnot. However, a more interesting question might be the relationships between the gradient of movement, especially close to the turn. I think a plot of that could be very interesting.
Fit between two curves
My suggestion is to rescale the points to be proportions of the length of the arc (the curve). At that point, you can look at interpolations, such as (0,0.01, ..., 1.00) of the arc length and compare
Fit between two curves My suggestion is to rescale the points to be proportions of the length of the arc (the curve). At that point, you can look at interpolations, such as (0,0.01, ..., 1.00) of the arc length and compare the correlation, or whatnot. However, a more interesting question might be the relationships between the gradient of movement, especially close to the turn. I think a plot of that could be very interesting.
Fit between two curves My suggestion is to rescale the points to be proportions of the length of the arc (the curve). At that point, you can look at interpolations, such as (0,0.01, ..., 1.00) of the arc length and compare
40,482
Feature selection for low probability event prediction
My first advice would be that unless identifying the informative features is a goal of the analysis, don't bother with feature selection and just use a regularised model, such a penalised logistic regression, ridge regression or SVM, and let the regularisation handle the over-fitting. It is often said that feature selection improves classifier performance, but it isn't always true. To deal with the class imbalance problem, give different weights to the patterns from each class in calculating the loss function used to fit the model. Choose the ratio of weights by cross-validation (for a probabilistic classifier you can work out the asymptically optimal weights, but it generally won't give optimal results on a finite sample). If you are using a classifier that can't give different weights to each class, then sub-sample the majority class instead, where again the ratio of positive and negative patterns is determined by cross-validation (make sure the test partition in each fold of the cross-validation procedure has the same relative class frequencies you expect to see in operation). Lastly, it is often the case in practical application with a class imbalance that false-positives and false-negatives are not of equal seriousness, so incorporate this into the construction of the classifier.
Feature selection for low probability event prediction
My first advice would be that unless identifying the informative features is a goal of the analysis, don't bother with feature selection and just use a regularised model, such a penalised logistic reg
Feature selection for low probability event prediction My first advice would be that unless identifying the informative features is a goal of the analysis, don't bother with feature selection and just use a regularised model, such a penalised logistic regression, ridge regression or SVM, and let the regularisation handle the over-fitting. It is often said that feature selection improves classifier performance, but it isn't always true. To deal with the class imbalance problem, give different weights to the patterns from each class in calculating the loss function used to fit the model. Choose the ratio of weights by cross-validation (for a probabilistic classifier you can work out the asymptically optimal weights, but it generally won't give optimal results on a finite sample). If you are using a classifier that can't give different weights to each class, then sub-sample the majority class instead, where again the ratio of positive and negative patterns is determined by cross-validation (make sure the test partition in each fold of the cross-validation procedure has the same relative class frequencies you expect to see in operation). Lastly, it is often the case in practical application with a class imbalance that false-positives and false-negatives are not of equal seriousness, so incorporate this into the construction of the classifier.
Feature selection for low probability event prediction My first advice would be that unless identifying the informative features is a goal of the analysis, don't bother with feature selection and just use a regularised model, such a penalised logistic reg
40,483
Feature selection for low probability event prediction
The problem of estimating probabilities falls under the category of "regression," since the probability is a conditional mean. Classical methods for feature selection (AKA "subset selection" or "model selection") methods for regression include best-k, forward- and backward- stepwise, and forward stagewise, all described in Chapter 3 of Elements of Statistical Learning. However, such methods are generally costly, and given the number of features in your dataset, my choice would be to use glmpath, which implements L1-regularized regression using a modification of the fantastically efficient LARS algorithm. EDIT: More details on L1 regularization. The LARS algorithm produces the entire "Lasso" path for $\lambda$ (the regularization constant) ranging from 0 to $\infty$. At $\lambda=0$, all features are used; at $\lambda=\infty$, none of the features have nonzero coefficients. In between there are values of $\lambda$ for which anywhere from 1 to 199 features are used. Using the results from LARS one can select the values of $\lambda$ with the best performance (according to whatever criteria). Then, using only the features with nonzero coefficients for a particular $\lambda$, one can then fit an unregularized logistic regression model for the final prediction.
Feature selection for low probability event prediction
The problem of estimating probabilities falls under the category of "regression," since the probability is a conditional mean. Classical methods for feature selection (AKA "subset selection" or "mode
Feature selection for low probability event prediction The problem of estimating probabilities falls under the category of "regression," since the probability is a conditional mean. Classical methods for feature selection (AKA "subset selection" or "model selection") methods for regression include best-k, forward- and backward- stepwise, and forward stagewise, all described in Chapter 3 of Elements of Statistical Learning. However, such methods are generally costly, and given the number of features in your dataset, my choice would be to use glmpath, which implements L1-regularized regression using a modification of the fantastically efficient LARS algorithm. EDIT: More details on L1 regularization. The LARS algorithm produces the entire "Lasso" path for $\lambda$ (the regularization constant) ranging from 0 to $\infty$. At $\lambda=0$, all features are used; at $\lambda=\infty$, none of the features have nonzero coefficients. In between there are values of $\lambda$ for which anywhere from 1 to 199 features are used. Using the results from LARS one can select the values of $\lambda$ with the best performance (according to whatever criteria). Then, using only the features with nonzero coefficients for a particular $\lambda$, one can then fit an unregularized logistic regression model for the final prediction.
Feature selection for low probability event prediction The problem of estimating probabilities falls under the category of "regression," since the probability is a conditional mean. Classical methods for feature selection (AKA "subset selection" or "mode
40,484
Mediation model with linear regression
You can run regression models separately, if you follow the Baron-Kenny approach. As far as I know, there are two general approaches to test for mediation: (1) path models (and, SEM, of course) and (2) the Baron-and-Kenny approach (see item (a)). I use Mplus to run my mediation models which is very handy (+ bootstrapped standard errors). Unfortunately, you did not tell us what software package you are using to do your analysis. You have a couple of options: (a) You might be interested in D Kenny's website on mediation . He gives a very clear description how to proceed in order to test for a mediation effect (see "Baron and Kenny Steps"). (b) If you happen to use Stata or R for your analysis, you could check out the ATA website on Stata Frequently Asked Questions (search for 'mediation') or the R package mediation. If you use SPSS, you will like this website. Kenny's website also offers a couple of tips for different software packages, e.g. how to get bootstrapped standard errors in SPSS or SAS.
Mediation model with linear regression
You can run regression models separately, if you follow the Baron-Kenny approach. As far as I know, there are two general approaches to test for mediation: (1) path models (and, SEM, of course) and (2
Mediation model with linear regression You can run regression models separately, if you follow the Baron-Kenny approach. As far as I know, there are two general approaches to test for mediation: (1) path models (and, SEM, of course) and (2) the Baron-and-Kenny approach (see item (a)). I use Mplus to run my mediation models which is very handy (+ bootstrapped standard errors). Unfortunately, you did not tell us what software package you are using to do your analysis. You have a couple of options: (a) You might be interested in D Kenny's website on mediation . He gives a very clear description how to proceed in order to test for a mediation effect (see "Baron and Kenny Steps"). (b) If you happen to use Stata or R for your analysis, you could check out the ATA website on Stata Frequently Asked Questions (search for 'mediation') or the R package mediation. If you use SPSS, you will like this website. Kenny's website also offers a couple of tips for different software packages, e.g. how to get bootstrapped standard errors in SPSS or SAS.
Mediation model with linear regression You can run regression models separately, if you follow the Baron-Kenny approach. As far as I know, there are two general approaches to test for mediation: (1) path models (and, SEM, of course) and (2
40,485
Mediation model with linear regression
Whether you control for A depends on what you are trying to accomplish. Including A in the model will increase your R-squared. But if A is uncorrelated with X or M (as your diagram indicates) then inclusion/non-Inclusion of A will not affect coefficients or p-values for X or M.
Mediation model with linear regression
Whether you control for A depends on what you are trying to accomplish. Including A in the model will increase your R-squared. But if A is uncorrelated with X or M (as your diagram indicates) then inc
Mediation model with linear regression Whether you control for A depends on what you are trying to accomplish. Including A in the model will increase your R-squared. But if A is uncorrelated with X or M (as your diagram indicates) then inclusion/non-Inclusion of A will not affect coefficients or p-values for X or M.
Mediation model with linear regression Whether you control for A depends on what you are trying to accomplish. Including A in the model will increase your R-squared. But if A is uncorrelated with X or M (as your diagram indicates) then inc
40,486
Training multiple models for classification using the same dataset
Just to make sure that we are on the same page, I take it from your description that you consider a supervised learning problem where you know the Good/Bad status of your objects and where you have a vector of features for each object that you want to use to classify the object as either Good or Bad. Moreover, the result of training an SVM is to give a classifier, which, on the holdout data, gives almost no false Bad predictions, but 55% false Good predictions. I have not personally worked with problems with such a huge difference in error rates on the two groups. It suggests to me that the distribution of features in the two groups overlap, but that the distribution of features in the Bad group is more spread out. Like two Gaussian distributions with almost the same mean but larger variance for the group of Bad objects. If that is the case, I would imagine that it will be difficult, if not impossible, to improve much on the error rate for the Good predictions. There may be other explanations that I am not aware of. Having said that, I think it is a sensible strategy to combine classification procedures in a hierarchical way as you suggest. First, one classifier splits the full training set into two groups, and then other classifiers split each of the groups into two groups etc. In fact, that is what classification trees do, but typically using very simple splits in each step. I see no formal problem in training whatever model you like on the training data that is classified as being Good by the SVM. You don't need to use the holdout data. In fact, you shouldn't, if you need the holdout data for assessment of the model. Your second suggestion is closely related to just using the group classified as Good from your training data to train a second model. I don't see any particular reason to use CV-based classifications to obtain this group. Just remember, that if you are going to use CV, then the entire training procedure must be carried out each time. My suggestion is to first get a better understanding of what the feature distributions look like in the two groups from low-dimensional projections and exploratory visualizations. It might shed some light on why the error rate on the Good classifications is so large.
Training multiple models for classification using the same dataset
Just to make sure that we are on the same page, I take it from your description that you consider a supervised learning problem where you know the Good/Bad status of your objects and where you have a
Training multiple models for classification using the same dataset Just to make sure that we are on the same page, I take it from your description that you consider a supervised learning problem where you know the Good/Bad status of your objects and where you have a vector of features for each object that you want to use to classify the object as either Good or Bad. Moreover, the result of training an SVM is to give a classifier, which, on the holdout data, gives almost no false Bad predictions, but 55% false Good predictions. I have not personally worked with problems with such a huge difference in error rates on the two groups. It suggests to me that the distribution of features in the two groups overlap, but that the distribution of features in the Bad group is more spread out. Like two Gaussian distributions with almost the same mean but larger variance for the group of Bad objects. If that is the case, I would imagine that it will be difficult, if not impossible, to improve much on the error rate for the Good predictions. There may be other explanations that I am not aware of. Having said that, I think it is a sensible strategy to combine classification procedures in a hierarchical way as you suggest. First, one classifier splits the full training set into two groups, and then other classifiers split each of the groups into two groups etc. In fact, that is what classification trees do, but typically using very simple splits in each step. I see no formal problem in training whatever model you like on the training data that is classified as being Good by the SVM. You don't need to use the holdout data. In fact, you shouldn't, if you need the holdout data for assessment of the model. Your second suggestion is closely related to just using the group classified as Good from your training data to train a second model. I don't see any particular reason to use CV-based classifications to obtain this group. Just remember, that if you are going to use CV, then the entire training procedure must be carried out each time. My suggestion is to first get a better understanding of what the feature distributions look like in the two groups from low-dimensional projections and exploratory visualizations. It might shed some light on why the error rate on the Good classifications is so large.
Training multiple models for classification using the same dataset Just to make sure that we are on the same page, I take it from your description that you consider a supervised learning problem where you know the Good/Bad status of your objects and where you have a
40,487
Training multiple models for classification using the same dataset
I would use the same training dataset for both models, and use the same CV-folds for tuning. Don't use ANY of the 25% hold-out for training or tuning. Once you've fit your 2 models on the 75% training sample, evaluate your performance using the holdout. If you are using R, the caret package has functions for creating folds on a dataset that you can re-use to tune multiple models and then evaluate their predictive accuracy. If you would like I can help you with some example code. Edit: Here is the promised code, modified from the vignette for the package caret: #Setup rm(list = ls(all = TRUE)) #CLEAR WORKSPACE set.seed(123) #Pretend we only care about virginica Data <- iris virginica <- Data$Species=='virginica' Data$Species <- NULL #Look at the variable relationships library(PerformanceAnalytics) chart.Correlation(Data,col=ifelse(virginica,1,2)) #Create cross-validation folds to use for multiple models #Use 10-fold CV, repeat 5 times library(caret) MyFolds <- createMultiFolds(virginica, k = 10, times = 5) MyControl <- trainControl(method = "repeatedCV", index = MyFolds, summaryFunction = twoClassSummary, classProbs = TRUE) #Define Equation for Models fmla <- as.formula(paste("virginica ~ ", paste(names(Data), collapse= "+"))) #Fit some models Data$virginica <- as.factor(ifelse(virginica,'Yes','No')) svmModel <- train(fmla,Data,method='svmRadial', tuneLength=3,metric='ROC',trControl=MyControl) rfModel <- train(fmla,Data,method='rf', tuneLength=3,metric='ROC',trControl=MyControl) #Compare Models resamps <- resamples(list( SVM = svmModel, RandomForest = rfModel )) summary(resamps) densityplot(resamps,auto.key = TRUE, metric='ROC')
Training multiple models for classification using the same dataset
I would use the same training dataset for both models, and use the same CV-folds for tuning. Don't use ANY of the 25% hold-out for training or tuning. Once you've fit your 2 models on the 75% traini
Training multiple models for classification using the same dataset I would use the same training dataset for both models, and use the same CV-folds for tuning. Don't use ANY of the 25% hold-out for training or tuning. Once you've fit your 2 models on the 75% training sample, evaluate your performance using the holdout. If you are using R, the caret package has functions for creating folds on a dataset that you can re-use to tune multiple models and then evaluate their predictive accuracy. If you would like I can help you with some example code. Edit: Here is the promised code, modified from the vignette for the package caret: #Setup rm(list = ls(all = TRUE)) #CLEAR WORKSPACE set.seed(123) #Pretend we only care about virginica Data <- iris virginica <- Data$Species=='virginica' Data$Species <- NULL #Look at the variable relationships library(PerformanceAnalytics) chart.Correlation(Data,col=ifelse(virginica,1,2)) #Create cross-validation folds to use for multiple models #Use 10-fold CV, repeat 5 times library(caret) MyFolds <- createMultiFolds(virginica, k = 10, times = 5) MyControl <- trainControl(method = "repeatedCV", index = MyFolds, summaryFunction = twoClassSummary, classProbs = TRUE) #Define Equation for Models fmla <- as.formula(paste("virginica ~ ", paste(names(Data), collapse= "+"))) #Fit some models Data$virginica <- as.factor(ifelse(virginica,'Yes','No')) svmModel <- train(fmla,Data,method='svmRadial', tuneLength=3,metric='ROC',trControl=MyControl) rfModel <- train(fmla,Data,method='rf', tuneLength=3,metric='ROC',trControl=MyControl) #Compare Models resamps <- resamples(list( SVM = svmModel, RandomForest = rfModel )) summary(resamps) densityplot(resamps,auto.key = TRUE, metric='ROC')
Training multiple models for classification using the same dataset I would use the same training dataset for both models, and use the same CV-folds for tuning. Don't use ANY of the 25% hold-out for training or tuning. Once you've fit your 2 models on the 75% traini
40,488
Weird residuals in linear regression
What is the value of the residual that shows such a high count? It does not appear to be zero (slightly to the right of 0), so maybe 1? In any case, there may be something about that value that may provide you with some insight about the underlying mechanism. For example, if X and Y are measurements taken by observers, some of them may have a tendency to follow a certain pattern (i.e., Joe thinks: "everybody knows that Y is always 1 point higher than X" and "observes" accordingly), leading to such results. Without domain-level knowledge though, it is difficult to guess what is going on here.
Weird residuals in linear regression
What is the value of the residual that shows such a high count? It does not appear to be zero (slightly to the right of 0), so maybe 1? In any case, there may be something about that value that may pr
Weird residuals in linear regression What is the value of the residual that shows such a high count? It does not appear to be zero (slightly to the right of 0), so maybe 1? In any case, there may be something about that value that may provide you with some insight about the underlying mechanism. For example, if X and Y are measurements taken by observers, some of them may have a tendency to follow a certain pattern (i.e., Joe thinks: "everybody knows that Y is always 1 point higher than X" and "observes" accordingly), leading to such results. Without domain-level knowledge though, it is difficult to guess what is going on here.
Weird residuals in linear regression What is the value of the residual that shows such a high count? It does not appear to be zero (slightly to the right of 0), so maybe 1? In any case, there may be something about that value that may pr
40,489
How to get generalisation performance from nnet in R using k-fold cross-validation?
If you are planning to tune the network (e.g. select a value for the learning rate) on your training data and determine the error generalization on that same data set, you need to use a nested cross validation, where in each fold, you are tuning the model on that 9/10 of the data set (using 10 fold cv). See this post where I asked a similar question and got very good answers (post). I am not sure if there is an R function to accomplish this - maybe the ipred package could be used by passing the tune function with the call - not sure. It is rather trivial to simply write a loop to accomplish this whole process though. As far as what metric to examine, that depends on your problem (classification versus regression) and if you are interested in accuracy (classifications rate or kappa) or how well the model ranks (e.g. lift) or the MAE or RMSE for regression.
How to get generalisation performance from nnet in R using k-fold cross-validation?
If you are planning to tune the network (e.g. select a value for the learning rate) on your training data and determine the error generalization on that same data set, you need to use a nested cross v
How to get generalisation performance from nnet in R using k-fold cross-validation? If you are planning to tune the network (e.g. select a value for the learning rate) on your training data and determine the error generalization on that same data set, you need to use a nested cross validation, where in each fold, you are tuning the model on that 9/10 of the data set (using 10 fold cv). See this post where I asked a similar question and got very good answers (post). I am not sure if there is an R function to accomplish this - maybe the ipred package could be used by passing the tune function with the call - not sure. It is rather trivial to simply write a loop to accomplish this whole process though. As far as what metric to examine, that depends on your problem (classification versus regression) and if you are interested in accuracy (classifications rate or kappa) or how well the model ranks (e.g. lift) or the MAE or RMSE for regression.
How to get generalisation performance from nnet in R using k-fold cross-validation? If you are planning to tune the network (e.g. select a value for the learning rate) on your training data and determine the error generalization on that same data set, you need to use a nested cross v
40,490
How to get generalisation performance from nnet in R using k-fold cross-validation?
Implementing k-fold CV (with or without nesting) is relatively straightforward in R; and stratified sampling (wrt. class membership or subjects' characteristics, e.g. age or gender) is not that difficult. About the way to assess one's classifier performance, you can directly look at the R code for the tune() function. (Just type tune at the R prompt.) For a classification problem, this is the class agreement (between predicted and observed class membership) that is computed. However, if you are looking for a complete R framework where data preprocessing (feature elimination, scaling, etc.), training/test resampling, and comparative measures of classifiers accuracy are provided in few commands, I would definitely recommend to have a look at the caret package, which also includes a lot of useful vignettes (see also the JSS paper). Of note, although NNs are part of the methods callable from within caret, you may probably have to look at other methods that perform as well and most of the times better than NNs (e.g., Random Forests, SVMs, etc.)
How to get generalisation performance from nnet in R using k-fold cross-validation?
Implementing k-fold CV (with or without nesting) is relatively straightforward in R; and stratified sampling (wrt. class membership or subjects' characteristics, e.g. age or gender) is not that diffic
How to get generalisation performance from nnet in R using k-fold cross-validation? Implementing k-fold CV (with or without nesting) is relatively straightforward in R; and stratified sampling (wrt. class membership or subjects' characteristics, e.g. age or gender) is not that difficult. About the way to assess one's classifier performance, you can directly look at the R code for the tune() function. (Just type tune at the R prompt.) For a classification problem, this is the class agreement (between predicted and observed class membership) that is computed. However, if you are looking for a complete R framework where data preprocessing (feature elimination, scaling, etc.), training/test resampling, and comparative measures of classifiers accuracy are provided in few commands, I would definitely recommend to have a look at the caret package, which also includes a lot of useful vignettes (see also the JSS paper). Of note, although NNs are part of the methods callable from within caret, you may probably have to look at other methods that perform as well and most of the times better than NNs (e.g., Random Forests, SVMs, etc.)
How to get generalisation performance from nnet in R using k-fold cross-validation? Implementing k-fold CV (with or without nesting) is relatively straightforward in R; and stratified sampling (wrt. class membership or subjects' characteristics, e.g. age or gender) is not that diffic
40,491
Two-way clustering in R
Generally speaking, you should always find useful pointers by looking at the relevant CRAN TAsk Views, in this case the one that deals with Cluster packages, or maybe Quick-R. It's not clear to me whether the link you gave referenced standard clustering techniques for $n$ (individuals) by $k$ (variables) matrix of measures where we impose constraints on the resulting heatmap displays, or two-mode clustering or biclustering. In the first approach, we could, for example, compute a measure of (dis)similarity between individuals, or correlation between variables, and show the resulting $n\times n$ or $k\times k$ matrix where rows and columns are rearranged by some kind of partitioning or ordering technique -- this help highlighting possible substructures in the association matrix, and you will find more information in this related question; compute the correlation between two blocks of data observed on the same individuals, and reorder the pattern of correlations following an external ordination technique (e.g., hierarchical clustering) -- it amounts to show a heatmap of the observed statistics reordered by rows and columns. As proposed in an earlier response, the latter is readily available in the cim() function from the mixOmics package. From the on-line help, we can end up with something like that: Please, note that this is just a two-step process to conveniently display summary measures of association: clustering of rows (individuals or variables) and columns (individuals or variables) is done separately. In the second approach (biclustering), that I'm inclined to favour, I only know one R package, biclust, that is greatly inspired for research in bioinformatics. Some pointers were also given in an earlier thread. (But there's even some papers in the psychometrics literature.) In this case, we need to put some constraints during clustering because we want to cluster both individuals and variables at the same time. Again, you can display the resulting structure as heatmaps (see help(heatmapBC)), as shown below
Two-way clustering in R
Generally speaking, you should always find useful pointers by looking at the relevant CRAN TAsk Views, in this case the one that deals with Cluster packages, or maybe Quick-R. It's not clear to me whe
Two-way clustering in R Generally speaking, you should always find useful pointers by looking at the relevant CRAN TAsk Views, in this case the one that deals with Cluster packages, or maybe Quick-R. It's not clear to me whether the link you gave referenced standard clustering techniques for $n$ (individuals) by $k$ (variables) matrix of measures where we impose constraints on the resulting heatmap displays, or two-mode clustering or biclustering. In the first approach, we could, for example, compute a measure of (dis)similarity between individuals, or correlation between variables, and show the resulting $n\times n$ or $k\times k$ matrix where rows and columns are rearranged by some kind of partitioning or ordering technique -- this help highlighting possible substructures in the association matrix, and you will find more information in this related question; compute the correlation between two blocks of data observed on the same individuals, and reorder the pattern of correlations following an external ordination technique (e.g., hierarchical clustering) -- it amounts to show a heatmap of the observed statistics reordered by rows and columns. As proposed in an earlier response, the latter is readily available in the cim() function from the mixOmics package. From the on-line help, we can end up with something like that: Please, note that this is just a two-step process to conveniently display summary measures of association: clustering of rows (individuals or variables) and columns (individuals or variables) is done separately. In the second approach (biclustering), that I'm inclined to favour, I only know one R package, biclust, that is greatly inspired for research in bioinformatics. Some pointers were also given in an earlier thread. (But there's even some papers in the psychometrics literature.) In this case, we need to put some constraints during clustering because we want to cluster both individuals and variables at the same time. Again, you can display the resulting structure as heatmaps (see help(heatmapBC)), as shown below
Two-way clustering in R Generally speaking, you should always find useful pointers by looking at the relevant CRAN TAsk Views, in this case the one that deals with Cluster packages, or maybe Quick-R. It's not clear to me whe
40,492
Validating an existing questionnaire into another language
I don't know what your questionnaire aims to assess. In Health-related Quality-of-Life studies, for example, there are a certain number of recommendations for translation issues that were discussed in the following papers (among others): Marquis et al., Translating and evaluating questionnaires: Cultural issues for international research, in Fayers & Hays (eds.), Assessing Quality of Life in Clinical Trials (2nd ed.), Oxford, pp. 77-93 (2005). Hui and Triandis, Measurement in cross-cultural psychology: A review and comparison of strategies. Journal of Cross-Cultural Psychology, 16(2), 131-152 (1985). Mathias et al., Rapid translation of quality of life measures for international clinical trials: Avoiding errors in the minimalist approach. Quality of Life Research, 3, 403-412 (1994). Translation can be done simultaneously in several languages, as was the case for the WHOQOL questionnaire, or in a primary language (e.g., English) for the SF-36 followed by translation in other target languages. There were many papers related to translation issues in either case that you will probably find on Pubmed. Various procedures have been developed to ensure consistent translation, but forward/backward translation is most commonly found in the above studies. In any case, most common issues when translating items (as single entities, and as a whole, that is at the level of the questionnaire) have to do with the equivalence of the hypothetical concept(s) that is/are supposed to be covered. Otherwise, the very first things I would look at would be: Am I measuring the same concepts? -- this is a question related to validity; Are the scores delivered in the foreign language reliable enough? -- this has to do with scores reliability; Are the items behaving as expected for everybody, i.e. without differential effects depending on country or native language? -- this is merely related to differential item functioning (DIF), which is said to occur when the probability of endorsing a particular item differs according to a subject-specific covariate (e.g., age, gender, country), when holding subject trait constant. Some of the common techniques used to assess those properties were discussed in an earlier related question, Validating questionnaires. About DIF specifically, here are some examples of subtle variation across subject-specific characteristics: In psychiatric studies, "I feel sad" / "Able to enjoy life" have been shown to highlight gender-related DIF (Crane et al., 2007). In personality assessment, there are well-known age and gender-effect on the NEO-PI questionnaire (reviewed in Kulas et al., 2008). In Health-related Quality-of-Life, items like "Did you worry?" / "Did you feel depressed?" have been shown to exhibit country-related DIF effect (Petersen et al. 2003). A good starting point is this review paper by Jeanne Teresi in 2004: Differential Item Functioning and Health Assessment.
Validating an existing questionnaire into another language
I don't know what your questionnaire aims to assess. In Health-related Quality-of-Life studies, for example, there are a certain number of recommendations for translation issues that were discussed in
Validating an existing questionnaire into another language I don't know what your questionnaire aims to assess. In Health-related Quality-of-Life studies, for example, there are a certain number of recommendations for translation issues that were discussed in the following papers (among others): Marquis et al., Translating and evaluating questionnaires: Cultural issues for international research, in Fayers & Hays (eds.), Assessing Quality of Life in Clinical Trials (2nd ed.), Oxford, pp. 77-93 (2005). Hui and Triandis, Measurement in cross-cultural psychology: A review and comparison of strategies. Journal of Cross-Cultural Psychology, 16(2), 131-152 (1985). Mathias et al., Rapid translation of quality of life measures for international clinical trials: Avoiding errors in the minimalist approach. Quality of Life Research, 3, 403-412 (1994). Translation can be done simultaneously in several languages, as was the case for the WHOQOL questionnaire, or in a primary language (e.g., English) for the SF-36 followed by translation in other target languages. There were many papers related to translation issues in either case that you will probably find on Pubmed. Various procedures have been developed to ensure consistent translation, but forward/backward translation is most commonly found in the above studies. In any case, most common issues when translating items (as single entities, and as a whole, that is at the level of the questionnaire) have to do with the equivalence of the hypothetical concept(s) that is/are supposed to be covered. Otherwise, the very first things I would look at would be: Am I measuring the same concepts? -- this is a question related to validity; Are the scores delivered in the foreign language reliable enough? -- this has to do with scores reliability; Are the items behaving as expected for everybody, i.e. without differential effects depending on country or native language? -- this is merely related to differential item functioning (DIF), which is said to occur when the probability of endorsing a particular item differs according to a subject-specific covariate (e.g., age, gender, country), when holding subject trait constant. Some of the common techniques used to assess those properties were discussed in an earlier related question, Validating questionnaires. About DIF specifically, here are some examples of subtle variation across subject-specific characteristics: In psychiatric studies, "I feel sad" / "Able to enjoy life" have been shown to highlight gender-related DIF (Crane et al., 2007). In personality assessment, there are well-known age and gender-effect on the NEO-PI questionnaire (reviewed in Kulas et al., 2008). In Health-related Quality-of-Life, items like "Did you worry?" / "Did you feel depressed?" have been shown to exhibit country-related DIF effect (Petersen et al. 2003). A good starting point is this review paper by Jeanne Teresi in 2004: Differential Item Functioning and Health Assessment.
Validating an existing questionnaire into another language I don't know what your questionnaire aims to assess. In Health-related Quality-of-Life studies, for example, there are a certain number of recommendations for translation issues that were discussed in
40,493
Validating an existing questionnaire into another language
I found some good ideas in the short Sage book, Translating Questionnaires and Other Research Instruments, at http://www.uk.sagepub.com/books/Book5861 . I wouldn't call it the most systematic or the most entertaining read, but it was helpful and it's fairly up-to-date and inexpensive.
Validating an existing questionnaire into another language
I found some good ideas in the short Sage book, Translating Questionnaires and Other Research Instruments, at http://www.uk.sagepub.com/books/Book5861 . I wouldn't call it the most systematic or the
Validating an existing questionnaire into another language I found some good ideas in the short Sage book, Translating Questionnaires and Other Research Instruments, at http://www.uk.sagepub.com/books/Book5861 . I wouldn't call it the most systematic or the most entertaining read, but it was helpful and it's fairly up-to-date and inexpensive.
Validating an existing questionnaire into another language I found some good ideas in the short Sage book, Translating Questionnaires and Other Research Instruments, at http://www.uk.sagepub.com/books/Book5861 . I wouldn't call it the most systematic or the
40,494
Validating an existing questionnaire into another language
The procedure i have normally seen followed is to translate the questionnaire from english, and then have it back translated by someone else. If the two english translations match up, then you are good to go, otherwise repeat until they do.
Validating an existing questionnaire into another language
The procedure i have normally seen followed is to translate the questionnaire from english, and then have it back translated by someone else. If the two english translations match up, then you are goo
Validating an existing questionnaire into another language The procedure i have normally seen followed is to translate the questionnaire from english, and then have it back translated by someone else. If the two english translations match up, then you are good to go, otherwise repeat until they do.
Validating an existing questionnaire into another language The procedure i have normally seen followed is to translate the questionnaire from english, and then have it back translated by someone else. If the two english translations match up, then you are goo
40,495
Validating an existing questionnaire into another language
Wakening up an old question I just wanted to add two sources concerning guidelines for translating questionnaires. The first one would be EORTC's Guidelines and the second PROMIS's Guidelines. Reading these will help you grasp the concept of translating according to every possible detail. From there, you can make your own decisions about how precise to be (although I hope you're already done since your question was asked some years ago...)
Validating an existing questionnaire into another language
Wakening up an old question I just wanted to add two sources concerning guidelines for translating questionnaires. The first one would be EORTC's Guidelines and the second PROMIS's Guidelines. Reading
Validating an existing questionnaire into another language Wakening up an old question I just wanted to add two sources concerning guidelines for translating questionnaires. The first one would be EORTC's Guidelines and the second PROMIS's Guidelines. Reading these will help you grasp the concept of translating according to every possible detail. From there, you can make your own decisions about how precise to be (although I hope you're already done since your question was asked some years ago...)
Validating an existing questionnaire into another language Wakening up an old question I just wanted to add two sources concerning guidelines for translating questionnaires. The first one would be EORTC's Guidelines and the second PROMIS's Guidelines. Reading
40,496
Is principal components analysis valid if the distribution(s) are Zipf like? What would be similar to PCA but suited to non gaussian data?
The truth is PCA contains an inherent assumption of linearity, i.e. that changing the basis can reframe the problem to provide a more discriminating view on the data. Does it have to be true when working with Zipf/power law following data? It depends on whether all your variables are of the same distribution. If so, you could take a logarithm of the values of all columns and perform PCA with sensible results. Power law makes your variances explode, PCA will of course yield results, but they will be hard to interpret without making a mistake of arguing that a phenomenon is happening when it actually is only happening in the top 20% outliers. You can also try to use PCA to see the major differences, then divide the data to a point where the long tail is separated from the top outliers and then a PCA on the tail? A good tutorial on PCA with assumptions can be found here: Jonathon Shlens: A Tutorial on Principal Component Analysis. CoRR abs/1404.1100 (2014)
Is principal components analysis valid if the distribution(s) are Zipf like? What would be similar t
The truth is PCA contains an inherent assumption of linearity, i.e. that changing the basis can reframe the problem to provide a more discriminating view on the data. Does it have to be true when work
Is principal components analysis valid if the distribution(s) are Zipf like? What would be similar to PCA but suited to non gaussian data? The truth is PCA contains an inherent assumption of linearity, i.e. that changing the basis can reframe the problem to provide a more discriminating view on the data. Does it have to be true when working with Zipf/power law following data? It depends on whether all your variables are of the same distribution. If so, you could take a logarithm of the values of all columns and perform PCA with sensible results. Power law makes your variances explode, PCA will of course yield results, but they will be hard to interpret without making a mistake of arguing that a phenomenon is happening when it actually is only happening in the top 20% outliers. You can also try to use PCA to see the major differences, then divide the data to a point where the long tail is separated from the top outliers and then a PCA on the tail? A good tutorial on PCA with assumptions can be found here: Jonathon Shlens: A Tutorial on Principal Component Analysis. CoRR abs/1404.1100 (2014)
Is principal components analysis valid if the distribution(s) are Zipf like? What would be similar t The truth is PCA contains an inherent assumption of linearity, i.e. that changing the basis can reframe the problem to provide a more discriminating view on the data. Does it have to be true when work
40,497
Is principal components analysis valid if the distribution(s) are Zipf like? What would be similar to PCA but suited to non gaussian data?
PCA is probably fine to use on your data, as it appears that it does not make any assumptions about the structure of the data. See link for a good introduction. The note leads to a short PDF tutorial on PCA. Hope this helps.
Is principal components analysis valid if the distribution(s) are Zipf like? What would be similar t
PCA is probably fine to use on your data, as it appears that it does not make any assumptions about the structure of the data. See link for a good introduction. The note leads to a short PDF tutorial
Is principal components analysis valid if the distribution(s) are Zipf like? What would be similar to PCA but suited to non gaussian data? PCA is probably fine to use on your data, as it appears that it does not make any assumptions about the structure of the data. See link for a good introduction. The note leads to a short PDF tutorial on PCA. Hope this helps.
Is principal components analysis valid if the distribution(s) are Zipf like? What would be similar t PCA is probably fine to use on your data, as it appears that it does not make any assumptions about the structure of the data. See link for a good introduction. The note leads to a short PDF tutorial
40,498
Is principal components analysis valid if the distribution(s) are Zipf like? What would be similar to PCA but suited to non gaussian data?
There's an excellent typology and discussion of different types of input to PCA as well as Matlab routines for PCA with extreme valued information in this paper by Xie and Xeng, Cauchy Principal Component Analysis. Basically, their approach involves shifting to probabilistic assumptions. They explicitly compare the location-scale family of distributions including Gaussian, Laplace, Logistic and Cauchy distributional fits to the same, simulated information. Having done it, their algorithm is also pretty easily programmed into languages other than Matlab.
Is principal components analysis valid if the distribution(s) are Zipf like? What would be similar t
There's an excellent typology and discussion of different types of input to PCA as well as Matlab routines for PCA with extreme valued information in this paper by Xie and Xeng, Cauchy Principal Compo
Is principal components analysis valid if the distribution(s) are Zipf like? What would be similar to PCA but suited to non gaussian data? There's an excellent typology and discussion of different types of input to PCA as well as Matlab routines for PCA with extreme valued information in this paper by Xie and Xeng, Cauchy Principal Component Analysis. Basically, their approach involves shifting to probabilistic assumptions. They explicitly compare the location-scale family of distributions including Gaussian, Laplace, Logistic and Cauchy distributional fits to the same, simulated information. Having done it, their algorithm is also pretty easily programmed into languages other than Matlab.
Is principal components analysis valid if the distribution(s) are Zipf like? What would be similar t There's an excellent typology and discussion of different types of input to PCA as well as Matlab routines for PCA with extreme valued information in this paper by Xie and Xeng, Cauchy Principal Compo
40,499
Randomized SVD and singular values
We have implemented this (along with a power iteration refinement) in the scikit-learn python package. Our implementation is able to find the exact same singular values and vectors if k + p > rank(M) as demonstrated in the tests. If you cut (k + p) before reaching near zero singular values (i.e. in the k + p < rank(M) case) then the singular vectors are indeed different from the ones you get with the un-truncated version but they might still be very useful in practice for features extraction in machine learning: for instance 'truncated' eigenfaces at 150 work as good for face recognition task with SVM as the top 150 first singular vectors of the full decomposition even though the rank of my faces dataset seems to be much higher. This randomized / truncated SVD method looks really interesting in practice: it can really cut down the computation time as shown in this benchmark:
Randomized SVD and singular values
We have implemented this (along with a power iteration refinement) in the scikit-learn python package. Our implementation is able to find the exact same singular values and vectors if k + p > rank(M)
Randomized SVD and singular values We have implemented this (along with a power iteration refinement) in the scikit-learn python package. Our implementation is able to find the exact same singular values and vectors if k + p > rank(M) as demonstrated in the tests. If you cut (k + p) before reaching near zero singular values (i.e. in the k + p < rank(M) case) then the singular vectors are indeed different from the ones you get with the un-truncated version but they might still be very useful in practice for features extraction in machine learning: for instance 'truncated' eigenfaces at 150 work as good for face recognition task with SVM as the top 150 first singular vectors of the full decomposition even though the rank of my faces dataset seems to be much higher. This randomized / truncated SVD method looks really interesting in practice: it can really cut down the computation time as shown in this benchmark:
Randomized SVD and singular values We have implemented this (along with a power iteration refinement) in the scikit-learn python package. Our implementation is able to find the exact same singular values and vectors if k + p > rank(M)
40,500
Randomized SVD and singular values
I do not think the singular values should match those of the full matrix. You are computing an approximation of the input matrix by projection onto $k+p$ random vectors. For a rank $k+p$ matrix to approximate a rank $n \gg k+p$ matrix, the trace should probably be the same, but then if the first $k$ singular values are to overlap, you have to push a lot of 'variance' to the last $p$ singular values of the approximation (probably so many that they are no longer the least significant singular values). Another way of looking at this is one is approximating $A = U\Sigma V'$ by another decomposition, $T \Gamma W'$. We should not expect a fast randomized algorithm to magically work such that $T$ is the first $k$ columns of $U$, $\Gamma$ is a submatrix of $\Sigma$, etc.
Randomized SVD and singular values
I do not think the singular values should match those of the full matrix. You are computing an approximation of the input matrix by projection onto $k+p$ random vectors. For a rank $k+p$ matrix to app
Randomized SVD and singular values I do not think the singular values should match those of the full matrix. You are computing an approximation of the input matrix by projection onto $k+p$ random vectors. For a rank $k+p$ matrix to approximate a rank $n \gg k+p$ matrix, the trace should probably be the same, but then if the first $k$ singular values are to overlap, you have to push a lot of 'variance' to the last $p$ singular values of the approximation (probably so many that they are no longer the least significant singular values). Another way of looking at this is one is approximating $A = U\Sigma V'$ by another decomposition, $T \Gamma W'$. We should not expect a fast randomized algorithm to magically work such that $T$ is the first $k$ columns of $U$, $\Gamma$ is a submatrix of $\Sigma$, etc.
Randomized SVD and singular values I do not think the singular values should match those of the full matrix. You are computing an approximation of the input matrix by projection onto $k+p$ random vectors. For a rank $k+p$ matrix to app