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
|
|---|---|---|---|---|---|---|
15,201
|
A 6th response option ("I don't know") was added to a 5-point Likert scale. Is the data lost?
|
If this was a standardized questionnaire that has been validated independently, then you cannot claim that the new questionnaire is equivalent, and the data is no longer comparable. You could try to validate and examine the questionnaire in separate experiments (very time- and effort-consuming, especially if you also want to show comparability to the old version) or just accept that you are dealing with lower evidence quality (since your data comes from a non-validated questionnaire).
When you use your data, you will have to take the change into consideration. When faced with an attitude question, people don't give you a somehow "objectively true" answer, they give you the answer they feel to be true - and this is certainly influenced both by the answer options available (they "norm" their answers to the scale) and to the knowledge they have about the subject (there are known biases which work differently, sometimes in different directions(!) depending on whether the participant has much or little knowledge about the subject matter).
So, if we are dealing with an established quesitonnaire, you have the nice option for a comparison between your version of the questionnaire and the original one. If the original assumed that people know what they are selecting, and it turns out they don't, you can discuss how the old model is based on wrong assumptions, and what are the consequences of that. Note that this is a "side" discovery, which makes a nice new research question, but brings you away from the original one, and indeed shows that answering the original one is much more difficult than thought, so it certainly multiplies your work.
If you are not dealing with an established questionnaire, you can roll with the flow and pretend that your ad-hoc questionnaire was planned that way, and evaluate the results accordingly. Again, it might mean that the results you were hoping for are unobtainable with this method, but this is also an important thing to know.
For a good understanding of how wording and options influence the way questionnaires are answered, I suggest reading Tourangeau et al.'s "Psychology of the survey response". It is a great read for everybody who ever creates a questionnaire.
|
A 6th response option ("I don't know") was added to a 5-point Likert scale. Is the data lost?
|
If this was a standardized questionnaire that has been validated independently, then you cannot claim that the new questionnaire is equivalent, and the data is no longer comparable. You could try to v
|
A 6th response option ("I don't know") was added to a 5-point Likert scale. Is the data lost?
If this was a standardized questionnaire that has been validated independently, then you cannot claim that the new questionnaire is equivalent, and the data is no longer comparable. You could try to validate and examine the questionnaire in separate experiments (very time- and effort-consuming, especially if you also want to show comparability to the old version) or just accept that you are dealing with lower evidence quality (since your data comes from a non-validated questionnaire).
When you use your data, you will have to take the change into consideration. When faced with an attitude question, people don't give you a somehow "objectively true" answer, they give you the answer they feel to be true - and this is certainly influenced both by the answer options available (they "norm" their answers to the scale) and to the knowledge they have about the subject (there are known biases which work differently, sometimes in different directions(!) depending on whether the participant has much or little knowledge about the subject matter).
So, if we are dealing with an established quesitonnaire, you have the nice option for a comparison between your version of the questionnaire and the original one. If the original assumed that people know what they are selecting, and it turns out they don't, you can discuss how the old model is based on wrong assumptions, and what are the consequences of that. Note that this is a "side" discovery, which makes a nice new research question, but brings you away from the original one, and indeed shows that answering the original one is much more difficult than thought, so it certainly multiplies your work.
If you are not dealing with an established questionnaire, you can roll with the flow and pretend that your ad-hoc questionnaire was planned that way, and evaluate the results accordingly. Again, it might mean that the results you were hoping for are unobtainable with this method, but this is also an important thing to know.
For a good understanding of how wording and options influence the way questionnaires are answered, I suggest reading Tourangeau et al.'s "Psychology of the survey response". It is a great read for everybody who ever creates a questionnaire.
|
A 6th response option ("I don't know") was added to a 5-point Likert scale. Is the data lost?
If this was a standardized questionnaire that has been validated independently, then you cannot claim that the new questionnaire is equivalent, and the data is no longer comparable. You could try to v
|
15,202
|
A 6th response option ("I don't know") was added to a 5-point Likert scale. Is the data lost?
|
If you ask how many children has the respondent given birth to, the answers "zero" and "not applicable" would not mean strictly the same thing, since men cannot give birth.
For some contexts, equating "I don't know" to the neutral response could be, likewise, a conceptual mistake.
Actually, you have two questions: a dichotomous "Do you have an opinion?" and an ordinal "What is it?", just as, above, you have an implicit "Are you a female?" beyond your explicit question.
Of course, you can introduce some assumptions (sometimes correctly, sometimes just for convenience, sometimes forcedly) to enable you some modeling, but I can see no universally applicable strategy without entering the realm of the specifics of your phenomenon.
As a last point to be thought of, it would not make sense to try and infer to male population anything from female fecundity answers.
|
A 6th response option ("I don't know") was added to a 5-point Likert scale. Is the data lost?
|
If you ask how many children has the respondent given birth to, the answers "zero" and "not applicable" would not mean strictly the same thing, since men cannot give birth.
For some contexts, equating
|
A 6th response option ("I don't know") was added to a 5-point Likert scale. Is the data lost?
If you ask how many children has the respondent given birth to, the answers "zero" and "not applicable" would not mean strictly the same thing, since men cannot give birth.
For some contexts, equating "I don't know" to the neutral response could be, likewise, a conceptual mistake.
Actually, you have two questions: a dichotomous "Do you have an opinion?" and an ordinal "What is it?", just as, above, you have an implicit "Are you a female?" beyond your explicit question.
Of course, you can introduce some assumptions (sometimes correctly, sometimes just for convenience, sometimes forcedly) to enable you some modeling, but I can see no universally applicable strategy without entering the realm of the specifics of your phenomenon.
As a last point to be thought of, it would not make sense to try and infer to male population anything from female fecundity answers.
|
A 6th response option ("I don't know") was added to a 5-point Likert scale. Is the data lost?
If you ask how many children has the respondent given birth to, the answers "zero" and "not applicable" would not mean strictly the same thing, since men cannot give birth.
For some contexts, equating
|
15,203
|
A 6th response option ("I don't know") was added to a 5-point Likert scale. Is the data lost?
|
The dilemma whether one should include or not the Don't know response option into a questionnaire consisting of rating scales of Likert type is eternal. Often, when the items ask about opinion, the DK is included because having no opinion is an important status on its own and the option as such is expected by respondents. In personal trait inventories where people ascribe qualities to a target DK option is typically dropped because a respondent normally is expected to be able to assess the extent of affinity of a characteristic (i.e. respondent is always seen qualified); and when he occasionally finds difficulty he is allowed (by instruction) to skip that item. In personal trait inventories where people describe a target (behavioural items) DK (or don't remember) could be incorporated or dropped depending on the scale design and the specific question of the study.
@Hatim in his answer, @Maarten and some other commentators of the OP question have sensibly put up that a large amount of DK responses observed in the current study indicate problems (content validity or face valitity) in the items or that the subjects don't fit in with the questionnaire ordered to them.
But you can never tell the story, ultimately the interpretation of the impediment is on you (unless you address it in a separate investigation). One could claim, for example, that the inclusion of DK option to the likerts in that questionnaire (say, it is a trait ascription inventory) serves bad, not good. It didn't give you information (of which the commentators say, that it proves that the [rating] model is inadequate) but rather distracted/seduced a respondent. Be it not supplied the rating decision guided by the implicit cognitive trait schema could have been elicited; but seeing the cooling option precludes the schema and makes one hastily to withdraw.
If you further admit - on your risk, but why not? - that an easily distracted or lazy subject is the one whose potential, held back view is valid but tends to be weakly differentiated - that is, he would easily invoke conventional das Man, in place of personal Erlebnis, schema - then you may tentatively speculate that his missing response is around the sample's or population's mean for that item. If so, why not do mean (+noise) substitution of the missing responses? Or you might do EM or regressional (+noise) imputation to take correlations into account.
To repeat: the imputation decision is possible but risky, and is unlikely, given the large amount of missing data, to restore "truly" the absent data. As @rumtscho said, surely that the new questionnaire with DK is not equivalent to the original one without DK, and the data is no longer comparable.
These were speculations. But first of all, you ought to attempt to investigate the observed patterns of missingness. Who are those subjects who selected DK? Do they cluster together in subtypes? How they are different on the rest of the items from the "okay" subsample? Some software have Missing Value Analysis package. Then you could decide whether to drop the people entirely or partly, or to impute, or to analyze them as a separate subsample.
P.S. Also note that respondents are "stupid". They often just mix up with the scale grades. For example, if the DK point was placed close to one pole of the scale it would often get confused by inattention with that pole. I'm not joking.
|
A 6th response option ("I don't know") was added to a 5-point Likert scale. Is the data lost?
|
The dilemma whether one should include or not the Don't know response option into a questionnaire consisting of rating scales of Likert type is eternal. Often, when the items ask about opinion, the DK
|
A 6th response option ("I don't know") was added to a 5-point Likert scale. Is the data lost?
The dilemma whether one should include or not the Don't know response option into a questionnaire consisting of rating scales of Likert type is eternal. Often, when the items ask about opinion, the DK is included because having no opinion is an important status on its own and the option as such is expected by respondents. In personal trait inventories where people ascribe qualities to a target DK option is typically dropped because a respondent normally is expected to be able to assess the extent of affinity of a characteristic (i.e. respondent is always seen qualified); and when he occasionally finds difficulty he is allowed (by instruction) to skip that item. In personal trait inventories where people describe a target (behavioural items) DK (or don't remember) could be incorporated or dropped depending on the scale design and the specific question of the study.
@Hatim in his answer, @Maarten and some other commentators of the OP question have sensibly put up that a large amount of DK responses observed in the current study indicate problems (content validity or face valitity) in the items or that the subjects don't fit in with the questionnaire ordered to them.
But you can never tell the story, ultimately the interpretation of the impediment is on you (unless you address it in a separate investigation). One could claim, for example, that the inclusion of DK option to the likerts in that questionnaire (say, it is a trait ascription inventory) serves bad, not good. It didn't give you information (of which the commentators say, that it proves that the [rating] model is inadequate) but rather distracted/seduced a respondent. Be it not supplied the rating decision guided by the implicit cognitive trait schema could have been elicited; but seeing the cooling option precludes the schema and makes one hastily to withdraw.
If you further admit - on your risk, but why not? - that an easily distracted or lazy subject is the one whose potential, held back view is valid but tends to be weakly differentiated - that is, he would easily invoke conventional das Man, in place of personal Erlebnis, schema - then you may tentatively speculate that his missing response is around the sample's or population's mean for that item. If so, why not do mean (+noise) substitution of the missing responses? Or you might do EM or regressional (+noise) imputation to take correlations into account.
To repeat: the imputation decision is possible but risky, and is unlikely, given the large amount of missing data, to restore "truly" the absent data. As @rumtscho said, surely that the new questionnaire with DK is not equivalent to the original one without DK, and the data is no longer comparable.
These were speculations. But first of all, you ought to attempt to investigate the observed patterns of missingness. Who are those subjects who selected DK? Do they cluster together in subtypes? How they are different on the rest of the items from the "okay" subsample? Some software have Missing Value Analysis package. Then you could decide whether to drop the people entirely or partly, or to impute, or to analyze them as a separate subsample.
P.S. Also note that respondents are "stupid". They often just mix up with the scale grades. For example, if the DK point was placed close to one pole of the scale it would often get confused by inattention with that pole. I'm not joking.
|
A 6th response option ("I don't know") was added to a 5-point Likert scale. Is the data lost?
The dilemma whether one should include or not the Don't know response option into a questionnaire consisting of rating scales of Likert type is eternal. Often, when the items ask about opinion, the DK
|
15,204
|
A 6th response option ("I don't know") was added to a 5-point Likert scale. Is the data lost?
|
You now have respondents self-selected for having an opinion on the matter. Whatever you conclude will solely be about those people. This might be OK, as polling those "don't knows" is by definition less useful.
|
A 6th response option ("I don't know") was added to a 5-point Likert scale. Is the data lost?
|
You now have respondents self-selected for having an opinion on the matter. Whatever you conclude will solely be about those people. This might be OK, as polling those "don't knows" is by definition l
|
A 6th response option ("I don't know") was added to a 5-point Likert scale. Is the data lost?
You now have respondents self-selected for having an opinion on the matter. Whatever you conclude will solely be about those people. This might be OK, as polling those "don't knows" is by definition less useful.
|
A 6th response option ("I don't know") was added to a 5-point Likert scale. Is the data lost?
You now have respondents self-selected for having an opinion on the matter. Whatever you conclude will solely be about those people. This might be OK, as polling those "don't knows" is by definition l
|
15,205
|
Are there any non-distance based clustering algorithms?
|
One example of such a method are Finite Mixture Models (e.g. here or here) used for clustering. In FMM you consider the distribution ($f$) of your variable $X$ as a mixture of $K$ distributions ($f_1,...,f_k$):
$$f(x, \vartheta) = \sum^K_{k=1} \pi_k f_k(x, \vartheta_k)$$
where $\vartheta$ is a vector of parameters $\vartheta = (\pi', \vartheta_1', ..., \vartheta_k')'$ and $\pi_k$ is a proportion of $k$'th distribution in the mixture and $\vartheta_k$ is a parameter (or parameters) of $f_k$ distribution.
A specific case for discrete data is Latent Class Analysis (e.g. Vermunt and Magidson, 2003) defined as:
$$P(x, k) = P(k) P(x|k)$$
where $P(k)$ is probability of observing latent class $k$ (i.e. $\pi_k$), $P(x)$ is probability of observing an $x$ value and $P(x|k)$ is probability of $x$ being in class $k$.
Usually for both FMM and LCA EM algorithm is used for estimation, but Bayesian approach is also possible, but a little bit more demanding because of problems such as model identification and label switching (e.g. Xi'an's blog).
So there is no distance measure but rather a statistical model defining the structure (distribution) of your data. Because of that other name of this method is "model-based clustering".
Check the two books on FMM:
McLachlan, G. & Peel, D. (2000). Finite Mixture Models. John Wiley & Sons.
Frühwirth-Schnatter, S. (2006). Finite Mixture and Markov Switching Models. Springer.
One of the most popular clustering packages that uses FMM is mclust (check here or here) that is implemented in R. However, more complicated FMM's are also possible, check for example flexmix package and it's documentation. For LCA there is an R poLCA package.
|
Are there any non-distance based clustering algorithms?
|
One example of such a method are Finite Mixture Models (e.g. here or here) used for clustering. In FMM you consider the distribution ($f$) of your variable $X$ as a mixture of $K$ distributions ($f_1,
|
Are there any non-distance based clustering algorithms?
One example of such a method are Finite Mixture Models (e.g. here or here) used for clustering. In FMM you consider the distribution ($f$) of your variable $X$ as a mixture of $K$ distributions ($f_1,...,f_k$):
$$f(x, \vartheta) = \sum^K_{k=1} \pi_k f_k(x, \vartheta_k)$$
where $\vartheta$ is a vector of parameters $\vartheta = (\pi', \vartheta_1', ..., \vartheta_k')'$ and $\pi_k$ is a proportion of $k$'th distribution in the mixture and $\vartheta_k$ is a parameter (or parameters) of $f_k$ distribution.
A specific case for discrete data is Latent Class Analysis (e.g. Vermunt and Magidson, 2003) defined as:
$$P(x, k) = P(k) P(x|k)$$
where $P(k)$ is probability of observing latent class $k$ (i.e. $\pi_k$), $P(x)$ is probability of observing an $x$ value and $P(x|k)$ is probability of $x$ being in class $k$.
Usually for both FMM and LCA EM algorithm is used for estimation, but Bayesian approach is also possible, but a little bit more demanding because of problems such as model identification and label switching (e.g. Xi'an's blog).
So there is no distance measure but rather a statistical model defining the structure (distribution) of your data. Because of that other name of this method is "model-based clustering".
Check the two books on FMM:
McLachlan, G. & Peel, D. (2000). Finite Mixture Models. John Wiley & Sons.
Frühwirth-Schnatter, S. (2006). Finite Mixture and Markov Switching Models. Springer.
One of the most popular clustering packages that uses FMM is mclust (check here or here) that is implemented in R. However, more complicated FMM's are also possible, check for example flexmix package and it's documentation. For LCA there is an R poLCA package.
|
Are there any non-distance based clustering algorithms?
One example of such a method are Finite Mixture Models (e.g. here or here) used for clustering. In FMM you consider the distribution ($f$) of your variable $X$ as a mixture of $K$ distributions ($f_1,
|
15,206
|
Are there any non-distance based clustering algorithms?
|
K-means isn't "really" distance based. It minimizes the variance. (But variance $\sim$ squared Euclidean distances; so every point is assigned to the nearest centroid by Euclidean distance, too).
There are plenty of grid-based clustering approaches. They don't compute distances because that would often yield quadratic runtime. Instead, they partition the data and aggregate it into grid cells. But the intuition behind such approaches is usually very closely related to distances.
There are a number of clustering algorithms for categorical data such as COOLCAT and STUCCO. Distances aren't easy to use with such data (one-hot encoding is a hack, and does not yield particularly meaningful distances). But I haven't heard of anyone using these algorithms...
There are clustering approaches for graphs. But either they reduce to classic graph problems such as clique or near-clique finding and graph coloring, or they are closely connected to distance-based clustering (if you have a weighted graph).
Density-based clustering like DBSCAN has a different name, and isn't focused around minimizing distances; but "density" is usually specified with respect to a distance, so technically these algorithms are either distance-based or grid-based.
The essential part of your question that you left out is what is your data?
|
Are there any non-distance based clustering algorithms?
|
K-means isn't "really" distance based. It minimizes the variance. (But variance $\sim$ squared Euclidean distances; so every point is assigned to the nearest centroid by Euclidean distance, too).
Ther
|
Are there any non-distance based clustering algorithms?
K-means isn't "really" distance based. It minimizes the variance. (But variance $\sim$ squared Euclidean distances; so every point is assigned to the nearest centroid by Euclidean distance, too).
There are plenty of grid-based clustering approaches. They don't compute distances because that would often yield quadratic runtime. Instead, they partition the data and aggregate it into grid cells. But the intuition behind such approaches is usually very closely related to distances.
There are a number of clustering algorithms for categorical data such as COOLCAT and STUCCO. Distances aren't easy to use with such data (one-hot encoding is a hack, and does not yield particularly meaningful distances). But I haven't heard of anyone using these algorithms...
There are clustering approaches for graphs. But either they reduce to classic graph problems such as clique or near-clique finding and graph coloring, or they are closely connected to distance-based clustering (if you have a weighted graph).
Density-based clustering like DBSCAN has a different name, and isn't focused around minimizing distances; but "density" is usually specified with respect to a distance, so technically these algorithms are either distance-based or grid-based.
The essential part of your question that you left out is what is your data?
|
Are there any non-distance based clustering algorithms?
K-means isn't "really" distance based. It minimizes the variance. (But variance $\sim$ squared Euclidean distances; so every point is assigned to the nearest centroid by Euclidean distance, too).
Ther
|
15,207
|
Are there any non-distance based clustering algorithms?
|
In addition to previous nice answers, I would suggest considering Dirichlet mixture models and Bayesian-based hierarchical Dirichlet process models. For a rather comprehensive and general overview of approaches and methods for determining an optimal number of clusters, please see this excellent answer on StackOverflow: https://stackoverflow.com/a/15376462/2872891.
|
Are there any non-distance based clustering algorithms?
|
In addition to previous nice answers, I would suggest considering Dirichlet mixture models and Bayesian-based hierarchical Dirichlet process models. For a rather comprehensive and general overview of
|
Are there any non-distance based clustering algorithms?
In addition to previous nice answers, I would suggest considering Dirichlet mixture models and Bayesian-based hierarchical Dirichlet process models. For a rather comprehensive and general overview of approaches and methods for determining an optimal number of clusters, please see this excellent answer on StackOverflow: https://stackoverflow.com/a/15376462/2872891.
|
Are there any non-distance based clustering algorithms?
In addition to previous nice answers, I would suggest considering Dirichlet mixture models and Bayesian-based hierarchical Dirichlet process models. For a rather comprehensive and general overview of
|
15,208
|
Are there any non-distance based clustering algorithms?
|
A purely discriminative approach is "regularized information maximisation" by Gomes et al. There is no notion of similarity/distance involved in it whatsoever.
The idea is to have a logistic regression like model that puts points into bins. But instead of training it to maximise some form of log-likelihood of the class labels, the objective function is one that puts points into different clusters.
To control the amount of clusters used by the model, an additional regularisation term weighted by the hyper parameter $\lambda$ is used. It boils down to a the inverse variance of a Gaussian prior over the weights.
Extension to kernel methods or neural networks for non-linear clustering is straightforward.
|
Are there any non-distance based clustering algorithms?
|
A purely discriminative approach is "regularized information maximisation" by Gomes et al. There is no notion of similarity/distance involved in it whatsoever.
The idea is to have a logistic regressio
|
Are there any non-distance based clustering algorithms?
A purely discriminative approach is "regularized information maximisation" by Gomes et al. There is no notion of similarity/distance involved in it whatsoever.
The idea is to have a logistic regression like model that puts points into bins. But instead of training it to maximise some form of log-likelihood of the class labels, the objective function is one that puts points into different clusters.
To control the amount of clusters used by the model, an additional regularisation term weighted by the hyper parameter $\lambda$ is used. It boils down to a the inverse variance of a Gaussian prior over the weights.
Extension to kernel methods or neural networks for non-linear clustering is straightforward.
|
Are there any non-distance based clustering algorithms?
A purely discriminative approach is "regularized information maximisation" by Gomes et al. There is no notion of similarity/distance involved in it whatsoever.
The idea is to have a logistic regressio
|
15,209
|
Mathematical demonstration of the distance concentration in high dimensions
|
There is a simple mathematical thought experiment that sheds light on this phenomenon, although it might not seem immediately applicable. I will therefore describe this experiment briefly and follow that, in a separate section, by a computer analysis of a concrete situation.
A Thought Experiment
An old cartographic chestnut is that most of the area of a map lies near its edges. Similarly, much of a pizza--more than you might think--consists of its crust. Even more so is the fact that a great deal of the volume of a thick-skinned fruit, like a grapefruit or watermelon, is in its skin.
More than half this pizza lies near its edge, outside the shaded area. However, the width of this "crust" is only $18\%$ of the diameter of the pie.
Maps and pizzas and grapefruits don't have a common shape, but there is a common underlying explanation. We may model the border of a map, the crust of a pizza, or the skin of a fruit by supposing its basic shape -- a rectangle, circle, sphere, or whatever -- has been shrunk uniformly by some factor $\alpha$ and that the "crust" or "rind" consists of what lies between these two concentric similar shapes.
In $n$ dimensions (the examples involve $n=2$ or $n=3$), the $n$-dimensional volume of the interior will therefore be $\alpha^n$ times the volume of the original shape. (This volume scaling law is sometimes used to define the number of dimensions of a space.) The volume of the rind relative to the original volume therefore is
$$1 - \alpha^n.$$
As a function of $\alpha$ its rate of growth is
$$\mathrm{d}(1 - \alpha^n) = -n\,\alpha^{n-1}\,\mathrm{d}\alpha.$$
Beginning with no shrinking ($\alpha=1$) and noting $\alpha$ is decreasing ($\mathrm{d}\alpha$ is negative), we find the initial rate of growth of the rind equals $n.$
This shows that the volume of the rind initially grows much faster -- $n$ times faster -- than the rate at which the object is being shrunk. The factor of $n$ implies
in higher dimensions, relatively tiny changes in distance translate to much larger changes in volume.
Let's call this the "edge-of-map principle."
Consider, now, a tabular dataset consisting of observations of $n$ numerical features. We may view each observation as a point in $\mathbb{R}^n$ and (at least in our imagination) might also suppose this collection of points is contained within some kind of compact region $\mathcal D$ with relatively simple boundary.
If we choose to use Euclidean distances to compare these points to each other (and to other points in $\mathcal D$) and consider an arbitrary observation $x,$ the edge-of-map principle implies that most of the room in $\mathcal D$ is nearly as far as possible from $x.$ (The fudge term "nearly" is needed to account for what goes on around the boundary of $\mathcal D.$)
Another implication that goes to the heart of the question is the generalization of the cartographer's quandary: if our observations are somewhat "spread out" over $\mathcal D,$ then the cartographer's question is "what proportion of this dataset is near the boundary?" To express this in a quantitative fashion, let's invert it: we ask, by how much should we shrink $\mathcal D$ to make it, say, only half its original volume? Let's call this the "half-length" of $\mathcal D,$ analogously to the half-life of a radioactive decay.
If the half-length is $\alpha,$ we need only solve the equation
$$\alpha^n = \frac{1}{2};\quad \alpha = 2^{-1/n} = e^{-(\log 2)/n} \approx 1 - \frac{\log 2}{n} \approx 1 - \frac{0.7}{n}.$$
In two dimensions the half-length is $1 - 0.35.$ Since half of the shrinking occurs on one side of the map or pizza and the other half on the other side (refer to the preceding figure), half of the area of a map ($n=2$) lies within (approximately) $35/2=18\%$ of its diameter from the boundary.
In three dimensions the half-length is $1 - 0.23:$ now, half the volume of a fruit lies within $12\%$ of its diameter from its boundary. A fruit whose skin is just one-eighth the width of the entire fruit is more than half skin.
Despite appearances, approximately half the volume of this grapefruit is rind. (Source: FreeDigitalPhotos.net.)
In very large dimensions the half-length is very close to $1.$ In $n=350$ dimensions it is greater than $98\%,$ within two percent of $1.$ Thus, expect half of any $350$-dimensional dataset to lie within $1\%$ of its diameter from its boundary. Unless the data are strongly clustered, this generalization will be accurate.
Another way to express these results is:
Absent strong clustering, in higher dimensions $n$ we can expect most Euclidean distances between observations in a dataset to be very nearly the same and to be very close to the diameter of the region in which they are enclosed. "Very close" means on the order of $1/n.$
Several parts of this analysis are really just hand-waving and approximations, due to the vagueness of $\mathcal D$ and the very general assumptions about the dataset. How is $\mathcal D$ defined, anyway? In some applications it is determined by inherent limits; for instance, when all features are proportions. In many applications the features are arbitrarily scaled to lie within a fixed interval ("normalized") and we often take $\mathcal D$ to be the corresponding hypercube. But that's only an artifice and it is exquisitely sensitive to any outlying data values. The rest of this post explores an alternative in which the boundary plays a less important role in the results. It comes to similar conclusions.
Analysis of distances in a closed Euclidean space
I find the paper's setting rather arbitrary, because it is exploring distances within unit cubes. The distance distributions depend strongly on the shapes of the boundaries of those cubes.
There's a way to avoid boundary effects. In one dimension, the "cube" is just the unit interval, $[0,1].$
Because this interval has two ends, some of the points are far from the rest; others (near the middle) tend to be close to all the points. This is asymmetric. To remove the asymmetry, roll the interval around into a loop where the beginning point $0$ meets the end point $1:$
Geometrically, all its points are equivalent.
We can do the same in higher dimensions by rolling up each coordinate separately into a loop. The result in dimension $d$ is the $d$-torus. It has no boundaries and all points are geometrically equivalent. It's not perfectly symmetrical like a sphere, though: unlike the (Euclidean) sphere, whose geometry no longer is Euclidean due to its curvature, these $d$-tori are flat, without curvature. They can give us insight into Euclidean distances without the complication of dealing with boundaries.
Analytical study of the distances in a torus is complicated, at least for dimensions greater than $1.$ Let's study these distances by generating random points from the uniform distribution on a $d$-torus and computing all their mutual distances (apart from the necessarily zero distances between each point and itself). For the following figures I generated 500 points in each of eight separate dimensions, resulting in over 100,000 distances in each dataset. How are these distances distributed and how do those distributions vary with the dimension $d$?
Here is an array of histograms of these distances, one per dimension.
It's not hard to prove mathematically what the eye already sees: the distributions tend to a Gaussian, or "Normal," shape, as the dimension increases.
There is another remarkable regularity: the spreads of these histograms are nearly constant. Beneath each I have printed the standard deviation (SD) of the distances. It hardly changes from $1$ through $128$ dimensions. In this sense, there is no "concentration" of distances in high dimensions at all!
Here are the same figures shown on a common plot for easier comparison:
The colors mean the same as before, showing that the average distances increase with dimension. They do so roughly with a square-root law: the average distance is about one-quarter the square root of the dimension. (Those familiar with the Pythagorean Theorem in higher dimensions will at once understand why.) The greatest possible distance in the $d$-torus is achieved by pairs of points whose coordinates all differ by $1/2$ (because you cannot get any further apart than that along a loop); that distance obviously is $\sqrt{d}/2.$
Thus, it makes sense to compare the relative distances in each dimension. Here we go with one more plot of the same datasets, now with the distances all divided by $\sqrt{d}/2:$
This normalization has centered the histograms near $0.58,$ regardless of dimension. Here we are looking at the clearest manifestation of a "concentration of distance:" although the relative distances are typically the same in each dimension, as the dimension increases the distances concentrate more closely around a central value. As you can tell from the posted standard deviations, they too enjoy an inverse square-root law: the spread of the relative distances is approximately $1/(4\sqrt{d}).$
In other words, around any given point on a high-dimensional torus (and all points are geometrically the same, so it doesn't matter which point), nearly all other points on the torus are nearly the same distance away! If you were an inhabitant of a high-dimensional flat Euclidean space, albeit one with no boundaries, most of that space would seem to lie close to a spherical shell surrounding you. In $d$ = a million dimensions, for instance, the maximum possible distance is $500,$ the average distance would be around $288.7,$ and virtually all distances would be within $0.5$ of that value.
All these general conclusions about the shape, typical value, and spread of Euclidean distances hold in other domain shapes, but the details vary. The general result, though, is that randomly selected points within reasonably compact high-dimensional domains tend not to cluster appreciably. This has obvious implications for statistical (and machine-learning) methods based on clustering and nearest neighbor analyses.
|
Mathematical demonstration of the distance concentration in high dimensions
|
There is a simple mathematical thought experiment that sheds light on this phenomenon, although it might not seem immediately applicable. I will therefore describe this experiment briefly and follow
|
Mathematical demonstration of the distance concentration in high dimensions
There is a simple mathematical thought experiment that sheds light on this phenomenon, although it might not seem immediately applicable. I will therefore describe this experiment briefly and follow that, in a separate section, by a computer analysis of a concrete situation.
A Thought Experiment
An old cartographic chestnut is that most of the area of a map lies near its edges. Similarly, much of a pizza--more than you might think--consists of its crust. Even more so is the fact that a great deal of the volume of a thick-skinned fruit, like a grapefruit or watermelon, is in its skin.
More than half this pizza lies near its edge, outside the shaded area. However, the width of this "crust" is only $18\%$ of the diameter of the pie.
Maps and pizzas and grapefruits don't have a common shape, but there is a common underlying explanation. We may model the border of a map, the crust of a pizza, or the skin of a fruit by supposing its basic shape -- a rectangle, circle, sphere, or whatever -- has been shrunk uniformly by some factor $\alpha$ and that the "crust" or "rind" consists of what lies between these two concentric similar shapes.
In $n$ dimensions (the examples involve $n=2$ or $n=3$), the $n$-dimensional volume of the interior will therefore be $\alpha^n$ times the volume of the original shape. (This volume scaling law is sometimes used to define the number of dimensions of a space.) The volume of the rind relative to the original volume therefore is
$$1 - \alpha^n.$$
As a function of $\alpha$ its rate of growth is
$$\mathrm{d}(1 - \alpha^n) = -n\,\alpha^{n-1}\,\mathrm{d}\alpha.$$
Beginning with no shrinking ($\alpha=1$) and noting $\alpha$ is decreasing ($\mathrm{d}\alpha$ is negative), we find the initial rate of growth of the rind equals $n.$
This shows that the volume of the rind initially grows much faster -- $n$ times faster -- than the rate at which the object is being shrunk. The factor of $n$ implies
in higher dimensions, relatively tiny changes in distance translate to much larger changes in volume.
Let's call this the "edge-of-map principle."
Consider, now, a tabular dataset consisting of observations of $n$ numerical features. We may view each observation as a point in $\mathbb{R}^n$ and (at least in our imagination) might also suppose this collection of points is contained within some kind of compact region $\mathcal D$ with relatively simple boundary.
If we choose to use Euclidean distances to compare these points to each other (and to other points in $\mathcal D$) and consider an arbitrary observation $x,$ the edge-of-map principle implies that most of the room in $\mathcal D$ is nearly as far as possible from $x.$ (The fudge term "nearly" is needed to account for what goes on around the boundary of $\mathcal D.$)
Another implication that goes to the heart of the question is the generalization of the cartographer's quandary: if our observations are somewhat "spread out" over $\mathcal D,$ then the cartographer's question is "what proportion of this dataset is near the boundary?" To express this in a quantitative fashion, let's invert it: we ask, by how much should we shrink $\mathcal D$ to make it, say, only half its original volume? Let's call this the "half-length" of $\mathcal D,$ analogously to the half-life of a radioactive decay.
If the half-length is $\alpha,$ we need only solve the equation
$$\alpha^n = \frac{1}{2};\quad \alpha = 2^{-1/n} = e^{-(\log 2)/n} \approx 1 - \frac{\log 2}{n} \approx 1 - \frac{0.7}{n}.$$
In two dimensions the half-length is $1 - 0.35.$ Since half of the shrinking occurs on one side of the map or pizza and the other half on the other side (refer to the preceding figure), half of the area of a map ($n=2$) lies within (approximately) $35/2=18\%$ of its diameter from the boundary.
In three dimensions the half-length is $1 - 0.23:$ now, half the volume of a fruit lies within $12\%$ of its diameter from its boundary. A fruit whose skin is just one-eighth the width of the entire fruit is more than half skin.
Despite appearances, approximately half the volume of this grapefruit is rind. (Source: FreeDigitalPhotos.net.)
In very large dimensions the half-length is very close to $1.$ In $n=350$ dimensions it is greater than $98\%,$ within two percent of $1.$ Thus, expect half of any $350$-dimensional dataset to lie within $1\%$ of its diameter from its boundary. Unless the data are strongly clustered, this generalization will be accurate.
Another way to express these results is:
Absent strong clustering, in higher dimensions $n$ we can expect most Euclidean distances between observations in a dataset to be very nearly the same and to be very close to the diameter of the region in which they are enclosed. "Very close" means on the order of $1/n.$
Several parts of this analysis are really just hand-waving and approximations, due to the vagueness of $\mathcal D$ and the very general assumptions about the dataset. How is $\mathcal D$ defined, anyway? In some applications it is determined by inherent limits; for instance, when all features are proportions. In many applications the features are arbitrarily scaled to lie within a fixed interval ("normalized") and we often take $\mathcal D$ to be the corresponding hypercube. But that's only an artifice and it is exquisitely sensitive to any outlying data values. The rest of this post explores an alternative in which the boundary plays a less important role in the results. It comes to similar conclusions.
Analysis of distances in a closed Euclidean space
I find the paper's setting rather arbitrary, because it is exploring distances within unit cubes. The distance distributions depend strongly on the shapes of the boundaries of those cubes.
There's a way to avoid boundary effects. In one dimension, the "cube" is just the unit interval, $[0,1].$
Because this interval has two ends, some of the points are far from the rest; others (near the middle) tend to be close to all the points. This is asymmetric. To remove the asymmetry, roll the interval around into a loop where the beginning point $0$ meets the end point $1:$
Geometrically, all its points are equivalent.
We can do the same in higher dimensions by rolling up each coordinate separately into a loop. The result in dimension $d$ is the $d$-torus. It has no boundaries and all points are geometrically equivalent. It's not perfectly symmetrical like a sphere, though: unlike the (Euclidean) sphere, whose geometry no longer is Euclidean due to its curvature, these $d$-tori are flat, without curvature. They can give us insight into Euclidean distances without the complication of dealing with boundaries.
Analytical study of the distances in a torus is complicated, at least for dimensions greater than $1.$ Let's study these distances by generating random points from the uniform distribution on a $d$-torus and computing all their mutual distances (apart from the necessarily zero distances between each point and itself). For the following figures I generated 500 points in each of eight separate dimensions, resulting in over 100,000 distances in each dataset. How are these distances distributed and how do those distributions vary with the dimension $d$?
Here is an array of histograms of these distances, one per dimension.
It's not hard to prove mathematically what the eye already sees: the distributions tend to a Gaussian, or "Normal," shape, as the dimension increases.
There is another remarkable regularity: the spreads of these histograms are nearly constant. Beneath each I have printed the standard deviation (SD) of the distances. It hardly changes from $1$ through $128$ dimensions. In this sense, there is no "concentration" of distances in high dimensions at all!
Here are the same figures shown on a common plot for easier comparison:
The colors mean the same as before, showing that the average distances increase with dimension. They do so roughly with a square-root law: the average distance is about one-quarter the square root of the dimension. (Those familiar with the Pythagorean Theorem in higher dimensions will at once understand why.) The greatest possible distance in the $d$-torus is achieved by pairs of points whose coordinates all differ by $1/2$ (because you cannot get any further apart than that along a loop); that distance obviously is $\sqrt{d}/2.$
Thus, it makes sense to compare the relative distances in each dimension. Here we go with one more plot of the same datasets, now with the distances all divided by $\sqrt{d}/2:$
This normalization has centered the histograms near $0.58,$ regardless of dimension. Here we are looking at the clearest manifestation of a "concentration of distance:" although the relative distances are typically the same in each dimension, as the dimension increases the distances concentrate more closely around a central value. As you can tell from the posted standard deviations, they too enjoy an inverse square-root law: the spread of the relative distances is approximately $1/(4\sqrt{d}).$
In other words, around any given point on a high-dimensional torus (and all points are geometrically the same, so it doesn't matter which point), nearly all other points on the torus are nearly the same distance away! If you were an inhabitant of a high-dimensional flat Euclidean space, albeit one with no boundaries, most of that space would seem to lie close to a spherical shell surrounding you. In $d$ = a million dimensions, for instance, the maximum possible distance is $500,$ the average distance would be around $288.7,$ and virtually all distances would be within $0.5$ of that value.
All these general conclusions about the shape, typical value, and spread of Euclidean distances hold in other domain shapes, but the details vary. The general result, though, is that randomly selected points within reasonably compact high-dimensional domains tend not to cluster appreciably. This has obvious implications for statistical (and machine-learning) methods based on clustering and nearest neighbor analyses.
|
Mathematical demonstration of the distance concentration in high dimensions
There is a simple mathematical thought experiment that sheds light on this phenomenon, although it might not seem immediately applicable. I will therefore describe this experiment briefly and follow
|
15,210
|
Mathematical demonstration of the distance concentration in high dimensions
|
Note that this depends on a) the distance measure (you are probably referring to the Euclidean distance) and b) the underlying measure/probability distribution, according to which you specify what "almost all" means. Surely all kinds of values and distributions for the distances are possible if you don't specify these.
That said, for a derivation of required conditions see:
Hall, P., Marron, J.S., Neeman, A.: Geometric Representation of High Dimension Low Sample Size Data. J. Roy. Stat. Soc. B67, 427–444 (2005),
https://www.jstor.org/stable/3647669?seq=1
Ahn, J., Marron, J.S., Muller, K.M., Chi, Y.-Y.: The High Dimension, Low Sample Size Geometric Representation Holds Under Mild Conditions. Biometrika94, 760–766 (2007)
https://www.jstor.org/stable/20441411?seq=1
|
Mathematical demonstration of the distance concentration in high dimensions
|
Note that this depends on a) the distance measure (you are probably referring to the Euclidean distance) and b) the underlying measure/probability distribution, according to which you specify what "al
|
Mathematical demonstration of the distance concentration in high dimensions
Note that this depends on a) the distance measure (you are probably referring to the Euclidean distance) and b) the underlying measure/probability distribution, according to which you specify what "almost all" means. Surely all kinds of values and distributions for the distances are possible if you don't specify these.
That said, for a derivation of required conditions see:
Hall, P., Marron, J.S., Neeman, A.: Geometric Representation of High Dimension Low Sample Size Data. J. Roy. Stat. Soc. B67, 427–444 (2005),
https://www.jstor.org/stable/3647669?seq=1
Ahn, J., Marron, J.S., Muller, K.M., Chi, Y.-Y.: The High Dimension, Low Sample Size Geometric Representation Holds Under Mild Conditions. Biometrika94, 760–766 (2007)
https://www.jstor.org/stable/20441411?seq=1
|
Mathematical demonstration of the distance concentration in high dimensions
Note that this depends on a) the distance measure (you are probably referring to the Euclidean distance) and b) the underlying measure/probability distribution, according to which you specify what "al
|
15,211
|
Can I use a tiny Validation set?
|
Larger validation sets give more accurate estimates of out-of-sample performance. But as you've noticed, at some point that estimate might be as accurate as you need it to be, and you can make some rough predictions as to the validation sample size you need to reach that point.
For simple correct/incorrect classification accuracy, you can calculate the standard error of the estimate as $\sqrt{p(1−p)/n}$ (standard deviation of a Bernouilli variable), where $p$ is the probability of a correct classification, and $n$ is the size of the validation set. Of course you don't know $p$, but you might have some idea of its range. E.g. let's say you expect an accuracy between 60-80%, and you want your estimates to have a standard error smaller than 0.1%:
$$
\sqrt{p(1−p)/n}<0.001
$$
How large should $n$ (the size of the validation set) be? For $p=0.6$ we get:
$$
n > \frac{0.6-0.6^2}{0.001^2}=240,000
$$
For $p=0.8$ we get:
$$
n > \frac{0.8-0.8^2}{0.001^2}=160,000
$$
So this tells us you could get away with using less than 5% of your 5 million data samples, for validation. This percentage goes down if you expect higher performance, or especially if you are satisfied with a lower standard error of your out-of-sample performance estimate (e.g. with $p=0.7$ and for a s.e. < 1%, you need only 2100 validation samples, or less than a twentieth of a percent of your data).
These calculations also showcase the point made by Tim in his answer, that the accuracy of your estimates depends on the absolute size of your validation set (i.e. on $n$), rather than its size relative to the training set.
(Also I might add that I'm assuming representative sampling here. If your data are very heterogeneous you might need to use larger validation sets just to make sure that the validation data includes all the same conditions etc. as your train & test data.)
|
Can I use a tiny Validation set?
|
Larger validation sets give more accurate estimates of out-of-sample performance. But as you've noticed, at some point that estimate might be as accurate as you need it to be, and you can make some ro
|
Can I use a tiny Validation set?
Larger validation sets give more accurate estimates of out-of-sample performance. But as you've noticed, at some point that estimate might be as accurate as you need it to be, and you can make some rough predictions as to the validation sample size you need to reach that point.
For simple correct/incorrect classification accuracy, you can calculate the standard error of the estimate as $\sqrt{p(1−p)/n}$ (standard deviation of a Bernouilli variable), where $p$ is the probability of a correct classification, and $n$ is the size of the validation set. Of course you don't know $p$, but you might have some idea of its range. E.g. let's say you expect an accuracy between 60-80%, and you want your estimates to have a standard error smaller than 0.1%:
$$
\sqrt{p(1−p)/n}<0.001
$$
How large should $n$ (the size of the validation set) be? For $p=0.6$ we get:
$$
n > \frac{0.6-0.6^2}{0.001^2}=240,000
$$
For $p=0.8$ we get:
$$
n > \frac{0.8-0.8^2}{0.001^2}=160,000
$$
So this tells us you could get away with using less than 5% of your 5 million data samples, for validation. This percentage goes down if you expect higher performance, or especially if you are satisfied with a lower standard error of your out-of-sample performance estimate (e.g. with $p=0.7$ and for a s.e. < 1%, you need only 2100 validation samples, or less than a twentieth of a percent of your data).
These calculations also showcase the point made by Tim in his answer, that the accuracy of your estimates depends on the absolute size of your validation set (i.e. on $n$), rather than its size relative to the training set.
(Also I might add that I'm assuming representative sampling here. If your data are very heterogeneous you might need to use larger validation sets just to make sure that the validation data includes all the same conditions etc. as your train & test data.)
|
Can I use a tiny Validation set?
Larger validation sets give more accurate estimates of out-of-sample performance. But as you've noticed, at some point that estimate might be as accurate as you need it to be, and you can make some ro
|
15,212
|
Can I use a tiny Validation set?
|
Nice discussion of this problem is provided by Andrew Ng on his Deep Learning course on Coursera.org. As he notes, the standard splits like 8:2, or 9:1 are valid if your data is small to moderately big, but many present day machine learning problems use huge amounts of data (e.g. millions of observations as in your case), and in such scenario you could leave 2%, 1%, or even less of the data as a test set, taking all the remaining data for your training set (he actually argues for using also a dev set). As he argues, the more data you feed your algorithm, the better for its performance and this is especially true for deep learning* (he also notes that this must not be the cases for non-deep learning machine learning algorithms).
As already noticed in comment by Alex Burn, it is not really about size of your test set, but about its representativeness for your problem. Usually with larger size of the data we hope for it to be more representative, but this does not have to be the case. This is always a trade-off and you need to make problem-specific considerations. There is no rules telling that test set should not be less then X cases, or less then Y% of your data.
* - Disclaimer: I am repeating Andrew Ng's arguments in here, I wouldn't consider myself as a specialist in deep learning.
|
Can I use a tiny Validation set?
|
Nice discussion of this problem is provided by Andrew Ng on his Deep Learning course on Coursera.org. As he notes, the standard splits like 8:2, or 9:1 are valid if your data is small to moderately bi
|
Can I use a tiny Validation set?
Nice discussion of this problem is provided by Andrew Ng on his Deep Learning course on Coursera.org. As he notes, the standard splits like 8:2, or 9:1 are valid if your data is small to moderately big, but many present day machine learning problems use huge amounts of data (e.g. millions of observations as in your case), and in such scenario you could leave 2%, 1%, or even less of the data as a test set, taking all the remaining data for your training set (he actually argues for using also a dev set). As he argues, the more data you feed your algorithm, the better for its performance and this is especially true for deep learning* (he also notes that this must not be the cases for non-deep learning machine learning algorithms).
As already noticed in comment by Alex Burn, it is not really about size of your test set, but about its representativeness for your problem. Usually with larger size of the data we hope for it to be more representative, but this does not have to be the case. This is always a trade-off and you need to make problem-specific considerations. There is no rules telling that test set should not be less then X cases, or less then Y% of your data.
* - Disclaimer: I am repeating Andrew Ng's arguments in here, I wouldn't consider myself as a specialist in deep learning.
|
Can I use a tiny Validation set?
Nice discussion of this problem is provided by Andrew Ng on his Deep Learning course on Coursera.org. As he notes, the standard splits like 8:2, or 9:1 are valid if your data is small to moderately bi
|
15,213
|
Can I use a tiny Validation set?
|
In the article Asymptotic Statistical Theory of Overtraining and Cross-Validation by Shun-ichi Amari et al. [1] they study the optimal amount of samples to leave out as a validation set (for the purpose of early stopping) and conclude that the optimal split is $1/\sqrt{2N}$, where $N$ is the number of samples available. In your case $N=5\cdot10^6$ and the optimal split is $\approx 0.00032=0.032\%$. According to the formula 1580 samples should be optimal in your case.
[1] https://www.ncbi.nlm.nih.gov/pubmed/18255701
|
Can I use a tiny Validation set?
|
In the article Asymptotic Statistical Theory of Overtraining and Cross-Validation by Shun-ichi Amari et al. [1] they study the optimal amount of samples to leave out as a validation set (for the purpo
|
Can I use a tiny Validation set?
In the article Asymptotic Statistical Theory of Overtraining and Cross-Validation by Shun-ichi Amari et al. [1] they study the optimal amount of samples to leave out as a validation set (for the purpose of early stopping) and conclude that the optimal split is $1/\sqrt{2N}$, where $N$ is the number of samples available. In your case $N=5\cdot10^6$ and the optimal split is $\approx 0.00032=0.032\%$. According to the formula 1580 samples should be optimal in your case.
[1] https://www.ncbi.nlm.nih.gov/pubmed/18255701
|
Can I use a tiny Validation set?
In the article Asymptotic Statistical Theory of Overtraining and Cross-Validation by Shun-ichi Amari et al. [1] they study the optimal amount of samples to leave out as a validation set (for the purpo
|
15,214
|
How to perform PCA for data of very high dimensionality?
|
The easiest way to do standard PCA is to center the columns of your data matrix (assuming the columns correspond to different variables) by subtracting the column means, and then perform an SVD. The left singular vectors, multiplied by the corresponding singular value, correspond to the (estimated) principal components. The right singular vectors correspond to the (estimated) principal component directions — these are the same as the eigenvectors given by PCA. The singular values correspond to the standard deviations of the principal components (multiplied by a factor of root n, where n is the number of rows in your data matrix) — the same as the square root of the eigenvalues given by PCA.
If you want to do PCA on the correlation matrix, you will need to standardize the columns of your data matrix before applying the SVD. This amounts to subtracting the means (centering) and then dividing by the standard deviations (scaling).
This will be the most efficient approach if you want the full PCA. You can verify with some algebra that this gives you the same answer as doing the spectral decomposition of the sample covariance matrix.
There are also efficient methods for computing a partial SVD, when you only need a few of the PCs. Some of these are variants of the power iteration. The Lanczos algorithm is one example that is also related to partial least squares. If your matrix is huge, you may be better off with an approximate method. There are also statistical reasons for regularizing PCA when this is the case.
|
How to perform PCA for data of very high dimensionality?
|
The easiest way to do standard PCA is to center the columns of your data matrix (assuming the columns correspond to different variables) by subtracting the column means, and then perform an SVD. The
|
How to perform PCA for data of very high dimensionality?
The easiest way to do standard PCA is to center the columns of your data matrix (assuming the columns correspond to different variables) by subtracting the column means, and then perform an SVD. The left singular vectors, multiplied by the corresponding singular value, correspond to the (estimated) principal components. The right singular vectors correspond to the (estimated) principal component directions — these are the same as the eigenvectors given by PCA. The singular values correspond to the standard deviations of the principal components (multiplied by a factor of root n, where n is the number of rows in your data matrix) — the same as the square root of the eigenvalues given by PCA.
If you want to do PCA on the correlation matrix, you will need to standardize the columns of your data matrix before applying the SVD. This amounts to subtracting the means (centering) and then dividing by the standard deviations (scaling).
This will be the most efficient approach if you want the full PCA. You can verify with some algebra that this gives you the same answer as doing the spectral decomposition of the sample covariance matrix.
There are also efficient methods for computing a partial SVD, when you only need a few of the PCs. Some of these are variants of the power iteration. The Lanczos algorithm is one example that is also related to partial least squares. If your matrix is huge, you may be better off with an approximate method. There are also statistical reasons for regularizing PCA when this is the case.
|
How to perform PCA for data of very high dimensionality?
The easiest way to do standard PCA is to center the columns of your data matrix (assuming the columns correspond to different variables) by subtracting the column means, and then perform an SVD. The
|
15,215
|
How to perform PCA for data of very high dimensionality?
|
What you're doing right now is close, but you need to make sure you multiply the eigenvectors of (data . data.T) / lines on the left by data.T, in order to get the eigenvectors of (data.T . data) / lines. This is sometimes called the "transpose trick".
Here are some more details. Suppose you have a matrix $A$ that you want to perform PCA on; for simplicity, suppose that the columns of $A$ have already been normalized to have zero mean, so that we just need to compute the eigenvectors of the covariance matrix $A^T A$.
Now if $A$ is an $m \times n$ matrix, with $n >> m$, then $A^T A$ is a very large $n \times n$ matrix. So instead of computing the eigenvectors of $A^T A$, we might like to compute the eigenvectors of the much smaller $m \times m$ matrix $A A^T$ -- assuming we can figure out a relationship between the two. So how are the eigenvectors of $A^T A$ related to the eigenvectors of $A A^T$?
Let $v$ be an eigenvector of $A A^T$ with eigenvalue $\lambda$. Then
$AA^T v = \lambda v$
$A^T(A A^T v) = A^T(\lambda v)$
$(A^T A)(A^T v) = \lambda (A^T v)$
In other words, if $v$ is an eigenvector of $A A^T$, then $A^T v$ is an eigenvector of $A^T A$, with the same eigenvalue. So when performing a PCA on $A$, instead of directly finding the eigenvectors of $A^T A$ (which may be very expensive), it's easier to find the eigenvectors $v$ of $AA^T$ and then multiply these on the left by $A^T$ to get the eigenvectors $A^T v$ of $A^T A$.
|
How to perform PCA for data of very high dimensionality?
|
What you're doing right now is close, but you need to make sure you multiply the eigenvectors of (data . data.T) / lines on the left by data.T, in order to get the eigenvectors of (data.T . data) / li
|
How to perform PCA for data of very high dimensionality?
What you're doing right now is close, but you need to make sure you multiply the eigenvectors of (data . data.T) / lines on the left by data.T, in order to get the eigenvectors of (data.T . data) / lines. This is sometimes called the "transpose trick".
Here are some more details. Suppose you have a matrix $A$ that you want to perform PCA on; for simplicity, suppose that the columns of $A$ have already been normalized to have zero mean, so that we just need to compute the eigenvectors of the covariance matrix $A^T A$.
Now if $A$ is an $m \times n$ matrix, with $n >> m$, then $A^T A$ is a very large $n \times n$ matrix. So instead of computing the eigenvectors of $A^T A$, we might like to compute the eigenvectors of the much smaller $m \times m$ matrix $A A^T$ -- assuming we can figure out a relationship between the two. So how are the eigenvectors of $A^T A$ related to the eigenvectors of $A A^T$?
Let $v$ be an eigenvector of $A A^T$ with eigenvalue $\lambda$. Then
$AA^T v = \lambda v$
$A^T(A A^T v) = A^T(\lambda v)$
$(A^T A)(A^T v) = \lambda (A^T v)$
In other words, if $v$ is an eigenvector of $A A^T$, then $A^T v$ is an eigenvector of $A^T A$, with the same eigenvalue. So when performing a PCA on $A$, instead of directly finding the eigenvectors of $A^T A$ (which may be very expensive), it's easier to find the eigenvectors $v$ of $AA^T$ and then multiply these on the left by $A^T$ to get the eigenvectors $A^T v$ of $A^T A$.
|
How to perform PCA for data of very high dimensionality?
What you're doing right now is close, but you need to make sure you multiply the eigenvectors of (data . data.T) / lines on the left by data.T, in order to get the eigenvectors of (data.T . data) / li
|
15,216
|
How to perform PCA for data of very high dimensionality?
|
It sounds like what you want is the NIPALS algorithm for performing PCA. It's a very popular algorithm among statisticians. It has many advantages:
Computationally less expensive than SVD or eigenvalue decomposition methods if only the first few components are required.
Has more modest storage requirements in general because the covariance matrix is never formed. This is a very important property for very large datasets.
Can handle missing data in the dataset (though that's not an issue in your problem, since you're dealing with images).
Description
http://en.wikipedia.org/wiki/Non-linear_iterative_partial_least_squares
Algorithm
Here's a simple and excellent description of the algorithm (in section 1.2)
http://stats4.eng.mcmaster.ca/w/mediafiles/mediawiki/f/f7/Section-Extra-Class-1.pdf
Remember to mean-center-scale first before doing PCA as it is scale-sensitive.
|
How to perform PCA for data of very high dimensionality?
|
It sounds like what you want is the NIPALS algorithm for performing PCA. It's a very popular algorithm among statisticians. It has many advantages:
Computationally less expensive than SVD or eigenval
|
How to perform PCA for data of very high dimensionality?
It sounds like what you want is the NIPALS algorithm for performing PCA. It's a very popular algorithm among statisticians. It has many advantages:
Computationally less expensive than SVD or eigenvalue decomposition methods if only the first few components are required.
Has more modest storage requirements in general because the covariance matrix is never formed. This is a very important property for very large datasets.
Can handle missing data in the dataset (though that's not an issue in your problem, since you're dealing with images).
Description
http://en.wikipedia.org/wiki/Non-linear_iterative_partial_least_squares
Algorithm
Here's a simple and excellent description of the algorithm (in section 1.2)
http://stats4.eng.mcmaster.ca/w/mediafiles/mediawiki/f/f7/Section-Extra-Class-1.pdf
Remember to mean-center-scale first before doing PCA as it is scale-sensitive.
|
How to perform PCA for data of very high dimensionality?
It sounds like what you want is the NIPALS algorithm for performing PCA. It's a very popular algorithm among statisticians. It has many advantages:
Computationally less expensive than SVD or eigenval
|
15,217
|
How to perform PCA for data of very high dimensionality?
|
To add on Gilead's answer, they are computationally less expensive algorithms for truncated PCAs. NIPALS is indeed very popular, but I have had a lot of success with approximate methods that perform a succession of fits on partial data (what is often called PCA by random projection). This was discussed in a metaoptimize thread.
As you mention Python, let me point out that the algorithm is implemented in the scikit-learn: the PCA class. In particular, it is used in an example demonstrating eigenfaces.
|
How to perform PCA for data of very high dimensionality?
|
To add on Gilead's answer, they are computationally less expensive algorithms for truncated PCAs. NIPALS is indeed very popular, but I have had a lot of success with approximate methods that perform a
|
How to perform PCA for data of very high dimensionality?
To add on Gilead's answer, they are computationally less expensive algorithms for truncated PCAs. NIPALS is indeed very popular, but I have had a lot of success with approximate methods that perform a succession of fits on partial data (what is often called PCA by random projection). This was discussed in a metaoptimize thread.
As you mention Python, let me point out that the algorithm is implemented in the scikit-learn: the PCA class. In particular, it is used in an example demonstrating eigenfaces.
|
How to perform PCA for data of very high dimensionality?
To add on Gilead's answer, they are computationally less expensive algorithms for truncated PCAs. NIPALS is indeed very popular, but I have had a lot of success with approximate methods that perform a
|
15,218
|
How to perform PCA for data of very high dimensionality?
|
If it helps someone, just adding on top of @raegtin's post, the following R code demonstrates how high-dimensional PCA can be done faster and more efficiently.
For the following matrix $A_{m\times n}$ with $n>>m$, the matrix $A^TA$ is a $n\times n$ matrix and not a full-rank matrix, having rank $=m$, so that only the first $m$ eigenvalues are non-zero.
Whereas $AA^T$ is a $m \times m$ matrix, which is a full-rank matrix, again with rank $m$ and $A^Tv$ is an eigenvector of $A^TA$ when $v$ is an eigenvector of $AA^T$. But we have to keep in mind that $A^Tv$ computed that way will not be of unit length, so we need to normalize the eigenvectors computed this way.
m <- 10
n <- 1000
A <- matrix(rnorm(m*n), m, n)
AtA <- t(A) %*% A
dim(AtA)
# [1] 1000 1000
qr(AtA)$rank
# [1] 10
AAt <- A %*% t(A)
dim(AAt)
# [1] 10 10
qr(AAt)$rank
# [1] 10
# eigenvalues and eigenvectors
res <- eigen(AtA)
val1 <- res$values
vec1 <- res$vectors
res <- eigen(AAt)
val2 <- res$values
vec2 <- res$vectors
vec2 <- t(A) %*% vec2
# eigenvalues
length(val1)
# [1] 1000
length(val2)
# [1] 10
val1 <- round(val1, 3)
val2 <- round(val2, 3)
val1
# [1] 1154.743 1098.774 1075.320 1049.960 1035.392 996.713 943.589 924.477 886.510 814.518
# 0.000 0.000 0.000 0.000 0.000 0.000 ...
val2
# [1] 1154.743 1098.774 1075.320 1049.960 1035.392 996.713 943.589 924.477 886.510 814.518
all.equal(val1[1:10], val2)
# [1] TRUE
# eigenvectors
sqrt(sum(vec1[,1]^2))
# [1] 1
sqrt(sum(vec2[,1]^2))
# [1] 33.9815
# normalize eigenvectors
vec2 <- apply(vec2, 2, function(x) x / sqrt(sum(x^2)))
sqrt(sum(vec2[,1]^2))
# [1] 1
# compare run times
library(microbenchmark)
library(ggplot2)
mbm <- microbenchmark("PCA_AtA" = {
res <- eigen(AtA)
val1 <- res$values
vec1 <- res$vectors
},
"PCA_AAt" = {
res <- eigen(AAt)
val2 <- res$values
vec2 <- res$vectors
vec2 <- t(A) %*% vec2
})
autoplot(mbm)
|
How to perform PCA for data of very high dimensionality?
|
If it helps someone, just adding on top of @raegtin's post, the following R code demonstrates how high-dimensional PCA can be done faster and more efficiently.
For the following matrix $A_{m\times n}$
|
How to perform PCA for data of very high dimensionality?
If it helps someone, just adding on top of @raegtin's post, the following R code demonstrates how high-dimensional PCA can be done faster and more efficiently.
For the following matrix $A_{m\times n}$ with $n>>m$, the matrix $A^TA$ is a $n\times n$ matrix and not a full-rank matrix, having rank $=m$, so that only the first $m$ eigenvalues are non-zero.
Whereas $AA^T$ is a $m \times m$ matrix, which is a full-rank matrix, again with rank $m$ and $A^Tv$ is an eigenvector of $A^TA$ when $v$ is an eigenvector of $AA^T$. But we have to keep in mind that $A^Tv$ computed that way will not be of unit length, so we need to normalize the eigenvectors computed this way.
m <- 10
n <- 1000
A <- matrix(rnorm(m*n), m, n)
AtA <- t(A) %*% A
dim(AtA)
# [1] 1000 1000
qr(AtA)$rank
# [1] 10
AAt <- A %*% t(A)
dim(AAt)
# [1] 10 10
qr(AAt)$rank
# [1] 10
# eigenvalues and eigenvectors
res <- eigen(AtA)
val1 <- res$values
vec1 <- res$vectors
res <- eigen(AAt)
val2 <- res$values
vec2 <- res$vectors
vec2 <- t(A) %*% vec2
# eigenvalues
length(val1)
# [1] 1000
length(val2)
# [1] 10
val1 <- round(val1, 3)
val2 <- round(val2, 3)
val1
# [1] 1154.743 1098.774 1075.320 1049.960 1035.392 996.713 943.589 924.477 886.510 814.518
# 0.000 0.000 0.000 0.000 0.000 0.000 ...
val2
# [1] 1154.743 1098.774 1075.320 1049.960 1035.392 996.713 943.589 924.477 886.510 814.518
all.equal(val1[1:10], val2)
# [1] TRUE
# eigenvectors
sqrt(sum(vec1[,1]^2))
# [1] 1
sqrt(sum(vec2[,1]^2))
# [1] 33.9815
# normalize eigenvectors
vec2 <- apply(vec2, 2, function(x) x / sqrt(sum(x^2)))
sqrt(sum(vec2[,1]^2))
# [1] 1
# compare run times
library(microbenchmark)
library(ggplot2)
mbm <- microbenchmark("PCA_AtA" = {
res <- eigen(AtA)
val1 <- res$values
vec1 <- res$vectors
},
"PCA_AAt" = {
res <- eigen(AAt)
val2 <- res$values
vec2 <- res$vectors
vec2 <- t(A) %*% vec2
})
autoplot(mbm)
|
How to perform PCA for data of very high dimensionality?
If it helps someone, just adding on top of @raegtin's post, the following R code demonstrates how high-dimensional PCA can be done faster and more efficiently.
For the following matrix $A_{m\times n}$
|
15,219
|
Speed in m/s is normally distributed, but same data expressed as "Time for 10 meters" is not
|
The image below illustrates intuitively why the transformed variable has a different distribution:
I have drawn two parallel lines.
On the lowest line I have plotted evenly spaced points at $0.1, 0.2, ..., 1.1, 1.2$ which represent the velocity $v$.
On the upper line I have draw points according to the formula $t=0.1/v$ (note I reversed the axis it has 1.2 on the left and 0 on the right)
I have drawn lines connecting the different points. You can see that the evenly spaced points $v$ are not transforming into evenly spaced points $t$ but instead the points are more dense in the low values than in the high values.
This squeezing will happen also to the density distribution. The distribution of times $t$ will not be just the same as the distribution of $v$ with a transformed location. Instead you also get a factor that is based on how much the space gets stretched out or squeezed in.
For instance: The region $0.1 < v < 0.2$ gets spread out over a region $0.5 < t <1$ which is a region with a larger size. So the same probability to fall into a specific region gets spread out over a region with larger size.
Another example: The region $0.4 < v < 0.5$ gets squeezed into a region $0.2 < t <0.25$ which is a region with a smaller size. So the same probability to fall into a specific region gets compressed into a region with smaller size.
In the image below these two corresponding regions $0.4 < v < 0.5$ and $0.2 < t <0.25$ and the area under the density curves are colored, the two different colored areas have the same area size.
So as the distribution for the times $g(t)$ you do not just take the distribution of the velocity $f(v)$ where you transform the variable $v=0.1/t$ (which actually already make the distribution look different than the normal curve, see the green curve in the image), but you also take into account the spreading/compressing of the probability mass over larger/smaller regions.
note: I have taken $t=0.1/v$ instead of $t = 100/v$ because this makes the two scales the same and makes the comparison of the two densities equivalent (when you squeeze an image then this will influence the density).
See more about transformations:
https://en.wikipedia.org/wiki/Random_variable#Functions_of_random_variables
The inverse of a normal distributed variable is more generally:
$$t = a/v \quad \text{with} \quad f_V(v) = \frac{1}{\sqrt{2 \pi \sigma^2}} e^{-\frac{1}{2}\frac{(v-\mu)^2}{\sigma^2}}$$
then
$$g_T(t) = \frac{1}{\sqrt{2 \pi \sigma^2}} \frac{a}{t^2} e^{-\frac{1}{2}\frac{(a/t-\mu)^2}{\sigma^2}}$$
you can find more about it by looking for the search term 'reciprocal normal distribution' https://math.stackexchange.com/search?q=reciprocal+normal+distribution
It is not the same as 'inverse Gaussian distribution', which relates to the waiting time in relation to Brownian motion with drift (which can be described by a Gaussian curve).
|
Speed in m/s is normally distributed, but same data expressed as "Time for 10 meters" is not
|
The image below illustrates intuitively why the transformed variable has a different distribution:
I have drawn two parallel lines.
On the lowest line I have plotted evenly spaced points at $0.1, 0.2
|
Speed in m/s is normally distributed, but same data expressed as "Time for 10 meters" is not
The image below illustrates intuitively why the transformed variable has a different distribution:
I have drawn two parallel lines.
On the lowest line I have plotted evenly spaced points at $0.1, 0.2, ..., 1.1, 1.2$ which represent the velocity $v$.
On the upper line I have draw points according to the formula $t=0.1/v$ (note I reversed the axis it has 1.2 on the left and 0 on the right)
I have drawn lines connecting the different points. You can see that the evenly spaced points $v$ are not transforming into evenly spaced points $t$ but instead the points are more dense in the low values than in the high values.
This squeezing will happen also to the density distribution. The distribution of times $t$ will not be just the same as the distribution of $v$ with a transformed location. Instead you also get a factor that is based on how much the space gets stretched out or squeezed in.
For instance: The region $0.1 < v < 0.2$ gets spread out over a region $0.5 < t <1$ which is a region with a larger size. So the same probability to fall into a specific region gets spread out over a region with larger size.
Another example: The region $0.4 < v < 0.5$ gets squeezed into a region $0.2 < t <0.25$ which is a region with a smaller size. So the same probability to fall into a specific region gets compressed into a region with smaller size.
In the image below these two corresponding regions $0.4 < v < 0.5$ and $0.2 < t <0.25$ and the area under the density curves are colored, the two different colored areas have the same area size.
So as the distribution for the times $g(t)$ you do not just take the distribution of the velocity $f(v)$ where you transform the variable $v=0.1/t$ (which actually already make the distribution look different than the normal curve, see the green curve in the image), but you also take into account the spreading/compressing of the probability mass over larger/smaller regions.
note: I have taken $t=0.1/v$ instead of $t = 100/v$ because this makes the two scales the same and makes the comparison of the two densities equivalent (when you squeeze an image then this will influence the density).
See more about transformations:
https://en.wikipedia.org/wiki/Random_variable#Functions_of_random_variables
The inverse of a normal distributed variable is more generally:
$$t = a/v \quad \text{with} \quad f_V(v) = \frac{1}{\sqrt{2 \pi \sigma^2}} e^{-\frac{1}{2}\frac{(v-\mu)^2}{\sigma^2}}$$
then
$$g_T(t) = \frac{1}{\sqrt{2 \pi \sigma^2}} \frac{a}{t^2} e^{-\frac{1}{2}\frac{(a/t-\mu)^2}{\sigma^2}}$$
you can find more about it by looking for the search term 'reciprocal normal distribution' https://math.stackexchange.com/search?q=reciprocal+normal+distribution
It is not the same as 'inverse Gaussian distribution', which relates to the waiting time in relation to Brownian motion with drift (which can be described by a Gaussian curve).
|
Speed in m/s is normally distributed, but same data expressed as "Time for 10 meters" is not
The image below illustrates intuitively why the transformed variable has a different distribution:
I have drawn two parallel lines.
On the lowest line I have plotted evenly spaced points at $0.1, 0.2
|
15,220
|
Speed in m/s is normally distributed, but same data expressed as "Time for 10 meters" is not
|
Yes, this is an instance of inverse Gaussian. It has been observed that there is an inverse relationship between the cumulant generating function of the time to cover a unit distance and the cumulant generating function of the distance covered in a unit time. Because the distance covered in a unit time (in this case, walking speed) is approximately normal, then the time to cover a unit distance (which is roughly the first-hitting time of 1-dimensional Brownian particle) is by definition approximately inverse Gaussian.
|
Speed in m/s is normally distributed, but same data expressed as "Time for 10 meters" is not
|
Yes, this is an instance of inverse Gaussian. It has been observed that there is an inverse relationship between the cumulant generating function of the time to cover a unit distance and the cumulant
|
Speed in m/s is normally distributed, but same data expressed as "Time for 10 meters" is not
Yes, this is an instance of inverse Gaussian. It has been observed that there is an inverse relationship between the cumulant generating function of the time to cover a unit distance and the cumulant generating function of the distance covered in a unit time. Because the distance covered in a unit time (in this case, walking speed) is approximately normal, then the time to cover a unit distance (which is roughly the first-hitting time of 1-dimensional Brownian particle) is by definition approximately inverse Gaussian.
|
Speed in m/s is normally distributed, but same data expressed as "Time for 10 meters" is not
Yes, this is an instance of inverse Gaussian. It has been observed that there is an inverse relationship between the cumulant generating function of the time to cover a unit distance and the cumulant
|
15,221
|
What regression/estimation is not a MLE?
|
Least squares is indeed maximum likelihood if the errors are iid normal, but if they aren't iid normal, least squares is not maximum likelihood. For example if my errors were logistic, least squares wouldn't be a terrible idea but it wouldn't be maximum likelihood.
Lots of estimators are not maximum likelihood estimators; while maximum likelihood estimators typically have a number of useful and attractive properties they're not the only game in town (and indeed not even always a great idea).
A few examples of other estimation methods would include
method of moments (this involves equating enough sample and population moments to solve for parameter estimates; sometimes this turns out to be maximum likelihood but usually it doesn't)
For example, equating first and second moments to estimate the parameters of a gamma distribution or a uniform distribution; not maximum likelihood in either case.
method of quantiles (equating sufficient sample and population quantiles to solve for parameter estimates; occasionally this is maximum likelihood but usually it isn't),
minimizing some other measure of lack of fit than $-\log\mathcal{L}$ (e.g. minimum chi-square, minimum K-S distance).
With fitting linear regression type models, you could for example look at robust regression (some of which do correspond to ML methods for some particular error distribution but many of which do not).
In the case of simple linear regression, I show an example of two methods of fitting lines that are not maximum likelihood here - there estimating slope by setting to 0 some other measure of correlation (i.e. other than the usual Pearson) between residuals and the predictor.
Another example would be the Tukey's resistant line/Tukey's three group line (e.g. see ?line in R). There are many other possibilities, though many of them don't generalize readily to the multiple regression situation.
|
What regression/estimation is not a MLE?
|
Least squares is indeed maximum likelihood if the errors are iid normal, but if they aren't iid normal, least squares is not maximum likelihood. For example if my errors were logistic, least squares w
|
What regression/estimation is not a MLE?
Least squares is indeed maximum likelihood if the errors are iid normal, but if they aren't iid normal, least squares is not maximum likelihood. For example if my errors were logistic, least squares wouldn't be a terrible idea but it wouldn't be maximum likelihood.
Lots of estimators are not maximum likelihood estimators; while maximum likelihood estimators typically have a number of useful and attractive properties they're not the only game in town (and indeed not even always a great idea).
A few examples of other estimation methods would include
method of moments (this involves equating enough sample and population moments to solve for parameter estimates; sometimes this turns out to be maximum likelihood but usually it doesn't)
For example, equating first and second moments to estimate the parameters of a gamma distribution or a uniform distribution; not maximum likelihood in either case.
method of quantiles (equating sufficient sample and population quantiles to solve for parameter estimates; occasionally this is maximum likelihood but usually it isn't),
minimizing some other measure of lack of fit than $-\log\mathcal{L}$ (e.g. minimum chi-square, minimum K-S distance).
With fitting linear regression type models, you could for example look at robust regression (some of which do correspond to ML methods for some particular error distribution but many of which do not).
In the case of simple linear regression, I show an example of two methods of fitting lines that are not maximum likelihood here - there estimating slope by setting to 0 some other measure of correlation (i.e. other than the usual Pearson) between residuals and the predictor.
Another example would be the Tukey's resistant line/Tukey's three group line (e.g. see ?line in R). There are many other possibilities, though many of them don't generalize readily to the multiple regression situation.
|
What regression/estimation is not a MLE?
Least squares is indeed maximum likelihood if the errors are iid normal, but if they aren't iid normal, least squares is not maximum likelihood. For example if my errors were logistic, least squares w
|
15,222
|
What regression/estimation is not a MLE?
|
All MLE is minimax but not all minimax is MLE. Some examples of minimax estimators that do not maximize a likelihood are ROC regression, conditional logistic regression, Cox proportional hazards models, nearest neighbor, quasilikelihood, the list goes on and on. Hodge's "superefficient" estimator beats maximum likelihood as a more efficient UMVUE (unbiased minimum variance) estimator of the mean in a normal sample but it is NOT minimax
|
What regression/estimation is not a MLE?
|
All MLE is minimax but not all minimax is MLE. Some examples of minimax estimators that do not maximize a likelihood are ROC regression, conditional logistic regression, Cox proportional hazards model
|
What regression/estimation is not a MLE?
All MLE is minimax but not all minimax is MLE. Some examples of minimax estimators that do not maximize a likelihood are ROC regression, conditional logistic regression, Cox proportional hazards models, nearest neighbor, quasilikelihood, the list goes on and on. Hodge's "superefficient" estimator beats maximum likelihood as a more efficient UMVUE (unbiased minimum variance) estimator of the mean in a normal sample but it is NOT minimax
|
What regression/estimation is not a MLE?
All MLE is minimax but not all minimax is MLE. Some examples of minimax estimators that do not maximize a likelihood are ROC regression, conditional logistic regression, Cox proportional hazards model
|
15,223
|
What regression/estimation is not a MLE?
|
Bayesian approaches do not involve maximizing a likelihood function, but rather integrating over a posterior distribution. Note that the underlying model may be exactly identical (i.e., linear regression, generalized linear regression), but we also need to provide a prior distribution which captures our uncertainty in the parameters before seeing the data. The posterior distribution is simply the normalized distribution of the prior times the likelihood.
I believe that most statisticians these days generally agree that a Bayesian approach is generally superior to an MLE approach for parameter estimation. However, when one has a lot of data, it may not be so much better that it's both the extra computational costs (integrating is harder than optimizing!) and extra effort of coming up with a prior distribution. In fact, one can show that asymptotically, the MLE + normal approximation approaches the posterior distribution under certain conditions.
|
What regression/estimation is not a MLE?
|
Bayesian approaches do not involve maximizing a likelihood function, but rather integrating over a posterior distribution. Note that the underlying model may be exactly identical (i.e., linear regress
|
What regression/estimation is not a MLE?
Bayesian approaches do not involve maximizing a likelihood function, but rather integrating over a posterior distribution. Note that the underlying model may be exactly identical (i.e., linear regression, generalized linear regression), but we also need to provide a prior distribution which captures our uncertainty in the parameters before seeing the data. The posterior distribution is simply the normalized distribution of the prior times the likelihood.
I believe that most statisticians these days generally agree that a Bayesian approach is generally superior to an MLE approach for parameter estimation. However, when one has a lot of data, it may not be so much better that it's both the extra computational costs (integrating is harder than optimizing!) and extra effort of coming up with a prior distribution. In fact, one can show that asymptotically, the MLE + normal approximation approaches the posterior distribution under certain conditions.
|
What regression/estimation is not a MLE?
Bayesian approaches do not involve maximizing a likelihood function, but rather integrating over a posterior distribution. Note that the underlying model may be exactly identical (i.e., linear regress
|
15,224
|
What regression/estimation is not a MLE?
|
$$
Y_i = \alpha + \beta x_i + \varepsilon_i
$$
$\alpha,\beta$ are non-random and not observable.
$\varepsilon_i$ are random and not observable.
$x_i$ are non-random and are observable.
$Y_i$ are consequently random, and are observable.
Suppose you have the Gauss–Markov assumptions:
The errors $\varepsilon_i$ have expected value zero.
The errors all have the same (finite) variance but not necessarily the same distribution (in particular, they are not assumed to be normal).
The errors are uncorrelated but not necessarily independent.
One cannot do MLE because there's no parametrized family of distributions. But one can still do ordinary least squares.
And among all linear combinations of the $y$-values with non-random observable coefficients, that are unbaised estimators of $\alpha$ and $\beta,$ the least-squares estimators have the smallest variance.
|
What regression/estimation is not a MLE?
|
$$
Y_i = \alpha + \beta x_i + \varepsilon_i
$$
$\alpha,\beta$ are non-random and not observable.
$\varepsilon_i$ are random and not observable.
$x_i$ are non-random and are observable.
$Y_i$ are cons
|
What regression/estimation is not a MLE?
$$
Y_i = \alpha + \beta x_i + \varepsilon_i
$$
$\alpha,\beta$ are non-random and not observable.
$\varepsilon_i$ are random and not observable.
$x_i$ are non-random and are observable.
$Y_i$ are consequently random, and are observable.
Suppose you have the Gauss–Markov assumptions:
The errors $\varepsilon_i$ have expected value zero.
The errors all have the same (finite) variance but not necessarily the same distribution (in particular, they are not assumed to be normal).
The errors are uncorrelated but not necessarily independent.
One cannot do MLE because there's no parametrized family of distributions. But one can still do ordinary least squares.
And among all linear combinations of the $y$-values with non-random observable coefficients, that are unbaised estimators of $\alpha$ and $\beta,$ the least-squares estimators have the smallest variance.
|
What regression/estimation is not a MLE?
$$
Y_i = \alpha + \beta x_i + \varepsilon_i
$$
$\alpha,\beta$ are non-random and not observable.
$\varepsilon_i$ are random and not observable.
$x_i$ are non-random and are observable.
$Y_i$ are cons
|
15,225
|
What regression/estimation is not a MLE?
|
An answer to the question "What regression/estimation is not a MLE?", a simple and robust alternative to Least-Squares (LS) is reportedly Least-Absolute Deviation (LAD).
To quote a source:
"The least absolute deviations method (LAD) is one of the principal alternatives to the least-squares method when one seeks to estimate regression parameters. The goal of the LAD regression is to provide a robust estimator."
Interestingly, per a reference, to quote "The least absolute deviations estimate also arises as the maximum likelihood estimate if the errors have a Laplace distribution." Here is a link that discusses some interesting applications of the Laplace (like as a Bayesian prior, and for extreme events).
Historically, the LAD procedure was introduced 50 years before the least-squares method (1757) by Roger Joseph Boscovich, who employed it to reconcile incoherent measures relating to the shape of the earth.
An illustrative difference is in the very simple case of Y = Constant, where the LS returns the sample mean, while the LAD selects the sample median! So in contexts with one or two extreme values, which for whatever reason (like heteroscedasticity), that may arise, LS could display a major shift in the true slope estimate, especially when there is one very low and/or a high observation, as a noted weakness. Wikipedia on robust regression makes a supporting comment:
"In particular, least squares estimates for regression models are highly sensitive to outliers."
With respect to applications, this can be particularly important, for example, in chemistry-based data analysis to predict a so-called reaction's Rate Law (which is based on the slope estimate).
|
What regression/estimation is not a MLE?
|
An answer to the question "What regression/estimation is not a MLE?", a simple and robust alternative to Least-Squares (LS) is reportedly Least-Absolute Deviation (LAD).
To quote a source:
"The least
|
What regression/estimation is not a MLE?
An answer to the question "What regression/estimation is not a MLE?", a simple and robust alternative to Least-Squares (LS) is reportedly Least-Absolute Deviation (LAD).
To quote a source:
"The least absolute deviations method (LAD) is one of the principal alternatives to the least-squares method when one seeks to estimate regression parameters. The goal of the LAD regression is to provide a robust estimator."
Interestingly, per a reference, to quote "The least absolute deviations estimate also arises as the maximum likelihood estimate if the errors have a Laplace distribution." Here is a link that discusses some interesting applications of the Laplace (like as a Bayesian prior, and for extreme events).
Historically, the LAD procedure was introduced 50 years before the least-squares method (1757) by Roger Joseph Boscovich, who employed it to reconcile incoherent measures relating to the shape of the earth.
An illustrative difference is in the very simple case of Y = Constant, where the LS returns the sample mean, while the LAD selects the sample median! So in contexts with one or two extreme values, which for whatever reason (like heteroscedasticity), that may arise, LS could display a major shift in the true slope estimate, especially when there is one very low and/or a high observation, as a noted weakness. Wikipedia on robust regression makes a supporting comment:
"In particular, least squares estimates for regression models are highly sensitive to outliers."
With respect to applications, this can be particularly important, for example, in chemistry-based data analysis to predict a so-called reaction's Rate Law (which is based on the slope estimate).
|
What regression/estimation is not a MLE?
An answer to the question "What regression/estimation is not a MLE?", a simple and robust alternative to Least-Squares (LS) is reportedly Least-Absolute Deviation (LAD).
To quote a source:
"The least
|
15,226
|
Family of GLM represents the distribution of the response variable or residuals?
|
The family argument for glm models determines the distribution family for the conditional distribution of the response, not of the residuals (except for the quasi-models).
Look at this way: For the usual linear regression, we can write the model as
$$Y_i \sim \text{Normal}(\beta_0+x_i^T\beta, \sigma^2).
$$
This means that the response $Y_i$ has a normal distribution (with constant variance), but the expectation is different for each $i$. Therefore the conditional distribution of the response is a normal distribution (but a different one for each $i$). Another way of writing this model is
$$
Y_i = \beta_0+x_i^T\beta + \epsilon_i
$$ where each $\epsilon_i$ is distributed $\text{Normal}(0, \sigma^2)$.
So for the normal distribution family both descriptions are correct (when interpreted correctly). This is because for the normal linear model we have a clean separation in the model of the systematic part (the $\beta_0+x_i^T\beta$) and the disturbance part (the $\epsilon_i$) which are simply added. But for other family functions, this separation is not possible! There is not even a clean definition of what residual means (and for that reason, many different definitions of "residual").
So for all those other families, we use a definition in the style of the first displayed equation above. That is, the conditional distribution of the response. So, no, the residuals (whatever defined) in Poisson regression do not have a Poisson distribution.
|
Family of GLM represents the distribution of the response variable or residuals?
|
The family argument for glm models determines the distribution family for the conditional distribution of the response, not of the residuals (except for the quasi-models).
Look at this way: For the u
|
Family of GLM represents the distribution of the response variable or residuals?
The family argument for glm models determines the distribution family for the conditional distribution of the response, not of the residuals (except for the quasi-models).
Look at this way: For the usual linear regression, we can write the model as
$$Y_i \sim \text{Normal}(\beta_0+x_i^T\beta, \sigma^2).
$$
This means that the response $Y_i$ has a normal distribution (with constant variance), but the expectation is different for each $i$. Therefore the conditional distribution of the response is a normal distribution (but a different one for each $i$). Another way of writing this model is
$$
Y_i = \beta_0+x_i^T\beta + \epsilon_i
$$ where each $\epsilon_i$ is distributed $\text{Normal}(0, \sigma^2)$.
So for the normal distribution family both descriptions are correct (when interpreted correctly). This is because for the normal linear model we have a clean separation in the model of the systematic part (the $\beta_0+x_i^T\beta$) and the disturbance part (the $\epsilon_i$) which are simply added. But for other family functions, this separation is not possible! There is not even a clean definition of what residual means (and for that reason, many different definitions of "residual").
So for all those other families, we use a definition in the style of the first displayed equation above. That is, the conditional distribution of the response. So, no, the residuals (whatever defined) in Poisson regression do not have a Poisson distribution.
|
Family of GLM represents the distribution of the response variable or residuals?
The family argument for glm models determines the distribution family for the conditional distribution of the response, not of the residuals (except for the quasi-models).
Look at this way: For the u
|
15,227
|
Family of GLM represents the distribution of the response variable or residuals?
|
Further to Kjetil's excellent answer, I wanted to add some specific examples to help clarify the meaning of a conditional distribution, which can be a bit of an elusive concept.
Let's say you took a random sample of 100 fish from a lake and you are interested in seeing how the age of the fish affects several outcome variables:
Fish weight (Weight);
Whether or not the fish are longer than 30cm;
Number of fish scales.
The first outcome variable is continuous, the second is binary (0 = fish is NOT longer than 30 cm; 1 = fish IS longer than 30 cm) and the third is a count variable.
Simple Linear Regression
How does Age affect Weight? You are going to formulate a simple linear regression model of the form:
$$
\text{Weight} = \beta_0+\beta_1*\text{Age} + \epsilon
$$
where the $\epsilon$'s are independent, identically distributed, following a Normal distribution with mean 0 and standard deviation $\sigma$. In this model, the mean of the Weight variable for all the fish in the lake sharing the same age is assumed to vary linearly with age. The conditional mean is represented by $\beta_0 + \beta_1*\text{Age}$. It is called conditional because it is the mean weight for all the fish in the lake with the same Age. (The unconditional mean weight would be the mean weight of all the fish in the lake, regardless of their age.)
Simple Binary Logistic Regression
How does Age affect whether or not the fish are longer than 30cm? You are going to formulate a simple binary logistic regression model of the form:
$$
\log\left(\frac{p}{1-p}\right) = \beta_0+\beta_1*\text{Age}
$$
where $p$ denotes the conditional probability that a fish of a given age is longer than 30cm. In this model, the conditional mean of the variable "whether or not the fish are longer than 30cm" corresponding to all fishes in the lake sharing the same age is assumed to vary linearly with age after being fed to the logit transformation. The logit-transformed conditional mean is represented by $\beta_0 + \beta_1*\text{Age}$. This model works because we assume that the distribution of values of the variable "whether or not the fish are longer than 30cm" for a given age is a Bernoulli distribution. Recall that for this distribution, the variance is a function of the mean value, so if we can estimate its mean value, we can also estimate its variance. (The mean of a Bernoulli variable is $p$ and the variance is $p*(1-p)$.) See also https://www.theanalysisfactor.com/link-functions-and-errors-in-logistic-regression/.
Simple Poisson Regression
How does Age affect the number of fish scales? You are going to formulate a simple Poisson regression model of the form:
$$
\log(\mu) = \beta_0+\beta_1*\text{Age}
$$
where $\mu$ denotes the conditional mean value of the outcome variable "number of fish scales" for fish of a given age (that is, the expected number of fish scales for all fish in the lake of a given age). In this model, the conditional mean of the outcome variable is assumed to vary linearly with age after being fed to the log transformation. The log-transformed conditional mean is represented by $\beta_0+\beta_1*\text{Age}$. This model works because we assume that the distribution of values of the variable "number of fish scales" for all the fish in the lake of a given age is a Poisson distribution. Recall that for this distribution, the mean and variance are equal so it is sufficient to model its mean value.
To sum up, a conditional distribution represents the distribution of the outcome values for specific values of the predictor variable(s) included in the model. Each type of regression model illustrated above imposes certain distributional assumptions on the conditional distribution of the outcome variable given Age. Based on these distributional assumptions, the model proceeds to formulate how (1) the mean of the conditional distribution varies as a function of age (simple linear regression), (2) the logit-transformed mean of the conditional distribution varies as a function of age (simple binary logistic regression) or (3) the log-transformed mean of the conditional distribution varies as a function of age.
For each type of model, one can define corresponding residuals for the purpose of model checking. In particular, Pearson and deviance residuals could be defined for the logistic and Poisson regression models.
|
Family of GLM represents the distribution of the response variable or residuals?
|
Further to Kjetil's excellent answer, I wanted to add some specific examples to help clarify the meaning of a conditional distribution, which can be a bit of an elusive concept.
Let's say you took a r
|
Family of GLM represents the distribution of the response variable or residuals?
Further to Kjetil's excellent answer, I wanted to add some specific examples to help clarify the meaning of a conditional distribution, which can be a bit of an elusive concept.
Let's say you took a random sample of 100 fish from a lake and you are interested in seeing how the age of the fish affects several outcome variables:
Fish weight (Weight);
Whether or not the fish are longer than 30cm;
Number of fish scales.
The first outcome variable is continuous, the second is binary (0 = fish is NOT longer than 30 cm; 1 = fish IS longer than 30 cm) and the third is a count variable.
Simple Linear Regression
How does Age affect Weight? You are going to formulate a simple linear regression model of the form:
$$
\text{Weight} = \beta_0+\beta_1*\text{Age} + \epsilon
$$
where the $\epsilon$'s are independent, identically distributed, following a Normal distribution with mean 0 and standard deviation $\sigma$. In this model, the mean of the Weight variable for all the fish in the lake sharing the same age is assumed to vary linearly with age. The conditional mean is represented by $\beta_0 + \beta_1*\text{Age}$. It is called conditional because it is the mean weight for all the fish in the lake with the same Age. (The unconditional mean weight would be the mean weight of all the fish in the lake, regardless of their age.)
Simple Binary Logistic Regression
How does Age affect whether or not the fish are longer than 30cm? You are going to formulate a simple binary logistic regression model of the form:
$$
\log\left(\frac{p}{1-p}\right) = \beta_0+\beta_1*\text{Age}
$$
where $p$ denotes the conditional probability that a fish of a given age is longer than 30cm. In this model, the conditional mean of the variable "whether or not the fish are longer than 30cm" corresponding to all fishes in the lake sharing the same age is assumed to vary linearly with age after being fed to the logit transformation. The logit-transformed conditional mean is represented by $\beta_0 + \beta_1*\text{Age}$. This model works because we assume that the distribution of values of the variable "whether or not the fish are longer than 30cm" for a given age is a Bernoulli distribution. Recall that for this distribution, the variance is a function of the mean value, so if we can estimate its mean value, we can also estimate its variance. (The mean of a Bernoulli variable is $p$ and the variance is $p*(1-p)$.) See also https://www.theanalysisfactor.com/link-functions-and-errors-in-logistic-regression/.
Simple Poisson Regression
How does Age affect the number of fish scales? You are going to formulate a simple Poisson regression model of the form:
$$
\log(\mu) = \beta_0+\beta_1*\text{Age}
$$
where $\mu$ denotes the conditional mean value of the outcome variable "number of fish scales" for fish of a given age (that is, the expected number of fish scales for all fish in the lake of a given age). In this model, the conditional mean of the outcome variable is assumed to vary linearly with age after being fed to the log transformation. The log-transformed conditional mean is represented by $\beta_0+\beta_1*\text{Age}$. This model works because we assume that the distribution of values of the variable "number of fish scales" for all the fish in the lake of a given age is a Poisson distribution. Recall that for this distribution, the mean and variance are equal so it is sufficient to model its mean value.
To sum up, a conditional distribution represents the distribution of the outcome values for specific values of the predictor variable(s) included in the model. Each type of regression model illustrated above imposes certain distributional assumptions on the conditional distribution of the outcome variable given Age. Based on these distributional assumptions, the model proceeds to formulate how (1) the mean of the conditional distribution varies as a function of age (simple linear regression), (2) the logit-transformed mean of the conditional distribution varies as a function of age (simple binary logistic regression) or (3) the log-transformed mean of the conditional distribution varies as a function of age.
For each type of model, one can define corresponding residuals for the purpose of model checking. In particular, Pearson and deviance residuals could be defined for the logistic and Poisson regression models.
|
Family of GLM represents the distribution of the response variable or residuals?
Further to Kjetil's excellent answer, I wanted to add some specific examples to help clarify the meaning of a conditional distribution, which can be a bit of an elusive concept.
Let's say you took a r
|
15,228
|
Adaptive GAM smooths in mgcv
|
Most of the extra smooths in the mgcv toolbox are really there for specialist applications — you can largely ignore them for general GAMs, especially univariate smooths (you don't need a random effect spline, a spline on the sphere, a Markov random field, or a soap-film smoother if you have univariate data for example.)
If you can bear the setup cost, use thin-plate regression splines (TPRS).
These splines are optimal in an asymptotic MSE sense, but require one basis function per observation. What Simon does in mgcv is generate a low-rank version of the standard TPRS by taking the full TPRS basis and subjecting it to an eigendecomposition. This creates a new basis where the first k basis function in the new space retain most of the signal in the original basis, but in many fewer basis functions. This is how mgcv manages to get a TPRS that uses only a specified number of basis functions rather than one per observation. This eigendecomposition preserves much of the optimality of the classic TPRS basis, but at considerable computational effort for large data sets.
If you can't bear the setup cost of TPRS, use cubic regression splines (CRS)
This is a quick basis to generate and hence is suited to problems with a lot of data. It is knot-based however, so to some extent the user now needs to choose where those knots should be placed. For most problems there is little to be gained by going beyond the default knot placement (at the boundary of the data and spaced evenly in between), but if you have particularly uneven sampling over the range of the covariate, you may choose to place knots evenly spaced sample quantiles of the covariate, for example.
Every other smooth in mgcv is special, being used where you want isotropic smooths or two or more covariates, or are for spatial smoothing, or which implement shrinkage, or random effects and random splines, or where covariates are cyclic, or the wiggliness varies over the range of a covariate. You only need to venture this far into the smooth toolbox if you have a problem that requires special handling.
Shrinkage
There are shrinkage versions of both the TPRS and CRS in mgcv. These implement a spline where the perfectly smooth part of the basis is also subject to the smoothness penalty. This allows the smoothness selection process to shrink a smooth back beyond even a linear function essentially to zero. This allows the smoothness penalty to also perform feature selection.
Duchon splines, P splines and B splines
These splines are available for specialist applications where you need to specify the basis order and the penalty order separately. Duchon splines generalise the TPRS. I get the impression that P splines were added to mgcv to allow comparison with other penalized likelihood-based approaches, and because they are splines used by Eilers & Marx in their 1996 paper which spurred a lot of the subsequent work in GAMs. The P splines are also useful as a base for other splines, like splines with shape constraints, and adaptive splines.
B splines, as implemented in mgcv allow for a great deal of flexibility in setting up the penalty and knots for the splines, which can allow for some extrapolation beyond the range of the observed data.
Cyclic splines
If the range of values for a covariate can be thought of as on a circle where the end points of the range should actually be equivalent (month or day of year, angle of movement, aspect, wind direction), this constraint can be imposed on the basis. If you have covariates like this, then it makes sense to impose this constraint.
Adaptive smoothers
Rather than fit a separate GAM in sections of the covariate, adaptive splines use a weighted penalty matrix, where the weights are allowed to vary smoothly over the range of the covariate. For the TPRS and CRS splines, for example, they assume the same degree of smoothness across the range of the covariate. If you have a relationship where this is not the case, then you can end up using more degrees of freedom than expected to allow for the spline to adapt to the wiggly and non-wiggly parts. A classic example in the smoothing literature is the
library('ggplot2')
theme_set(theme_bw())
library('mgcv')
data(mcycle, package = 'MASS')
pdata <- with(mcycle,
data.frame(times = seq(min(times), max(times), length = 500)))
ggplot(mcycle, aes(x = times, y = accel)) + geom_point()
These data clearly exhibit periods of different smoothness - effectively zero for the first part of the series, lots during the impact, reducing thereafter.
if we fit a standard GAM to these data,
m1 <- gam(accel ~ s(times, k = 20), data = mcycle, method = 'REML')
we get a reasonable fit but there is some extra wiggliness at the beginning and end the range of times and the fit used ~14 degrees of freedom
plot(m1, scheme = 1, residuals = TRUE, pch= 16)
To accommodate the varying wiggliness, an adaptive spline uses a weighted penalty matrix with the weights varying smoothly with the covariate. Here I refit the original model with the same basis dimension (k = 20) but now we have 5 smoothness parameters (default is m = 5) instead of the original's 1.
m2 <- gam(accel ~ s(times, k = 20, bs = 'ad'), data = mcycle, method = 'REML')
Notice that this model uses far fewer degrees of freedom (~8) and the fitted smooth is much less wiggly at the ends, whilst still being able to adequately fit the large changes in head acceleration during the impact.
What's actually going on here is that the spline has a basis for smooth and a basis for the penalty (to allow the weights to vary smoothly with the covariate). By default both of these are P splines, but you can also use the CRS basis types too (bs can only be one of 'ps', 'cr', 'cc', 'cs'.)
As illustrated here, the choice of whether to go adaptive or not really depends on the problem; if you have a relationship for which you assume the functional form is smooth, but the degree of smoothness varies over the range of the covariate in the relationship then an adaptive spline can make sense. If your series had periods of rapid change and periods of low or more gradual change, that could indicate that an adaptive smooth may be needed.
|
Adaptive GAM smooths in mgcv
|
Most of the extra smooths in the mgcv toolbox are really there for specialist applications — you can largely ignore them for general GAMs, especially univariate smooths (you don't need a random effect
|
Adaptive GAM smooths in mgcv
Most of the extra smooths in the mgcv toolbox are really there for specialist applications — you can largely ignore them for general GAMs, especially univariate smooths (you don't need a random effect spline, a spline on the sphere, a Markov random field, or a soap-film smoother if you have univariate data for example.)
If you can bear the setup cost, use thin-plate regression splines (TPRS).
These splines are optimal in an asymptotic MSE sense, but require one basis function per observation. What Simon does in mgcv is generate a low-rank version of the standard TPRS by taking the full TPRS basis and subjecting it to an eigendecomposition. This creates a new basis where the first k basis function in the new space retain most of the signal in the original basis, but in many fewer basis functions. This is how mgcv manages to get a TPRS that uses only a specified number of basis functions rather than one per observation. This eigendecomposition preserves much of the optimality of the classic TPRS basis, but at considerable computational effort for large data sets.
If you can't bear the setup cost of TPRS, use cubic regression splines (CRS)
This is a quick basis to generate and hence is suited to problems with a lot of data. It is knot-based however, so to some extent the user now needs to choose where those knots should be placed. For most problems there is little to be gained by going beyond the default knot placement (at the boundary of the data and spaced evenly in between), but if you have particularly uneven sampling over the range of the covariate, you may choose to place knots evenly spaced sample quantiles of the covariate, for example.
Every other smooth in mgcv is special, being used where you want isotropic smooths or two or more covariates, or are for spatial smoothing, or which implement shrinkage, or random effects and random splines, or where covariates are cyclic, or the wiggliness varies over the range of a covariate. You only need to venture this far into the smooth toolbox if you have a problem that requires special handling.
Shrinkage
There are shrinkage versions of both the TPRS and CRS in mgcv. These implement a spline where the perfectly smooth part of the basis is also subject to the smoothness penalty. This allows the smoothness selection process to shrink a smooth back beyond even a linear function essentially to zero. This allows the smoothness penalty to also perform feature selection.
Duchon splines, P splines and B splines
These splines are available for specialist applications where you need to specify the basis order and the penalty order separately. Duchon splines generalise the TPRS. I get the impression that P splines were added to mgcv to allow comparison with other penalized likelihood-based approaches, and because they are splines used by Eilers & Marx in their 1996 paper which spurred a lot of the subsequent work in GAMs. The P splines are also useful as a base for other splines, like splines with shape constraints, and adaptive splines.
B splines, as implemented in mgcv allow for a great deal of flexibility in setting up the penalty and knots for the splines, which can allow for some extrapolation beyond the range of the observed data.
Cyclic splines
If the range of values for a covariate can be thought of as on a circle where the end points of the range should actually be equivalent (month or day of year, angle of movement, aspect, wind direction), this constraint can be imposed on the basis. If you have covariates like this, then it makes sense to impose this constraint.
Adaptive smoothers
Rather than fit a separate GAM in sections of the covariate, adaptive splines use a weighted penalty matrix, where the weights are allowed to vary smoothly over the range of the covariate. For the TPRS and CRS splines, for example, they assume the same degree of smoothness across the range of the covariate. If you have a relationship where this is not the case, then you can end up using more degrees of freedom than expected to allow for the spline to adapt to the wiggly and non-wiggly parts. A classic example in the smoothing literature is the
library('ggplot2')
theme_set(theme_bw())
library('mgcv')
data(mcycle, package = 'MASS')
pdata <- with(mcycle,
data.frame(times = seq(min(times), max(times), length = 500)))
ggplot(mcycle, aes(x = times, y = accel)) + geom_point()
These data clearly exhibit periods of different smoothness - effectively zero for the first part of the series, lots during the impact, reducing thereafter.
if we fit a standard GAM to these data,
m1 <- gam(accel ~ s(times, k = 20), data = mcycle, method = 'REML')
we get a reasonable fit but there is some extra wiggliness at the beginning and end the range of times and the fit used ~14 degrees of freedom
plot(m1, scheme = 1, residuals = TRUE, pch= 16)
To accommodate the varying wiggliness, an adaptive spline uses a weighted penalty matrix with the weights varying smoothly with the covariate. Here I refit the original model with the same basis dimension (k = 20) but now we have 5 smoothness parameters (default is m = 5) instead of the original's 1.
m2 <- gam(accel ~ s(times, k = 20, bs = 'ad'), data = mcycle, method = 'REML')
Notice that this model uses far fewer degrees of freedom (~8) and the fitted smooth is much less wiggly at the ends, whilst still being able to adequately fit the large changes in head acceleration during the impact.
What's actually going on here is that the spline has a basis for smooth and a basis for the penalty (to allow the weights to vary smoothly with the covariate). By default both of these are P splines, but you can also use the CRS basis types too (bs can only be one of 'ps', 'cr', 'cc', 'cs'.)
As illustrated here, the choice of whether to go adaptive or not really depends on the problem; if you have a relationship for which you assume the functional form is smooth, but the degree of smoothness varies over the range of the covariate in the relationship then an adaptive spline can make sense. If your series had periods of rapid change and periods of low or more gradual change, that could indicate that an adaptive smooth may be needed.
|
Adaptive GAM smooths in mgcv
Most of the extra smooths in the mgcv toolbox are really there for specialist applications — you can largely ignore them for general GAMs, especially univariate smooths (you don't need a random effect
|
15,229
|
A gallery of charts, diagrams, and plot types
|
Nathan Yau's books might be useful for people starting off, but are pitched lower than most visitors here should want to reach. I gave a very qualified 4 stars to "Data points" on amazon.com as can be seen at http://www.amazon.com/Data-Points-Visualization-Means-Something/dp/111846219X/
I can be very much more positive about William Cleveland's outstanding books (see http://www.hobart.com/). One of many compliments about Cleveland's books is that although now 19 or 20 years old, they don't really date at all. Indeed, it is now much easier to do what Cleveland did across a wide range of software.
I am a fan of Tufte's work (indeed should disclose an interest as a very marginal contributor to the enterprise). Of his four books on graphics that cited remains the place to start. See http://www.edwardtufte.com/tufte/ (Visual display is often misrepresented as Tufte's first book; not so).
But probably the widest collection of statistical graphics is to be found in Leland Wilkinson's magnum opus The Grammar of Graphics
R users should know about that as the main inspiration for ggplot2.
|
A gallery of charts, diagrams, and plot types
|
Nathan Yau's books might be useful for people starting off, but are pitched lower than most visitors here should want to reach. I gave a very qualified 4 stars to "Data points" on amazon.com as can be
|
A gallery of charts, diagrams, and plot types
Nathan Yau's books might be useful for people starting off, but are pitched lower than most visitors here should want to reach. I gave a very qualified 4 stars to "Data points" on amazon.com as can be seen at http://www.amazon.com/Data-Points-Visualization-Means-Something/dp/111846219X/
I can be very much more positive about William Cleveland's outstanding books (see http://www.hobart.com/). One of many compliments about Cleveland's books is that although now 19 or 20 years old, they don't really date at all. Indeed, it is now much easier to do what Cleveland did across a wide range of software.
I am a fan of Tufte's work (indeed should disclose an interest as a very marginal contributor to the enterprise). Of his four books on graphics that cited remains the place to start. See http://www.edwardtufte.com/tufte/ (Visual display is often misrepresented as Tufte's first book; not so).
But probably the widest collection of statistical graphics is to be found in Leland Wilkinson's magnum opus The Grammar of Graphics
R users should know about that as the main inspiration for ggplot2.
|
A gallery of charts, diagrams, and plot types
Nathan Yau's books might be useful for people starting off, but are pitched lower than most visitors here should want to reach. I gave a very qualified 4 stars to "Data points" on amazon.com as can be
|
15,230
|
A gallery of charts, diagrams, and plot types
|
I personally prefer the D3 gallery because many of the plots there are dynamic and interactive (not to mention incredibly appealing and professional-looking from a graphic design perspective). There's also a tremendous range of variability in the style of plots and the type of information being displayed, so it makes a good place to peruse just for general inspiration to "up your game" with regard to data visualization.
|
A gallery of charts, diagrams, and plot types
|
I personally prefer the D3 gallery because many of the plots there are dynamic and interactive (not to mention incredibly appealing and professional-looking from a graphic design perspective). There'
|
A gallery of charts, diagrams, and plot types
I personally prefer the D3 gallery because many of the plots there are dynamic and interactive (not to mention incredibly appealing and professional-looking from a graphic design perspective). There's also a tremendous range of variability in the style of plots and the type of information being displayed, so it makes a good place to peruse just for general inspiration to "up your game" with regard to data visualization.
|
A gallery of charts, diagrams, and plot types
I personally prefer the D3 gallery because many of the plots there are dynamic and interactive (not to mention incredibly appealing and professional-looking from a graphic design perspective). There'
|
15,231
|
A gallery of charts, diagrams, and plot types
|
There is the R Graphical Manual. Although it is presumably somewhat less useful for people who use other software, you can still look up topics and see some examples of possibilities that you could then try to reproduce by other means.
|
A gallery of charts, diagrams, and plot types
|
There is the R Graphical Manual. Although it is presumably somewhat less useful for people who use other software, you can still look up topics and see some examples of possibilities that you could t
|
A gallery of charts, diagrams, and plot types
There is the R Graphical Manual. Although it is presumably somewhat less useful for people who use other software, you can still look up topics and see some examples of possibilities that you could then try to reproduce by other means.
|
A gallery of charts, diagrams, and plot types
There is the R Graphical Manual. Although it is presumably somewhat less useful for people who use other software, you can still look up topics and see some examples of possibilities that you could t
|
15,232
|
A gallery of charts, diagrams, and plot types
|
Ralph Lengler and Martin J. Eppler's Periodic Table of Visualization Methods is an ingenious and far-ranging single-page display of about a hundred types of charts and diagrams for visualizing data as well as concepts, strategies, processes, and so on. A nice reference when looking for a catchy or creative way to display something.
|
A gallery of charts, diagrams, and plot types
|
Ralph Lengler and Martin J. Eppler's Periodic Table of Visualization Methods is an ingenious and far-ranging single-page display of about a hundred types of charts and diagrams for visualizing data
|
A gallery of charts, diagrams, and plot types
Ralph Lengler and Martin J. Eppler's Periodic Table of Visualization Methods is an ingenious and far-ranging single-page display of about a hundred types of charts and diagrams for visualizing data as well as concepts, strategies, processes, and so on. A nice reference when looking for a catchy or creative way to display something.
|
A gallery of charts, diagrams, and plot types
Ralph Lengler and Martin J. Eppler's Periodic Table of Visualization Methods is an ingenious and far-ranging single-page display of about a hundred types of charts and diagrams for visualizing data
|
15,233
|
A gallery of charts, diagrams, and plot types
|
For a good overview of different types of plots (and examples good and bad), including a timeline of graphical development, there is plenty to explore here:
http://www.datavis.ca/gallery/
|
A gallery of charts, diagrams, and plot types
|
For a good overview of different types of plots (and examples good and bad), including a timeline of graphical development, there is plenty to explore here:
http://www.datavis.ca/gallery/
|
A gallery of charts, diagrams, and plot types
For a good overview of different types of plots (and examples good and bad), including a timeline of graphical development, there is plenty to explore here:
http://www.datavis.ca/gallery/
|
A gallery of charts, diagrams, and plot types
For a good overview of different types of plots (and examples good and bad), including a timeline of graphical development, there is plenty to explore here:
http://www.datavis.ca/gallery/
|
15,234
|
A gallery of charts, diagrams, and plot types
|
I would like to propose the R graph gallery. It displays more than hundred graphics, all made with the R software, and always giving the associated code to make it reproducible !
|
A gallery of charts, diagrams, and plot types
|
I would like to propose the R graph gallery. It displays more than hundred graphics, all made with the R software, and always giving the associated code to make it reproducible !
|
A gallery of charts, diagrams, and plot types
I would like to propose the R graph gallery. It displays more than hundred graphics, all made with the R software, and always giving the associated code to make it reproducible !
|
A gallery of charts, diagrams, and plot types
I would like to propose the R graph gallery. It displays more than hundred graphics, all made with the R software, and always giving the associated code to make it reproducible !
|
15,235
|
A gallery of charts, diagrams, and plot types
|
There's an excellent gallery from UBC Statistics dept made by an undergraduate research student.
You can preview with Shiny here, or get full code and fork on GitHub.
It's currently my go-to resource for ease of use, like picking a graph off a shelf, selection on the basis of whether it's "recommended", pointing out what styles ought be avoided etc.
|
A gallery of charts, diagrams, and plot types
|
There's an excellent gallery from UBC Statistics dept made by an undergraduate research student.
You can preview with Shiny here, or get full code and fork on GitHub.
It's currently my go-to resource
|
A gallery of charts, diagrams, and plot types
There's an excellent gallery from UBC Statistics dept made by an undergraduate research student.
You can preview with Shiny here, or get full code and fork on GitHub.
It's currently my go-to resource for ease of use, like picking a graph off a shelf, selection on the basis of whether it's "recommended", pointing out what styles ought be avoided etc.
|
A gallery of charts, diagrams, and plot types
There's an excellent gallery from UBC Statistics dept made by an undergraduate research student.
You can preview with Shiny here, or get full code and fork on GitHub.
It's currently my go-to resource
|
15,236
|
A gallery of charts, diagrams, and plot types
|
Highcharts and highstocks, something like d3, might also give you lots of inspiration. Consider for example http://www.highcharts.com/demo/polar-wind-rose. On the left of that page, you can click around in their library of graphs.
|
A gallery of charts, diagrams, and plot types
|
Highcharts and highstocks, something like d3, might also give you lots of inspiration. Consider for example http://www.highcharts.com/demo/polar-wind-rose. On the left of that page, you can click arou
|
A gallery of charts, diagrams, and plot types
Highcharts and highstocks, something like d3, might also give you lots of inspiration. Consider for example http://www.highcharts.com/demo/polar-wind-rose. On the left of that page, you can click around in their library of graphs.
|
A gallery of charts, diagrams, and plot types
Highcharts and highstocks, something like d3, might also give you lots of inspiration. Consider for example http://www.highcharts.com/demo/polar-wind-rose. On the left of that page, you can click arou
|
15,237
|
A gallery of charts, diagrams, and plot types
|
Coming from a python environment I can recommend:
http://matplotlib.org/gallery.html
http://bokeh.pydata.org/en/latest/docs/gallery.html
|
A gallery of charts, diagrams, and plot types
|
Coming from a python environment I can recommend:
http://matplotlib.org/gallery.html
http://bokeh.pydata.org/en/latest/docs/gallery.html
|
A gallery of charts, diagrams, and plot types
Coming from a python environment I can recommend:
http://matplotlib.org/gallery.html
http://bokeh.pydata.org/en/latest/docs/gallery.html
|
A gallery of charts, diagrams, and plot types
Coming from a python environment I can recommend:
http://matplotlib.org/gallery.html
http://bokeh.pydata.org/en/latest/docs/gallery.html
|
15,238
|
Is logistic regression a non-parametric test?
|
Larry Wasserman defines a parametric model as a set of distributions "that can be parameterized by a finite number of parameters." (p.87) In contrast a nonparametric model is a set of distributions that cannot be paramterised by a finite number of parameters.
Thus, by that definition standard logistic regression is a parametric model. The logistic regression model is parametric because it has a finite set of parameters. Specifically, the parameters are the regression coefficients. These usually correspond to one for each predictor plus a constant.
Logistic regression is a particular form of the generalised linear model. Specifically it involves using a logit link function to model binomially distributed data.
Interestingly, it is possible to perform a nonparametric logistic regression (e.g., Hastie, 1983). This might involve using splines or some form of non-parametric smoothing to model the effect of the predictors.
References
Wasserman, L. (2004). All of statistics: a concise course in statistical inference. Springer Verlag.
Hastie, T. (1983). Non-parametric logistic regression. SLAC PUB-3160, June. PDF
|
Is logistic regression a non-parametric test?
|
Larry Wasserman defines a parametric model as a set of distributions "that can be parameterized by a finite number of parameters." (p.87) In contrast a nonparametric model is a set of distributions th
|
Is logistic regression a non-parametric test?
Larry Wasserman defines a parametric model as a set of distributions "that can be parameterized by a finite number of parameters." (p.87) In contrast a nonparametric model is a set of distributions that cannot be paramterised by a finite number of parameters.
Thus, by that definition standard logistic regression is a parametric model. The logistic regression model is parametric because it has a finite set of parameters. Specifically, the parameters are the regression coefficients. These usually correspond to one for each predictor plus a constant.
Logistic regression is a particular form of the generalised linear model. Specifically it involves using a logit link function to model binomially distributed data.
Interestingly, it is possible to perform a nonparametric logistic regression (e.g., Hastie, 1983). This might involve using splines or some form of non-parametric smoothing to model the effect of the predictors.
References
Wasserman, L. (2004). All of statistics: a concise course in statistical inference. Springer Verlag.
Hastie, T. (1983). Non-parametric logistic regression. SLAC PUB-3160, June. PDF
|
Is logistic regression a non-parametric test?
Larry Wasserman defines a parametric model as a set of distributions "that can be parameterized by a finite number of parameters." (p.87) In contrast a nonparametric model is a set of distributions th
|
15,239
|
Is logistic regression a non-parametric test?
|
I'd say logistic regression isn't a test at all; however a logistic regression may then lead to no tests or several tests.
You're quite correct that labelling something nonparametric because it's not normal is insufficient. I'd call the exponential family explicitly parametric, so I'd usually regard logistic regression (and Poisson regression and Gamma regression and ...) as parametric, though there can be circumstances in which I might accept an argument that particular logistic regressions could be regarded as nonparametric (or at least in a vaguely hand-wavy sense, only quasi-"parametric").
Beware any confusion over the two senses in which a regression may be called nonparametric.
If I fit a Theil linear regression it is nonparametric in the sense that I have left the error distribution undefined (it corresponds to adjusting the regression slope until the Kendall correlation between residuals and $x$ is 0) ... but it is parametric in the sense that I have a fully specified relationship between $y$ and $x$ parameterized by the slope and intercept coefficients.
If on the other hand I fit a kernel polynomial regression (say a local linear regression), but with normal errors, that is also called nonparametric, but in this case it's the parameterization of the relationship between $y$ and $x$ that's nonparametric (at least potentially infinite-dimensional), not the error distribution.
Both senses are used, but when it comes to regression, the second kind is actually used more often.
It's also possible to be nonparametric in both senses, but harder (with sufficient data, I could, for example, fit a Theil locally-weighted linear regression).
The two senses aren't quite as distinct as it may seem at first, however, since if we consider the model as specifying the conditional distribution of the response, then the second sense is specifically about modelling the location (typically the mean) of that conditional distribution, while the first sense relates to the model for the shape of the conditional distribution model. They're both relating to aspects of the conditional distribution. Going back to that second sense, if the distribution is otherwise specified (up to a fixed finite number of parameters) it might be better described as semiparametric, but that's not the convention in this area.
In the case of GLMs, the second form of nonparametric multiple regression include GAMs; that second form is the sense in which Hastie is generally operating (and under which he's operating in that quote).
|
Is logistic regression a non-parametric test?
|
I'd say logistic regression isn't a test at all; however a logistic regression may then lead to no tests or several tests.
You're quite correct that labelling something nonparametric because it's not
|
Is logistic regression a non-parametric test?
I'd say logistic regression isn't a test at all; however a logistic regression may then lead to no tests or several tests.
You're quite correct that labelling something nonparametric because it's not normal is insufficient. I'd call the exponential family explicitly parametric, so I'd usually regard logistic regression (and Poisson regression and Gamma regression and ...) as parametric, though there can be circumstances in which I might accept an argument that particular logistic regressions could be regarded as nonparametric (or at least in a vaguely hand-wavy sense, only quasi-"parametric").
Beware any confusion over the two senses in which a regression may be called nonparametric.
If I fit a Theil linear regression it is nonparametric in the sense that I have left the error distribution undefined (it corresponds to adjusting the regression slope until the Kendall correlation between residuals and $x$ is 0) ... but it is parametric in the sense that I have a fully specified relationship between $y$ and $x$ parameterized by the slope and intercept coefficients.
If on the other hand I fit a kernel polynomial regression (say a local linear regression), but with normal errors, that is also called nonparametric, but in this case it's the parameterization of the relationship between $y$ and $x$ that's nonparametric (at least potentially infinite-dimensional), not the error distribution.
Both senses are used, but when it comes to regression, the second kind is actually used more often.
It's also possible to be nonparametric in both senses, but harder (with sufficient data, I could, for example, fit a Theil locally-weighted linear regression).
The two senses aren't quite as distinct as it may seem at first, however, since if we consider the model as specifying the conditional distribution of the response, then the second sense is specifically about modelling the location (typically the mean) of that conditional distribution, while the first sense relates to the model for the shape of the conditional distribution model. They're both relating to aspects of the conditional distribution. Going back to that second sense, if the distribution is otherwise specified (up to a fixed finite number of parameters) it might be better described as semiparametric, but that's not the convention in this area.
In the case of GLMs, the second form of nonparametric multiple regression include GAMs; that second form is the sense in which Hastie is generally operating (and under which he's operating in that quote).
|
Is logistic regression a non-parametric test?
I'd say logistic regression isn't a test at all; however a logistic regression may then lead to no tests or several tests.
You're quite correct that labelling something nonparametric because it's not
|
15,240
|
Is logistic regression a non-parametric test?
|
One helpful distinction that might add a little to the answers above: Andrew Ng gives a heuristic for what it means to be a non-parametric model in Lecture 1 from the course materials for Stanford's CS-229 course on machine learning.
There Ng says (pp. 14-15):
Locally weighted linear regression is the first example we’re seeing of a non-parametric
algorithm. The (unweighted) linear regression algorithm that we saw earlier is known as a
parametric learning algorithm, because it has a fixed, finite number of parameters (the
$\theta_{i}$’s), which are fit to the data. Once we’ve fit the $\theta_{i}$’s and stored them away, we no longer need to keep the training data around to make future predictions. In contrast, to make predictions using locally weighted linear regression, we need to keep
the entire training set around. The term “non-parametric” (roughly) refers to the fact that the amount of stuff we need to keep in order to represent the hypothesis $h$ grows linearly with the size of the training set.
I think this is a useful contrasting way to think about it because it infuses the notion of complexity directly. Non-parametric models are not inherently less-complex, because they may require keeping much more of the training data around. It just means that you're not reducing your use of the training data by compressing it down into a finitely parameterized calculation. For efficiency or unbiasedness or a host of other properties, you may want to parameterize. But there may be performance gains if you can afford to forgo parameterizing and keep lots of the data around.
|
Is logistic regression a non-parametric test?
|
One helpful distinction that might add a little to the answers above: Andrew Ng gives a heuristic for what it means to be a non-parametric model in Lecture 1 from the course materials for Stanford's C
|
Is logistic regression a non-parametric test?
One helpful distinction that might add a little to the answers above: Andrew Ng gives a heuristic for what it means to be a non-parametric model in Lecture 1 from the course materials for Stanford's CS-229 course on machine learning.
There Ng says (pp. 14-15):
Locally weighted linear regression is the first example we’re seeing of a non-parametric
algorithm. The (unweighted) linear regression algorithm that we saw earlier is known as a
parametric learning algorithm, because it has a fixed, finite number of parameters (the
$\theta_{i}$’s), which are fit to the data. Once we’ve fit the $\theta_{i}$’s and stored them away, we no longer need to keep the training data around to make future predictions. In contrast, to make predictions using locally weighted linear regression, we need to keep
the entire training set around. The term “non-parametric” (roughly) refers to the fact that the amount of stuff we need to keep in order to represent the hypothesis $h$ grows linearly with the size of the training set.
I think this is a useful contrasting way to think about it because it infuses the notion of complexity directly. Non-parametric models are not inherently less-complex, because they may require keeping much more of the training data around. It just means that you're not reducing your use of the training data by compressing it down into a finitely parameterized calculation. For efficiency or unbiasedness or a host of other properties, you may want to parameterize. But there may be performance gains if you can afford to forgo parameterizing and keep lots of the data around.
|
Is logistic regression a non-parametric test?
One helpful distinction that might add a little to the answers above: Andrew Ng gives a heuristic for what it means to be a non-parametric model in Lecture 1 from the course materials for Stanford's C
|
15,241
|
Is logistic regression a non-parametric test?
|
I think logistic regression is a parametric technique.
This might be helpful, from Wolfowitz (1942) [Additive Partition Functions and a Class of Statistical Hypotheses The Annals of Mathematical Statistics, 1942, 13, 247-279]:
“the distribution functions [note: plural!!!] of the various stochastic variables which enter into their problems are assumed to be of known functional form, and the theories of estimation and of testing hypotheses are theories of estimation of and of testing hypotheses about, one or more parameters, finite in number, the knowledge of which would completely determine the various distribution functions involved. We shall refer to this situation for brevity as the parametric case, and denote the opposite situation, where the functional forms of the distributions are unknown’, as the non-parametric case.
Also, having heard this discussed rather a lot, I found this amusing by Noether (1984) [Nonparametrics: The Early Years-Impressions and Recollections The American Statistician, 1984, 38, 173-178]:
“The term nonparametric may have some historical significance and meaning for theoretical statisticians, but it only serves to confuse applied statisticians.”
|
Is logistic regression a non-parametric test?
|
I think logistic regression is a parametric technique.
This might be helpful, from Wolfowitz (1942) [Additive Partition Functions and a Class of Statistical Hypotheses The Annals of Mathematical Stati
|
Is logistic regression a non-parametric test?
I think logistic regression is a parametric technique.
This might be helpful, from Wolfowitz (1942) [Additive Partition Functions and a Class of Statistical Hypotheses The Annals of Mathematical Statistics, 1942, 13, 247-279]:
“the distribution functions [note: plural!!!] of the various stochastic variables which enter into their problems are assumed to be of known functional form, and the theories of estimation and of testing hypotheses are theories of estimation of and of testing hypotheses about, one or more parameters, finite in number, the knowledge of which would completely determine the various distribution functions involved. We shall refer to this situation for brevity as the parametric case, and denote the opposite situation, where the functional forms of the distributions are unknown’, as the non-parametric case.
Also, having heard this discussed rather a lot, I found this amusing by Noether (1984) [Nonparametrics: The Early Years-Impressions and Recollections The American Statistician, 1984, 38, 173-178]:
“The term nonparametric may have some historical significance and meaning for theoretical statisticians, but it only serves to confuse applied statisticians.”
|
Is logistic regression a non-parametric test?
I think logistic regression is a parametric technique.
This might be helpful, from Wolfowitz (1942) [Additive Partition Functions and a Class of Statistical Hypotheses The Annals of Mathematical Stati
|
15,242
|
Is logistic regression a non-parametric test?
|
Hastie and Tibshirani defines that linear regression is a parametric approach since it assumes a linear functional form of f(X). Non-parametric methods do not explicitly assume the form for f(X). This means that a non-parametric method will fit the model based on an estimate of f, calculated from the model. Logistic regression establishes that p(x) = Pr(Y=1|X=x) where the probability is calculated by the logistic function but the logistic boundary that separates such classes is not assumed, which confirms that LR is also non-parametric
|
Is logistic regression a non-parametric test?
|
Hastie and Tibshirani defines that linear regression is a parametric approach since it assumes a linear functional form of f(X). Non-parametric methods do not explicitly assume the form for f(X). This
|
Is logistic regression a non-parametric test?
Hastie and Tibshirani defines that linear regression is a parametric approach since it assumes a linear functional form of f(X). Non-parametric methods do not explicitly assume the form for f(X). This means that a non-parametric method will fit the model based on an estimate of f, calculated from the model. Logistic regression establishes that p(x) = Pr(Y=1|X=x) where the probability is calculated by the logistic function but the logistic boundary that separates such classes is not assumed, which confirms that LR is also non-parametric
|
Is logistic regression a non-parametric test?
Hastie and Tibshirani defines that linear regression is a parametric approach since it assumes a linear functional form of f(X). Non-parametric methods do not explicitly assume the form for f(X). This
|
15,243
|
Factor analysis of questionnaires composed of Likert items
|
From what I've seen so far, FA is used for attitude items as it is for other kind of rating scales. The problem arising from the metric used (that is, "are Likert scales really to be treated as numeric scales?" is a long-standing debate, but providing you check for the bell-shaped response distribution you may handle them as continuous measurements, otherwise check for non-linear FA models or optimal scaling) may be handled by polytmomous IRT models, like the Graded Response, Rating Scale, or Partial Credit Model. The latter two may be used as a rough check of whether the threshold distances, as used in Likert-type items, are a characteristic of the response format (RSM) or of the particular item (PCM).
Regarding your second point, it is known, for example, that response distributions in attitude or health surveys differ from one country to the other (e.g. chinese people tend to highlight 'extreme' response patterns compared to those coming from western countries, see e.g. Song, X.-Y. (2007) Analysis of multisample structural equation models with applications to Quality of Life data, in Handbook of Latent Variable and Related Models, Lee, S.-Y. (Ed.), pp 279-302, North-Holland). Some methods to handle such situation off the top of my head:
use of log-linear models (marginal approach) to highlight strong between-groups imbalance at the item level (coefficients are then interpreted as relative risks instead of odds);
the multi-sample SEM method from Song cited above (Don't know if they do further work on that approach, though).
Now, the point is that most of these approaches focus at the item level (ceiling/floor effect, decreased reliability, bad item fit statistics, etc.), but when one is interested in how people deviate from what would be expected from an ideal set of observers/respondents, I think we must focus on person fit indices instead.
Such $\chi^2$ statistics are readily available for IRT models, like INFIT or OUTFIT mean square, but generally they apply on the whole questionnaire. Moreover, since estimation of items parameters rely in part on persons parameters (e.g., in the marginal likelihood framework, we assume a gaussian distribution), the presence of outlying individuals may lead to potentially biased estimates and poor model fit.
As proposed by Eid and Zickar (2007), combining a latent class model (to isolate group of respondents, e.g. those always answering on the extreme categories vs. the others) and an IRT model (to estimate item parameters and persons locations on the latent trait in both groups) appears a nice solution. Other modeling strategies are described in their paper (e.g. HYBRID model, see also Holden and Book, 2009).
Likewise, unfolding models may be used to cope with response style, which is defined as a consistent and content-independent pattern of response category (e.g. tendency to agree with all statements). In the social sciences or psychological literature, this is know as Extreme Response Style (ERS). References (1–3) may be useful to get an idea on how it manifests and how it may be measured.
Here is a short list of papers that may help to progress on this subject:
Hamilton, D.L. (1968). Personality attributes associated with extreme response style. Psychological Bulletin, 69(3): 192–203.
Greanleaf, E.A. (1992). Measuring extreme response style. Public Opinion Quaterly, 56(3): 328-351.
de Jong, M.G., Steenkamp, J.-B.E.M., Fox, J.-P., and Baumgartner, H. (2008). Using Item Response Theory to Measure Extreme Response Style in Marketing Research: A Global Investigation. Journal of marketing research, 45(1): 104-115.
Morren, M., Gelissen, J., and Vermunt, J.K. (2009). Dealing with extreme response style in cross-cultural research: A restricted latent class factor analysis approach
Moors, G. (2003). Diagnosing Response Style Behavior by Means of a Latent-Class Factor Approach. Socio-Demographic Correlates of Gender Role Attitudes and Perceptions of Ethnic Discrimination Reexamined. Quality & Quantity, 37(3), 277-302.
de Jong, M.G. Steenkamp J.B., Fox, J.-P., and Baumgartner, H. (2008). Item Response Theory to Measure Extreme Response Style in Marketing Research: A Global Investigation. Journal of Marketing Research, 45(1), 104-115.
Javaras, K.N. and Ripley, B.D. (2007). An “Unfolding” Latent Variable Model for Likert Attitude Data. JASA, 102(478): 454-463.
slides from Moustaki, Knott and Mavridis, Methods for detecting outliers in latent variable models
Eid, M. and Zickar, M.J. (2007). Detecting response styles and faking in personality and organizational assessments by Mixed Rasch Models. In von Davier, M. and Carstensen, C.H. (Eds.), Multivariate and Mixture Distribution Rasch Models, pp. 255–270, Springer.
Holden, R.R. and Book, A.S. (2009). Using hybrid Rasch-latent class modeling to improve the detection of fakers on a personality inventory. Personality and Individual Differences, 47(3): 185-190.
|
Factor analysis of questionnaires composed of Likert items
|
From what I've seen so far, FA is used for attitude items as it is for other kind of rating scales. The problem arising from the metric used (that is, "are Likert scales really to be treated as numeri
|
Factor analysis of questionnaires composed of Likert items
From what I've seen so far, FA is used for attitude items as it is for other kind of rating scales. The problem arising from the metric used (that is, "are Likert scales really to be treated as numeric scales?" is a long-standing debate, but providing you check for the bell-shaped response distribution you may handle them as continuous measurements, otherwise check for non-linear FA models or optimal scaling) may be handled by polytmomous IRT models, like the Graded Response, Rating Scale, or Partial Credit Model. The latter two may be used as a rough check of whether the threshold distances, as used in Likert-type items, are a characteristic of the response format (RSM) or of the particular item (PCM).
Regarding your second point, it is known, for example, that response distributions in attitude or health surveys differ from one country to the other (e.g. chinese people tend to highlight 'extreme' response patterns compared to those coming from western countries, see e.g. Song, X.-Y. (2007) Analysis of multisample structural equation models with applications to Quality of Life data, in Handbook of Latent Variable and Related Models, Lee, S.-Y. (Ed.), pp 279-302, North-Holland). Some methods to handle such situation off the top of my head:
use of log-linear models (marginal approach) to highlight strong between-groups imbalance at the item level (coefficients are then interpreted as relative risks instead of odds);
the multi-sample SEM method from Song cited above (Don't know if they do further work on that approach, though).
Now, the point is that most of these approaches focus at the item level (ceiling/floor effect, decreased reliability, bad item fit statistics, etc.), but when one is interested in how people deviate from what would be expected from an ideal set of observers/respondents, I think we must focus on person fit indices instead.
Such $\chi^2$ statistics are readily available for IRT models, like INFIT or OUTFIT mean square, but generally they apply on the whole questionnaire. Moreover, since estimation of items parameters rely in part on persons parameters (e.g., in the marginal likelihood framework, we assume a gaussian distribution), the presence of outlying individuals may lead to potentially biased estimates and poor model fit.
As proposed by Eid and Zickar (2007), combining a latent class model (to isolate group of respondents, e.g. those always answering on the extreme categories vs. the others) and an IRT model (to estimate item parameters and persons locations on the latent trait in both groups) appears a nice solution. Other modeling strategies are described in their paper (e.g. HYBRID model, see also Holden and Book, 2009).
Likewise, unfolding models may be used to cope with response style, which is defined as a consistent and content-independent pattern of response category (e.g. tendency to agree with all statements). In the social sciences or psychological literature, this is know as Extreme Response Style (ERS). References (1–3) may be useful to get an idea on how it manifests and how it may be measured.
Here is a short list of papers that may help to progress on this subject:
Hamilton, D.L. (1968). Personality attributes associated with extreme response style. Psychological Bulletin, 69(3): 192–203.
Greanleaf, E.A. (1992). Measuring extreme response style. Public Opinion Quaterly, 56(3): 328-351.
de Jong, M.G., Steenkamp, J.-B.E.M., Fox, J.-P., and Baumgartner, H. (2008). Using Item Response Theory to Measure Extreme Response Style in Marketing Research: A Global Investigation. Journal of marketing research, 45(1): 104-115.
Morren, M., Gelissen, J., and Vermunt, J.K. (2009). Dealing with extreme response style in cross-cultural research: A restricted latent class factor analysis approach
Moors, G. (2003). Diagnosing Response Style Behavior by Means of a Latent-Class Factor Approach. Socio-Demographic Correlates of Gender Role Attitudes and Perceptions of Ethnic Discrimination Reexamined. Quality & Quantity, 37(3), 277-302.
de Jong, M.G. Steenkamp J.B., Fox, J.-P., and Baumgartner, H. (2008). Item Response Theory to Measure Extreme Response Style in Marketing Research: A Global Investigation. Journal of Marketing Research, 45(1), 104-115.
Javaras, K.N. and Ripley, B.D. (2007). An “Unfolding” Latent Variable Model for Likert Attitude Data. JASA, 102(478): 454-463.
slides from Moustaki, Knott and Mavridis, Methods for detecting outliers in latent variable models
Eid, M. and Zickar, M.J. (2007). Detecting response styles and faking in personality and organizational assessments by Mixed Rasch Models. In von Davier, M. and Carstensen, C.H. (Eds.), Multivariate and Mixture Distribution Rasch Models, pp. 255–270, Springer.
Holden, R.R. and Book, A.S. (2009). Using hybrid Rasch-latent class modeling to improve the detection of fakers on a personality inventory. Personality and Individual Differences, 47(3): 185-190.
|
Factor analysis of questionnaires composed of Likert items
From what I've seen so far, FA is used for attitude items as it is for other kind of rating scales. The problem arising from the metric used (that is, "are Likert scales really to be treated as numeri
|
15,244
|
Factor analysis of questionnaires composed of Likert items
|
Exploratory factor analysis (EFA) is appropriate (psychometrically and otherwise) for examining the extent to which one may explain correlations among multiple items by inferring the common influence of (an) unmeasured (i.e., latent) factor(s). If this is not your specific intent, consider alternative analyses, e.g.:
General linear modeling (e.g., multiple regression, canonical correlation, or (M)AN(C)OVA)
Confirmatory factor analysis (CFA) or latent trait/class/profile analyses
Structural equation (SEM) / partial least squares modeling
Dimensionality is the first issue EFA can address. You can examine the eigenvalues of the covariance matrix (as by producing a scree plot via EFA) and conduct a parallel analysis to resolve the dimensionality of your measures. (See also some great advice and alternative suggestions from William Revelle.) You should do this carefully before extracting a limited number of factors and rotating them in EFA, or before fitting a model with a specific number of latent factors using CFA, SEM, or the like. If a parallel analysis indicates multidimensionality, but your general (first) factor vastly outweighs all others (i.e., has by far the largest eigenvalue / explains the majority of variance in your measures), consider bifactor analysis (Gibbons & Hedeker, 1992; Reise, Moore, & Haviland, 2010).
Many problems arise in EFA and latent factor modeling of Likert scale ratings. Likert scales produce ordinal (i.e., categorical, polytomous, ordered) data, not continuous data. Factor analysis generally assumes any raw data input are continuous, and people often conduct factor analyses of matrices of Pearson product-moment correlations, which are only appropriate for continuous data. Here's a quote from Reise and colleagues (2010):
Ordinary confirmatory factor analytic techniques do not apply to dichotomous or polytomous data (Byrne, 2006). Instead, special estimation procedures are required (Wirth & Edwards, 2007). There basically are three options for working with polytomous item response data. The first is to compute a polychoric matrix and then apply standard factor analytic methods (see Knol & Berger, 1991). A second option is to use full-information item factor analysis (Gibbons & Hedeker, 1992). The third is to use limited information estimation procedures
designed specifically for ordered data such as weighted least squares with mean and variance adjustment (MPLUS; Muthén & Muthén, 2009).
I would recommend combining both the first and third approaches (i.e., use diagonally weighted least squares estimation on a polychoric correlation matrix), based on Wang and Cunningham's (2005) discussion of the problems with typical alternatives:
When confirmatory factor analysis was conducted with nonnormal ordinal data using maximum likelihood and based on Pearson product-moment correlations, the downward parameter estimates produced in this study were consistent with Olsson's (1979) findings. In other words, the magnitude of nonnormality in the observed ordinal variables is a major determinant of the accuracy of parameter estimates.
The results also support the findings of Babakus, et al. (1987). When maximum likelihood estimation is used with a polychoric correlation input matrix in confirmatory factor analyses, the solutions tend to result in unacceptable
and therefore significant chi-square values together with poor fit statistics.
The question remains as to whether researchers should use weighted least squares or diagonally weighted least squares estimators in estimating structural equation models with nonnormal categorical data. Neither weighted least squares nor diagonally weighted least squares estimation makes assumptions about the nature of the distribution of the variables and both methods produce asymptotically valid results. Nevertheless, because weighted least squares estimation is based on fourth-order moments, this approach frequently leads to practical problems and is very computationally demanding. This means that weighted least squares estimation may lack robustness when used to evaluate models of medium, i.e., with 10 indicators, to large size and small to moderate sample sizes.
It isn't clear to me whether the same concern with weighted least squares estimation applies to DWLS estimation; regardless, the authors recommend that estimator. In case you don't have the means already:
R (R Core Team, 2012) is free. You'll need an old version (e.g., 2.15.2) for these packages:
The psych package (Revelle, 2013) contains the polychoric function.
The fa.parallel function can help identify the number of factors to extract.
The lavaan package (Rosseel, 2012) offers DWLS estimation for latent variable analysis.
The semTools package contains the efaUnrotate, orthRotate, and oblqRotate functions.
The mirt package (Chalmers, 2012) offers promising alternatives using item response theory.
I imagine Mplus (Muthén & Muthén, 1998-2011) would work too, but the free demo version won't accommodate more than six measurements, and the licensed version isn't cheap. It may be worth it if you can afford it though; people love Mplus, and the Muthéns' customer service via their forums is incredible!
As stated above, DWLS estimation overcomes the problem of normality assumption violations (both univariate and multivariate), which is a very common problem, and almost ubiquitous in Likert scale rating data. However, it's not necessarily a pragmatically consequential problem; most methods aren't too sensitive to (heavily biased by) small violations (cf. Is normality testing 'essentially useless'?). @chl's answer to this question raises more important, excellent points and suggestions regarding problems with extreme response style too; definitely an issue with Likert scale ratings and other subjective data.
References
· Babakus, E., Ferguson, J. C. E., & Jöreskog, K. G. (1987). The sensitivity of confirmatory maximum likelihood factor analysis to violations of measurement scale and distributional assumptions. Journal of Marketing Research, 24, 222–228.
· Byrne, B. M. (2006). Structural Equation Modeling with EQS. Mahwah, NJ:
Lawrence Erlbaum.
· Chalmers, R. P. (2012). mirt: A multidimensional item response theory package for the R environment. Journal of Statistical Software, 48(6), 1–29. Retrieved from http://www.jstatsoft.org/v48/i06/.
· Gibbons, R. D., & Hedeker, D. R. (1992). Full-information item bi-factor analysis.
Psychometrika, 57, 423–436.
· Knol, D. L., & Berger, M. P. F. (1991). Empirical comparison between factor analysis and multidimensional item response models. Multivariate Behavioral Research, 26, 457–477.
· Muthén, L. K., & Muthén, B. O. (1998-2011). Mplus user's guide (6th ed.). Los Angeles, CA: Muthén & Muthén.
· Muthén, L. K., & Muthén, B. O. (2009). Mplus (Version 4.00). [Computer software]. Los Angeles, CA: Author. URL: http://www.statmodel.com.
· Olsson, U. (1979). Maximum likelihood estimates for the polychoric correlation coefficient. Psychometrika, 44, 443–460.
· R Core Team. (2012). R: A language and environment for statistical computing. R Foundation for Statistical Computing, Vienna, Austria. ISBN 3-900051-07-0, URL: http://www.R-project.org/.
· Reise, S. P., Moore, T. M., & Haviland, M. G. (2010). Bifactor models and rotations: Exploring the extent to which multidimensional data yield univocal scale scores. Journal of Personality Assessment, 92(6), 544–559. Retrieved from http://www.ncbi.nlm.nih.gov/pmc/articles/PMC2981404/.
· Revelle, W. (2013). psych: Procedures for Personality and Psychological Research. Northwestern University, Evanston, Illinois, USA. Retrieved from http://CRAN.R-project.org/package=psych. Version = 1.3.2.
· Rosseel, Y. (2012). lavaan: An R Package for Structural Equation Modeling. Journal of Statistical Software, 48(2), 1–36. Retrieved from http://www.jstatsoft.org/v48/i02/.
· Wang, W. C., & Cunningham, E. G. (2005). Comparison of alternative estimation methods in confirmatory factor analyses of the General Health Questionnaire. Psychological Reports, 97, 3–10.
· Wirth, R. J., & Edwards, M. C. (2007). Item factor analysis: Current approaches
and future directions. Psychological Methods, 12, 58–79. Retrieved from http://www.ncbi.nlm.nih.gov/pmc/articles/PMC3162326/.
|
Factor analysis of questionnaires composed of Likert items
|
Exploratory factor analysis (EFA) is appropriate (psychometrically and otherwise) for examining the extent to which one may explain correlations among multiple items by inferring the common influence
|
Factor analysis of questionnaires composed of Likert items
Exploratory factor analysis (EFA) is appropriate (psychometrically and otherwise) for examining the extent to which one may explain correlations among multiple items by inferring the common influence of (an) unmeasured (i.e., latent) factor(s). If this is not your specific intent, consider alternative analyses, e.g.:
General linear modeling (e.g., multiple regression, canonical correlation, or (M)AN(C)OVA)
Confirmatory factor analysis (CFA) or latent trait/class/profile analyses
Structural equation (SEM) / partial least squares modeling
Dimensionality is the first issue EFA can address. You can examine the eigenvalues of the covariance matrix (as by producing a scree plot via EFA) and conduct a parallel analysis to resolve the dimensionality of your measures. (See also some great advice and alternative suggestions from William Revelle.) You should do this carefully before extracting a limited number of factors and rotating them in EFA, or before fitting a model with a specific number of latent factors using CFA, SEM, or the like. If a parallel analysis indicates multidimensionality, but your general (first) factor vastly outweighs all others (i.e., has by far the largest eigenvalue / explains the majority of variance in your measures), consider bifactor analysis (Gibbons & Hedeker, 1992; Reise, Moore, & Haviland, 2010).
Many problems arise in EFA and latent factor modeling of Likert scale ratings. Likert scales produce ordinal (i.e., categorical, polytomous, ordered) data, not continuous data. Factor analysis generally assumes any raw data input are continuous, and people often conduct factor analyses of matrices of Pearson product-moment correlations, which are only appropriate for continuous data. Here's a quote from Reise and colleagues (2010):
Ordinary confirmatory factor analytic techniques do not apply to dichotomous or polytomous data (Byrne, 2006). Instead, special estimation procedures are required (Wirth & Edwards, 2007). There basically are three options for working with polytomous item response data. The first is to compute a polychoric matrix and then apply standard factor analytic methods (see Knol & Berger, 1991). A second option is to use full-information item factor analysis (Gibbons & Hedeker, 1992). The third is to use limited information estimation procedures
designed specifically for ordered data such as weighted least squares with mean and variance adjustment (MPLUS; Muthén & Muthén, 2009).
I would recommend combining both the first and third approaches (i.e., use diagonally weighted least squares estimation on a polychoric correlation matrix), based on Wang and Cunningham's (2005) discussion of the problems with typical alternatives:
When confirmatory factor analysis was conducted with nonnormal ordinal data using maximum likelihood and based on Pearson product-moment correlations, the downward parameter estimates produced in this study were consistent with Olsson's (1979) findings. In other words, the magnitude of nonnormality in the observed ordinal variables is a major determinant of the accuracy of parameter estimates.
The results also support the findings of Babakus, et al. (1987). When maximum likelihood estimation is used with a polychoric correlation input matrix in confirmatory factor analyses, the solutions tend to result in unacceptable
and therefore significant chi-square values together with poor fit statistics.
The question remains as to whether researchers should use weighted least squares or diagonally weighted least squares estimators in estimating structural equation models with nonnormal categorical data. Neither weighted least squares nor diagonally weighted least squares estimation makes assumptions about the nature of the distribution of the variables and both methods produce asymptotically valid results. Nevertheless, because weighted least squares estimation is based on fourth-order moments, this approach frequently leads to practical problems and is very computationally demanding. This means that weighted least squares estimation may lack robustness when used to evaluate models of medium, i.e., with 10 indicators, to large size and small to moderate sample sizes.
It isn't clear to me whether the same concern with weighted least squares estimation applies to DWLS estimation; regardless, the authors recommend that estimator. In case you don't have the means already:
R (R Core Team, 2012) is free. You'll need an old version (e.g., 2.15.2) for these packages:
The psych package (Revelle, 2013) contains the polychoric function.
The fa.parallel function can help identify the number of factors to extract.
The lavaan package (Rosseel, 2012) offers DWLS estimation for latent variable analysis.
The semTools package contains the efaUnrotate, orthRotate, and oblqRotate functions.
The mirt package (Chalmers, 2012) offers promising alternatives using item response theory.
I imagine Mplus (Muthén & Muthén, 1998-2011) would work too, but the free demo version won't accommodate more than six measurements, and the licensed version isn't cheap. It may be worth it if you can afford it though; people love Mplus, and the Muthéns' customer service via their forums is incredible!
As stated above, DWLS estimation overcomes the problem of normality assumption violations (both univariate and multivariate), which is a very common problem, and almost ubiquitous in Likert scale rating data. However, it's not necessarily a pragmatically consequential problem; most methods aren't too sensitive to (heavily biased by) small violations (cf. Is normality testing 'essentially useless'?). @chl's answer to this question raises more important, excellent points and suggestions regarding problems with extreme response style too; definitely an issue with Likert scale ratings and other subjective data.
References
· Babakus, E., Ferguson, J. C. E., & Jöreskog, K. G. (1987). The sensitivity of confirmatory maximum likelihood factor analysis to violations of measurement scale and distributional assumptions. Journal of Marketing Research, 24, 222–228.
· Byrne, B. M. (2006). Structural Equation Modeling with EQS. Mahwah, NJ:
Lawrence Erlbaum.
· Chalmers, R. P. (2012). mirt: A multidimensional item response theory package for the R environment. Journal of Statistical Software, 48(6), 1–29. Retrieved from http://www.jstatsoft.org/v48/i06/.
· Gibbons, R. D., & Hedeker, D. R. (1992). Full-information item bi-factor analysis.
Psychometrika, 57, 423–436.
· Knol, D. L., & Berger, M. P. F. (1991). Empirical comparison between factor analysis and multidimensional item response models. Multivariate Behavioral Research, 26, 457–477.
· Muthén, L. K., & Muthén, B. O. (1998-2011). Mplus user's guide (6th ed.). Los Angeles, CA: Muthén & Muthén.
· Muthén, L. K., & Muthén, B. O. (2009). Mplus (Version 4.00). [Computer software]. Los Angeles, CA: Author. URL: http://www.statmodel.com.
· Olsson, U. (1979). Maximum likelihood estimates for the polychoric correlation coefficient. Psychometrika, 44, 443–460.
· R Core Team. (2012). R: A language and environment for statistical computing. R Foundation for Statistical Computing, Vienna, Austria. ISBN 3-900051-07-0, URL: http://www.R-project.org/.
· Reise, S. P., Moore, T. M., & Haviland, M. G. (2010). Bifactor models and rotations: Exploring the extent to which multidimensional data yield univocal scale scores. Journal of Personality Assessment, 92(6), 544–559. Retrieved from http://www.ncbi.nlm.nih.gov/pmc/articles/PMC2981404/.
· Revelle, W. (2013). psych: Procedures for Personality and Psychological Research. Northwestern University, Evanston, Illinois, USA. Retrieved from http://CRAN.R-project.org/package=psych. Version = 1.3.2.
· Rosseel, Y. (2012). lavaan: An R Package for Structural Equation Modeling. Journal of Statistical Software, 48(2), 1–36. Retrieved from http://www.jstatsoft.org/v48/i02/.
· Wang, W. C., & Cunningham, E. G. (2005). Comparison of alternative estimation methods in confirmatory factor analyses of the General Health Questionnaire. Psychological Reports, 97, 3–10.
· Wirth, R. J., & Edwards, M. C. (2007). Item factor analysis: Current approaches
and future directions. Psychological Methods, 12, 58–79. Retrieved from http://www.ncbi.nlm.nih.gov/pmc/articles/PMC3162326/.
|
Factor analysis of questionnaires composed of Likert items
Exploratory factor analysis (EFA) is appropriate (psychometrically and otherwise) for examining the extent to which one may explain correlations among multiple items by inferring the common influence
|
15,245
|
Factor analysis of questionnaires composed of Likert items
|
Just a short note that you might want to look at polychoric correlation with factor analysis rather than the traditional correlation/covariance matrix.
http://www.john-uebersax.com/stat/sem.htm
|
Factor analysis of questionnaires composed of Likert items
|
Just a short note that you might want to look at polychoric correlation with factor analysis rather than the traditional correlation/covariance matrix.
http://www.john-uebersax.com/stat/sem.htm
|
Factor analysis of questionnaires composed of Likert items
Just a short note that you might want to look at polychoric correlation with factor analysis rather than the traditional correlation/covariance matrix.
http://www.john-uebersax.com/stat/sem.htm
|
Factor analysis of questionnaires composed of Likert items
Just a short note that you might want to look at polychoric correlation with factor analysis rather than the traditional correlation/covariance matrix.
http://www.john-uebersax.com/stat/sem.htm
|
15,246
|
Should the y-axis on a survival plot go from 0 to 100 even if the lines are all above 0.9?
|
Bar charts should start at 0*, because the lengths of the bars (distances from top to bottom of each bar) are what your eye compares.
But for line charts (whether survival or any other), there's no hard and fast rule. It depends on the primary goal of the chart:
If the goal is to show that the vast majority survive, keep it at 0 to 100.
If the chart is being shown so that readers can compare nuanced differences between the lines, zoom in to 80 to 100.
Also on the context:
Since this is in a scientific article, presumably the reader has time to read the axis limits carefully and to think about the graph in context of the rest of the article. There's little chance of being misled by zooming in the y-axis to 80 to 100.
If this graph were in a format where the graph is only shown briefly (slide show or video), readers can't be expected to read the axis labels quickly enough before the graph disappears. So unless the presenter points it out, readers might not realize that the y-axis is zoomed in. In that case, you might want to err on the side of keeping the full y-axis of 0 to 100.
Naomi Robbins' book Creating More Effective Graphs is a great resource for best practices. She collects and summarizes advice from many dataviz experts, illustrates each best practice with a few examples, and points out where the rules of thumb can go wrong.
*(or other reference point, as @AdamO notes in the comments. Usually the length of each bar represents a "difference from 0," so 0 must be included on the y-axis to show the whole bar. But if the length of each bar represents a difference from some other reference value, the y-axis range needn't include 0---it just needs to be wide enough to include all of each bar. If you want a narrower y-axis, just use dots or lines instead of bars.)
|
Should the y-axis on a survival plot go from 0 to 100 even if the lines are all above 0.9?
|
Bar charts should start at 0*, because the lengths of the bars (distances from top to bottom of each bar) are what your eye compares.
But for line charts (whether survival or any other), there's no ha
|
Should the y-axis on a survival plot go from 0 to 100 even if the lines are all above 0.9?
Bar charts should start at 0*, because the lengths of the bars (distances from top to bottom of each bar) are what your eye compares.
But for line charts (whether survival or any other), there's no hard and fast rule. It depends on the primary goal of the chart:
If the goal is to show that the vast majority survive, keep it at 0 to 100.
If the chart is being shown so that readers can compare nuanced differences between the lines, zoom in to 80 to 100.
Also on the context:
Since this is in a scientific article, presumably the reader has time to read the axis limits carefully and to think about the graph in context of the rest of the article. There's little chance of being misled by zooming in the y-axis to 80 to 100.
If this graph were in a format where the graph is only shown briefly (slide show or video), readers can't be expected to read the axis labels quickly enough before the graph disappears. So unless the presenter points it out, readers might not realize that the y-axis is zoomed in. In that case, you might want to err on the side of keeping the full y-axis of 0 to 100.
Naomi Robbins' book Creating More Effective Graphs is a great resource for best practices. She collects and summarizes advice from many dataviz experts, illustrates each best practice with a few examples, and points out where the rules of thumb can go wrong.
*(or other reference point, as @AdamO notes in the comments. Usually the length of each bar represents a "difference from 0," so 0 must be included on the y-axis to show the whole bar. But if the length of each bar represents a difference from some other reference value, the y-axis range needn't include 0---it just needs to be wide enough to include all of each bar. If you want a narrower y-axis, just use dots or lines instead of bars.)
|
Should the y-axis on a survival plot go from 0 to 100 even if the lines are all above 0.9?
Bar charts should start at 0*, because the lengths of the bars (distances from top to bottom of each bar) are what your eye compares.
But for line charts (whether survival or any other), there's no ha
|
15,247
|
Should the y-axis on a survival plot go from 0 to 100 even if the lines are all above 0.9?
|
I have seen it both ways. It depends on the message you are trying to send. It's true that non-statisticians (and some statisticians) are likely to be confused and miss it if the Y-axis starts at anything other than 0. In a huge study, you can have curves that barely cross 95% survival with hazard ratios of astounding magnitude (0.5 or lower) and significant $p$-values. Another "confusion" in the community might be why an analysis is so well powered but the graph "doesn't show anything". Hopefully statisticians understand that 100,000s of people in an analysis without events are the explanation here, but they'd be right to question "if the graph really does anything" - we shouldn't say it did or didn't based on the results, that is an a posteriori finding.
Alternately, you could include a cumulative incidence plot, which can be defined as 1-S(t).
Example from here.
|
Should the y-axis on a survival plot go from 0 to 100 even if the lines are all above 0.9?
|
I have seen it both ways. It depends on the message you are trying to send. It's true that non-statisticians (and some statisticians) are likely to be confused and miss it if the Y-axis starts at anyt
|
Should the y-axis on a survival plot go from 0 to 100 even if the lines are all above 0.9?
I have seen it both ways. It depends on the message you are trying to send. It's true that non-statisticians (and some statisticians) are likely to be confused and miss it if the Y-axis starts at anything other than 0. In a huge study, you can have curves that barely cross 95% survival with hazard ratios of astounding magnitude (0.5 or lower) and significant $p$-values. Another "confusion" in the community might be why an analysis is so well powered but the graph "doesn't show anything". Hopefully statisticians understand that 100,000s of people in an analysis without events are the explanation here, but they'd be right to question "if the graph really does anything" - we shouldn't say it did or didn't based on the results, that is an a posteriori finding.
Alternately, you could include a cumulative incidence plot, which can be defined as 1-S(t).
Example from here.
|
Should the y-axis on a survival plot go from 0 to 100 even if the lines are all above 0.9?
I have seen it both ways. It depends on the message you are trying to send. It's true that non-statisticians (and some statisticians) are likely to be confused and miss it if the Y-axis starts at anyt
|
15,248
|
Should the y-axis on a survival plot go from 0 to 100 even if the lines are all above 0.9?
|
Generally, starting the graph above zero is preferable, as it allows the viewer to more easily digest the information, which is the point of the graph. You do have to be careful to not mislead the viewer into such misperceptions as that twice the distance from the bottom means twice the value. You can emphasize that it doesn't start at zero, such as by having squiggly lines . Depending on the context, you might want to just change the variable from "survival" to something like "attrition", and show 1-survival; going from 90% to 95% is a small percentage change in survival, but half the attrition (going from 10% to 5%), so the question arises as to which is more pertinent.
|
Should the y-axis on a survival plot go from 0 to 100 even if the lines are all above 0.9?
|
Generally, starting the graph above zero is preferable, as it allows the viewer to more easily digest the information, which is the point of the graph. You do have to be careful to not mislead the vi
|
Should the y-axis on a survival plot go from 0 to 100 even if the lines are all above 0.9?
Generally, starting the graph above zero is preferable, as it allows the viewer to more easily digest the information, which is the point of the graph. You do have to be careful to not mislead the viewer into such misperceptions as that twice the distance from the bottom means twice the value. You can emphasize that it doesn't start at zero, such as by having squiggly lines . Depending on the context, you might want to just change the variable from "survival" to something like "attrition", and show 1-survival; going from 90% to 95% is a small percentage change in survival, but half the attrition (going from 10% to 5%), so the question arises as to which is more pertinent.
|
Should the y-axis on a survival plot go from 0 to 100 even if the lines are all above 0.9?
Generally, starting the graph above zero is preferable, as it allows the viewer to more easily digest the information, which is the point of the graph. You do have to be careful to not mislead the vi
|
15,249
|
Can $\sin(x)$ be used as activation in deep learning?
|
Here's a paper dedicated to this very question:
Parascandolo and Virtanen (2016). Taming the waves: sine as activation function in deep neural networks.
Some key points from the paper:
Sinusoidal activation functions have been largely ignored, and are considered difficult to train.
They review past work that has used sinusoidal activation functions. Most of this is earlier work (before the modern 'deep learning' boom). But, there are a couple more recent papers.
The periodic nature of sinusoidal activation functions can give rise to a 'rippling' cost function with bad local minima, which may make training difficult.
The problem may not be so bad when the data is dominated by low-frequency components (which is expected for many real-world datasets). Learning is easier in this regime, but is sensitive to how network parameters are initialized.
They show that networks with sinusoidal activation functions can perform reasonably well on a couple real-world datasets. But, after training, the networks don't really use the periodic nature of the activation function. Rather, they only use the central region near zero, where the sinusoid is nearly equivalent to the more traditional $\tanh$ activation function.
They trained recurrent networks on a synthetic task where periodic structure is expected to be helpful. Networks learn faster and are more accurate using $\sin$ compared to $\tanh$ activation functions. But, the difference is bigger for vanilla RNNs than LSTMs.
Here's another relevant paper:
Ramachandran, Zoph, Le (2017). Searching for Activation Functions.
They performed a large-scale, automatic search over activation functions to find new variants that perform well. Some of the activation functions they discovered use sinusoidal components (but they're not pure sinusoids--they also tend to have a monotonic component). The paper doesn't discuss these variants much, except to say that they're an interesting future research direction.
|
Can $\sin(x)$ be used as activation in deep learning?
|
Here's a paper dedicated to this very question:
Parascandolo and Virtanen (2016). Taming the waves: sine as activation function in deep neural networks.
Some key points from the paper:
Sinusoidal a
|
Can $\sin(x)$ be used as activation in deep learning?
Here's a paper dedicated to this very question:
Parascandolo and Virtanen (2016). Taming the waves: sine as activation function in deep neural networks.
Some key points from the paper:
Sinusoidal activation functions have been largely ignored, and are considered difficult to train.
They review past work that has used sinusoidal activation functions. Most of this is earlier work (before the modern 'deep learning' boom). But, there are a couple more recent papers.
The periodic nature of sinusoidal activation functions can give rise to a 'rippling' cost function with bad local minima, which may make training difficult.
The problem may not be so bad when the data is dominated by low-frequency components (which is expected for many real-world datasets). Learning is easier in this regime, but is sensitive to how network parameters are initialized.
They show that networks with sinusoidal activation functions can perform reasonably well on a couple real-world datasets. But, after training, the networks don't really use the periodic nature of the activation function. Rather, they only use the central region near zero, where the sinusoid is nearly equivalent to the more traditional $\tanh$ activation function.
They trained recurrent networks on a synthetic task where periodic structure is expected to be helpful. Networks learn faster and are more accurate using $\sin$ compared to $\tanh$ activation functions. But, the difference is bigger for vanilla RNNs than LSTMs.
Here's another relevant paper:
Ramachandran, Zoph, Le (2017). Searching for Activation Functions.
They performed a large-scale, automatic search over activation functions to find new variants that perform well. Some of the activation functions they discovered use sinusoidal components (but they're not pure sinusoids--they also tend to have a monotonic component). The paper doesn't discuss these variants much, except to say that they're an interesting future research direction.
|
Can $\sin(x)$ be used as activation in deep learning?
Here's a paper dedicated to this very question:
Parascandolo and Virtanen (2016). Taming the waves: sine as activation function in deep neural networks.
Some key points from the paper:
Sinusoidal a
|
15,250
|
Can $\sin(x)$ be used as activation in deep learning?
|
As of June 2020, work from Stanford has demonstrated that your intuition was right and that $sin(x)$ can be indeed used for a variety of tasks effectively:
https://vsitzmann.github.io/siren/
https://arxiv.org/pdf/2006.09661.pdf
|
Can $\sin(x)$ be used as activation in deep learning?
|
As of June 2020, work from Stanford has demonstrated that your intuition was right and that $sin(x)$ can be indeed used for a variety of tasks effectively:
https://vsitzmann.github.io/siren/
https://
|
Can $\sin(x)$ be used as activation in deep learning?
As of June 2020, work from Stanford has demonstrated that your intuition was right and that $sin(x)$ can be indeed used for a variety of tasks effectively:
https://vsitzmann.github.io/siren/
https://arxiv.org/pdf/2006.09661.pdf
|
Can $\sin(x)$ be used as activation in deep learning?
As of June 2020, work from Stanford has demonstrated that your intuition was right and that $sin(x)$ can be indeed used for a variety of tasks effectively:
https://vsitzmann.github.io/siren/
https://
|
15,251
|
Can $\sin(x)$ be used as activation in deep learning?
|
It surely "can" be used. The fact that it is not being used1, however, suggests that it is not very much practical. The gradient of $\sin$ is actually zero at $\frac \pi 2+k\pi$ for any integer $k$. I think the main problem with using $\sin$ activation is that it introduces infinitely many symmetries, which may make the learning even harder than it is.
However, the right architecture always depends on the specific problem and data representation that you are dealing with. I am sure there are scenarios where tailoring $\sin$ into the network may not only make sense, but also improve the performance.
1 That is, not being commonly used. To the extent that I have not seen it ever being used (though my experience is limited to computer vision problems). It certainly is not one of the generally applicable nonlinearities such as ReLU or sigmoid.
|
Can $\sin(x)$ be used as activation in deep learning?
|
It surely "can" be used. The fact that it is not being used1, however, suggests that it is not very much practical. The gradient of $\sin$ is actually zero at $\frac \pi 2+k\pi$ for any integer $k$. I
|
Can $\sin(x)$ be used as activation in deep learning?
It surely "can" be used. The fact that it is not being used1, however, suggests that it is not very much practical. The gradient of $\sin$ is actually zero at $\frac \pi 2+k\pi$ for any integer $k$. I think the main problem with using $\sin$ activation is that it introduces infinitely many symmetries, which may make the learning even harder than it is.
However, the right architecture always depends on the specific problem and data representation that you are dealing with. I am sure there are scenarios where tailoring $\sin$ into the network may not only make sense, but also improve the performance.
1 That is, not being commonly used. To the extent that I have not seen it ever being used (though my experience is limited to computer vision problems). It certainly is not one of the generally applicable nonlinearities such as ReLU or sigmoid.
|
Can $\sin(x)$ be used as activation in deep learning?
It surely "can" be used. The fact that it is not being used1, however, suggests that it is not very much practical. The gradient of $\sin$ is actually zero at $\frac \pi 2+k\pi$ for any integer $k$. I
|
15,252
|
Can $\sin(x)$ be used as activation in deep learning?
|
This was a part of my master thesis. I have researched and mentioned previous publications on the use of sine function as activation and as the basis function. In addition, I have designed several different versions of the sine function and used them as the basis function in the artificial neural networks as a replacement for the linear function. It was last year. You can find the paper that represents the "use of sine" part of my thesis in the link: CSIMQ
I mentioned in the paper, but you can also search for Fourier Neural Networks for this subject. The artificial neural networks that use sine function as a basis are named like that mostly.
In addition, I have shared several articles in Medium regarding this subject that can help you.
Creating Alternative Truths with Sine Activation Function in Neural Networks
Sinusoidal Neural Networks for Digit Classification
Neural Networks with Sine Basis Function
|
Can $\sin(x)$ be used as activation in deep learning?
|
This was a part of my master thesis. I have researched and mentioned previous publications on the use of sine function as activation and as the basis function. In addition, I have designed several dif
|
Can $\sin(x)$ be used as activation in deep learning?
This was a part of my master thesis. I have researched and mentioned previous publications on the use of sine function as activation and as the basis function. In addition, I have designed several different versions of the sine function and used them as the basis function in the artificial neural networks as a replacement for the linear function. It was last year. You can find the paper that represents the "use of sine" part of my thesis in the link: CSIMQ
I mentioned in the paper, but you can also search for Fourier Neural Networks for this subject. The artificial neural networks that use sine function as a basis are named like that mostly.
In addition, I have shared several articles in Medium regarding this subject that can help you.
Creating Alternative Truths with Sine Activation Function in Neural Networks
Sinusoidal Neural Networks for Digit Classification
Neural Networks with Sine Basis Function
|
Can $\sin(x)$ be used as activation in deep learning?
This was a part of my master thesis. I have researched and mentioned previous publications on the use of sine function as activation and as the basis function. In addition, I have designed several dif
|
15,253
|
Probability that Secret Santa arrangement will result in perfect pairings
|
The total number of assignments among $2n$ people, where nobody is assigned to themselves, is $$d(2n) = (2n)!(1/2 - 1/6 + \cdots + (-1)^k/k! + \cdots + 1/(2n)!).$$ (These are called derangements.) The value is very close to $(2n)! / e$.
If they correspond to perfect pairings, then they are a product of disjoint transpositions. This implies their cycle structure is of the form
$$(a_{11}a_{12})(a_{21}a_{22})\cdots(a_{n1}a_{n2}).$$
The number of distinct such patterns is the order of the group of all permutations of the $2n$ names divided by the order of the stabilizer of the pattern. A stabilizing element may swap any number of the pairs and it may also permute the $n!$ pairs, whence there are $2^n n!$ stabilizing elements. Therefore there are
$$p(2n) = \frac{(2n)!}{2^n n!}$$
such pairings.
Since all such perfect pairings are derangements, and all derangements are equally likely, the chance equals
$$\frac{p(2n)}{d(2n)} = \frac{1}{2^n n!(1 - 1/2 + 1/6 - \cdots + (-1)^k/k! + \cdots + 1/(2n)!)} \approx \frac{e}{2^n n!}.$$
For $2n=8$ people the exact answer therefore is $15/2119 \approx 0.00707881$ while the approximation is $e/(2^4\, 4!) \approx 0.00707886$: they agree to five significant figures.
To check, this R simulation draws a million random permutations of eight objects, retains only those that are derangements, and counts those that are perfect pairings. It outputs its estimate, the standard error of the estimate, and a Z-score to compare it to the theoretical value. Its output is
p.hat se Z
0.006981031 0.000137385 -0.711721705
The small Z-score is consistent with the theoretical value. (These results would be consistent with any theoretical value between $0.0066$ and $0.0073$.)
paired <- function(x) crossprod(x[x] - 1:length(x))==0
good <- function(x) sum(x==1:length(x)) == 0
n <- 8
set.seed(17)
x <- replicate(1e6, sample(1:n, n))
i.good <- apply(x, 2, good)
i.paired <- apply(x, 2, paired)
n.deranged <- sum(i.good)
k.paired <- sum(i.good & i.paired)
p.hat <- k.paired / n.deranged
se <- sqrt(p.hat * (1-p.hat) / n.deranged)
(c(p.hat=p.hat, se=se, Z=(p.hat - 15/2119)/se))
|
Probability that Secret Santa arrangement will result in perfect pairings
|
The total number of assignments among $2n$ people, where nobody is assigned to themselves, is $$d(2n) = (2n)!(1/2 - 1/6 + \cdots + (-1)^k/k! + \cdots + 1/(2n)!).$$ (These are called derangements.) T
|
Probability that Secret Santa arrangement will result in perfect pairings
The total number of assignments among $2n$ people, where nobody is assigned to themselves, is $$d(2n) = (2n)!(1/2 - 1/6 + \cdots + (-1)^k/k! + \cdots + 1/(2n)!).$$ (These are called derangements.) The value is very close to $(2n)! / e$.
If they correspond to perfect pairings, then they are a product of disjoint transpositions. This implies their cycle structure is of the form
$$(a_{11}a_{12})(a_{21}a_{22})\cdots(a_{n1}a_{n2}).$$
The number of distinct such patterns is the order of the group of all permutations of the $2n$ names divided by the order of the stabilizer of the pattern. A stabilizing element may swap any number of the pairs and it may also permute the $n!$ pairs, whence there are $2^n n!$ stabilizing elements. Therefore there are
$$p(2n) = \frac{(2n)!}{2^n n!}$$
such pairings.
Since all such perfect pairings are derangements, and all derangements are equally likely, the chance equals
$$\frac{p(2n)}{d(2n)} = \frac{1}{2^n n!(1 - 1/2 + 1/6 - \cdots + (-1)^k/k! + \cdots + 1/(2n)!)} \approx \frac{e}{2^n n!}.$$
For $2n=8$ people the exact answer therefore is $15/2119 \approx 0.00707881$ while the approximation is $e/(2^4\, 4!) \approx 0.00707886$: they agree to five significant figures.
To check, this R simulation draws a million random permutations of eight objects, retains only those that are derangements, and counts those that are perfect pairings. It outputs its estimate, the standard error of the estimate, and a Z-score to compare it to the theoretical value. Its output is
p.hat se Z
0.006981031 0.000137385 -0.711721705
The small Z-score is consistent with the theoretical value. (These results would be consistent with any theoretical value between $0.0066$ and $0.0073$.)
paired <- function(x) crossprod(x[x] - 1:length(x))==0
good <- function(x) sum(x==1:length(x)) == 0
n <- 8
set.seed(17)
x <- replicate(1e6, sample(1:n, n))
i.good <- apply(x, 2, good)
i.paired <- apply(x, 2, paired)
n.deranged <- sum(i.good)
k.paired <- sum(i.good & i.paired)
p.hat <- k.paired / n.deranged
se <- sqrt(p.hat * (1-p.hat) / n.deranged)
(c(p.hat=p.hat, se=se, Z=(p.hat - 15/2119)/se))
|
Probability that Secret Santa arrangement will result in perfect pairings
The total number of assignments among $2n$ people, where nobody is assigned to themselves, is $$d(2n) = (2n)!(1/2 - 1/6 + \cdots + (-1)^k/k! + \cdots + 1/(2n)!).$$ (These are called derangements.) T
|
15,254
|
Probability that Secret Santa arrangement will result in perfect pairings
|
I was quite impressed by the elegance in @whuber answer. To be honest I had to do a lot of acquainting myself with new concepts to follow the steps in his solution. After spending a lot of time on it, I've decided to post what I got. So what follows is an exegetical note to his already accepted response. In this way there is no attempt at originality, and my only objective is to provide some additional anchoring points to follow some of the steps involved.
So here it goes...
1. Why $2n$? Well this one may be way too basic: we need an even number of people to play the game.
2. Can we derive the formula for derangements?
Following the Wikipedia entry with the example based on matching of people and hats, $n$ hats to be precise, we have that the options for the first person picking up a hat are shown here as follows:
$d(n)=(n-1)[d(n-2) + d(n-1)]=$
$=n\,d(n-2)-d(n-2)+n\,d(n-1)-d(n-1)$, which can be reorganized as:
$d(n) - n\,d(n-1) = -[d(n-1)-(n-1)\,d(n-2)]$.
Now noticing the parallelism between the LHS of this equation and the part on the RHS within brackets we can continue recursively:
$d(n) - n\,d(n-1)=-[d(n-1)-(n-1)\,d(n-2)] =$
$=(-1)^2\,[d(n-2)-(n-2)\,d(n-3)]=\cdots=(-1)^{n-2}\,d(2)-2\,d(1)$
This implies that $d(n) = n\,d(n-1)+(-1)^n$.
Working backwards:
$d(2)=1$
$d(3)= 3\,d(2)-1 =3*1\,-1$
$d(4)= 4\,d(3)+1 =4*3*1\,-4\,\,+1$
$d(5)= 5\,d(4)-1 =5*4*3*1\,-5*4\,+5\,\,-1$
$d(6)= 6\,d(5)+1 = 6*5*4*3*1\,-6*5*4\,+6*5\,-6\,+1=$
$=6!\left(\frac{1}{2}- \frac{1}{3*2}+\frac{1}{4*3*2}-\frac{1}{5*4*3*2}+\frac{1}{6!}\right)=$
$=6!\left(\frac{1}{6!}-\frac{1}{5!}+\frac{1}{4!}-\frac{1}{3!}+\frac{1}{2!}-\frac{1}{1!}+1\right)$
So in general,
$d(n)=n!\left(1-1+\frac{1}{2!}-\frac{1}{3!}+\frac{1}{4!}+\cdots+\frac{1}{n!}\right)$
And remembering the Taylor series of $e^x$ evaluated at $x=-1$:
$d(n)\approx\frac{n!}{e}$
3. Disjoint transposition: The concept of transposition is easy to get from the link provided in the original answer, but "disjoint" was a bit less clear. Looking at an example, from the set ${a,b,c,d,e,f}$, the permutation ${b,d,a,c,f,e}$ can be expressed as a cycle as: a -> b -> d -> c after which it returns to a, but e -> f forms a loop onto itself - a disjoint cycle. Or, putting these two cycles together, the permutation can be expressed as the product $(\text {a b d c})(\text{e f})$.
In the Santa Claus question (eight employees happening to have drawn names in perfectly matched pairs: Anna gives Martha a gift, while Martha has drawn Anna's name) there will be $4$ closed loops.
4. To find the number of two-element loops we need to divide all possible permutations $(2n)!$ of the set of eight ($2n$) people by the total possible number of swaps of two elements $2^n$ and the total number of permutations of these pairs $n!$: $p(2n) = \frac{(2n)!}{2^n n!}$.
For the R simulation:
1. paired <- function(x) crossprod(x[x] - 1:length(x))==0
This function boils down to understanding x[x]: It is meant to evaluate an $8$ element vector representing the present assignments, and determine whether it is composed of 2-element loops, as in the Santa Claus problem. As long as the permutations correspond to transposing elements so that if Paul was supposed to give a present to Maria (Paul -> Maria and vice versa, Maria -> Paul) and Max to John (Max -> John / John -> Max) initially, the resultant transposition just results in new perfect pairing (Max -> Maria / Maria -> Max and Paul -> John / John -> Paul) we are fulfilling the initial condition of perfect pairing:
In other words, if we go back to the example of the hats in Wikipedia person i always takes back hat $1$.
2. good <- function(x) sum(x==1:length(x)) == 0
This function evaluates whether we are dealing with a derangement by comparing the vector $x$ element wise to the the vector $(1,2,3,4,5,6,7,8)$, and making sure there is no coincidence.
3. k.paired <- sum(i.good & i.paired) is there to exclude paired permutations like the one above in the diagram, which are not derangements:
v <- c(1,2,3,4,5,6,7,8)
w <- c(1,2,3,5,4,6,7,8)
(c("is v paired?" = paired(v), "is w paired?" = paired(w),
"is v a derang?" = good(w), "is w a derang?" = good(w)))
# not all paired permutations are derangements.
|
Probability that Secret Santa arrangement will result in perfect pairings
|
I was quite impressed by the elegance in @whuber answer. To be honest I had to do a lot of acquainting myself with new concepts to follow the steps in his solution. After spending a lot of time on it,
|
Probability that Secret Santa arrangement will result in perfect pairings
I was quite impressed by the elegance in @whuber answer. To be honest I had to do a lot of acquainting myself with new concepts to follow the steps in his solution. After spending a lot of time on it, I've decided to post what I got. So what follows is an exegetical note to his already accepted response. In this way there is no attempt at originality, and my only objective is to provide some additional anchoring points to follow some of the steps involved.
So here it goes...
1. Why $2n$? Well this one may be way too basic: we need an even number of people to play the game.
2. Can we derive the formula for derangements?
Following the Wikipedia entry with the example based on matching of people and hats, $n$ hats to be precise, we have that the options for the first person picking up a hat are shown here as follows:
$d(n)=(n-1)[d(n-2) + d(n-1)]=$
$=n\,d(n-2)-d(n-2)+n\,d(n-1)-d(n-1)$, which can be reorganized as:
$d(n) - n\,d(n-1) = -[d(n-1)-(n-1)\,d(n-2)]$.
Now noticing the parallelism between the LHS of this equation and the part on the RHS within brackets we can continue recursively:
$d(n) - n\,d(n-1)=-[d(n-1)-(n-1)\,d(n-2)] =$
$=(-1)^2\,[d(n-2)-(n-2)\,d(n-3)]=\cdots=(-1)^{n-2}\,d(2)-2\,d(1)$
This implies that $d(n) = n\,d(n-1)+(-1)^n$.
Working backwards:
$d(2)=1$
$d(3)= 3\,d(2)-1 =3*1\,-1$
$d(4)= 4\,d(3)+1 =4*3*1\,-4\,\,+1$
$d(5)= 5\,d(4)-1 =5*4*3*1\,-5*4\,+5\,\,-1$
$d(6)= 6\,d(5)+1 = 6*5*4*3*1\,-6*5*4\,+6*5\,-6\,+1=$
$=6!\left(\frac{1}{2}- \frac{1}{3*2}+\frac{1}{4*3*2}-\frac{1}{5*4*3*2}+\frac{1}{6!}\right)=$
$=6!\left(\frac{1}{6!}-\frac{1}{5!}+\frac{1}{4!}-\frac{1}{3!}+\frac{1}{2!}-\frac{1}{1!}+1\right)$
So in general,
$d(n)=n!\left(1-1+\frac{1}{2!}-\frac{1}{3!}+\frac{1}{4!}+\cdots+\frac{1}{n!}\right)$
And remembering the Taylor series of $e^x$ evaluated at $x=-1$:
$d(n)\approx\frac{n!}{e}$
3. Disjoint transposition: The concept of transposition is easy to get from the link provided in the original answer, but "disjoint" was a bit less clear. Looking at an example, from the set ${a,b,c,d,e,f}$, the permutation ${b,d,a,c,f,e}$ can be expressed as a cycle as: a -> b -> d -> c after which it returns to a, but e -> f forms a loop onto itself - a disjoint cycle. Or, putting these two cycles together, the permutation can be expressed as the product $(\text {a b d c})(\text{e f})$.
In the Santa Claus question (eight employees happening to have drawn names in perfectly matched pairs: Anna gives Martha a gift, while Martha has drawn Anna's name) there will be $4$ closed loops.
4. To find the number of two-element loops we need to divide all possible permutations $(2n)!$ of the set of eight ($2n$) people by the total possible number of swaps of two elements $2^n$ and the total number of permutations of these pairs $n!$: $p(2n) = \frac{(2n)!}{2^n n!}$.
For the R simulation:
1. paired <- function(x) crossprod(x[x] - 1:length(x))==0
This function boils down to understanding x[x]: It is meant to evaluate an $8$ element vector representing the present assignments, and determine whether it is composed of 2-element loops, as in the Santa Claus problem. As long as the permutations correspond to transposing elements so that if Paul was supposed to give a present to Maria (Paul -> Maria and vice versa, Maria -> Paul) and Max to John (Max -> John / John -> Max) initially, the resultant transposition just results in new perfect pairing (Max -> Maria / Maria -> Max and Paul -> John / John -> Paul) we are fulfilling the initial condition of perfect pairing:
In other words, if we go back to the example of the hats in Wikipedia person i always takes back hat $1$.
2. good <- function(x) sum(x==1:length(x)) == 0
This function evaluates whether we are dealing with a derangement by comparing the vector $x$ element wise to the the vector $(1,2,3,4,5,6,7,8)$, and making sure there is no coincidence.
3. k.paired <- sum(i.good & i.paired) is there to exclude paired permutations like the one above in the diagram, which are not derangements:
v <- c(1,2,3,4,5,6,7,8)
w <- c(1,2,3,5,4,6,7,8)
(c("is v paired?" = paired(v), "is w paired?" = paired(w),
"is v a derang?" = good(w), "is w a derang?" = good(w)))
# not all paired permutations are derangements.
|
Probability that Secret Santa arrangement will result in perfect pairings
I was quite impressed by the elegance in @whuber answer. To be honest I had to do a lot of acquainting myself with new concepts to follow the steps in his solution. After spending a lot of time on it,
|
15,255
|
Probability that Secret Santa arrangement will result in perfect pairings
|
So this answer is prompted by a few questions in the comments. The earlier two answers are correct if the implicit assumption that all derangements are equally likely is true. This is sadly not the case with the method actually used in the question which is why quite a lot of secret santas are now using computer based methods as these can afford to discard the full drawing and re-start when the random assignment gives someone themselves.
To check that the difference actually was real, I implemented a set of python functions to systematically generate all possible options for a given set of people.
Firstly I implemented a version using the method that a computer will use which is generate a completely random option and repeat till we get a valid answer. This gives the same result as just counting the number of valid options (which is the same as the number of derangements) and assigning equal probability to each of them.
Second added in the handling of the replace and re-draw if you select your own name. As written a person could keep drawing them selves, putting their name back in and repeating for an infinite number of times, however we can show that this is actually the same as drawing any of the valid options with equal probability as
$$
\frac{1}{n}\sum_{i=0}^\infty\left(\frac{1}{n}\right)^i= \frac{1}{n-1}
$$
This gives us another way of viewing the problem. The probability of selecting each option now depends on if your name is still in the hat or not. We aren't suggesting people should check if they are in the hat, just that the probabilities are the same. The effect this difference in probabilities has is also compounded by the effect of the having to still abandon and re-start if we end up with the last name in the hat being the name of the last person to pick.
Sadly I haven't found an explicit formula for the probabilities of each option but I have implemented python code with this calculation and produced graphs of the resulting probabilities and calculated the probabilities for the pairing to happen.
The calculation done in the other answers gives a probability of 0.0070788107597923545 where as the accurate calculation for the stated method gives a probability of 0.006876714828601176. This isn't a large difference but it definitely is a measurable difference.
My code is included below for reference:
import pylab as pl
def generate_options(count):
entries = set(range(count))
return do_generate_options([], entries)
def do_generate_options(selected, available):
""" Calculate the probabilities of a secret santa draw if we abandom if someone draws their own name. """
if len(available) == 0:
yield 1,tuple(selected)
return
factor = 1.0/len(available)
for i in list(available):
if i == len(selected):
yield factor, None
else:
selected.append(i)
available.remove(i)
for p, option in do_generate_options(selected, available):
yield p * factor, option
selected.pop()
available.add(i)
def do_generate_options(selected, available):
""" Calculate the probabilities of a secret santa draw if you return the name and re-draw from that person if someone draws their own name. """
if len(available) == 0:
yield 1,tuple(selected)
return
factor = 1.0/len(available)
if len(selected) in available:
if len(available) == 1:
yield 1, None
return
# sum 1/n^i for i from 1 to infinity = 1/n + 1/n * 1/(n-1) = 1/(n-1)
factor = 1.0/(len(available) - 1)
for i in list(available):
if i != len(selected):
selected.append(i)
available.remove(i)
for p, option in do_generate_options(selected, available):
yield p * factor, option
selected.pop()
available.add(i)
def plot_probability_counts(count):
data = {}
for p, entry in generate_options(count):
if entry is not None:
if p in data:
data[p] = data[p] + 1
else:
data[p] = 1
entries = list(data.items())
plt = pl.figure().add_subplot(111)
plt.set_xlabel("probability")
plt.set_ylabel("count")
plt.plot([p * total for p, c in entries], [c for p, c in entries], "+")
def plot_probability_counts_scaled(count):
data = {}
total = 0
for p, entry in generate_options(count):
if entry is not None:
total = total + 1
if p in data:
data[p] = data[p] + 1
else:
data[p] = 1
entries = list(data.items())
plt = pl.figure().add_subplot(111)
plt.set_xlabel("probability/uniform probability")
plt.set_ylabel("fraction")
plt.plot([p * total for p, c in entries], [c / total for p, c in entries], "+")
def plot_probabilities_per_person(count):
total = 0
probabilites = [[0] * count for i in range(count)]
for p, entry in generate_options(count):
if entry is not None:
total = total + p
for i,j in enumerate(entry):
probabilites[i][j] = probabilites[i][j] + p
width = 1/(count + 1.5)
xticks = range(count)
plt = pl.figure().add_subplot(111)
plt.set_xticks(xticks)
plt.set_xticklabels(xticks)
plt.set_xlabel("person giving")
plt.set_ylabel("probability")
plt.set_xlim(-0.5, count + 1.5)
for i, a_probabilities in enumerate(probabilites):
plt.bar([x + (i - (count - 1)/2) * width for x in xticks], [p/total for p in a_probabilities], width, label = i)
plt.legend(title = "giving to", loc = "upper right")
def probability_paired(count):
totalProbability = 0
pairedProbability = 0
totalCount = 0
pairedCount = 0
for p, entry in generate_options(count):
if entry is not None:
totalProbability = totalProbability + p
totalCount = totalCount + 1
valid = True
for i in range(count):
if entry[entry[i]] != i:
valid = False
break
if valid:
pairedProbability = pairedProbability + p
pairedCount = pairedCount + 1
return pairedProbability, totalProbability, pairedCount, totalCount
|
Probability that Secret Santa arrangement will result in perfect pairings
|
So this answer is prompted by a few questions in the comments. The earlier two answers are correct if the implicit assumption that all derangements are equally likely is true. This is sadly not the ca
|
Probability that Secret Santa arrangement will result in perfect pairings
So this answer is prompted by a few questions in the comments. The earlier two answers are correct if the implicit assumption that all derangements are equally likely is true. This is sadly not the case with the method actually used in the question which is why quite a lot of secret santas are now using computer based methods as these can afford to discard the full drawing and re-start when the random assignment gives someone themselves.
To check that the difference actually was real, I implemented a set of python functions to systematically generate all possible options for a given set of people.
Firstly I implemented a version using the method that a computer will use which is generate a completely random option and repeat till we get a valid answer. This gives the same result as just counting the number of valid options (which is the same as the number of derangements) and assigning equal probability to each of them.
Second added in the handling of the replace and re-draw if you select your own name. As written a person could keep drawing them selves, putting their name back in and repeating for an infinite number of times, however we can show that this is actually the same as drawing any of the valid options with equal probability as
$$
\frac{1}{n}\sum_{i=0}^\infty\left(\frac{1}{n}\right)^i= \frac{1}{n-1}
$$
This gives us another way of viewing the problem. The probability of selecting each option now depends on if your name is still in the hat or not. We aren't suggesting people should check if they are in the hat, just that the probabilities are the same. The effect this difference in probabilities has is also compounded by the effect of the having to still abandon and re-start if we end up with the last name in the hat being the name of the last person to pick.
Sadly I haven't found an explicit formula for the probabilities of each option but I have implemented python code with this calculation and produced graphs of the resulting probabilities and calculated the probabilities for the pairing to happen.
The calculation done in the other answers gives a probability of 0.0070788107597923545 where as the accurate calculation for the stated method gives a probability of 0.006876714828601176. This isn't a large difference but it definitely is a measurable difference.
My code is included below for reference:
import pylab as pl
def generate_options(count):
entries = set(range(count))
return do_generate_options([], entries)
def do_generate_options(selected, available):
""" Calculate the probabilities of a secret santa draw if we abandom if someone draws their own name. """
if len(available) == 0:
yield 1,tuple(selected)
return
factor = 1.0/len(available)
for i in list(available):
if i == len(selected):
yield factor, None
else:
selected.append(i)
available.remove(i)
for p, option in do_generate_options(selected, available):
yield p * factor, option
selected.pop()
available.add(i)
def do_generate_options(selected, available):
""" Calculate the probabilities of a secret santa draw if you return the name and re-draw from that person if someone draws their own name. """
if len(available) == 0:
yield 1,tuple(selected)
return
factor = 1.0/len(available)
if len(selected) in available:
if len(available) == 1:
yield 1, None
return
# sum 1/n^i for i from 1 to infinity = 1/n + 1/n * 1/(n-1) = 1/(n-1)
factor = 1.0/(len(available) - 1)
for i in list(available):
if i != len(selected):
selected.append(i)
available.remove(i)
for p, option in do_generate_options(selected, available):
yield p * factor, option
selected.pop()
available.add(i)
def plot_probability_counts(count):
data = {}
for p, entry in generate_options(count):
if entry is not None:
if p in data:
data[p] = data[p] + 1
else:
data[p] = 1
entries = list(data.items())
plt = pl.figure().add_subplot(111)
plt.set_xlabel("probability")
plt.set_ylabel("count")
plt.plot([p * total for p, c in entries], [c for p, c in entries], "+")
def plot_probability_counts_scaled(count):
data = {}
total = 0
for p, entry in generate_options(count):
if entry is not None:
total = total + 1
if p in data:
data[p] = data[p] + 1
else:
data[p] = 1
entries = list(data.items())
plt = pl.figure().add_subplot(111)
plt.set_xlabel("probability/uniform probability")
plt.set_ylabel("fraction")
plt.plot([p * total for p, c in entries], [c / total for p, c in entries], "+")
def plot_probabilities_per_person(count):
total = 0
probabilites = [[0] * count for i in range(count)]
for p, entry in generate_options(count):
if entry is not None:
total = total + p
for i,j in enumerate(entry):
probabilites[i][j] = probabilites[i][j] + p
width = 1/(count + 1.5)
xticks = range(count)
plt = pl.figure().add_subplot(111)
plt.set_xticks(xticks)
plt.set_xticklabels(xticks)
plt.set_xlabel("person giving")
plt.set_ylabel("probability")
plt.set_xlim(-0.5, count + 1.5)
for i, a_probabilities in enumerate(probabilites):
plt.bar([x + (i - (count - 1)/2) * width for x in xticks], [p/total for p in a_probabilities], width, label = i)
plt.legend(title = "giving to", loc = "upper right")
def probability_paired(count):
totalProbability = 0
pairedProbability = 0
totalCount = 0
pairedCount = 0
for p, entry in generate_options(count):
if entry is not None:
totalProbability = totalProbability + p
totalCount = totalCount + 1
valid = True
for i in range(count):
if entry[entry[i]] != i:
valid = False
break
if valid:
pairedProbability = pairedProbability + p
pairedCount = pairedCount + 1
return pairedProbability, totalProbability, pairedCount, totalCount
|
Probability that Secret Santa arrangement will result in perfect pairings
So this answer is prompted by a few questions in the comments. The earlier two answers are correct if the implicit assumption that all derangements are equally likely is true. This is sadly not the ca
|
15,256
|
Probability that Secret Santa arrangement will result in perfect pairings
|
As @Juho-Kokkala and others have stated, the valid derangements are not equally likely and it is not stated in the problem what happens if the last person (H in the example) is the same as the last name in the bowl. I think it is understood from the question what happens when a person prior to the last one draws their own name: that person- and that person only- redraws and then replaces their name (that's equivalent to replacing their name and redrawing, but more efficient).
I suspect that in practice, the group would have the last person switch with the name chosen by the previous person (Person G in the example). That always gives a valid assignment because G did not pick H (so H, after the switch will have a name other than their own) and G will now have H after the switch. A second option to handle the case when the last person has only their own name to draw is to have all people put the names back in the bowl and redraw from the beginning. These two options give different probabilities and the valid derangements are not equally likely using either option.
The case of 8 names is not easy to analyze, but the case of 4 names is not too hard. This is the way of choosing the names: i) person A chooses until they get a name different than A. Each name {B, C, D} is equally likely. ii) person B chooses until they get a name different than B. If A chose B, then there are 3 equally likely choices; if A did not choose B, then there are 2 equally likely choices. iii) C chooses until they get a name different from C. iv) If D is the only name left, then D swaps names with C; otherwise D gets the last name remaining. That's option 1. Option 2 is identical until reaching step iv) which becomes: If D is the only name left, then replace all the names into the bowl and redraw from the beginning.
Option 1
There are these possible derangements with the probability of choosing that derangement using option 1 given next to each:
BADC $\frac{1}3\frac{1}3$
BCDA $\frac{1}3\frac{1}3\frac{1}2$
BDAC $\frac{1}3\frac{1}3$
CADB $\frac{1}3\frac{1}2\frac{1}2$
CDAB $\frac{1}3\frac{1}2\frac{1}2$
CDBA $\frac{1}3\frac{1}2\frac{1}2$
DABC $\frac{1}3\frac{1}2$
DCAB $\frac{1}3\frac{1}2\frac{1}2$
DCBA $\frac{1}3\frac{1}2\frac{1}2$
Then, the perfect pairings are BADC, CDBA, and DCBA and the probability of having a perfect pairing is $\frac{1}3\frac{1}3+\frac{1}3\frac{1}2\frac{1}2+\frac{1}3\frac{1}2\frac{1}2=\frac{5}{18}$
Option 2
First consider what happens in the first round of drawing (that is, when all the people have drawn a valid name until the last person's turn to draw). The probability of reaching the last person with only their name in the bowl is $\frac{5}{36}$. There are these possible derangements with the probability of choosing that derangement using option 2 in the first round given next to each:
BADC $\frac{1}3\frac{1}3$
BCDA $\frac{1}3\frac{1}3\frac{1}2$
BDAC $\frac{1}3\frac{1}3$
CADB $\frac{1}3\frac{1}2\frac{1}2$
CDAB $\frac{1}3\frac{1}2\frac{1}2$
CDBA $\frac{1}3\frac{1}2\frac{1}2$
DABC $\frac{1}3\frac{1}2$
DCAB $\frac{1}3\frac{1}2\frac{1}2$
DCBA $\frac{1}3\frac{1}2\frac{1}2$
Now, those probabilities add up to $\frac{31}{36}$. Therefore, accounting for the fact that the whole group will redraw in the cases where D has only their own name left to draw, those probabilities have to be divided by the sum in order to find the probability of achieving each derangement eventually (either in the first round or after re-starting as often as needed to get a valid derangement).
Finally, for option 2, the probability of having a perfect pairing is $\frac{\frac{1}9+\frac{1}{12}+\frac{1}{12}}{\frac{31}{36}}=\frac{10}{31}$
Back to the original question- the following R program enumerates all of the possible outcomes with 8 people and the probabilities using option 1 and then using option 2. The probability of a perfect pair is 0.006254409 using option 1 and 0.006876715 using option 2. This program only works for the case 8 people and would not be easy to adapt to the general case.
x=data.frame(A=as.character(rep("A",14833)),B=as.character(rep("A",14833)),C=as.character(rep("A",14833)),D=as.character(rep("A",14833)),
E=as.character(rep("A",14833)),F1=as.character(rep("A",14833)),G=as.character(rep("A",14833)),H=as.character(rep("A",14833)),
probinv=rep(0,14833),perfectpair=rep(F,14833),stringsAsFactors = F)
i=0
fulllist=c("A","B","C","D","E","F","G","H")
proba=7
for (a in c("B","C","D","E","F","G","H")) {
validlistb=setdiff(fulllist,c(a,"B"))
probb=proba*length(validlistb)
for (b in validlistb) {
validlistc=setdiff(fulllist,c(a,b,"C"))
probc=probb*length(validlistc)
for (c1 in validlistc) {
validlistd=setdiff(fulllist,c(a,b,c1,"D"))
probd=probc*length(validlistd)
for (d in validlistd) {
validliste=setdiff(fulllist,c(a,b,c1,d,"E"))
probe=probd*length(validliste)
for (e in validliste) {
validlistf=setdiff(fulllist,c(a,b,c1,d,e,"F"))
probf=probe*length(validlistf)
for (f in validlistf) {
validlistg=setdiff(fulllist,c(a,b,c1,d,e,f,"G"))
if (is.element("H",validlistg)) {
i=i+1
x[i,1:7]=c(a,b,c1,d,e,f,"H")
x[i,8]=setdiff(fulllist,x[i,1:7])
x$probinv[i]=probf
if (sum(x[i,rank(x[i,1:8])]==fulllist)==8) x$perfectpair[i]=T
} else if (length(validlistg)==1) {
i=i+1
x[i,1:7]=c(a,b,c1,d,e,f,validlistg)
x[i,8]=setdiff(fulllist,x[i,1:7])
x$probinv[i]=probf
if (sum(x[i,rank(x[i,1:8])]==fulllist)==8) x$perfectpair[i]=T
} else {
i=i+1
x[i,1:7]=c(a,b,c1,d,e,f,validlistg[1])
x[i,8]=setdiff(fulllist,x[i,1:7])
x$probinv[i]=2*probf
if (sum(x[i,rank(x[i,1:8])]==fulllist)==8) x$perfectpair[i]=T
i=i+1
x[i,1:7]=c(a,b,c1,d,e,f,validlistg[2])
x[i,8]=setdiff(fulllist,x[i,1:7])
x$probinv[i]=2*probf
if (sum(x[i,rank(x[i,1:8])]==fulllist)==8) x$perfectpair[i]=T
}
}
}
}
}
}
}
sum(1/x$probinv)
sum(((1/x$probinv[x$perfectpair])))
#option 2
x=data.frame(A=as.character(rep("A",14833)),B=as.character(rep("A",14833)),C=as.character(rep("A",14833)),D=as.character(rep("A",14833)),
E=as.character(rep("A",14833)),F1=as.character(rep("A",14833)),G=as.character(rep("A",14833)),H=as.character(rep("A",14833)),
probinv=rep(0,14833),perfectpair=rep(F,14833),stringsAsFactors = F)
i=0
fulllist=c("A","B","C","D","E","F","G","H")
proba=7
for (a in c("B","C","D","E","F","G","H")) {
validlistb=setdiff(fulllist,c(a,"B"))
probb=proba*length(validlistb)
for (b in validlistb) {
validlistc=setdiff(fulllist,c(a,b,"C"))
probc=probb*length(validlistc)
for (c1 in validlistc) {
validlistd=setdiff(fulllist,c(a,b,c1,"D"))
probd=probc*length(validlistd)
for (d in validlistd) {
validliste=setdiff(fulllist,c(a,b,c1,d,"E"))
probe=probd*length(validliste)
for (e in validliste) {
validlistf=setdiff(fulllist,c(a,b,c1,d,e,"F"))
probf=probe*length(validlistf)
for (f in validlistf) {
validlistg=setdiff(fulllist,c(a,b,c1,d,e,f,"G"))
probg=probf*length(validlistg)
for (g in validlistg) {
h=setdiff(fulllist,c(a,b,c1,d,e,f,g))
if (h!="H") {
i=i+1
x[i,1:8]=c(a,b,c1,d,e,f,g,h)
x$probinv[i]=probg
if (sum(x[i,rank(x[i,1:8])]==fulllist)==8) x$perfectpair[i]=T
}
}
}
}
}
}
}
}
sum(1/x$probinv)
sum(((1/x$probinv[x$perfectpair])/sum(1/x$probinv)))
|
Probability that Secret Santa arrangement will result in perfect pairings
|
As @Juho-Kokkala and others have stated, the valid derangements are not equally likely and it is not stated in the problem what happens if the last person (H in the example) is the same as the last na
|
Probability that Secret Santa arrangement will result in perfect pairings
As @Juho-Kokkala and others have stated, the valid derangements are not equally likely and it is not stated in the problem what happens if the last person (H in the example) is the same as the last name in the bowl. I think it is understood from the question what happens when a person prior to the last one draws their own name: that person- and that person only- redraws and then replaces their name (that's equivalent to replacing their name and redrawing, but more efficient).
I suspect that in practice, the group would have the last person switch with the name chosen by the previous person (Person G in the example). That always gives a valid assignment because G did not pick H (so H, after the switch will have a name other than their own) and G will now have H after the switch. A second option to handle the case when the last person has only their own name to draw is to have all people put the names back in the bowl and redraw from the beginning. These two options give different probabilities and the valid derangements are not equally likely using either option.
The case of 8 names is not easy to analyze, but the case of 4 names is not too hard. This is the way of choosing the names: i) person A chooses until they get a name different than A. Each name {B, C, D} is equally likely. ii) person B chooses until they get a name different than B. If A chose B, then there are 3 equally likely choices; if A did not choose B, then there are 2 equally likely choices. iii) C chooses until they get a name different from C. iv) If D is the only name left, then D swaps names with C; otherwise D gets the last name remaining. That's option 1. Option 2 is identical until reaching step iv) which becomes: If D is the only name left, then replace all the names into the bowl and redraw from the beginning.
Option 1
There are these possible derangements with the probability of choosing that derangement using option 1 given next to each:
BADC $\frac{1}3\frac{1}3$
BCDA $\frac{1}3\frac{1}3\frac{1}2$
BDAC $\frac{1}3\frac{1}3$
CADB $\frac{1}3\frac{1}2\frac{1}2$
CDAB $\frac{1}3\frac{1}2\frac{1}2$
CDBA $\frac{1}3\frac{1}2\frac{1}2$
DABC $\frac{1}3\frac{1}2$
DCAB $\frac{1}3\frac{1}2\frac{1}2$
DCBA $\frac{1}3\frac{1}2\frac{1}2$
Then, the perfect pairings are BADC, CDBA, and DCBA and the probability of having a perfect pairing is $\frac{1}3\frac{1}3+\frac{1}3\frac{1}2\frac{1}2+\frac{1}3\frac{1}2\frac{1}2=\frac{5}{18}$
Option 2
First consider what happens in the first round of drawing (that is, when all the people have drawn a valid name until the last person's turn to draw). The probability of reaching the last person with only their name in the bowl is $\frac{5}{36}$. There are these possible derangements with the probability of choosing that derangement using option 2 in the first round given next to each:
BADC $\frac{1}3\frac{1}3$
BCDA $\frac{1}3\frac{1}3\frac{1}2$
BDAC $\frac{1}3\frac{1}3$
CADB $\frac{1}3\frac{1}2\frac{1}2$
CDAB $\frac{1}3\frac{1}2\frac{1}2$
CDBA $\frac{1}3\frac{1}2\frac{1}2$
DABC $\frac{1}3\frac{1}2$
DCAB $\frac{1}3\frac{1}2\frac{1}2$
DCBA $\frac{1}3\frac{1}2\frac{1}2$
Now, those probabilities add up to $\frac{31}{36}$. Therefore, accounting for the fact that the whole group will redraw in the cases where D has only their own name left to draw, those probabilities have to be divided by the sum in order to find the probability of achieving each derangement eventually (either in the first round or after re-starting as often as needed to get a valid derangement).
Finally, for option 2, the probability of having a perfect pairing is $\frac{\frac{1}9+\frac{1}{12}+\frac{1}{12}}{\frac{31}{36}}=\frac{10}{31}$
Back to the original question- the following R program enumerates all of the possible outcomes with 8 people and the probabilities using option 1 and then using option 2. The probability of a perfect pair is 0.006254409 using option 1 and 0.006876715 using option 2. This program only works for the case 8 people and would not be easy to adapt to the general case.
x=data.frame(A=as.character(rep("A",14833)),B=as.character(rep("A",14833)),C=as.character(rep("A",14833)),D=as.character(rep("A",14833)),
E=as.character(rep("A",14833)),F1=as.character(rep("A",14833)),G=as.character(rep("A",14833)),H=as.character(rep("A",14833)),
probinv=rep(0,14833),perfectpair=rep(F,14833),stringsAsFactors = F)
i=0
fulllist=c("A","B","C","D","E","F","G","H")
proba=7
for (a in c("B","C","D","E","F","G","H")) {
validlistb=setdiff(fulllist,c(a,"B"))
probb=proba*length(validlistb)
for (b in validlistb) {
validlistc=setdiff(fulllist,c(a,b,"C"))
probc=probb*length(validlistc)
for (c1 in validlistc) {
validlistd=setdiff(fulllist,c(a,b,c1,"D"))
probd=probc*length(validlistd)
for (d in validlistd) {
validliste=setdiff(fulllist,c(a,b,c1,d,"E"))
probe=probd*length(validliste)
for (e in validliste) {
validlistf=setdiff(fulllist,c(a,b,c1,d,e,"F"))
probf=probe*length(validlistf)
for (f in validlistf) {
validlistg=setdiff(fulllist,c(a,b,c1,d,e,f,"G"))
if (is.element("H",validlistg)) {
i=i+1
x[i,1:7]=c(a,b,c1,d,e,f,"H")
x[i,8]=setdiff(fulllist,x[i,1:7])
x$probinv[i]=probf
if (sum(x[i,rank(x[i,1:8])]==fulllist)==8) x$perfectpair[i]=T
} else if (length(validlistg)==1) {
i=i+1
x[i,1:7]=c(a,b,c1,d,e,f,validlistg)
x[i,8]=setdiff(fulllist,x[i,1:7])
x$probinv[i]=probf
if (sum(x[i,rank(x[i,1:8])]==fulllist)==8) x$perfectpair[i]=T
} else {
i=i+1
x[i,1:7]=c(a,b,c1,d,e,f,validlistg[1])
x[i,8]=setdiff(fulllist,x[i,1:7])
x$probinv[i]=2*probf
if (sum(x[i,rank(x[i,1:8])]==fulllist)==8) x$perfectpair[i]=T
i=i+1
x[i,1:7]=c(a,b,c1,d,e,f,validlistg[2])
x[i,8]=setdiff(fulllist,x[i,1:7])
x$probinv[i]=2*probf
if (sum(x[i,rank(x[i,1:8])]==fulllist)==8) x$perfectpair[i]=T
}
}
}
}
}
}
}
sum(1/x$probinv)
sum(((1/x$probinv[x$perfectpair])))
#option 2
x=data.frame(A=as.character(rep("A",14833)),B=as.character(rep("A",14833)),C=as.character(rep("A",14833)),D=as.character(rep("A",14833)),
E=as.character(rep("A",14833)),F1=as.character(rep("A",14833)),G=as.character(rep("A",14833)),H=as.character(rep("A",14833)),
probinv=rep(0,14833),perfectpair=rep(F,14833),stringsAsFactors = F)
i=0
fulllist=c("A","B","C","D","E","F","G","H")
proba=7
for (a in c("B","C","D","E","F","G","H")) {
validlistb=setdiff(fulllist,c(a,"B"))
probb=proba*length(validlistb)
for (b in validlistb) {
validlistc=setdiff(fulllist,c(a,b,"C"))
probc=probb*length(validlistc)
for (c1 in validlistc) {
validlistd=setdiff(fulllist,c(a,b,c1,"D"))
probd=probc*length(validlistd)
for (d in validlistd) {
validliste=setdiff(fulllist,c(a,b,c1,d,"E"))
probe=probd*length(validliste)
for (e in validliste) {
validlistf=setdiff(fulllist,c(a,b,c1,d,e,"F"))
probf=probe*length(validlistf)
for (f in validlistf) {
validlistg=setdiff(fulllist,c(a,b,c1,d,e,f,"G"))
probg=probf*length(validlistg)
for (g in validlistg) {
h=setdiff(fulllist,c(a,b,c1,d,e,f,g))
if (h!="H") {
i=i+1
x[i,1:8]=c(a,b,c1,d,e,f,g,h)
x$probinv[i]=probg
if (sum(x[i,rank(x[i,1:8])]==fulllist)==8) x$perfectpair[i]=T
}
}
}
}
}
}
}
}
sum(1/x$probinv)
sum(((1/x$probinv[x$perfectpair])/sum(1/x$probinv)))
|
Probability that Secret Santa arrangement will result in perfect pairings
As @Juho-Kokkala and others have stated, the valid derangements are not equally likely and it is not stated in the problem what happens if the last person (H in the example) is the same as the last na
|
15,257
|
R Language what is difference between rnorm and runif [closed]
|
rnorm generates a random value from the normal distribution. runif generates a random value from the uniform.
|
R Language what is difference between rnorm and runif [closed]
|
rnorm generates a random value from the normal distribution. runif generates a random value from the uniform.
|
R Language what is difference between rnorm and runif [closed]
rnorm generates a random value from the normal distribution. runif generates a random value from the uniform.
|
R Language what is difference between rnorm and runif [closed]
rnorm generates a random value from the normal distribution. runif generates a random value from the uniform.
|
15,258
|
R Language what is difference between rnorm and runif [closed]
|
rnorm(n, mean = , sd = ) is used to generate n normal random numbers with arguments mean and sd; while runif(n, min = , max = ) is used to generate n uniform random numbers lie in the interval (min, max).
Please check corresponding R help documents for details.
|
R Language what is difference between rnorm and runif [closed]
|
rnorm(n, mean = , sd = ) is used to generate n normal random numbers with arguments mean and sd; while runif(n, min = , max = ) is used to generate n uniform random numbers lie in the interval (min, m
|
R Language what is difference between rnorm and runif [closed]
rnorm(n, mean = , sd = ) is used to generate n normal random numbers with arguments mean and sd; while runif(n, min = , max = ) is used to generate n uniform random numbers lie in the interval (min, max).
Please check corresponding R help documents for details.
|
R Language what is difference between rnorm and runif [closed]
rnorm(n, mean = , sd = ) is used to generate n normal random numbers with arguments mean and sd; while runif(n, min = , max = ) is used to generate n uniform random numbers lie in the interval (min, m
|
15,259
|
Relationships between correlation and causation
|
"Conditioning" is a word from probability theory : https://en.wikipedia.org/wiki/Conditional_probability
Conditioning on C means that we are only looking at cases where C is true. "Implicitly" means that we may not be making this restriction explicit, sometimes not even aware of doing it.
The point means that, when A and B both cause C, observing a correlation between A and B in cases where C is true, does not mean there is a real relationship between A and B. It's just conditioning on C (maybe unwillingly) that creates an artificial correlation.
Let's take an example.
In a country there exists exactly two sorts of diseases, perfectly independent. Call A : "person has first disease", B : "person has second disease". Assume $P(A)=0.1$, $P(B)=0.1$.
Now any person who has one of these diseases goes to see the doctor and only then. Call C : "person goes to see the doctor". We have $C=A \text{ or } B$.
Now let's calculate a few probabilities :
$P(C)=0.19$
$P(A|C)=P(B|C)=\frac{0.1}{0.19}\approx 0.53$
$P(A \text{ and } B|C)=\frac{0.01}{0.19}\approx 0.053$
$P(A|C)P(B|C)\approx 0.28$
Clearly, when conditioned on C, $A$ and $B$ are very far from being independent. Actually, conditioned on C, $not A$ seems to "cause" $B$.
If you use the list of persons who where recorded by their doctor(s) as a data source for an analysis, then there seems to be a strong correlation between diseases $A$ and $B$. You may not be aware of the fact that your data source is actually a conditioning. This is also called a "selection bias".
|
Relationships between correlation and causation
|
"Conditioning" is a word from probability theory : https://en.wikipedia.org/wiki/Conditional_probability
Conditioning on C means that we are only looking at cases where C is true. "Implicitly" means t
|
Relationships between correlation and causation
"Conditioning" is a word from probability theory : https://en.wikipedia.org/wiki/Conditional_probability
Conditioning on C means that we are only looking at cases where C is true. "Implicitly" means that we may not be making this restriction explicit, sometimes not even aware of doing it.
The point means that, when A and B both cause C, observing a correlation between A and B in cases where C is true, does not mean there is a real relationship between A and B. It's just conditioning on C (maybe unwillingly) that creates an artificial correlation.
Let's take an example.
In a country there exists exactly two sorts of diseases, perfectly independent. Call A : "person has first disease", B : "person has second disease". Assume $P(A)=0.1$, $P(B)=0.1$.
Now any person who has one of these diseases goes to see the doctor and only then. Call C : "person goes to see the doctor". We have $C=A \text{ or } B$.
Now let's calculate a few probabilities :
$P(C)=0.19$
$P(A|C)=P(B|C)=\frac{0.1}{0.19}\approx 0.53$
$P(A \text{ and } B|C)=\frac{0.01}{0.19}\approx 0.053$
$P(A|C)P(B|C)\approx 0.28$
Clearly, when conditioned on C, $A$ and $B$ are very far from being independent. Actually, conditioned on C, $not A$ seems to "cause" $B$.
If you use the list of persons who where recorded by their doctor(s) as a data source for an analysis, then there seems to be a strong correlation between diseases $A$ and $B$. You may not be aware of the fact that your data source is actually a conditioning. This is also called a "selection bias".
|
Relationships between correlation and causation
"Conditioning" is a word from probability theory : https://en.wikipedia.org/wiki/Conditional_probability
Conditioning on C means that we are only looking at cases where C is true. "Implicitly" means t
|
15,260
|
Relationships between correlation and causation
|
The fourth point is an example of Berkson's paradox, also known as conditioning on a collider, also known as the explaining-away phenomenon.
As an example, consider a young woman who is frequently asked on dates by young men, and she must decide whether to accept or reject each date proposal. The young men vary in how attractive and charming they are, and let's suppose that these two traits are independent in the population of date-proposing men. Naturally the young woman is more inclined to accept a date proposal the more attractive or charming the man is. So a causal model for this situation may look like:
$$
Attractive \rightarrow Accept \leftarrow Charming
$$
That is, $Attractive$ and $Charming$ both cause $Accept$, which takes on values of 0 or 1 if the woman rejects or accepts the date proposal, respectively.
We supposed above that $Attractive$ and $Charming$ are independent in the population of date-proposing men. But are they still independent if we consider only the men whose proposals the woman accepted? In other words, we condition on $Accept=1$. Now suppose I tell you about a man who the woman agreed to date, and I tell you that he is (in the woman's opinion) not attractive at all. Well, we know that the woman agreed to date him anyway, so we would reasonably infer that he must be quite charming indeed. Conversely, if we learn about a man whose date proposal was accepted and who is not charming, we would reasonably infer that he must be quite attractive.
Do you see what's happened here? By conditioning on $Accept=1$, we've induced a negative correlation between $Attractive$ and $Charming$, even though these two traits are (by assumption) marginally independent. From the perspective of the woman, the attractive men she dates tend to be less charming, and the charming men she dates tend to be less attractive. But this is because, by thinking only of the men she has dated, she is implicitly conditioning on $Accept$. If she would instead consider all the men who have proposed dates, regardless of whether she accepted the proposal, she would see that there is no statistical association between the two traits.
|
Relationships between correlation and causation
|
The fourth point is an example of Berkson's paradox, also known as conditioning on a collider, also known as the explaining-away phenomenon.
As an example, consider a young woman who is frequently ask
|
Relationships between correlation and causation
The fourth point is an example of Berkson's paradox, also known as conditioning on a collider, also known as the explaining-away phenomenon.
As an example, consider a young woman who is frequently asked on dates by young men, and she must decide whether to accept or reject each date proposal. The young men vary in how attractive and charming they are, and let's suppose that these two traits are independent in the population of date-proposing men. Naturally the young woman is more inclined to accept a date proposal the more attractive or charming the man is. So a causal model for this situation may look like:
$$
Attractive \rightarrow Accept \leftarrow Charming
$$
That is, $Attractive$ and $Charming$ both cause $Accept$, which takes on values of 0 or 1 if the woman rejects or accepts the date proposal, respectively.
We supposed above that $Attractive$ and $Charming$ are independent in the population of date-proposing men. But are they still independent if we consider only the men whose proposals the woman accepted? In other words, we condition on $Accept=1$. Now suppose I tell you about a man who the woman agreed to date, and I tell you that he is (in the woman's opinion) not attractive at all. Well, we know that the woman agreed to date him anyway, so we would reasonably infer that he must be quite charming indeed. Conversely, if we learn about a man whose date proposal was accepted and who is not charming, we would reasonably infer that he must be quite attractive.
Do you see what's happened here? By conditioning on $Accept=1$, we've induced a negative correlation between $Attractive$ and $Charming$, even though these two traits are (by assumption) marginally independent. From the perspective of the woman, the attractive men she dates tend to be less charming, and the charming men she dates tend to be less attractive. But this is because, by thinking only of the men she has dated, she is implicitly conditioning on $Accept$. If she would instead consider all the men who have proposed dates, regardless of whether she accepted the proposal, she would see that there is no statistical association between the two traits.
|
Relationships between correlation and causation
The fourth point is an example of Berkson's paradox, also known as conditioning on a collider, also known as the explaining-away phenomenon.
As an example, consider a young woman who is frequently ask
|
15,261
|
Relationships between correlation and causation
|
Simpson's paradox and Berkson's paradox can each give examples of "A and B both cause C, which is (explicitly or implicitly) conditioned on"
As an example suppose I have $1000$ stamps in my collection of which $100$ are rare ($10\%$) and $200$ are pretty ($20\%$). If there is no intrinsic relationship between rarity and prettiness, it might turn out $20$ of my stamps are both pretty and rare.
If I now display my $280$ interesting stamps, i.e. those which are rare or pretty or both, there will be an apparent negative correlation between rarity and prettiness ($20\%$ of displayed rare stamps are pretty while $100\%$ of displayed common stamps are pretty) due entirely to conditioning on being interesting.
|
Relationships between correlation and causation
|
Simpson's paradox and Berkson's paradox can each give examples of "A and B both cause C, which is (explicitly or implicitly) conditioned on"
As an example suppose I have $1000$ stamps in my collection
|
Relationships between correlation and causation
Simpson's paradox and Berkson's paradox can each give examples of "A and B both cause C, which is (explicitly or implicitly) conditioned on"
As an example suppose I have $1000$ stamps in my collection of which $100$ are rare ($10\%$) and $200$ are pretty ($20\%$). If there is no intrinsic relationship between rarity and prettiness, it might turn out $20$ of my stamps are both pretty and rare.
If I now display my $280$ interesting stamps, i.e. those which are rare or pretty or both, there will be an apparent negative correlation between rarity and prettiness ($20\%$ of displayed rare stamps are pretty while $100\%$ of displayed common stamps are pretty) due entirely to conditioning on being interesting.
|
Relationships between correlation and causation
Simpson's paradox and Berkson's paradox can each give examples of "A and B both cause C, which is (explicitly or implicitly) conditioned on"
As an example suppose I have $1000$ stamps in my collection
|
15,262
|
Relationships between correlation and causation
|
The paragraph starts with "For any two correlated events, A and B,...", so my guess is that correlation is assumed at the beginning. In other words, they need not be correlated to simultaneously cause C, but if they were correlated and they did both cause C, it does not imply that there exists a causal relationship between them.
|
Relationships between correlation and causation
|
The paragraph starts with "For any two correlated events, A and B,...", so my guess is that correlation is assumed at the beginning. In other words, they need not be correlated to simultaneously cause
|
Relationships between correlation and causation
The paragraph starts with "For any two correlated events, A and B,...", so my guess is that correlation is assumed at the beginning. In other words, they need not be correlated to simultaneously cause C, but if they were correlated and they did both cause C, it does not imply that there exists a causal relationship between them.
|
Relationships between correlation and causation
The paragraph starts with "For any two correlated events, A and B,...", so my guess is that correlation is assumed at the beginning. In other words, they need not be correlated to simultaneously cause
|
15,263
|
Calculate coefficients in a logistic regression with R
|
The OLS estimator in the linear regression model is quite rare in
having the property that it can be represented in closed form, that is
without needing to be expressed as the optimizer of a function. It is, however, an optimizer of a function -- the residual sum of squares
function -- and can be computed as such.
The MLE in the logistic regression model is also the optimizer of a
suitably defined log-likelihood function, but since it is not available
in a closed form expression, it must be computed as an optimizer.
Most statistical estimators are only expressible as optimizers of
appropriately constructed functions of the data called criterion functions.
Such optimizers require the use of appropriate numerical optimization
algorithms.
Optimizers of functions can be computed in R using the optim() function
that provides some general purpose optimization algorithms, or one of the more
specialized packages such as optimx. Knowing which
optimization algorithm to use for different types of models and statistical criterion
functions is key.
Linear regression residual sum of squares
The OLS estimator is defined as the optimizer of the well-known residual sum of
squares function:
$$
\begin{align}
\hat{\boldsymbol{\beta}} &= \arg\min_{\boldsymbol{\beta}}\left(\boldsymbol{Y} - \mathbf{X}\boldsymbol{\beta}\right)'\left(\boldsymbol{Y} - \mathbf{X}\boldsymbol{\beta}\right) \\
&= (\mathbf{X}'\mathbf{X})^{-1}\mathbf{X}'\boldsymbol{Y}
\end{align}
$$
In the case of a twice differentiable, convex function like the residual sum of squares,
most gradient-based optimizers do good job. In this case, I will be using the BFGS
algorithm.
#================================================
# reading in the data & pre-processing
#================================================
urlSheatherData = "http://www.stat.tamu.edu/~sheather/book/docs/datasets/MichelinNY.csv"
dfSheather = as.data.frame(read.csv(urlSheatherData, header = TRUE))
# create the design matrices
vY = as.matrix(dfSheather['InMichelin'])
mX = as.matrix(dfSheather[c('Service','Decor', 'Food', 'Price')])
# add an intercept to the predictor variables
mX = cbind(1, mX)
# the number of variables and observations
iK = ncol(mX)
iN = nrow(mX)
#================================================
# compute the linear regression parameters as
# an optimal value
#================================================
# the residual sum of squares criterion function
fnRSS = function(vBeta, vY, mX) {
return(sum((vY - mX %*% vBeta)^2))
}
# arbitrary starting values
vBeta0 = rep(0, ncol(mX))
# minimise the RSS function to get the parameter estimates
optimLinReg = optim(vBeta0, fnRSS,
mX = mX, vY = vY, method = 'BFGS',
hessian=TRUE)
#================================================
# compare to the LM function
#================================================
linregSheather = lm(InMichelin ~ Service + Decor + Food + Price,
data = dfSheather)
This yields:
> print(cbind(coef(linregSheather), optimLinReg$par))
[,1] [,2]
(Intercept) -1.492092490 -1.492093965
Service -0.011176619 -0.011176583
Decor 0.044193000 0.044193023
Food 0.057733737 0.057733770
Price 0.001797941 0.001797934
Logistic regression log-likelihood
The criterion function corresponding to the MLE in the logistic regression model is
the log-likelihood function.
$$
\begin{align}
\log L_n(\boldsymbol{\beta}) &= \sum_{i=1}^n \left(Y_i \log \Lambda(\boldsymbol{X}_i'\boldsymbol{\beta}) +
(1-Y_i)\log(1 - \Lambda(\boldsymbol{X}_i'\boldsymbol{\beta}))\right)
\end{align}
$$
where $\Lambda(k) = 1/(1+ \exp(-k))$ is the logistic function. The parameter estimates are the optimizers of this function
$$
\hat{\boldsymbol{\beta}} = \arg\max_{\boldsymbol{\beta}}\log L_n(\boldsymbol{\beta})
$$
I show how to construct and optimize the criterion function using the optim() function
once again employing the BFGS algorithm.
#================================================
# compute the logistic regression parameters as
# an optimal value
#================================================
# define the logistic transformation
logit = function(mX, vBeta) {
return(exp(mX %*% vBeta)/(1+ exp(mX %*% vBeta)) )
}
# stable parametrisation of the log-likelihood function
# Note: The negative of the log-likelihood is being returned, since we will be
# /minimising/ the function.
logLikelihoodLogitStable = function(vBeta, mX, vY) {
return(-sum(
vY*(mX %*% vBeta - log(1+exp(mX %*% vBeta)))
+ (1-vY)*(-log(1 + exp(mX %*% vBeta)))
)
)
}
# initial set of parameters
vBeta0 = c(10, -0.1, -0.3, 0.001, 0.01) # arbitrary starting parameters
# minimise the (negative) log-likelihood to get the logit fit
optimLogit = optim(vBeta0, logLikelihoodLogitStable,
mX = mX, vY = vY, method = 'BFGS',
hessian=TRUE)
#================================================
# test against the implementation in R
# NOTE glm uses IRWLS:
# http://en.wikipedia.org/wiki/Iteratively_reweighted_least_squares
# rather than the BFGS algorithm that we have reported
#================================================
logitSheather = glm(InMichelin ~ Service + Decor + Food + Price,
data = dfSheather,
family = binomial, x = TRUE)
This yields
> print(cbind(coef(logitSheather), optimLogit$par))
[,1] [,2]
(Intercept) -11.19745057 -11.19661798
Service -0.19242411 -0.19249119
Decor 0.09997273 0.09992445
Food 0.40484706 0.40483753
Price 0.09171953 0.09175369
As a caveat, note that numerical optimization algorithms require careful use or you can end up with
all sorts of pathological solutions. Until you understand them well, it is best to
use the available packaged options that allow you to concentrate on specifying the model
rather than worrying about how to numerically compute the estimates.
|
Calculate coefficients in a logistic regression with R
|
The OLS estimator in the linear regression model is quite rare in
having the property that it can be represented in closed form, that is
without needing to be expressed as the optimizer of a function
|
Calculate coefficients in a logistic regression with R
The OLS estimator in the linear regression model is quite rare in
having the property that it can be represented in closed form, that is
without needing to be expressed as the optimizer of a function. It is, however, an optimizer of a function -- the residual sum of squares
function -- and can be computed as such.
The MLE in the logistic regression model is also the optimizer of a
suitably defined log-likelihood function, but since it is not available
in a closed form expression, it must be computed as an optimizer.
Most statistical estimators are only expressible as optimizers of
appropriately constructed functions of the data called criterion functions.
Such optimizers require the use of appropriate numerical optimization
algorithms.
Optimizers of functions can be computed in R using the optim() function
that provides some general purpose optimization algorithms, or one of the more
specialized packages such as optimx. Knowing which
optimization algorithm to use for different types of models and statistical criterion
functions is key.
Linear regression residual sum of squares
The OLS estimator is defined as the optimizer of the well-known residual sum of
squares function:
$$
\begin{align}
\hat{\boldsymbol{\beta}} &= \arg\min_{\boldsymbol{\beta}}\left(\boldsymbol{Y} - \mathbf{X}\boldsymbol{\beta}\right)'\left(\boldsymbol{Y} - \mathbf{X}\boldsymbol{\beta}\right) \\
&= (\mathbf{X}'\mathbf{X})^{-1}\mathbf{X}'\boldsymbol{Y}
\end{align}
$$
In the case of a twice differentiable, convex function like the residual sum of squares,
most gradient-based optimizers do good job. In this case, I will be using the BFGS
algorithm.
#================================================
# reading in the data & pre-processing
#================================================
urlSheatherData = "http://www.stat.tamu.edu/~sheather/book/docs/datasets/MichelinNY.csv"
dfSheather = as.data.frame(read.csv(urlSheatherData, header = TRUE))
# create the design matrices
vY = as.matrix(dfSheather['InMichelin'])
mX = as.matrix(dfSheather[c('Service','Decor', 'Food', 'Price')])
# add an intercept to the predictor variables
mX = cbind(1, mX)
# the number of variables and observations
iK = ncol(mX)
iN = nrow(mX)
#================================================
# compute the linear regression parameters as
# an optimal value
#================================================
# the residual sum of squares criterion function
fnRSS = function(vBeta, vY, mX) {
return(sum((vY - mX %*% vBeta)^2))
}
# arbitrary starting values
vBeta0 = rep(0, ncol(mX))
# minimise the RSS function to get the parameter estimates
optimLinReg = optim(vBeta0, fnRSS,
mX = mX, vY = vY, method = 'BFGS',
hessian=TRUE)
#================================================
# compare to the LM function
#================================================
linregSheather = lm(InMichelin ~ Service + Decor + Food + Price,
data = dfSheather)
This yields:
> print(cbind(coef(linregSheather), optimLinReg$par))
[,1] [,2]
(Intercept) -1.492092490 -1.492093965
Service -0.011176619 -0.011176583
Decor 0.044193000 0.044193023
Food 0.057733737 0.057733770
Price 0.001797941 0.001797934
Logistic regression log-likelihood
The criterion function corresponding to the MLE in the logistic regression model is
the log-likelihood function.
$$
\begin{align}
\log L_n(\boldsymbol{\beta}) &= \sum_{i=1}^n \left(Y_i \log \Lambda(\boldsymbol{X}_i'\boldsymbol{\beta}) +
(1-Y_i)\log(1 - \Lambda(\boldsymbol{X}_i'\boldsymbol{\beta}))\right)
\end{align}
$$
where $\Lambda(k) = 1/(1+ \exp(-k))$ is the logistic function. The parameter estimates are the optimizers of this function
$$
\hat{\boldsymbol{\beta}} = \arg\max_{\boldsymbol{\beta}}\log L_n(\boldsymbol{\beta})
$$
I show how to construct and optimize the criterion function using the optim() function
once again employing the BFGS algorithm.
#================================================
# compute the logistic regression parameters as
# an optimal value
#================================================
# define the logistic transformation
logit = function(mX, vBeta) {
return(exp(mX %*% vBeta)/(1+ exp(mX %*% vBeta)) )
}
# stable parametrisation of the log-likelihood function
# Note: The negative of the log-likelihood is being returned, since we will be
# /minimising/ the function.
logLikelihoodLogitStable = function(vBeta, mX, vY) {
return(-sum(
vY*(mX %*% vBeta - log(1+exp(mX %*% vBeta)))
+ (1-vY)*(-log(1 + exp(mX %*% vBeta)))
)
)
}
# initial set of parameters
vBeta0 = c(10, -0.1, -0.3, 0.001, 0.01) # arbitrary starting parameters
# minimise the (negative) log-likelihood to get the logit fit
optimLogit = optim(vBeta0, logLikelihoodLogitStable,
mX = mX, vY = vY, method = 'BFGS',
hessian=TRUE)
#================================================
# test against the implementation in R
# NOTE glm uses IRWLS:
# http://en.wikipedia.org/wiki/Iteratively_reweighted_least_squares
# rather than the BFGS algorithm that we have reported
#================================================
logitSheather = glm(InMichelin ~ Service + Decor + Food + Price,
data = dfSheather,
family = binomial, x = TRUE)
This yields
> print(cbind(coef(logitSheather), optimLogit$par))
[,1] [,2]
(Intercept) -11.19745057 -11.19661798
Service -0.19242411 -0.19249119
Decor 0.09997273 0.09992445
Food 0.40484706 0.40483753
Price 0.09171953 0.09175369
As a caveat, note that numerical optimization algorithms require careful use or you can end up with
all sorts of pathological solutions. Until you understand them well, it is best to
use the available packaged options that allow you to concentrate on specifying the model
rather than worrying about how to numerically compute the estimates.
|
Calculate coefficients in a logistic regression with R
The OLS estimator in the linear regression model is quite rare in
having the property that it can be represented in closed form, that is
without needing to be expressed as the optimizer of a function
|
15,264
|
Calculate coefficients in a logistic regression with R
|
You can't get there from here. The solutions to both the general linear model and the logistic model arise from solving the respective maximum likelihood equations, but only the linear model has a closed form solution.
If you consult McCullagh and Nelder's book, you can learn how the solutions are obtained in the logistic case (or other generalized model). In effect, the solutions are produced iteratively, where each iteration involves solving a weighted linear regression. The weights depend in part on the link function.
|
Calculate coefficients in a logistic regression with R
|
You can't get there from here. The solutions to both the general linear model and the logistic model arise from solving the respective maximum likelihood equations, but only the linear model has a clo
|
Calculate coefficients in a logistic regression with R
You can't get there from here. The solutions to both the general linear model and the logistic model arise from solving the respective maximum likelihood equations, but only the linear model has a closed form solution.
If you consult McCullagh and Nelder's book, you can learn how the solutions are obtained in the logistic case (or other generalized model). In effect, the solutions are produced iteratively, where each iteration involves solving a weighted linear regression. The weights depend in part on the link function.
|
Calculate coefficients in a logistic regression with R
You can't get there from here. The solutions to both the general linear model and the logistic model arise from solving the respective maximum likelihood equations, but only the linear model has a clo
|
15,265
|
Why can't I match glmer (family=binomial) output with manual implementation of Gauss-Newton algorithm?
|
If you change your model fitting command to the following, your matching
approach works:
my.lmer <- glmer(y ~ x1 + (1 | subject), data = df, family = binomial, nAGQ = 0)
The key change is the nAGQ = 0, which matches your approach, whereas the
default (nAGQ = 1) does not. nAGQ means 'number of adaptive
Gauss-Hermite quadrature points', and sets how glmer will integrate out
the random effects when fitting the mixed model. When nAGQ is greater
than 1, then adaptive quadrature is used with nAGQ points. When nAGQ =
1, the Laplace approximation is used, and when nAGQ = 0, the integral is
'ignored'. Without being too specific (and therefore perhaps too
technical), nAGQ = 0 means that the random effects only influence the
estimates of the fixed effects through their estimated conditional modes
-- therefore, nAGQ = 0 does not completely account for the randomness of
the random effects. To fully account for the random effects, they need
to be integrated out. However, as you discovered this difference
between nAGQ = 0 and nAGQ = 1 can often be fairly small.
Your matching approach will not work with nAGQ > 0. This is because in
these cases there are three steps to the optimization: (1) penalized
iteratively reweighted least squares (PIRLS) to estimate the conditional
modes of the random effects, (2) (approximately) integrate out the
random effects about their conditional modes, and (3) nonlinear
optimization of the objective function (i.e. the result of the
integration). These steps are themselves iterated until convergence.
You are simply doing an iteratively reweighted least squares (IRLS) run,
which assumes b is known and putting Z%*%b in an offset term. Your
approach turns out to be equivalent to PIRLS, but this equivalence only
holds because you use glmer to get estimated conditional modes (which
you wouldn't otherwise know).
Apologies if this isn't well explained, but it isn't a topic that lends
itself well to a quick description. You might find
https://github.com/lme4/lme4pureR useful, which is an (incomplete)
implementation of the lme4 approach in pure R code. lme4pureR is
designed to be more readable than lme4 itself (although much slower).
|
Why can't I match glmer (family=binomial) output with manual implementation of Gauss-Newton algorith
|
If you change your model fitting command to the following, your matching
approach works:
my.lmer <- glmer(y ~ x1 + (1 | subject), data = df, family = binomial, nAGQ = 0)
The key change is the nAGQ =
|
Why can't I match glmer (family=binomial) output with manual implementation of Gauss-Newton algorithm?
If you change your model fitting command to the following, your matching
approach works:
my.lmer <- glmer(y ~ x1 + (1 | subject), data = df, family = binomial, nAGQ = 0)
The key change is the nAGQ = 0, which matches your approach, whereas the
default (nAGQ = 1) does not. nAGQ means 'number of adaptive
Gauss-Hermite quadrature points', and sets how glmer will integrate out
the random effects when fitting the mixed model. When nAGQ is greater
than 1, then adaptive quadrature is used with nAGQ points. When nAGQ =
1, the Laplace approximation is used, and when nAGQ = 0, the integral is
'ignored'. Without being too specific (and therefore perhaps too
technical), nAGQ = 0 means that the random effects only influence the
estimates of the fixed effects through their estimated conditional modes
-- therefore, nAGQ = 0 does not completely account for the randomness of
the random effects. To fully account for the random effects, they need
to be integrated out. However, as you discovered this difference
between nAGQ = 0 and nAGQ = 1 can often be fairly small.
Your matching approach will not work with nAGQ > 0. This is because in
these cases there are three steps to the optimization: (1) penalized
iteratively reweighted least squares (PIRLS) to estimate the conditional
modes of the random effects, (2) (approximately) integrate out the
random effects about their conditional modes, and (3) nonlinear
optimization of the objective function (i.e. the result of the
integration). These steps are themselves iterated until convergence.
You are simply doing an iteratively reweighted least squares (IRLS) run,
which assumes b is known and putting Z%*%b in an offset term. Your
approach turns out to be equivalent to PIRLS, but this equivalence only
holds because you use glmer to get estimated conditional modes (which
you wouldn't otherwise know).
Apologies if this isn't well explained, but it isn't a topic that lends
itself well to a quick description. You might find
https://github.com/lme4/lme4pureR useful, which is an (incomplete)
implementation of the lme4 approach in pure R code. lme4pureR is
designed to be more readable than lme4 itself (although much slower).
|
Why can't I match glmer (family=binomial) output with manual implementation of Gauss-Newton algorith
If you change your model fitting command to the following, your matching
approach works:
my.lmer <- glmer(y ~ x1 + (1 | subject), data = df, family = binomial, nAGQ = 0)
The key change is the nAGQ =
|
15,266
|
Converting standardized betas back to original variables
|
For the regression model using the standardized variables, we assume the following form for the regression line
$$
\mathbb E[Y] =\beta_{0}+\sum_{j=1}^{k}\beta_{j}z_{j},
$$
where $z_{j}$ is the j-th (standardized) regressor, generated from $x_j$ by subtracting the sample mean $\bar x_j$ and dividing by the sample standard deviation $S_j$:
$$
z_j = \frac{x_j - \bar{x}_j}{S_j}
$$
Carrying out the regression with the standardized regressors, we obtain the fitted regression line:
$$
\hat Y = \hat \beta_0 +\sum_{j=1}^{k} \hat \beta_{j}z_{j}
$$
We now wish to find the regression coefficients for the non-standardized predictors. We have
$$
\hat Y = \hat \beta_0 +\sum_{j=1}^{k} \hat \beta_{j}\left(\frac{x_j - \bar{x}_j}{S_j}\right)
$$
Re-arranging, this expression can be written as
$$
\hat Y = \left( \hat \beta_0 - \sum_{j=1}^k \hat \beta_j \frac{\bar x_j}{S_j} \right) + \sum_{j=1}^k \left(\frac{\hat \beta_j}{S_j}\right) x_j
$$
As we can see, the intercept for the regression using the non-transformed variables is given by $ \hat \beta_0 - \sum_{j=1}^k \hat \beta_j \frac{\bar x_j}{S_j}$. The regression coefficient of the $j$-th predictor is $\frac{\hat \beta_j}{S_j}$.
In the presented case, I have assumed that only the predictors had been standardized. If one also standardizes the response variable, transforming the covariate coefficients back to the original scale is done by using the formula from the reference you gave. We have:
$$
\frac{\mathbb E[Y] - \hat y}{S_y} =\beta_{0}+\sum_{j=1}^{k}\beta_{j}z_{j}
$$
Carrying out the regression, we get the fitted regression equation
$$
\hat Y_{scaled} = \frac{\hat Y_{unscaled} - \bar y}{S_y} = \hat \beta_0 +\sum_{j=1}^{k} \hat \beta_{j}\left(\frac{x_j - \bar{x}_j}{S_j}\right),
$$
where the fitted values are on the scale of the standardized response. To unscale them and recover the coefficient estimates for the untransformed model, we multiply the equation by $S_y$ and bring the sample mean of the $y$ to the other side:
$$
\hat Y_{unscaled} = \hat \beta_0 S_y + \bar y +\sum_{j=1}^{k} \hat \beta_{j}\left(\frac{S_y}{S_j}\right) (x_j - \bar{x}_j).
$$
The intercept corresponding to the model in which neither the response nor the predictors have been standardized is consequently given by
$ \hat \beta_0 S_y + \bar y - \sum_{j=1}^k \hat \beta_j \frac{S_y}{S_j}\bar x_j$,
while the covariate coefficients for the model of interest can be obtained by multiplying each coefficient with $S_y / S_j$.
|
Converting standardized betas back to original variables
|
For the regression model using the standardized variables, we assume the following form for the regression line
$$
\mathbb E[Y] =\beta_{0}+\sum_{j=1}^{k}\beta_{j}z_{j},
$$
where $z_{j}$ is the j-th (s
|
Converting standardized betas back to original variables
For the regression model using the standardized variables, we assume the following form for the regression line
$$
\mathbb E[Y] =\beta_{0}+\sum_{j=1}^{k}\beta_{j}z_{j},
$$
where $z_{j}$ is the j-th (standardized) regressor, generated from $x_j$ by subtracting the sample mean $\bar x_j$ and dividing by the sample standard deviation $S_j$:
$$
z_j = \frac{x_j - \bar{x}_j}{S_j}
$$
Carrying out the regression with the standardized regressors, we obtain the fitted regression line:
$$
\hat Y = \hat \beta_0 +\sum_{j=1}^{k} \hat \beta_{j}z_{j}
$$
We now wish to find the regression coefficients for the non-standardized predictors. We have
$$
\hat Y = \hat \beta_0 +\sum_{j=1}^{k} \hat \beta_{j}\left(\frac{x_j - \bar{x}_j}{S_j}\right)
$$
Re-arranging, this expression can be written as
$$
\hat Y = \left( \hat \beta_0 - \sum_{j=1}^k \hat \beta_j \frac{\bar x_j}{S_j} \right) + \sum_{j=1}^k \left(\frac{\hat \beta_j}{S_j}\right) x_j
$$
As we can see, the intercept for the regression using the non-transformed variables is given by $ \hat \beta_0 - \sum_{j=1}^k \hat \beta_j \frac{\bar x_j}{S_j}$. The regression coefficient of the $j$-th predictor is $\frac{\hat \beta_j}{S_j}$.
In the presented case, I have assumed that only the predictors had been standardized. If one also standardizes the response variable, transforming the covariate coefficients back to the original scale is done by using the formula from the reference you gave. We have:
$$
\frac{\mathbb E[Y] - \hat y}{S_y} =\beta_{0}+\sum_{j=1}^{k}\beta_{j}z_{j}
$$
Carrying out the regression, we get the fitted regression equation
$$
\hat Y_{scaled} = \frac{\hat Y_{unscaled} - \bar y}{S_y} = \hat \beta_0 +\sum_{j=1}^{k} \hat \beta_{j}\left(\frac{x_j - \bar{x}_j}{S_j}\right),
$$
where the fitted values are on the scale of the standardized response. To unscale them and recover the coefficient estimates for the untransformed model, we multiply the equation by $S_y$ and bring the sample mean of the $y$ to the other side:
$$
\hat Y_{unscaled} = \hat \beta_0 S_y + \bar y +\sum_{j=1}^{k} \hat \beta_{j}\left(\frac{S_y}{S_j}\right) (x_j - \bar{x}_j).
$$
The intercept corresponding to the model in which neither the response nor the predictors have been standardized is consequently given by
$ \hat \beta_0 S_y + \bar y - \sum_{j=1}^k \hat \beta_j \frac{S_y}{S_j}\bar x_j$,
while the covariate coefficients for the model of interest can be obtained by multiplying each coefficient with $S_y / S_j$.
|
Converting standardized betas back to original variables
For the regression model using the standardized variables, we assume the following form for the regression line
$$
\mathbb E[Y] =\beta_{0}+\sum_{j=1}^{k}\beta_{j}z_{j},
$$
where $z_{j}$ is the j-th (s
|
15,267
|
Converting standardized betas back to original variables
|
If you standardize both the regressor matrix and the response vector then the intercept vector is zero. See proof:
https://www.statlect.com/fundamentals-of-statistics/linear-regression-with-standardized-variables
So the assumed form for the regression line is incorrect for the standardized case.
Nevertheless, the derivation is correct. If you set the intercept vector in the final result to zero, you will convert the coefficients back to non-standardized form.
|
Converting standardized betas back to original variables
|
If you standardize both the regressor matrix and the response vector then the intercept vector is zero. See proof:
https://www.statlect.com/fundamentals-of-statistics/linear-regression-with-standardiz
|
Converting standardized betas back to original variables
If you standardize both the regressor matrix and the response vector then the intercept vector is zero. See proof:
https://www.statlect.com/fundamentals-of-statistics/linear-regression-with-standardized-variables
So the assumed form for the regression line is incorrect for the standardized case.
Nevertheless, the derivation is correct. If you set the intercept vector in the final result to zero, you will convert the coefficients back to non-standardized form.
|
Converting standardized betas back to original variables
If you standardize both the regressor matrix and the response vector then the intercept vector is zero. See proof:
https://www.statlect.com/fundamentals-of-statistics/linear-regression-with-standardiz
|
15,268
|
Does this quantity related to independence have a name?
|
It's observed to expected ratio (abbreviation: o/e).
Quoting an answer to About joint probability divided by the product of the probabilities at Math.SE (pointed out by Procrastinator):
Then, at least in the environmental, medical and life sciences literature, P(A∩B)/(P(A)P(B)) is called the observed to expected ratio (abbreviation o/e). The idea is that the numerator is the actual probability of A∩B while the denominator is what it would be if A and B were independent.
|
Does this quantity related to independence have a name?
|
It's observed to expected ratio (abbreviation: o/e).
Quoting an answer to About joint probability divided by the product of the probabilities at Math.SE (pointed out by Procrastinator):
Then, at lea
|
Does this quantity related to independence have a name?
It's observed to expected ratio (abbreviation: o/e).
Quoting an answer to About joint probability divided by the product of the probabilities at Math.SE (pointed out by Procrastinator):
Then, at least in the environmental, medical and life sciences literature, P(A∩B)/(P(A)P(B)) is called the observed to expected ratio (abbreviation o/e). The idea is that the numerator is the actual probability of A∩B while the denominator is what it would be if A and B were independent.
|
Does this quantity related to independence have a name?
It's observed to expected ratio (abbreviation: o/e).
Quoting an answer to About joint probability divided by the product of the probabilities at Math.SE (pointed out by Procrastinator):
Then, at lea
|
15,269
|
Does this quantity related to independence have a name?
|
I think that you are looking for Lift (or improvement). Lift is the ratio of the probability that A and B occur together to the multiple of the two individual probabilities for A and B. It is used to interpret the importance of a rule in association rule mining. Lift is a way to measure how much better a model is over benchmark and it is defined as the confidence divided by the benchmark, where any value that is greater that one suggest that there is some usefulness to the rule. See this page also as another example.
|
Does this quantity related to independence have a name?
|
I think that you are looking for Lift (or improvement). Lift is the ratio of the probability that A and B occur together to the multiple of the two individual probabilities for A and B. It is used to
|
Does this quantity related to independence have a name?
I think that you are looking for Lift (or improvement). Lift is the ratio of the probability that A and B occur together to the multiple of the two individual probabilities for A and B. It is used to interpret the importance of a rule in association rule mining. Lift is a way to measure how much better a model is over benchmark and it is defined as the confidence divided by the benchmark, where any value that is greater that one suggest that there is some usefulness to the rule. See this page also as another example.
|
Does this quantity related to independence have a name?
I think that you are looking for Lift (or improvement). Lift is the ratio of the probability that A and B occur together to the multiple of the two individual probabilities for A and B. It is used to
|
15,270
|
Does this quantity related to independence have a name?
|
The correspondence analysis folk call one of these quantities a contingency ratio, in the context of cross-tabulated counts. The distances of multiple such ratios from 1 are what biplots visualize. See e.g. Greenacre (1993) ch.13.
The old-school machine learning feature selection folk call the log of this quantity pointwise mutual information. See e.g. Manning and Schütze (1999) p.66.
|
Does this quantity related to independence have a name?
|
The correspondence analysis folk call one of these quantities a contingency ratio, in the context of cross-tabulated counts. The distances of multiple such ratios from 1 are what biplots visualize.
|
Does this quantity related to independence have a name?
The correspondence analysis folk call one of these quantities a contingency ratio, in the context of cross-tabulated counts. The distances of multiple such ratios from 1 are what biplots visualize. See e.g. Greenacre (1993) ch.13.
The old-school machine learning feature selection folk call the log of this quantity pointwise mutual information. See e.g. Manning and Schütze (1999) p.66.
|
Does this quantity related to independence have a name?
The correspondence analysis folk call one of these quantities a contingency ratio, in the context of cross-tabulated counts. The distances of multiple such ratios from 1 are what biplots visualize.
|
15,271
|
Does this quantity related to independence have a name?
|
In Data Mining it seems they call this lift.
|
Does this quantity related to independence have a name?
|
In Data Mining it seems they call this lift.
|
Does this quantity related to independence have a name?
In Data Mining it seems they call this lift.
|
Does this quantity related to independence have a name?
In Data Mining it seems they call this lift.
|
15,272
|
Does this quantity related to independence have a name?
|
Maybe you are asking how this quantity is related to the Odds Ratio,
as a quantity for measuring independence.
I think you are searching for "Relation to statistical independence". See http://en.wikipedia.org/wiki/Odds_ratio
|
Does this quantity related to independence have a name?
|
Maybe you are asking how this quantity is related to the Odds Ratio,
as a quantity for measuring independence.
I think you are searching for "Relation to statistical independence". See http://en.wikip
|
Does this quantity related to independence have a name?
Maybe you are asking how this quantity is related to the Odds Ratio,
as a quantity for measuring independence.
I think you are searching for "Relation to statistical independence". See http://en.wikipedia.org/wiki/Odds_ratio
|
Does this quantity related to independence have a name?
Maybe you are asking how this quantity is related to the Odds Ratio,
as a quantity for measuring independence.
I think you are searching for "Relation to statistical independence". See http://en.wikip
|
15,273
|
What is the difference between statistics and biostatistics?
|
When I look at the Wikipedia entry for biostatistics, the relation to biometrics doesn't seem so obvious to me since, historically, biometrics was more concerned with characterizing individuals by some phenotypes of interest, with large applications in population genetics (as exemplified by the work of Fisher), whereas part of this discipline now focus on biometric systems (whose objectives are the "recognition or identification of individuals based on some physical or behavioral characteristics that are intrinsically unique for each individual", according to Boulgouris et al., Biometrics, 2010). Anyway, there still are reviews like Biometrika and Biometrics; although I read the latter on an irregular basis, most articles focus on "biostatistical" theoretical or applied work. The same applies for Biostatistics. By "biostatistical" applications, I mean that it has to do with applications or models related to the biomedical domain, in a wide sense (biology, health science, genetics, etc.).
According to the Encyclopedia of Biostatistics (2005, 2nd ed.),
(...) As is clear from the above examples,
biostatistics is problem oriented. It
is specifically directed to questions
that arise in biomedical science. The
methods of biostatistics are the
methods of statistics -- concepts
directed at variation in observations
and methods for extracting information
from observations in the face of
variation from various sources, but
notably from variation in the
responses of living organisms and
particularly human beings under study.
Biostatistical activity spans a broad
range of scientific inquiry, from the
basic structure and functions of human
beings, through the interactions of
human beings with their environment,
including problems of environmental
toxicities and sanitation, health
enhancement and education, disease
prevention and therapy, the
organization of health care systems
and health care financing.
In sum, I think that Biostatistics is part of a super-family--Statistics--, and share most of its methods, but has a more focused area of interest (hence, an historical background, specific designs, and a general theoretical framework) and dedicated modeling strategies.
|
What is the difference between statistics and biostatistics?
|
When I look at the Wikipedia entry for biostatistics, the relation to biometrics doesn't seem so obvious to me since, historically, biometrics was more concerned with characterizing individuals by som
|
What is the difference between statistics and biostatistics?
When I look at the Wikipedia entry for biostatistics, the relation to biometrics doesn't seem so obvious to me since, historically, biometrics was more concerned with characterizing individuals by some phenotypes of interest, with large applications in population genetics (as exemplified by the work of Fisher), whereas part of this discipline now focus on biometric systems (whose objectives are the "recognition or identification of individuals based on some physical or behavioral characteristics that are intrinsically unique for each individual", according to Boulgouris et al., Biometrics, 2010). Anyway, there still are reviews like Biometrika and Biometrics; although I read the latter on an irregular basis, most articles focus on "biostatistical" theoretical or applied work. The same applies for Biostatistics. By "biostatistical" applications, I mean that it has to do with applications or models related to the biomedical domain, in a wide sense (biology, health science, genetics, etc.).
According to the Encyclopedia of Biostatistics (2005, 2nd ed.),
(...) As is clear from the above examples,
biostatistics is problem oriented. It
is specifically directed to questions
that arise in biomedical science. The
methods of biostatistics are the
methods of statistics -- concepts
directed at variation in observations
and methods for extracting information
from observations in the face of
variation from various sources, but
notably from variation in the
responses of living organisms and
particularly human beings under study.
Biostatistical activity spans a broad
range of scientific inquiry, from the
basic structure and functions of human
beings, through the interactions of
human beings with their environment,
including problems of environmental
toxicities and sanitation, health
enhancement and education, disease
prevention and therapy, the
organization of health care systems
and health care financing.
In sum, I think that Biostatistics is part of a super-family--Statistics--, and share most of its methods, but has a more focused area of interest (hence, an historical background, specific designs, and a general theoretical framework) and dedicated modeling strategies.
|
What is the difference between statistics and biostatistics?
When I look at the Wikipedia entry for biostatistics, the relation to biometrics doesn't seem so obvious to me since, historically, biometrics was more concerned with characterizing individuals by som
|
15,274
|
What is the difference between statistics and biostatistics?
|
To quote the "Encyclopedic dictionary of mathematics" by Kiyosi Itô (ed.):
In many applied fields there exist systems of statistical methods which have been developed specifically for the respective fields, and although all of them are based essentially on the same general principles of statistical inference, each has its own special techniques and procedures. Specific names have been invented, such as biometrics, econometrics, psychometrics, technometrics, sociometrics, etc.
|
What is the difference between statistics and biostatistics?
|
To quote the "Encyclopedic dictionary of mathematics" by Kiyosi Itô (ed.):
In many applied fields there exist systems of statistical methods which have been developed specifically for the respective f
|
What is the difference between statistics and biostatistics?
To quote the "Encyclopedic dictionary of mathematics" by Kiyosi Itô (ed.):
In many applied fields there exist systems of statistical methods which have been developed specifically for the respective fields, and although all of them are based essentially on the same general principles of statistical inference, each has its own special techniques and procedures. Specific names have been invented, such as biometrics, econometrics, psychometrics, technometrics, sociometrics, etc.
|
What is the difference between statistics and biostatistics?
To quote the "Encyclopedic dictionary of mathematics" by Kiyosi Itô (ed.):
In many applied fields there exist systems of statistical methods which have been developed specifically for the respective f
|
15,275
|
What is the difference between statistics and biostatistics?
|
As someone who took courses from the Statistics department of a university which did not offer a Biostatistics major and worked in clinical trials with biostatisticians and read many papers written by biostatisticians, I can offer a particular perspective. I see biostatistics as a field that applies a subset of standard statistical techniques to clinical research. Biostatistics focuses on categorical variables and logistic regression to a greater degree than statistics applied to subjects studied in the physical sciences and engineering. Biostatistics tends to seek answers to binary questions, such as these: 1) Is this subject healthy or sick? or 2) does this drug cause more good than harm? It often uses discrete independent variables such as whether a subject was alive or dead at the end of the study. This isn't an ironclad distinction, though: biostatistics also uses survival analysis, which involves measuring a continuous variable, i.e., the length of time to an event of biological significance.
|
What is the difference between statistics and biostatistics?
|
As someone who took courses from the Statistics department of a university which did not offer a Biostatistics major and worked in clinical trials with biostatisticians and read many papers written by
|
What is the difference between statistics and biostatistics?
As someone who took courses from the Statistics department of a university which did not offer a Biostatistics major and worked in clinical trials with biostatisticians and read many papers written by biostatisticians, I can offer a particular perspective. I see biostatistics as a field that applies a subset of standard statistical techniques to clinical research. Biostatistics focuses on categorical variables and logistic regression to a greater degree than statistics applied to subjects studied in the physical sciences and engineering. Biostatistics tends to seek answers to binary questions, such as these: 1) Is this subject healthy or sick? or 2) does this drug cause more good than harm? It often uses discrete independent variables such as whether a subject was alive or dead at the end of the study. This isn't an ironclad distinction, though: biostatistics also uses survival analysis, which involves measuring a continuous variable, i.e., the length of time to an event of biological significance.
|
What is the difference between statistics and biostatistics?
As someone who took courses from the Statistics department of a university which did not offer a Biostatistics major and worked in clinical trials with biostatisticians and read many papers written by
|
15,276
|
What is the difference between statistics and biostatistics?
|
I will take a swing at answering this from the perspective of someone who is neither a statistician nor a biostatistician. Rather, I exist in the blurry grey area that is "epidemiological methods".
As other posters have mentioned, biostatistics is a discipline particularly focused on statistics as they apply to biological problems - including those that arise in medicine. While this seems somewhat semantic, it does result in some things that I think it make it a distinct entity on its own, though none of these are strictly exclusive:
A reliance on subject-matter expertise. Be this through collaboration with subject matter experts, or simply working on the same problem for a long time, biostats involves the fusion of a statistical method with a particularly applied problem.
A common and fairly restricted set of study designs. While exotic study designs are growing more acceptable, by and large the field is still dominated by cohort, case-control and clinical trial designs. The focus is often on estimating categorical exposures (given the drug, not given the drug...) and categorical outcomes (died, didn't die).
A ubiquity of missing/misclassified/poor data.
Less emphasis on classification and prediction. As @Alexis has mentioned, causal inference, and the desire to explore counterfactuals is hugely important for biostatistics. While not exclusively true, something that is a good predictor but has no etiologic explanation is of less interest. This has, for example, somewhat limited the penetration of machine learning methods.
|
What is the difference between statistics and biostatistics?
|
I will take a swing at answering this from the perspective of someone who is neither a statistician nor a biostatistician. Rather, I exist in the blurry grey area that is "epidemiological methods".
As
|
What is the difference between statistics and biostatistics?
I will take a swing at answering this from the perspective of someone who is neither a statistician nor a biostatistician. Rather, I exist in the blurry grey area that is "epidemiological methods".
As other posters have mentioned, biostatistics is a discipline particularly focused on statistics as they apply to biological problems - including those that arise in medicine. While this seems somewhat semantic, it does result in some things that I think it make it a distinct entity on its own, though none of these are strictly exclusive:
A reliance on subject-matter expertise. Be this through collaboration with subject matter experts, or simply working on the same problem for a long time, biostats involves the fusion of a statistical method with a particularly applied problem.
A common and fairly restricted set of study designs. While exotic study designs are growing more acceptable, by and large the field is still dominated by cohort, case-control and clinical trial designs. The focus is often on estimating categorical exposures (given the drug, not given the drug...) and categorical outcomes (died, didn't die).
A ubiquity of missing/misclassified/poor data.
Less emphasis on classification and prediction. As @Alexis has mentioned, causal inference, and the desire to explore counterfactuals is hugely important for biostatistics. While not exclusively true, something that is a good predictor but has no etiologic explanation is of less interest. This has, for example, somewhat limited the penetration of machine learning methods.
|
What is the difference between statistics and biostatistics?
I will take a swing at answering this from the perspective of someone who is neither a statistician nor a biostatistician. Rather, I exist in the blurry grey area that is "epidemiological methods".
As
|
15,277
|
What is the difference between statistics and biostatistics?
|
Biostatistics, biometrics and biometry are synonyms. Medical statistics (sometimes called 'clinical biostatistics' for no clear reason) is a subset of these.
|
What is the difference between statistics and biostatistics?
|
Biostatistics, biometrics and biometry are synonyms. Medical statistics (sometimes called 'clinical biostatistics' for no clear reason) is a subset of these.
|
What is the difference between statistics and biostatistics?
Biostatistics, biometrics and biometry are synonyms. Medical statistics (sometimes called 'clinical biostatistics' for no clear reason) is a subset of these.
|
What is the difference between statistics and biostatistics?
Biostatistics, biometrics and biometry are synonyms. Medical statistics (sometimes called 'clinical biostatistics' for no clear reason) is a subset of these.
|
15,278
|
What is the difference between statistics and biostatistics?
|
Statistics vs. Biostatistics does not make sense as a comparison; biostatistics is really a sub topic of statistics. This would be like asking "what's the difference between mathematics and probability?"; probability is a subfield of mathematics.
As others have noted, biostatistics applies to problems that are very common in both medical studies and biological research. This includes, but certainly is not limited to, survival analysis, sequential trial design, longitudinal analysis and genomic analyses, to name only a few topics.
As for the difference between programs in statistics and biostatistics, the obvious difference between two programs is that the biostatistics programs will be specializing in the topics above. Most statistics programs will still cover biostatistics (for example, I have my PhD in Statistics, and of all possible specializations of statistician, I am most qualified as a biostatistician, my current position), but it is definitely possible to get a PhD in statistics with only a mild introduction to biostatistic-specific topics.
It's my understanding that the high demand for statisticians by pharmaceutical companies lead to the demand for biostatistics programs.
|
What is the difference between statistics and biostatistics?
|
Statistics vs. Biostatistics does not make sense as a comparison; biostatistics is really a sub topic of statistics. This would be like asking "what's the difference between mathematics and probabilit
|
What is the difference between statistics and biostatistics?
Statistics vs. Biostatistics does not make sense as a comparison; biostatistics is really a sub topic of statistics. This would be like asking "what's the difference between mathematics and probability?"; probability is a subfield of mathematics.
As others have noted, biostatistics applies to problems that are very common in both medical studies and biological research. This includes, but certainly is not limited to, survival analysis, sequential trial design, longitudinal analysis and genomic analyses, to name only a few topics.
As for the difference between programs in statistics and biostatistics, the obvious difference between two programs is that the biostatistics programs will be specializing in the topics above. Most statistics programs will still cover biostatistics (for example, I have my PhD in Statistics, and of all possible specializations of statistician, I am most qualified as a biostatistician, my current position), but it is definitely possible to get a PhD in statistics with only a mild introduction to biostatistic-specific topics.
It's my understanding that the high demand for statisticians by pharmaceutical companies lead to the demand for biostatistics programs.
|
What is the difference between statistics and biostatistics?
Statistics vs. Biostatistics does not make sense as a comparison; biostatistics is really a sub topic of statistics. This would be like asking "what's the difference between mathematics and probabilit
|
15,279
|
What is the difference between statistics and biostatistics?
|
I see the answers here just define the domain of work so I try to give a more comprehensive answer based on my experience of learning statistics as a medical practitioner. Most of my experience is on clinical trials, but this can be applied to any domain of biostatistics.
The purpose of biostatistics is biological and medical field, this gives it subtle differences according to this purpose.
Statistics is all the same! it is just math! However, here is the difference that comes to my head when I define biostatistics.
1- Ordinary statistician will not understand all the terminologies in biostatistics but he will understand the math!
Both of them are coming from mathematical and probability theories. So you will find most of the tests resonates will with both words like regression analysis, t-test ... etc
However, when it comes some other tests like relative risk, attributable risk reduction, kaplen mieir curves ... etc these few tests will sound strange for someone with no biostatistical knowledge. However, they can easily go through it when they read about these tests
2- Biostatistics field usually don't reinvent the wheel, they just enhance what is available
As I said biostatistics is built on statistics. But unlike the previous point, most of the current active research on biostatistics is mostly about enhancing few properties of existing test with different terminology to serve the purpose of biostatistics. For example, something like overall survival or time-to-death are all terminologies exclusive for biostatistics (that's for sure or who would study life and death) however they are built on time-to-event analysis that biostatistician has created these terminologies to make the test serve the purpose of biostatistics, more standardized and easy to interpret in among medical practitioners.
3- Biostatistics has its specific guidelines (just like any other field) however it is more strict.
Biostatistics has established many guidelines and conventions to analyze the data of different field. For example, statisticians working in biology and genomics are doing different tests and have different thinking than who are working in clinical trials(and of course who are working in business intelligence). But this way of working is considered fixed among the community of biostatistician, so a biostatistician don't usually think out of the box unless there is something urges that has not existed before, and this usually don't happen as study design of biostatistics fields is very definitive.
A clearer example of this is the baysian statistics application on biostatistics. Bayesian statistics are known to be flexible, so you will not find a lot of usage of this type of statistics. Also, this usage is tied to a certain repetitive application like sensitivity measurement. There is no need to think of probabilities when there are easier options that are easier to interpret and perform.
Why This restriction?
1. The community is trying to avoid p hacking and beautifying the results. Especially if you are working in clinical trials, you don't just use the tests the gives the best results. You even don't use one-sided tests usually! These conventions are there to protect the trials validity and anything else will make the community suspicious.
That's the most important part. All the work of biostatistics should be interpreted by a medical practitioner, so he should make some sense of results himself. So they try to stick to a few approaches.
This point is unfair because there is no comparison, but study design in biostatistics is very definitive. Usually, you don't have to think a lot on how to prove the efficacy of a drug or adverse effect or so. So it is very unlikely you will need to keep your head busy of learning different techniques and tests every while as it is very rare to see a pattern change.
That's all I have right now, I will update my answer if I remembered something else.
|
What is the difference between statistics and biostatistics?
|
I see the answers here just define the domain of work so I try to give a more comprehensive answer based on my experience of learning statistics as a medical practitioner. Most of my experience is on
|
What is the difference between statistics and biostatistics?
I see the answers here just define the domain of work so I try to give a more comprehensive answer based on my experience of learning statistics as a medical practitioner. Most of my experience is on clinical trials, but this can be applied to any domain of biostatistics.
The purpose of biostatistics is biological and medical field, this gives it subtle differences according to this purpose.
Statistics is all the same! it is just math! However, here is the difference that comes to my head when I define biostatistics.
1- Ordinary statistician will not understand all the terminologies in biostatistics but he will understand the math!
Both of them are coming from mathematical and probability theories. So you will find most of the tests resonates will with both words like regression analysis, t-test ... etc
However, when it comes some other tests like relative risk, attributable risk reduction, kaplen mieir curves ... etc these few tests will sound strange for someone with no biostatistical knowledge. However, they can easily go through it when they read about these tests
2- Biostatistics field usually don't reinvent the wheel, they just enhance what is available
As I said biostatistics is built on statistics. But unlike the previous point, most of the current active research on biostatistics is mostly about enhancing few properties of existing test with different terminology to serve the purpose of biostatistics. For example, something like overall survival or time-to-death are all terminologies exclusive for biostatistics (that's for sure or who would study life and death) however they are built on time-to-event analysis that biostatistician has created these terminologies to make the test serve the purpose of biostatistics, more standardized and easy to interpret in among medical practitioners.
3- Biostatistics has its specific guidelines (just like any other field) however it is more strict.
Biostatistics has established many guidelines and conventions to analyze the data of different field. For example, statisticians working in biology and genomics are doing different tests and have different thinking than who are working in clinical trials(and of course who are working in business intelligence). But this way of working is considered fixed among the community of biostatistician, so a biostatistician don't usually think out of the box unless there is something urges that has not existed before, and this usually don't happen as study design of biostatistics fields is very definitive.
A clearer example of this is the baysian statistics application on biostatistics. Bayesian statistics are known to be flexible, so you will not find a lot of usage of this type of statistics. Also, this usage is tied to a certain repetitive application like sensitivity measurement. There is no need to think of probabilities when there are easier options that are easier to interpret and perform.
Why This restriction?
1. The community is trying to avoid p hacking and beautifying the results. Especially if you are working in clinical trials, you don't just use the tests the gives the best results. You even don't use one-sided tests usually! These conventions are there to protect the trials validity and anything else will make the community suspicious.
That's the most important part. All the work of biostatistics should be interpreted by a medical practitioner, so he should make some sense of results himself. So they try to stick to a few approaches.
This point is unfair because there is no comparison, but study design in biostatistics is very definitive. Usually, you don't have to think a lot on how to prove the efficacy of a drug or adverse effect or so. So it is very unlikely you will need to keep your head busy of learning different techniques and tests every while as it is very rare to see a pattern change.
That's all I have right now, I will update my answer if I remembered something else.
|
What is the difference between statistics and biostatistics?
I see the answers here just define the domain of work so I try to give a more comprehensive answer based on my experience of learning statistics as a medical practitioner. Most of my experience is on
|
15,280
|
What is the difference between statistics and biostatistics?
|
As for what I see this seems to be just a matter of semantics. Statistics applied to research or testing in the social sciences is just called Statistics. A person working with this type of situations needs to have a through knowledge of his or her field before applying a statistical procedure. Anyway we just call it Statistics. I think that this discussion is just about a system of preferences. If in the biological fields it is preferred to call it biostatistics there is no problem. This is just a choice of words.
|
What is the difference between statistics and biostatistics?
|
As for what I see this seems to be just a matter of semantics. Statistics applied to research or testing in the social sciences is just called Statistics. A person working with this type of situations
|
What is the difference between statistics and biostatistics?
As for what I see this seems to be just a matter of semantics. Statistics applied to research or testing in the social sciences is just called Statistics. A person working with this type of situations needs to have a through knowledge of his or her field before applying a statistical procedure. Anyway we just call it Statistics. I think that this discussion is just about a system of preferences. If in the biological fields it is preferred to call it biostatistics there is no problem. This is just a choice of words.
|
What is the difference between statistics and biostatistics?
As for what I see this seems to be just a matter of semantics. Statistics applied to research or testing in the social sciences is just called Statistics. A person working with this type of situations
|
15,281
|
What is the difference between statistics and biostatistics?
|
There is not a significant difference between statistics and biostatistics. In my definition, biostatistics is the application of statistics to biology. So a Biostatistician has a relatively strong command in biology, well at least enough to understand how to apply his statistics to biology.
It would be the same concept as Artstatistics, or Sociostatistics; application of statistics to art or statistics to sociology, respectively.
Biostatistics is simply the statistics of BIOLOGY. So you need a command of biology and statistics to do well as a Biostatistician.'Tis all.
|
What is the difference between statistics and biostatistics?
|
There is not a significant difference between statistics and biostatistics. In my definition, biostatistics is the application of statistics to biology. So a Biostatistician has a relatively strong co
|
What is the difference between statistics and biostatistics?
There is not a significant difference between statistics and biostatistics. In my definition, biostatistics is the application of statistics to biology. So a Biostatistician has a relatively strong command in biology, well at least enough to understand how to apply his statistics to biology.
It would be the same concept as Artstatistics, or Sociostatistics; application of statistics to art or statistics to sociology, respectively.
Biostatistics is simply the statistics of BIOLOGY. So you need a command of biology and statistics to do well as a Biostatistician.'Tis all.
|
What is the difference between statistics and biostatistics?
There is not a significant difference between statistics and biostatistics. In my definition, biostatistics is the application of statistics to biology. So a Biostatistician has a relatively strong co
|
15,282
|
Why was the letter Q chosen in Q-learning?
|
I'm sorry to disappoint everyone, but Q doesn't stand for anything :)
Q-learning was proposed by Watkins in his PhD thesis in 1989, see p.96. The Q in the equation on that page is updated in certain way at each step. The Q is the expected return from action at a given state, see the definition of Q on p.46. The return is in a economic or game theory sense, i.e. discounted probability weighted rewards, not a computer science term like a return from a function.
Notice, how he already used P for probability and R for reward, so he grabbed Q for the return. That's it. There's no deeper meaning for a choice of a letter Q.
|
Why was the letter Q chosen in Q-learning?
|
I'm sorry to disappoint everyone, but Q doesn't stand for anything :)
Q-learning was proposed by Watkins in his PhD thesis in 1989, see p.96. The Q in the equation on that page is updated in certain w
|
Why was the letter Q chosen in Q-learning?
I'm sorry to disappoint everyone, but Q doesn't stand for anything :)
Q-learning was proposed by Watkins in his PhD thesis in 1989, see p.96. The Q in the equation on that page is updated in certain way at each step. The Q is the expected return from action at a given state, see the definition of Q on p.46. The return is in a economic or game theory sense, i.e. discounted probability weighted rewards, not a computer science term like a return from a function.
Notice, how he already used P for probability and R for reward, so he grabbed Q for the return. That's it. There's no deeper meaning for a choice of a letter Q.
|
Why was the letter Q chosen in Q-learning?
I'm sorry to disappoint everyone, but Q doesn't stand for anything :)
Q-learning was proposed by Watkins in his PhD thesis in 1989, see p.96. The Q in the equation on that page is updated in certain w
|
15,283
|
Why was the letter Q chosen in Q-learning?
|
The reason Q-Learning is called so because it uses Q values to form it's estimates. The usual learning rule is, $Q(s_t,a_t)\gets Q(s_t,a_t)+\alpha(r_t+\gamma \times \max_{a} Q(s_{t+1},a)-Q(s_t,a_t))$ and it should be clear why it is called Q-Learning.
But the actual question in my view is why Q-Learning is called so. Though there does not seem to be a satisfactory answer, this link mentions that Andrew Barto, who is one of the founders of Modern Reinforcement Learning, thinks that $Q$ stands for Quality, called so because it characterizes how good the result of pulling an arm would be.
|
Why was the letter Q chosen in Q-learning?
|
The reason Q-Learning is called so because it uses Q values to form it's estimates. The usual learning rule is, $Q(s_t,a_t)\gets Q(s_t,a_t)+\alpha(r_t+\gamma \times \max_{a} Q(s_{t+1},a)-Q(s_t,a_t))$
|
Why was the letter Q chosen in Q-learning?
The reason Q-Learning is called so because it uses Q values to form it's estimates. The usual learning rule is, $Q(s_t,a_t)\gets Q(s_t,a_t)+\alpha(r_t+\gamma \times \max_{a} Q(s_{t+1},a)-Q(s_t,a_t))$ and it should be clear why it is called Q-Learning.
But the actual question in my view is why Q-Learning is called so. Though there does not seem to be a satisfactory answer, this link mentions that Andrew Barto, who is one of the founders of Modern Reinforcement Learning, thinks that $Q$ stands for Quality, called so because it characterizes how good the result of pulling an arm would be.
|
Why was the letter Q chosen in Q-learning?
The reason Q-Learning is called so because it uses Q values to form it's estimates. The usual learning rule is, $Q(s_t,a_t)\gets Q(s_t,a_t)+\alpha(r_t+\gamma \times \max_{a} Q(s_{t+1},a)-Q(s_t,a_t))$
|
15,284
|
Google Inception model:why there is multiple softmax?
|
Short answer: Deep architectures, and specifically GoogLeNet (22 layers) are in danger of the vanishing gradients problem during training (back-propagation algorithm). The engineers of GoogLeNet addressed this issue by adding classifiers in the intermediate layers as well, such that the final loss is a combination of the intermediate loss and the final loss. This is why you see a total of three loss layers, unlike the usual single layer as the last layer of the network.
Longer answer: In classic Machine Learning, there is usually a distinction between feature engineering and classification. Neural networks are most famous for their ability to solve problems "end to end", i.e, they combine the stages of learning a representation for the data, and training a classifier. Therefore, you can think of a neural network with a standard architecture (for example, AlexNet) as being composed of a "representation learning" phase (the layers up until previous to last) and a "classification" phase, which as expected, includes a loss function.
When creating deeper networks, there arises a problem coined as the "vanishing gradients" problem. It's actually not specific to neural networks; rather to any gradient based learning methods. It not that trivial and therefore deserves a proper explanation for itself; see here for a good reference. Intuitively, you can think about the gradients carrying less and less information the deeper we go inside the network, which is of course a major concern, since we tune the network's parameters (weights) based solely on the gradients, using the "back-prop" algorithm.
How did the developers of GoogLeNet handle this problem? They recognized the fact that it's not only the features of the final layers that carry all the discriminatory information: intermediate features are also capable of discriminating different labels; and, most importantly, their values are more "reliable" since they are extracted from earlier layers in which the gradient carry more information. Building on this intuition, they added "auxiliary classifiers" in two intermediate layers. This is the reason for the "early escape" loss layers in the middle of the network which you referenced to in your question.
The total loss is then a combination of these three loss layers. I quote from the original article:
These classifiers take the form
of smaller convolutional networks put on top of the output
of the Inception (4a) and (4d) modules. During training,
their loss gets added to the total loss of the network
with a discount weight (the losses of the auxiliary classi-
fiers were weighted by 0.3). At inference time, these auxiliary
networks are discarded.
Visually:
|
Google Inception model:why there is multiple softmax?
|
Short answer: Deep architectures, and specifically GoogLeNet (22 layers) are in danger of the vanishing gradients problem during training (back-propagation algorithm). The engineers of GoogLeNet addre
|
Google Inception model:why there is multiple softmax?
Short answer: Deep architectures, and specifically GoogLeNet (22 layers) are in danger of the vanishing gradients problem during training (back-propagation algorithm). The engineers of GoogLeNet addressed this issue by adding classifiers in the intermediate layers as well, such that the final loss is a combination of the intermediate loss and the final loss. This is why you see a total of three loss layers, unlike the usual single layer as the last layer of the network.
Longer answer: In classic Machine Learning, there is usually a distinction between feature engineering and classification. Neural networks are most famous for their ability to solve problems "end to end", i.e, they combine the stages of learning a representation for the data, and training a classifier. Therefore, you can think of a neural network with a standard architecture (for example, AlexNet) as being composed of a "representation learning" phase (the layers up until previous to last) and a "classification" phase, which as expected, includes a loss function.
When creating deeper networks, there arises a problem coined as the "vanishing gradients" problem. It's actually not specific to neural networks; rather to any gradient based learning methods. It not that trivial and therefore deserves a proper explanation for itself; see here for a good reference. Intuitively, you can think about the gradients carrying less and less information the deeper we go inside the network, which is of course a major concern, since we tune the network's parameters (weights) based solely on the gradients, using the "back-prop" algorithm.
How did the developers of GoogLeNet handle this problem? They recognized the fact that it's not only the features of the final layers that carry all the discriminatory information: intermediate features are also capable of discriminating different labels; and, most importantly, their values are more "reliable" since they are extracted from earlier layers in which the gradient carry more information. Building on this intuition, they added "auxiliary classifiers" in two intermediate layers. This is the reason for the "early escape" loss layers in the middle of the network which you referenced to in your question.
The total loss is then a combination of these three loss layers. I quote from the original article:
These classifiers take the form
of smaller convolutional networks put on top of the output
of the Inception (4a) and (4d) modules. During training,
their loss gets added to the total loss of the network
with a discount weight (the losses of the auxiliary classi-
fiers were weighted by 0.3). At inference time, these auxiliary
networks are discarded.
Visually:
|
Google Inception model:why there is multiple softmax?
Short answer: Deep architectures, and specifically GoogLeNet (22 layers) are in danger of the vanishing gradients problem during training (back-propagation algorithm). The engineers of GoogLeNet addre
|
15,285
|
Google Inception model:why there is multiple softmax?
|
In addition to the answer of @galoosh33: It seems to me that the auxiliary classifiers use the same labels as the final output classifier. Source: slide 34 in https://pdfs.semanticscholar.org/0b99/d677883883584d9a328f6f2d54738363997a.pdf
Previously, I wondered whether these auxiliary classifiers used other type of labels (e.g. simply dog instead of Siberian husky).
|
Google Inception model:why there is multiple softmax?
|
In addition to the answer of @galoosh33: It seems to me that the auxiliary classifiers use the same labels as the final output classifier. Source: slide 34 in https://pdfs.semanticscholar.org/0b99/d67
|
Google Inception model:why there is multiple softmax?
In addition to the answer of @galoosh33: It seems to me that the auxiliary classifiers use the same labels as the final output classifier. Source: slide 34 in https://pdfs.semanticscholar.org/0b99/d677883883584d9a328f6f2d54738363997a.pdf
Previously, I wondered whether these auxiliary classifiers used other type of labels (e.g. simply dog instead of Siberian husky).
|
Google Inception model:why there is multiple softmax?
In addition to the answer of @galoosh33: It seems to me that the auxiliary classifiers use the same labels as the final output classifier. Source: slide 34 in https://pdfs.semanticscholar.org/0b99/d67
|
15,286
|
What is the intuition behind the independence of $X_2-X_1$ and $X_1+X_2$, $X_i \sim N(0,1)$?
|
This is standard normal distributed data:
Notice that the distribution is circulary symmetric.
When you switch to $Y_1 = X_2 - X_1$ and $Y_2 = X_1 + X_2$, you effectively rotate and scale the axis, like this:
This new coordinate system has the same origin as the original one, and the axis are orthogonal. Due to the circulary symmetry, the variables are still independent in the new coordinate system.
|
What is the intuition behind the independence of $X_2-X_1$ and $X_1+X_2$, $X_i \sim N(0,1)$?
|
This is standard normal distributed data:
Notice that the distribution is circulary symmetric.
When you switch to $Y_1 = X_2 - X_1$ and $Y_2 = X_1 + X_2$, you effectively rotate and scale the axis, l
|
What is the intuition behind the independence of $X_2-X_1$ and $X_1+X_2$, $X_i \sim N(0,1)$?
This is standard normal distributed data:
Notice that the distribution is circulary symmetric.
When you switch to $Y_1 = X_2 - X_1$ and $Y_2 = X_1 + X_2$, you effectively rotate and scale the axis, like this:
This new coordinate system has the same origin as the original one, and the axis are orthogonal. Due to the circulary symmetry, the variables are still independent in the new coordinate system.
|
What is the intuition behind the independence of $X_2-X_1$ and $X_1+X_2$, $X_i \sim N(0,1)$?
This is standard normal distributed data:
Notice that the distribution is circulary symmetric.
When you switch to $Y_1 = X_2 - X_1$ and $Y_2 = X_1 + X_2$, you effectively rotate and scale the axis, l
|
15,287
|
What is the intuition behind the independence of $X_2-X_1$ and $X_1+X_2$, $X_i \sim N(0,1)$?
|
The result works for $(X_1,X_2)$ jointly normal (i.e. with correlation, $-1<\rho<1$), with common $\sigma$.
If you know a couple of basic results, this is about all you need:
$\quad\quad\quad$
dobiwan's approach is essentially fine - it's just that the result is more general than the case dealt with there.
|
What is the intuition behind the independence of $X_2-X_1$ and $X_1+X_2$, $X_i \sim N(0,1)$?
|
The result works for $(X_1,X_2)$ jointly normal (i.e. with correlation, $-1<\rho<1$), with common $\sigma$.
If you know a couple of basic results, this is about all you need:
$\quad\quad\quad$
dobiw
|
What is the intuition behind the independence of $X_2-X_1$ and $X_1+X_2$, $X_i \sim N(0,1)$?
The result works for $(X_1,X_2)$ jointly normal (i.e. with correlation, $-1<\rho<1$), with common $\sigma$.
If you know a couple of basic results, this is about all you need:
$\quad\quad\quad$
dobiwan's approach is essentially fine - it's just that the result is more general than the case dealt with there.
|
What is the intuition behind the independence of $X_2-X_1$ and $X_1+X_2$, $X_i \sim N(0,1)$?
The result works for $(X_1,X_2)$ jointly normal (i.e. with correlation, $-1<\rho<1$), with common $\sigma$.
If you know a couple of basic results, this is about all you need:
$\quad\quad\quad$
dobiw
|
15,288
|
What is the intuition behind the independence of $X_2-X_1$ and $X_1+X_2$, $X_i \sim N(0,1)$?
|
The result you claim to be true is not true in general, not even for the case when all that is known is that $X_1$ and $X_2$ are normal random variables with identical variance, but the result does hold for the usual interpretation of the condition you stated later:
The subscripts do not indicate Order Statistics but observations from the standard normal distrubution.
The usual interpretation of the last few words in this statement is, of course, that $X_1$ and $X_2$ are independent
(normal) random variables, and hence jointly normal random variables.
For jointly normal random variables with identical variance, it is
true that $X_1+X_2$ and $X_1-X_2$ are independent (normal) random
variables (with, in general, unequal variances), and the intuitive explanation for this is best given in Glen_b's answer. For your special case of
$X_1$ and $X_2$ being independent as well, dobiwan's answer, which you
have accepted, is simplest, and indeed reveals that any rotation of
the axes, not just by the $\pm \frac{\pi}{4}$ implicit in the transformation $(X_1,X_2)\to (X_1+X_2, X_1-X_2)$, will yield independent random variables.
What can be said in general? In everything I say below, please bear in
mind that $X$ and $Y$ have the same variance, no matter what other
properties might be attributed to them.
If $X$ and $Y$ are any random variables (note: not necessarily
normal) with identical variance, then
$X+Y$ and $X-Y$ are uncorrelated random variables (that is, they have
zero covariance). This is because
the covariance function is bilinear:
$$\begin{align}
\operatorname{cov}(X+Y, X-Y) &= \operatorname{cov}(X,X) - \operatorname{cov}(X,Y) + \operatorname{cov}(Y,X) - \operatorname{cov}(Y,Y)\\
&= \operatorname{var}(X) - \operatorname{cov}(X,Y) + \operatorname{cov}(X,Y) - \operatorname{var}(Y)\\
&= 0.
\end{align}$$
Here we have used the fact that $\operatorname{cov}(X,X)$ is just
the variance $\operatorname{var}(X)$ of $X$ (and similarly
for $Y$) and, of course,
$\operatorname{cov}(Y,X) = \operatorname{cov}(X,Y)$. Note that
this result holds when $X$ and $Y$ are (marginally) normal random variables
but not necessarily jointly normal random variables.
(If you are not familiar with this notion of marginal normality
not being the same as joint normality, see
this great answer by cardinal).
In the special case when $X$ and $Y$ are jointly normal
(but not necessarily independent) normal random variables,
so are $X+Y$ and $X-Y$ jointly normal, and since their covariance
is $0$, $X+Y$ and $X-Y$ are independent random variables.
|
What is the intuition behind the independence of $X_2-X_1$ and $X_1+X_2$, $X_i \sim N(0,1)$?
|
The result you claim to be true is not true in general, not even for the case when all that is known is that $X_1$ and $X_2$ are normal random variables with identical variance, but the result does ho
|
What is the intuition behind the independence of $X_2-X_1$ and $X_1+X_2$, $X_i \sim N(0,1)$?
The result you claim to be true is not true in general, not even for the case when all that is known is that $X_1$ and $X_2$ are normal random variables with identical variance, but the result does hold for the usual interpretation of the condition you stated later:
The subscripts do not indicate Order Statistics but observations from the standard normal distrubution.
The usual interpretation of the last few words in this statement is, of course, that $X_1$ and $X_2$ are independent
(normal) random variables, and hence jointly normal random variables.
For jointly normal random variables with identical variance, it is
true that $X_1+X_2$ and $X_1-X_2$ are independent (normal) random
variables (with, in general, unequal variances), and the intuitive explanation for this is best given in Glen_b's answer. For your special case of
$X_1$ and $X_2$ being independent as well, dobiwan's answer, which you
have accepted, is simplest, and indeed reveals that any rotation of
the axes, not just by the $\pm \frac{\pi}{4}$ implicit in the transformation $(X_1,X_2)\to (X_1+X_2, X_1-X_2)$, will yield independent random variables.
What can be said in general? In everything I say below, please bear in
mind that $X$ and $Y$ have the same variance, no matter what other
properties might be attributed to them.
If $X$ and $Y$ are any random variables (note: not necessarily
normal) with identical variance, then
$X+Y$ and $X-Y$ are uncorrelated random variables (that is, they have
zero covariance). This is because
the covariance function is bilinear:
$$\begin{align}
\operatorname{cov}(X+Y, X-Y) &= \operatorname{cov}(X,X) - \operatorname{cov}(X,Y) + \operatorname{cov}(Y,X) - \operatorname{cov}(Y,Y)\\
&= \operatorname{var}(X) - \operatorname{cov}(X,Y) + \operatorname{cov}(X,Y) - \operatorname{var}(Y)\\
&= 0.
\end{align}$$
Here we have used the fact that $\operatorname{cov}(X,X)$ is just
the variance $\operatorname{var}(X)$ of $X$ (and similarly
for $Y$) and, of course,
$\operatorname{cov}(Y,X) = \operatorname{cov}(X,Y)$. Note that
this result holds when $X$ and $Y$ are (marginally) normal random variables
but not necessarily jointly normal random variables.
(If you are not familiar with this notion of marginal normality
not being the same as joint normality, see
this great answer by cardinal).
In the special case when $X$ and $Y$ are jointly normal
(but not necessarily independent) normal random variables,
so are $X+Y$ and $X-Y$ jointly normal, and since their covariance
is $0$, $X+Y$ and $X-Y$ are independent random variables.
|
What is the intuition behind the independence of $X_2-X_1$ and $X_1+X_2$, $X_i \sim N(0,1)$?
The result you claim to be true is not true in general, not even for the case when all that is known is that $X_1$ and $X_2$ are normal random variables with identical variance, but the result does ho
|
15,289
|
What is the intuition behind the independence of $X_2-X_1$ and $X_1+X_2$, $X_i \sim N(0,1)$?
|
I first argue for general identically distributed $X_1,X_2$ that the conditional mean of $Y_1$ conditional on $Y_2$ is constant $0$. Based on this, I argue that the covariance of $Y_1,Y_2$ is 0. Then, under normality, zero covariance implies independence.
The conditional mean
Intuition: $X_1+X_2=y$ does not imply anything about which component contributed more to the sum (e.g., $X_1=x, X_2 = y-x$ is as likely as $X_1 = y-x, X_2=x$). Thus, the expected difference must be 0.
Proof: $X_1$ and $X_2$ have identical distribution and $X_1+X_2$ is symmetric with respect to the indexing. Thus, for symmetry reasons, the conditional distribution $X_1 \mid Y_2 = y$ must be equal to the conditional distribution $X_2 \mid Y_2 = y$. Hence, the conditional distributions also have the same mean, and
\begin{equation}
\mathbb{E}(Y_1 \mid Y_2 = y) = \mathbb{E}(X_1 - X_2 \mid X_1+X_2 = y) \\ = \mathbb{E}(X_1 \mid X_1+X_2 = y) - \mathbb{E}(X_2 \mid X_1+X_2 = y)= 0.
\end{equation}
(Caveat: I did not consider the possibility that the conditional mean might not exist.)
Constant conditional mean implies zero correlation/covariance
Intuition: correlation measures how much $Y_1$ tends to increase when $Y_2$ increases. If observing $Y_2$ never changes our mean of $Y_1$, $Y_1$ and $Y_2$ are uncorrelated.
Proof: By definition, covariance is
\begin{equation}
Cov(Y_1,Y_2) = \mathbb{E}\left[\left(Y_1 - \mathbb{E}(Y_1)\right)\left(Y_2 -\mathbb{E}(Y_2) \right)\right]
\end{equation}
to this expectation, we apply the law of iterated expectations: take the expectation of the conditional expectation conditional on $Y_2$:
\begin{equation}
= \mathbb{E}\left[\mathbb{E}\left[\left(Y_1 - \mathbb{E}(Y_1)\right)\left(Y_2 -\mathbb{E}(Y_2) \right) \mid Y_2\right]\right] = \mathbb{E}\left[(Y_2 - \mathbb{E}(Y_2))\mathbb{E}\left[Y_1 - \mathbb{E}(Y_1) \mid Y_2\right] \right].
\end{equation}
Recall that the conditional mean was shown to be independent of $Y_2$ and thus the expression simplifies as
\begin{equation}
= \mathbb{E}\left[(Y_2 - \mathbb{E}(Y_2))\mathbb{E}\left[Y_1-\mathbb{E}(Y_1)\right]\right]
\end{equation}
but the inner expectation is $0$ and we get
\begin{equation}
= \mathbb{E}\left[(Y_2 - \mathbb{E}(Y_2))\times0\right] = 0.
\end{equation}
Independence
Just by assuming identical distributions for $X_1,X_2$, it was shown that $Y_1$ and $Y_2$ are uncorrelated. When $X_1,X_2$ are jointly normal (for example, iid. normal as in the question), their linear combinations $Y_1,Y_2$ are also jointly normal and thus uncorrelatedness implies independence.
|
What is the intuition behind the independence of $X_2-X_1$ and $X_1+X_2$, $X_i \sim N(0,1)$?
|
I first argue for general identically distributed $X_1,X_2$ that the conditional mean of $Y_1$ conditional on $Y_2$ is constant $0$. Based on this, I argue that the covariance of $Y_1,Y_2$ is 0. Then
|
What is the intuition behind the independence of $X_2-X_1$ and $X_1+X_2$, $X_i \sim N(0,1)$?
I first argue for general identically distributed $X_1,X_2$ that the conditional mean of $Y_1$ conditional on $Y_2$ is constant $0$. Based on this, I argue that the covariance of $Y_1,Y_2$ is 0. Then, under normality, zero covariance implies independence.
The conditional mean
Intuition: $X_1+X_2=y$ does not imply anything about which component contributed more to the sum (e.g., $X_1=x, X_2 = y-x$ is as likely as $X_1 = y-x, X_2=x$). Thus, the expected difference must be 0.
Proof: $X_1$ and $X_2$ have identical distribution and $X_1+X_2$ is symmetric with respect to the indexing. Thus, for symmetry reasons, the conditional distribution $X_1 \mid Y_2 = y$ must be equal to the conditional distribution $X_2 \mid Y_2 = y$. Hence, the conditional distributions also have the same mean, and
\begin{equation}
\mathbb{E}(Y_1 \mid Y_2 = y) = \mathbb{E}(X_1 - X_2 \mid X_1+X_2 = y) \\ = \mathbb{E}(X_1 \mid X_1+X_2 = y) - \mathbb{E}(X_2 \mid X_1+X_2 = y)= 0.
\end{equation}
(Caveat: I did not consider the possibility that the conditional mean might not exist.)
Constant conditional mean implies zero correlation/covariance
Intuition: correlation measures how much $Y_1$ tends to increase when $Y_2$ increases. If observing $Y_2$ never changes our mean of $Y_1$, $Y_1$ and $Y_2$ are uncorrelated.
Proof: By definition, covariance is
\begin{equation}
Cov(Y_1,Y_2) = \mathbb{E}\left[\left(Y_1 - \mathbb{E}(Y_1)\right)\left(Y_2 -\mathbb{E}(Y_2) \right)\right]
\end{equation}
to this expectation, we apply the law of iterated expectations: take the expectation of the conditional expectation conditional on $Y_2$:
\begin{equation}
= \mathbb{E}\left[\mathbb{E}\left[\left(Y_1 - \mathbb{E}(Y_1)\right)\left(Y_2 -\mathbb{E}(Y_2) \right) \mid Y_2\right]\right] = \mathbb{E}\left[(Y_2 - \mathbb{E}(Y_2))\mathbb{E}\left[Y_1 - \mathbb{E}(Y_1) \mid Y_2\right] \right].
\end{equation}
Recall that the conditional mean was shown to be independent of $Y_2$ and thus the expression simplifies as
\begin{equation}
= \mathbb{E}\left[(Y_2 - \mathbb{E}(Y_2))\mathbb{E}\left[Y_1-\mathbb{E}(Y_1)\right]\right]
\end{equation}
but the inner expectation is $0$ and we get
\begin{equation}
= \mathbb{E}\left[(Y_2 - \mathbb{E}(Y_2))\times0\right] = 0.
\end{equation}
Independence
Just by assuming identical distributions for $X_1,X_2$, it was shown that $Y_1$ and $Y_2$ are uncorrelated. When $X_1,X_2$ are jointly normal (for example, iid. normal as in the question), their linear combinations $Y_1,Y_2$ are also jointly normal and thus uncorrelatedness implies independence.
|
What is the intuition behind the independence of $X_2-X_1$ and $X_1+X_2$, $X_i \sim N(0,1)$?
I first argue for general identically distributed $X_1,X_2$ that the conditional mean of $Y_1$ conditional on $Y_2$ is constant $0$. Based on this, I argue that the covariance of $Y_1,Y_2$ is 0. Then
|
15,290
|
Testing randomly generated data against its intended distribution
|
Here is a general description of how the 3 methods mentioned work.
The Chi-Squared method works by comparing the number of observations in a bin to the number expected to be in the bin based on the distribution. For discrete distributions the bins are usually the discrete possibilities or combinations of those. For continuous distributions you can choose cut points to create the bins. Many functions that implement this will automatically create the bins, but you should be able to create your own bins if you want to compare in specific areas. The disadvantage of this method is that differences between the theoretical distribution and the empirical data that still put the values in the same bin will not be detected, an example would be rounding, if theoretically the numbers between 2 and 3 should be spread througout the range (we expect to see values like 2.34296), but in practice all those values are rounded to 2 or 3 (we don't even see a 2.5) and our bin includes the range from 2 to 3 inclusive, then the count in the bin will be similar to the theoretical prediction (this can be good or bad), if you want to detect this rounding you can just manually choose the bins to capture this.
The KS test statistic is the maximum distance between the 2 Cumulative Distribution Functions being compared (often a theoretical and an empirical). If the 2 probability distributions only have 1 intersection point then 1 minus the maximum distance is the area of overlap between the 2 probability distributions (this helps some people visualize what is being measured). Think of plotting on the same plot the theoretical distribution function and the EDF then measure the distance between the 2 "curves", the largest difference is the test statistic and it is compared against the distribution of values for this when the null is true. This captures differences is shape of the distribution or 1 distribution shifted or stretched compared to the other. It does not have a lot of power based on single outliers (if you take the maximum or minimum in the data and send it to Infinity or Negative Infinity then the maximum effect it will have on the test stat is $\frac1n$. This test depends on you knowing the parameters of the reference distribution rather than estimating them from the data (your situation seems fine here). If you estimate the parameters from the same data then you can still get a valid test by comparing to your own simulations rather than the standard reference distribution.
The Anderson-Darling test also uses the difference between the CDF curves like the KS test, but rather than using the maximum difference it uses a function of the total area between the 2 curves (it actually squares the differences, weights them so the tails have more influence, then integrates over the domain of the distributions). This gives more weight to outliers than KS and also gives more weight if there are several small differences (compared to 1 big difference that KS would emphasize). This may end up overpowering the test to find differences that you would consider unimportant (mild rounding, etc.). Like the KS test this assumes that you did not estimate parameters from the data.
Here is a graph to show the general ideas of the last 2:
based on this R code:
set.seed(1)
tmp <- rnorm(25)
edf <- approxfun( sort(tmp), (0:24)/25, method='constant',
yleft=0, yright=1, f=1 )
par(mfrow=c(3,1), mar=c(4,4,0,0)+.1)
curve( edf, from=-3, to=3, n=1000, col='green' )
curve( pnorm, from=-3, to=3, col='blue', add=TRUE)
tmp.x <- seq(-3, 3, length=1000)
ediff <- function(x) pnorm(x) - edf(x)
m.x <- tmp.x[ which.max( abs( ediff(tmp.x) ) ) ]
ediff( m.x ) # KS stat
segments( m.x, edf(m.x), m.x, pnorm(m.x), col='red' ) # KS stat
curve( ediff, from=-3, to=3, n=1000 )
abline(h=0, col='lightgrey')
ediff2 <- function(x) (pnorm(x) - edf(x))^2/( pnorm(x)*(1-pnorm(x)) )*dnorm(x)
curve( ediff2, from=-3, to=3, n=1000 )
abline(h=0)
The top graph shows an EDF of a sample from a standard normal compared to the CDF of the standard normal with a line showing the KS stat. The middle graph then shows the difference in the 2 curves (you can see where the KS stat occurs). The bottom is then the squared, weighted difference, the AD test is based on the area under this curve (assuming I got everything correct).
Other tests look at the correlation in a qqplot, look at the slope in the qqplot, compare the mean, var, and other stats based on the moments.
|
Testing randomly generated data against its intended distribution
|
Here is a general description of how the 3 methods mentioned work.
The Chi-Squared method works by comparing the number of observations in a bin to the number expected to be in the bin based on the di
|
Testing randomly generated data against its intended distribution
Here is a general description of how the 3 methods mentioned work.
The Chi-Squared method works by comparing the number of observations in a bin to the number expected to be in the bin based on the distribution. For discrete distributions the bins are usually the discrete possibilities or combinations of those. For continuous distributions you can choose cut points to create the bins. Many functions that implement this will automatically create the bins, but you should be able to create your own bins if you want to compare in specific areas. The disadvantage of this method is that differences between the theoretical distribution and the empirical data that still put the values in the same bin will not be detected, an example would be rounding, if theoretically the numbers between 2 and 3 should be spread througout the range (we expect to see values like 2.34296), but in practice all those values are rounded to 2 or 3 (we don't even see a 2.5) and our bin includes the range from 2 to 3 inclusive, then the count in the bin will be similar to the theoretical prediction (this can be good or bad), if you want to detect this rounding you can just manually choose the bins to capture this.
The KS test statistic is the maximum distance between the 2 Cumulative Distribution Functions being compared (often a theoretical and an empirical). If the 2 probability distributions only have 1 intersection point then 1 minus the maximum distance is the area of overlap between the 2 probability distributions (this helps some people visualize what is being measured). Think of plotting on the same plot the theoretical distribution function and the EDF then measure the distance between the 2 "curves", the largest difference is the test statistic and it is compared against the distribution of values for this when the null is true. This captures differences is shape of the distribution or 1 distribution shifted or stretched compared to the other. It does not have a lot of power based on single outliers (if you take the maximum or minimum in the data and send it to Infinity or Negative Infinity then the maximum effect it will have on the test stat is $\frac1n$. This test depends on you knowing the parameters of the reference distribution rather than estimating them from the data (your situation seems fine here). If you estimate the parameters from the same data then you can still get a valid test by comparing to your own simulations rather than the standard reference distribution.
The Anderson-Darling test also uses the difference between the CDF curves like the KS test, but rather than using the maximum difference it uses a function of the total area between the 2 curves (it actually squares the differences, weights them so the tails have more influence, then integrates over the domain of the distributions). This gives more weight to outliers than KS and also gives more weight if there are several small differences (compared to 1 big difference that KS would emphasize). This may end up overpowering the test to find differences that you would consider unimportant (mild rounding, etc.). Like the KS test this assumes that you did not estimate parameters from the data.
Here is a graph to show the general ideas of the last 2:
based on this R code:
set.seed(1)
tmp <- rnorm(25)
edf <- approxfun( sort(tmp), (0:24)/25, method='constant',
yleft=0, yright=1, f=1 )
par(mfrow=c(3,1), mar=c(4,4,0,0)+.1)
curve( edf, from=-3, to=3, n=1000, col='green' )
curve( pnorm, from=-3, to=3, col='blue', add=TRUE)
tmp.x <- seq(-3, 3, length=1000)
ediff <- function(x) pnorm(x) - edf(x)
m.x <- tmp.x[ which.max( abs( ediff(tmp.x) ) ) ]
ediff( m.x ) # KS stat
segments( m.x, edf(m.x), m.x, pnorm(m.x), col='red' ) # KS stat
curve( ediff, from=-3, to=3, n=1000 )
abline(h=0, col='lightgrey')
ediff2 <- function(x) (pnorm(x) - edf(x))^2/( pnorm(x)*(1-pnorm(x)) )*dnorm(x)
curve( ediff2, from=-3, to=3, n=1000 )
abline(h=0)
The top graph shows an EDF of a sample from a standard normal compared to the CDF of the standard normal with a line showing the KS stat. The middle graph then shows the difference in the 2 curves (you can see where the KS stat occurs). The bottom is then the squared, weighted difference, the AD test is based on the area under this curve (assuming I got everything correct).
Other tests look at the correlation in a qqplot, look at the slope in the qqplot, compare the mean, var, and other stats based on the moments.
|
Testing randomly generated data against its intended distribution
Here is a general description of how the 3 methods mentioned work.
The Chi-Squared method works by comparing the number of observations in a bin to the number expected to be in the bin based on the di
|
15,291
|
Testing randomly generated data against its intended distribution
|
+1 for writing a clear and detailed question. I hope that my answer isn't too frustrating. I believe that hypothesis testing is not an appropriate approach in your case. Null hypothesis significance testing is a reasonable thing to do when the answer could be yes or no, but you don't know which. (Unfortunately, it doesn't actually tell you which, but this is a different issue.) In your case, I gather, you want to know if your algorithm is good. However, it is known (with certainty), that no computer program can generate truly random data from any probability distribution. This is true firstly, because all computers are finite state machines, and thus can only produce pseudorandom numbers. Furthermore (setting the lack of true randomness aside), it is not possible that the generated values perfectly follow any continuous distribution. There are several ways to understand this, but perhaps the easiest is that there will be 'gaps' in the number line, which is not true of any continuous random variable. Moreover, these gaps are not all perfectly equally wide or perfectly equally spaced. Among computer scientists who work on pseudorandom number generation, the name of the game is to improve the algorithms such that the gaps are smaller, more even, with longer periods (and also that can generate more values faster). At any rate, these facts establish that hypothesis testing is the wrong approach for determining if your algorithm is properly following "a specific, known probability distribution", because it isn't. (Sorry.)
Instead, a more appropriate framework is to determine how close your data are to the theoretical distribution. For this, I would recommend reconsidering plots, specifically qq-plots and pp-plots. (Again, I recognize that this must be frustrating, and I apologize for that.) However, you don't have to actually make the plots or look at them, as weird as that sounds. Instead, having converted your data appropriately for plotting, and having calculated the corresponding values from the theoretical distribution in question, you can correlate them. This gives you a number, specifically an r-score, just like you want. Moreover, the number gives you an appropriate measure of how good your algorithm is. For this process, you can generate as much data as you would like; more data will give you more precision with respect to the measurement. That is, we have shifted our conception of power from $1-\beta$, the probability of rejecting a truly false null (which is guaranteed), to the accuracy in parameter estimation perspective. Obviously, your goal here is to produce an algorithm that gets you as close to $r=1$ as possible. It may well be worthwhile to do this for both types of plots as they have different strengths and weaknesses (specifically, qq-plots give you better resolution in the tails of the distribution, whereas pp-plots afford better resolution in the center).
On one other note, with regard to evaluating the quality of your algorithm, you may want to time it relative to other standard pRNG's.
Hope this helps.
|
Testing randomly generated data against its intended distribution
|
+1 for writing a clear and detailed question. I hope that my answer isn't too frustrating. I believe that hypothesis testing is not an appropriate approach in your case. Null hypothesis significanc
|
Testing randomly generated data against its intended distribution
+1 for writing a clear and detailed question. I hope that my answer isn't too frustrating. I believe that hypothesis testing is not an appropriate approach in your case. Null hypothesis significance testing is a reasonable thing to do when the answer could be yes or no, but you don't know which. (Unfortunately, it doesn't actually tell you which, but this is a different issue.) In your case, I gather, you want to know if your algorithm is good. However, it is known (with certainty), that no computer program can generate truly random data from any probability distribution. This is true firstly, because all computers are finite state machines, and thus can only produce pseudorandom numbers. Furthermore (setting the lack of true randomness aside), it is not possible that the generated values perfectly follow any continuous distribution. There are several ways to understand this, but perhaps the easiest is that there will be 'gaps' in the number line, which is not true of any continuous random variable. Moreover, these gaps are not all perfectly equally wide or perfectly equally spaced. Among computer scientists who work on pseudorandom number generation, the name of the game is to improve the algorithms such that the gaps are smaller, more even, with longer periods (and also that can generate more values faster). At any rate, these facts establish that hypothesis testing is the wrong approach for determining if your algorithm is properly following "a specific, known probability distribution", because it isn't. (Sorry.)
Instead, a more appropriate framework is to determine how close your data are to the theoretical distribution. For this, I would recommend reconsidering plots, specifically qq-plots and pp-plots. (Again, I recognize that this must be frustrating, and I apologize for that.) However, you don't have to actually make the plots or look at them, as weird as that sounds. Instead, having converted your data appropriately for plotting, and having calculated the corresponding values from the theoretical distribution in question, you can correlate them. This gives you a number, specifically an r-score, just like you want. Moreover, the number gives you an appropriate measure of how good your algorithm is. For this process, you can generate as much data as you would like; more data will give you more precision with respect to the measurement. That is, we have shifted our conception of power from $1-\beta$, the probability of rejecting a truly false null (which is guaranteed), to the accuracy in parameter estimation perspective. Obviously, your goal here is to produce an algorithm that gets you as close to $r=1$ as possible. It may well be worthwhile to do this for both types of plots as they have different strengths and weaknesses (specifically, qq-plots give you better resolution in the tails of the distribution, whereas pp-plots afford better resolution in the center).
On one other note, with regard to evaluating the quality of your algorithm, you may want to time it relative to other standard pRNG's.
Hope this helps.
|
Testing randomly generated data against its intended distribution
+1 for writing a clear and detailed question. I hope that my answer isn't too frustrating. I believe that hypothesis testing is not an appropriate approach in your case. Null hypothesis significanc
|
15,292
|
Testing randomly generated data against its intended distribution
|
I haven't completely read all the answers but I do see they are pretty thorough and accurate. Running the risk that I am repeating something buried in the long answers I just want to say that v=the chi square test can be used for continuous data. It may not be the best test and like many tests it relies on asymptotic theory and so may not be accurate in small samples with sparse cells (this depends also on how you do the binning). Anderson-Darling is more powerful for testing normality than the K-S test but K-S may be better for other continuous distributions. Lillefors has a test that is designed for exponential distributions.
|
Testing randomly generated data against its intended distribution
|
I haven't completely read all the answers but I do see they are pretty thorough and accurate. Running the risk that I am repeating something buried in the long answers I just want to say that v=the ch
|
Testing randomly generated data against its intended distribution
I haven't completely read all the answers but I do see they are pretty thorough and accurate. Running the risk that I am repeating something buried in the long answers I just want to say that v=the chi square test can be used for continuous data. It may not be the best test and like many tests it relies on asymptotic theory and so may not be accurate in small samples with sparse cells (this depends also on how you do the binning). Anderson-Darling is more powerful for testing normality than the K-S test but K-S may be better for other continuous distributions. Lillefors has a test that is designed for exponential distributions.
|
Testing randomly generated data against its intended distribution
I haven't completely read all the answers but I do see they are pretty thorough and accurate. Running the risk that I am repeating something buried in the long answers I just want to say that v=the ch
|
15,293
|
Differences between prior distribution and prior predictive distribution?
|
Predictive here means predictive for observations. The prior distribution is a distribution for the parameters whereas the prior predictive distribution is a distribution for the observations.
If $X$ denotes the observations and we use the model (or likelihood) $p(x \mid \theta)$ for $\theta \in \Theta$ then a prior distribution is a distribution for $\theta$, for example $p_\beta(\theta)$ where $\beta$ is a set of hyperparameters. Note that there's no conditioning on $\beta$, and therefore the hyperparameters are considered fixed, which is not the case in hierarchical models but this not the point here.
The prior predictive distribution is the distribution of $X$ "averaged" over all possible values of $\theta$:
\begin{align*}
p_\beta(x) &= \int_\Theta p(x , \theta) d\theta \\
&= \int_\Theta p(x \mid \theta) p_\beta(\theta) d\theta
\end{align*}
This distribution is prior as it does not rely on any observation.
We can also define in the same way the posterior predictive distribution, that is if we have a sample $X = (X_1, \dots, X_n)$, the posterior predictive distribution is:
\begin{align*}
p_\beta(x \mid X) &= \int_\Theta p(x ,\theta \mid X) d\theta \\
&= \int_\Theta p(x \mid \theta,X) p_\beta(\theta \mid X)d\theta \\
&= \int_\Theta p(x \mid \theta) p_\beta(\theta \mid X)d\theta.
\end{align*}
The last line is based on the assumption that the upcoming observation is independent of $X$ given $\theta$.
Thus the posterior predictive distribution is constructed the same way as the prior predictive distribution but while in the latter we weight with $p_\beta(\theta)$ in the former we weight with $p_\beta(\theta \mid X)$ that is with our "updated" knowledge about $\theta$.
Example : Beta-Binomial
Suppose our model is $X \mid \theta \sim {\rm Bin}(n,\theta)$ i.e $P(X = x \mid \theta) = \theta^x(1-\theta)^{n-x}$.
Here $\Theta = [0,1]$.
We also assume a beta prior distribution for $\theta$, $\beta(a,b)$, where $(a,b)$ is the set of hyper parameters.
The prior predictive distribution, $p_{a,b}(x)$, is the beta-binomial distribution with parameters $(n,a,b)$.
This discrete distribution gives the probability of getting $k$ successes out of $n$ trials given the hyper-parameters $(a,b)$ on the probability of success.
Now suppose we observe $n_1$ draws $(x_1, \dots, x_{n_1})$ with $m$ successes.
Since the binomial and beta distributions are conjugate distributions we have:
\begin{align*}
p(\theta \mid X=m)
&\propto \theta^m (1 - \theta)^{n_1-m} \times \theta^{a-1}(1-\theta)^{b-1}\\
&\propto \theta^{a+m-1}(1-\theta)^{n_1+b-m-1} \\
&\propto \beta(a+m,n_1+b-m)
\end{align*}
Thus $\theta \mid X$ follows a beta distribution with parameters $(a+m,n_1+b-m)$.
Then, $p_{a,b}(x \mid X = m)$ is also a beta-binomial distribution but this time with parameters $(n_2,a+m,b+n_1-m)$ rather than $(n_2,a,b)$.
Upon a $\beta(a,b)$ prior distribution and a ${\rm Bin}(n,\theta)$ likelihood, if we observe $m$ successes out of $n_1$ trials, the posterior predictive distribution is a beta-binomial with parameters $(n_2,a+x,b+n_1-x)$. Note that $n_2$ and $n_1$ play different roles here, since the posterior predictive distribution is about:
Given my current knowledge on $\theta$ after observing $m$ successes out of $n_1$ trials, i.e $\beta(n_1,a+x,n+b-x)$, what probability do I have of observing $k$ successes out of $n_2$ additional trials?
I hope this is useful and clear.
|
Differences between prior distribution and prior predictive distribution?
|
Predictive here means predictive for observations. The prior distribution is a distribution for the parameters whereas the prior predictive distribution is a distribution for the observations.
If $X$
|
Differences between prior distribution and prior predictive distribution?
Predictive here means predictive for observations. The prior distribution is a distribution for the parameters whereas the prior predictive distribution is a distribution for the observations.
If $X$ denotes the observations and we use the model (or likelihood) $p(x \mid \theta)$ for $\theta \in \Theta$ then a prior distribution is a distribution for $\theta$, for example $p_\beta(\theta)$ where $\beta$ is a set of hyperparameters. Note that there's no conditioning on $\beta$, and therefore the hyperparameters are considered fixed, which is not the case in hierarchical models but this not the point here.
The prior predictive distribution is the distribution of $X$ "averaged" over all possible values of $\theta$:
\begin{align*}
p_\beta(x) &= \int_\Theta p(x , \theta) d\theta \\
&= \int_\Theta p(x \mid \theta) p_\beta(\theta) d\theta
\end{align*}
This distribution is prior as it does not rely on any observation.
We can also define in the same way the posterior predictive distribution, that is if we have a sample $X = (X_1, \dots, X_n)$, the posterior predictive distribution is:
\begin{align*}
p_\beta(x \mid X) &= \int_\Theta p(x ,\theta \mid X) d\theta \\
&= \int_\Theta p(x \mid \theta,X) p_\beta(\theta \mid X)d\theta \\
&= \int_\Theta p(x \mid \theta) p_\beta(\theta \mid X)d\theta.
\end{align*}
The last line is based on the assumption that the upcoming observation is independent of $X$ given $\theta$.
Thus the posterior predictive distribution is constructed the same way as the prior predictive distribution but while in the latter we weight with $p_\beta(\theta)$ in the former we weight with $p_\beta(\theta \mid X)$ that is with our "updated" knowledge about $\theta$.
Example : Beta-Binomial
Suppose our model is $X \mid \theta \sim {\rm Bin}(n,\theta)$ i.e $P(X = x \mid \theta) = \theta^x(1-\theta)^{n-x}$.
Here $\Theta = [0,1]$.
We also assume a beta prior distribution for $\theta$, $\beta(a,b)$, where $(a,b)$ is the set of hyper parameters.
The prior predictive distribution, $p_{a,b}(x)$, is the beta-binomial distribution with parameters $(n,a,b)$.
This discrete distribution gives the probability of getting $k$ successes out of $n$ trials given the hyper-parameters $(a,b)$ on the probability of success.
Now suppose we observe $n_1$ draws $(x_1, \dots, x_{n_1})$ with $m$ successes.
Since the binomial and beta distributions are conjugate distributions we have:
\begin{align*}
p(\theta \mid X=m)
&\propto \theta^m (1 - \theta)^{n_1-m} \times \theta^{a-1}(1-\theta)^{b-1}\\
&\propto \theta^{a+m-1}(1-\theta)^{n_1+b-m-1} \\
&\propto \beta(a+m,n_1+b-m)
\end{align*}
Thus $\theta \mid X$ follows a beta distribution with parameters $(a+m,n_1+b-m)$.
Then, $p_{a,b}(x \mid X = m)$ is also a beta-binomial distribution but this time with parameters $(n_2,a+m,b+n_1-m)$ rather than $(n_2,a,b)$.
Upon a $\beta(a,b)$ prior distribution and a ${\rm Bin}(n,\theta)$ likelihood, if we observe $m$ successes out of $n_1$ trials, the posterior predictive distribution is a beta-binomial with parameters $(n_2,a+x,b+n_1-x)$. Note that $n_2$ and $n_1$ play different roles here, since the posterior predictive distribution is about:
Given my current knowledge on $\theta$ after observing $m$ successes out of $n_1$ trials, i.e $\beta(n_1,a+x,n+b-x)$, what probability do I have of observing $k$ successes out of $n_2$ additional trials?
I hope this is useful and clear.
|
Differences between prior distribution and prior predictive distribution?
Predictive here means predictive for observations. The prior distribution is a distribution for the parameters whereas the prior predictive distribution is a distribution for the observations.
If $X$
|
15,294
|
Differences between prior distribution and prior predictive distribution?
|
Let $Y$ be a random variable representing the (maybe future) data. We have a (parametric) model for $Y$ with $Y \sim f(y \mid \theta), \theta \in \Theta$, $\Theta$ the parameter space. Then we have a prior distribution represented by $\pi(\theta)$. Given an observation of $Y$, the posterior distribution of $\theta$ is
$$
f(\theta \mid y) =\frac{f(y\mid\theta) \pi(\theta)}{\int_\Theta f(y\mid\theta) \pi(\theta)\; d\theta} $$
The prior predictive distribution of $Y$ is then the (modeled) distribution of $Y$ marginalized over the prior, that is, integrated over $\pi(\theta)$:
$$
f(y) = \int_\Theta f(y\mid\theta) \pi(\theta)\; d\theta
$$ that is, the denominator in Bayes theorem above. This is also called the preposterior distribution of $Y$. This tells you what data (that is $Y$) you expect to see before learning more about $\theta$. This have many uses, for instance in design of experiments, for an example, see Experimental Design on Testing Proportions or Intersections of chemistry and statistics.
Another use is as a way to understand the prior distribution better. Say you are interested in modeling the variation in weight of elephants, and your prior distribution leads to a prior predictive with substantial probability over 20 tons. Then you might want to rethink, typical weight of largest elephants is seldom above 6 tons, so a substantial probability over 20 tons seem wrong. One interesting paper in this direction is Gelman (which do not use the terminology ...)
Finally, preposterior concepts are typically not useful with uninformative priors, they require prior modeling taken serious. One example is the following: Let $Y \sim \mathcal{N}(\theta, 1)$ with a flat prior $\pi(\theta)=1$. Then the prior predictive of $Y$ is
$$
f(y)= \int_{-\infty}^\infty \frac1{\sqrt{2\pi}} e^{-\frac12 (y-\theta)^2}\; d\theta = 1
$$
so is itself uniform, so not very useful.
|
Differences between prior distribution and prior predictive distribution?
|
Let $Y$ be a random variable representing the (maybe future) data. We have a (parametric) model for $Y$ with $Y \sim f(y \mid \theta), \theta \in \Theta$, $\Theta$ the parameter space. Then we have a
|
Differences between prior distribution and prior predictive distribution?
Let $Y$ be a random variable representing the (maybe future) data. We have a (parametric) model for $Y$ with $Y \sim f(y \mid \theta), \theta \in \Theta$, $\Theta$ the parameter space. Then we have a prior distribution represented by $\pi(\theta)$. Given an observation of $Y$, the posterior distribution of $\theta$ is
$$
f(\theta \mid y) =\frac{f(y\mid\theta) \pi(\theta)}{\int_\Theta f(y\mid\theta) \pi(\theta)\; d\theta} $$
The prior predictive distribution of $Y$ is then the (modeled) distribution of $Y$ marginalized over the prior, that is, integrated over $\pi(\theta)$:
$$
f(y) = \int_\Theta f(y\mid\theta) \pi(\theta)\; d\theta
$$ that is, the denominator in Bayes theorem above. This is also called the preposterior distribution of $Y$. This tells you what data (that is $Y$) you expect to see before learning more about $\theta$. This have many uses, for instance in design of experiments, for an example, see Experimental Design on Testing Proportions or Intersections of chemistry and statistics.
Another use is as a way to understand the prior distribution better. Say you are interested in modeling the variation in weight of elephants, and your prior distribution leads to a prior predictive with substantial probability over 20 tons. Then you might want to rethink, typical weight of largest elephants is seldom above 6 tons, so a substantial probability over 20 tons seem wrong. One interesting paper in this direction is Gelman (which do not use the terminology ...)
Finally, preposterior concepts are typically not useful with uninformative priors, they require prior modeling taken serious. One example is the following: Let $Y \sim \mathcal{N}(\theta, 1)$ with a flat prior $\pi(\theta)=1$. Then the prior predictive of $Y$ is
$$
f(y)= \int_{-\infty}^\infty \frac1{\sqrt{2\pi}} e^{-\frac12 (y-\theta)^2}\; d\theta = 1
$$
so is itself uniform, so not very useful.
|
Differences between prior distribution and prior predictive distribution?
Let $Y$ be a random variable representing the (maybe future) data. We have a (parametric) model for $Y$ with $Y \sim f(y \mid \theta), \theta \in \Theta$, $\Theta$ the parameter space. Then we have a
|
15,295
|
Why is increasing the non-linearity of neural networks desired?
|
That part of the Wikipedia article leaves a bit to be desired. Let's separate two aspects:
The need for nonlinear activation functions
It's obvious that a feedforward neural network with linear activation functions and $n$ layers each having $m$ hidden units (linear neural network, for brevity) is equivalent to a linear neural network without hidden layers. Proof:
$$ y = h(\mathbf{x})=\mathbf{b}_n+W_n(\mathbf{b}_{n-1}+W_{n-1}(\dots (\mathbf{b}_1+W_1 \mathbf{x})\dots))=\mathbf{b}_n+W_n\mathbf{b}_{n-1}+W_nW_{n-1}\mathbf{b}_{n-2}+\dots+W_nW_{n-1}\dots W_1\mathbf{x}=\mathbf{b}'+W'\mathbf{x}$$
Thus it's clear that adding layers ("going deep") doesn't increase the approximation power of a linear neural network at all, unlike for nonlinear neural network.
Also, nonlinear activation functions are needed for the universal approximation theorem for neural networks to be valid. This theorem states that under certain conditions, for any continuous function $f:[0,1]^d\to\mathbb{R}$ and any $\epsilon>0$, there exist a neural network with one hidden layer and a sufficiently large number of hidden units $m$ which approximates $f$ on $[0,1]^d$ uniformly to within $\epsilon$. One of the conditions for the universal approximation theorem to be valid is that the neural network is a composition of nonlinear activation functions: if only linear functions are used, the theorem is not valid anymore. Thus we know that there exist some continuous functions over hypercubes which we just can't approximate accurately with linear neural networks.
You can see the limits of linear neural networks in practice, thanks to the Tensorflow playground. I built a 4 hidden layers linear neural network for classification. As you can see, no matter how many layers you use, the linear neural network can only find linear separation boundaries, since it's equivalent to a linear neural network without hidden layers, i.e., to a linear classifier.
The need for ReLU
The activation function $h(s)=\max(0,cs)$ is not used because "it increases the nonlinearity of the decision function": whatever that may mean, ReLU is no more nonlinear than $\tanh$, sigmoid, etc. The actual reason why it's used is that, when stacking more and more layers in a CNN, it has been empirically observed that a CNN with ReLU is much easier and faster to train than a CNN with $\tanh$ (the situation with a sigmoid is even worse). Why is it so? There are two theories currently:
$\tanh(s)$ has the vanishing gradient problem. As the independent variable $s$ goes to $\pm \infty$, the derivative of $\tanh(s)$ goes to 0:
This means that as more layers are stacked, the gradients get smaller
and smaller. Since the step in weight space of the backpropagation
algorithm is proportional to the magnitude of the gradient, vanishing
gradients mean that the neural network cannot be trained anymore.
This manifests itself in training times which increase exponentially
with the increase in the number of layers. On the contrary, the
derivative of ReLU is constant (equal to $c$) if $s>0$, no matter how
many layers we stack (it's also equal to 0 if $s<0$ which leads to
the dead neurons issue, but this is another problem).
there are theorems which guarantee that local minima, under certain conditions, are global minima (see here). Some of the assumptions of these theorems don't hold if the activation function is a $\tanh$ or sigmoid, but they hold if the activation function is a ReLU.
|
Why is increasing the non-linearity of neural networks desired?
|
That part of the Wikipedia article leaves a bit to be desired. Let's separate two aspects:
The need for nonlinear activation functions
It's obvious that a feedforward neural network with linear activa
|
Why is increasing the non-linearity of neural networks desired?
That part of the Wikipedia article leaves a bit to be desired. Let's separate two aspects:
The need for nonlinear activation functions
It's obvious that a feedforward neural network with linear activation functions and $n$ layers each having $m$ hidden units (linear neural network, for brevity) is equivalent to a linear neural network without hidden layers. Proof:
$$ y = h(\mathbf{x})=\mathbf{b}_n+W_n(\mathbf{b}_{n-1}+W_{n-1}(\dots (\mathbf{b}_1+W_1 \mathbf{x})\dots))=\mathbf{b}_n+W_n\mathbf{b}_{n-1}+W_nW_{n-1}\mathbf{b}_{n-2}+\dots+W_nW_{n-1}\dots W_1\mathbf{x}=\mathbf{b}'+W'\mathbf{x}$$
Thus it's clear that adding layers ("going deep") doesn't increase the approximation power of a linear neural network at all, unlike for nonlinear neural network.
Also, nonlinear activation functions are needed for the universal approximation theorem for neural networks to be valid. This theorem states that under certain conditions, for any continuous function $f:[0,1]^d\to\mathbb{R}$ and any $\epsilon>0$, there exist a neural network with one hidden layer and a sufficiently large number of hidden units $m$ which approximates $f$ on $[0,1]^d$ uniformly to within $\epsilon$. One of the conditions for the universal approximation theorem to be valid is that the neural network is a composition of nonlinear activation functions: if only linear functions are used, the theorem is not valid anymore. Thus we know that there exist some continuous functions over hypercubes which we just can't approximate accurately with linear neural networks.
You can see the limits of linear neural networks in practice, thanks to the Tensorflow playground. I built a 4 hidden layers linear neural network for classification. As you can see, no matter how many layers you use, the linear neural network can only find linear separation boundaries, since it's equivalent to a linear neural network without hidden layers, i.e., to a linear classifier.
The need for ReLU
The activation function $h(s)=\max(0,cs)$ is not used because "it increases the nonlinearity of the decision function": whatever that may mean, ReLU is no more nonlinear than $\tanh$, sigmoid, etc. The actual reason why it's used is that, when stacking more and more layers in a CNN, it has been empirically observed that a CNN with ReLU is much easier and faster to train than a CNN with $\tanh$ (the situation with a sigmoid is even worse). Why is it so? There are two theories currently:
$\tanh(s)$ has the vanishing gradient problem. As the independent variable $s$ goes to $\pm \infty$, the derivative of $\tanh(s)$ goes to 0:
This means that as more layers are stacked, the gradients get smaller
and smaller. Since the step in weight space of the backpropagation
algorithm is proportional to the magnitude of the gradient, vanishing
gradients mean that the neural network cannot be trained anymore.
This manifests itself in training times which increase exponentially
with the increase in the number of layers. On the contrary, the
derivative of ReLU is constant (equal to $c$) if $s>0$, no matter how
many layers we stack (it's also equal to 0 if $s<0$ which leads to
the dead neurons issue, but this is another problem).
there are theorems which guarantee that local minima, under certain conditions, are global minima (see here). Some of the assumptions of these theorems don't hold if the activation function is a $\tanh$ or sigmoid, but they hold if the activation function is a ReLU.
|
Why is increasing the non-linearity of neural networks desired?
That part of the Wikipedia article leaves a bit to be desired. Let's separate two aspects:
The need for nonlinear activation functions
It's obvious that a feedforward neural network with linear activa
|
15,296
|
Why is increasing the non-linearity of neural networks desired?
|
I'll give you a very loose analogy (emphasis is important here) that may help you understand the intuition. There's this technical drawing tool, called a French curve, here's an example:
We were trained to use it in high school in a technical drawing class. These days, the same class is taught with CAD software, so you may not have encountered it. See, how to use them in this video.
Here's a straight ruler:
(source: officeworks.com.au)
Can you draw a curved line with a straight ruler? Of course, you can! However, it's more work. Take a look at this video to appreciate the difference.
It's more efficient to use a French curve to draw curved lines than with a straight ruler. You'd have to make a lot of small lines to draft any smooth curve with the latter.
It's not exactly the same with machine learning, but this analogy provides you with an intuition why nonlinear activation may work better in many cases: your problems are nonlinear, and having nonlinear pieces can be more efficient when combining them into a solution to nonlinear problems.
|
Why is increasing the non-linearity of neural networks desired?
|
I'll give you a very loose analogy (emphasis is important here) that may help you understand the intuition. There's this technical drawing tool, called a French curve, here's an example:
We were trai
|
Why is increasing the non-linearity of neural networks desired?
I'll give you a very loose analogy (emphasis is important here) that may help you understand the intuition. There's this technical drawing tool, called a French curve, here's an example:
We were trained to use it in high school in a technical drawing class. These days, the same class is taught with CAD software, so you may not have encountered it. See, how to use them in this video.
Here's a straight ruler:
(source: officeworks.com.au)
Can you draw a curved line with a straight ruler? Of course, you can! However, it's more work. Take a look at this video to appreciate the difference.
It's more efficient to use a French curve to draw curved lines than with a straight ruler. You'd have to make a lot of small lines to draft any smooth curve with the latter.
It's not exactly the same with machine learning, but this analogy provides you with an intuition why nonlinear activation may work better in many cases: your problems are nonlinear, and having nonlinear pieces can be more efficient when combining them into a solution to nonlinear problems.
|
Why is increasing the non-linearity of neural networks desired?
I'll give you a very loose analogy (emphasis is important here) that may help you understand the intuition. There's this technical drawing tool, called a French curve, here's an example:
We were trai
|
15,297
|
Why is increasing the non-linearity of neural networks desired?
|
Why is increasing non-linearity desired?
Simply put: the more 'non-linear' our decision function, the more complex decisions it can make. In many cases this is desired because the decision function we are modeling with the neural network is unlikely to have a linear relationship with the input. Having more neurons in the layers with ReLU, a non-linear activation function, means that the output of the network should have a non-linear relationship with the input. 'Input' in this case is going to be the convoluted image segments.
What effect does it have on the overall performance of the model?
It depends on the problem. Considering CNNs: if the relationship between the class you want to predict and, in this case, convoluted image segments, is 'non-linear' then
the performance of the network will improve if the fully connected layers (decision function) have non-linear activation functions (like ReLU). Stacking more layers will also increase your non-linearity.
|
Why is increasing the non-linearity of neural networks desired?
|
Why is increasing non-linearity desired?
Simply put: the more 'non-linear' our decision function, the more complex decisions it can make. In many cases this is desired because the decision function w
|
Why is increasing the non-linearity of neural networks desired?
Why is increasing non-linearity desired?
Simply put: the more 'non-linear' our decision function, the more complex decisions it can make. In many cases this is desired because the decision function we are modeling with the neural network is unlikely to have a linear relationship with the input. Having more neurons in the layers with ReLU, a non-linear activation function, means that the output of the network should have a non-linear relationship with the input. 'Input' in this case is going to be the convoluted image segments.
What effect does it have on the overall performance of the model?
It depends on the problem. Considering CNNs: if the relationship between the class you want to predict and, in this case, convoluted image segments, is 'non-linear' then
the performance of the network will improve if the fully connected layers (decision function) have non-linear activation functions (like ReLU). Stacking more layers will also increase your non-linearity.
|
Why is increasing the non-linearity of neural networks desired?
Why is increasing non-linearity desired?
Simply put: the more 'non-linear' our decision function, the more complex decisions it can make. In many cases this is desired because the decision function w
|
15,298
|
Why is increasing the non-linearity of neural networks desired?
|
Because linear model has limited "capacity" to perform the task. Consider the data set shown here Why does feature engineering work ?, we cannot draw a line to separate two classes.
On the other hand, using nonlinear transformation (feature engineering), the classification tasks becomes easy.
For neural network, it is usually a very big and complex system that uses nonlinear transformation on original data to achieve better performance.
|
Why is increasing the non-linearity of neural networks desired?
|
Because linear model has limited "capacity" to perform the task. Consider the data set shown here Why does feature engineering work ?, we cannot draw a line to separate two classes.
On the other hand,
|
Why is increasing the non-linearity of neural networks desired?
Because linear model has limited "capacity" to perform the task. Consider the data set shown here Why does feature engineering work ?, we cannot draw a line to separate two classes.
On the other hand, using nonlinear transformation (feature engineering), the classification tasks becomes easy.
For neural network, it is usually a very big and complex system that uses nonlinear transformation on original data to achieve better performance.
|
Why is increasing the non-linearity of neural networks desired?
Because linear model has limited "capacity" to perform the task. Consider the data set shown here Why does feature engineering work ?, we cannot draw a line to separate two classes.
On the other hand,
|
15,299
|
Why is increasing the non-linearity of neural networks desired?
|
it depends on your task. If you are doing processing of linear data (eg. text processing) you actually do not need non-linearity. But most of signal processing (image/audio) tasks are non-linear there you have to have non-linear layers.
|
Why is increasing the non-linearity of neural networks desired?
|
it depends on your task. If you are doing processing of linear data (eg. text processing) you actually do not need non-linearity. But most of signal processing (image/audio) tasks are non-linear there
|
Why is increasing the non-linearity of neural networks desired?
it depends on your task. If you are doing processing of linear data (eg. text processing) you actually do not need non-linearity. But most of signal processing (image/audio) tasks are non-linear there you have to have non-linear layers.
|
Why is increasing the non-linearity of neural networks desired?
it depends on your task. If you are doing processing of linear data (eg. text processing) you actually do not need non-linearity. But most of signal processing (image/audio) tasks are non-linear there
|
15,300
|
Why is increasing the non-linearity of neural networks desired?
|
That sounds like it was written by someone who doesn't know what they are talking about. Having a non-linearity is important because it allows the subsequent layers to build off each other. Two consecutive linear layers have the same power (they can represent the exact same set of functions) as a single linear layer. Two consecutive non-linear layers can represent more functions than a single non-linear layer.
|
Why is increasing the non-linearity of neural networks desired?
|
That sounds like it was written by someone who doesn't know what they are talking about. Having a non-linearity is important because it allows the subsequent layers to build off each other. Two consec
|
Why is increasing the non-linearity of neural networks desired?
That sounds like it was written by someone who doesn't know what they are talking about. Having a non-linearity is important because it allows the subsequent layers to build off each other. Two consecutive linear layers have the same power (they can represent the exact same set of functions) as a single linear layer. Two consecutive non-linear layers can represent more functions than a single non-linear layer.
|
Why is increasing the non-linearity of neural networks desired?
That sounds like it was written by someone who doesn't know what they are talking about. Having a non-linearity is important because it allows the subsequent layers to build off each other. Two consec
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.